1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* A GNU-like <stdio.h>.
5 Copyright (C) 2004, 2007-2010 Free Software Foundation, Inc.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
22 @PRAGMA_SYSTEM_HEADER@
26 #if defined __need_FILE || defined __need___FILE
27 /* Special invocation convention inside glibc header files. */
29 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
32 /* Normal invocation convention. */
36 /* The include_next requires a split double-inclusion guard. */
37 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
42 /* Get va_list. Needed on many systems, including glibc 2.8. */
47 /* Get off_t and ssize_t. Needed on many systems, including glibc 2.8. */
48 #include <sys/types.h>
51 /* The __attribute__ feature is available in gcc versions 2.5 and later.
52 The __-protected variants of the attributes 'format' and 'printf' are
53 accepted by gcc versions 2.6.4 (effectively 2.7) and later.
54 We enable __attribute__ only if these are supported too, because
55 gnulib and libintl do '#define printf __printf__' when they override
56 the 'printf' function. */
57 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
58 # define __attribute__(Spec) /* empty */
63 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
65 /* The definition of _GL_ARG_NONNULL is copied here. */
67 /* The definition of _GL_WARN_ON_USE is copied here. */
69 /* Macros for stringification. */
70 #define _GL_STDIO_STRINGIZE(token) #token
71 #define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
75 # if @REPLACE_DPRINTF@
76 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
77 # define dprintf rpl_dprintf
79 _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...)
80 __attribute__ ((__format__ (__printf__, 2, 3)))
81 _GL_ARG_NONNULL ((2)));
82 _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...));
85 _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...)
86 __attribute__ ((__format__ (__printf__, 2, 3)))
87 _GL_ARG_NONNULL ((2)));
89 _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...));
91 _GL_CXXALIASWARN (dprintf);
92 #elif defined GNULIB_POSIXCHECK
94 # if HAVE_RAW_DECL_DPRINTF
95 _GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
96 "use gnulib module dprintf for portability");
101 /* Close STREAM and its underlying file descriptor. */
102 # if @REPLACE_FCLOSE@
103 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
104 # define fclose rpl_fclose
106 _GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
107 _GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
109 _GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
111 _GL_CXXALIASWARN (fclose);
112 #elif defined GNULIB_POSIXCHECK
114 /* Assume fclose is always declared. */
115 _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
116 "use gnulib module fclose for portable POSIX compliance");
120 /* Flush all pending data on STREAM according to POSIX rules. Both
121 output and seekable input streams are supported.
122 Note! LOSS OF DATA can occur if fflush is applied on an input stream
123 that is _not_seekable_ or on an update stream that is _not_seekable_
124 and in which the most recent operation was input. Seekability can
125 be tested with lseek(fileno(fp),0,SEEK_CUR). */
126 # if @REPLACE_FFLUSH@
127 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
128 # define fflush rpl_fflush
130 _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream));
131 _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
133 _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
135 _GL_CXXALIASWARN (fflush);
136 #elif defined GNULIB_POSIXCHECK
138 /* Assume fflush is always declared. */
139 _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
140 "use gnulib module fflush for portable POSIX compliance");
143 /* It is very rare that the developer ever has full control of stdin,
144 so any use of gets warrants an unconditional warning. Assume it is
145 always declared, since it is required by C89. */
147 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
151 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
153 # define fopen rpl_fopen
155 _GL_FUNCDECL_RPL (fopen, FILE *, (const char *filename, const char *mode)
156 _GL_ARG_NONNULL ((1, 2)));
157 _GL_CXXALIAS_RPL (fopen, FILE *, (const char *filename, const char *mode));
159 _GL_CXXALIAS_SYS (fopen, FILE *, (const char *filename, const char *mode));
161 _GL_CXXALIASWARN (fopen);
162 #elif defined GNULIB_POSIXCHECK
164 /* Assume fopen is always declared. */
165 _GL_WARN_ON_USE (fopen, "fopen on Win32 platforms is not POSIX compatible - "
166 "use gnulib module fopen for portability");
169 #if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
170 # if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
171 || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
172 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
173 # define fprintf rpl_fprintf
175 # define GNULIB_overrides_fprintf 1
176 _GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
177 __attribute__ ((__format__ (__printf__, 2, 3)))
178 _GL_ARG_NONNULL ((1, 2)));
179 _GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...));
181 _GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...));
183 _GL_CXXALIASWARN (fprintf);
185 #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
186 # if !GNULIB_overrides_fprintf
189 /* Assume fprintf is always declared. */
190 _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
191 "use gnulib module fprintf-posix for portable "
196 /* Discard all pending buffered I/O data on STREAM.
197 STREAM must not be wide-character oriented.
198 When discarding pending output, the file position is set back to where it
199 was before the write calls. When discarding pending input, the file
200 position is advanced to match the end of the previously read input.
201 Return 0 if successful. Upon error, return -1 and set errno. */
202 # if @REPLACE_FPURGE@
203 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
204 # define fpurge rpl_fpurge
206 _GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
207 _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream));
209 # if !@HAVE_DECL_FPURGE@
210 _GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
212 _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream));
214 _GL_CXXALIASWARN (fpurge);
215 #elif defined GNULIB_POSIXCHECK
217 # if HAVE_RAW_DECL_FPURGE
218 _GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
219 "use gnulib module fpurge for portability");
224 # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
225 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
227 # define fputc rpl_fputc
229 _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
230 _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
232 _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
234 _GL_CXXALIASWARN (fputc);
238 # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
239 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
241 # define fputs rpl_fputs
243 _GL_FUNCDECL_RPL (fputs, int, (const char *string, FILE *stream)
244 _GL_ARG_NONNULL ((1, 2)));
245 _GL_CXXALIAS_RPL (fputs, int, (const char *string, FILE *stream));
247 _GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream));
249 _GL_CXXALIASWARN (fputs);
253 # if @REPLACE_FREOPEN@
254 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
256 # define freopen rpl_freopen
258 _GL_FUNCDECL_RPL (freopen, FILE *,
259 (const char *filename, const char *mode, FILE *stream)
260 _GL_ARG_NONNULL ((2, 3)));
261 _GL_CXXALIAS_RPL (freopen, FILE *,
262 (const char *filename, const char *mode, FILE *stream));
264 _GL_CXXALIAS_SYS (freopen, FILE *,
265 (const char *filename, const char *mode, FILE *stream));
267 _GL_CXXALIASWARN (freopen);
268 #elif defined GNULIB_POSIXCHECK
270 /* Assume freopen is always declared. */
271 _GL_WARN_ON_USE (freopen,
272 "freopen on Win32 platforms is not POSIX compatible - "
273 "use gnulib module freopen for portability");
277 /* Set up the following warnings, based on which modules are in use.
278 GNU Coding Standards discourage the use of fseek, since it imposes
279 an arbitrary limitation on some 32-bit hosts. Remember that the
280 fseek module depends on the fseeko module, so we only have three
283 1. The developer is not using either module. Issue a warning under
284 GNULIB_POSIXCHECK for both functions, to remind them that both
285 functions have bugs on some systems. _GL_NO_LARGE_FILES has no
286 impact on this warning.
288 2. The developer is using both modules. They may be unaware of the
289 arbitrary limitations of fseek, so issue a warning under
290 GNULIB_POSIXCHECK. On the other hand, they may be using both
291 modules intentionally, so the developer can define
292 _GL_NO_LARGE_FILES in the compilation units where the use of fseek
293 is safe, to silence the warning.
295 3. The developer is using the fseeko module, but not fseek. Gnulib
296 guarantees that fseek will still work around platform bugs in that
297 case, but we presume that the developer is aware of the pitfalls of
298 fseek and was trying to avoid it, so issue a warning even when
299 GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be
300 defined to silence the warning in particular compilation units.
301 In C++ compilations with GNULIB_NAMESPACE, in order to avoid that
302 fseek gets defined as a macro, it is recommended that the developer
303 uses the fseek module, even if he is not calling the fseek function.
305 Most gnulib clients that perform stream operations should fall into
309 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
310 # define _GL_FSEEK_WARN /* Category 2, above. */
314 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
316 # define fseek rpl_fseek
318 _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence)
319 _GL_ARG_NONNULL ((1)));
320 _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
322 _GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence));
324 _GL_CXXALIASWARN (fseek);
328 # if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES
329 # define _GL_FSEEK_WARN /* Category 3, above. */
332 # if @REPLACE_FSEEKO@
333 /* Provide an fseeko function that is aware of a preceding fflush(), and which
335 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
337 # define fseeko rpl_fseeko
339 _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
340 _GL_ARG_NONNULL ((1)));
341 _GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
344 _GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)
345 _GL_ARG_NONNULL ((1)));
347 _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
349 _GL_CXXALIASWARN (fseeko);
350 # if (@REPLACE_FSEEKO@ || !@HAVE_FSEEKO@) && !@GNULIB_FSEEK@
351 /* Provide an fseek function that is consistent with fseeko. */
352 /* In order to avoid that fseek gets defined as a macro here, the
353 developer can request the 'fseek' module. */
355 # define fseek rpl_fseek
356 static inline int _GL_ARG_NONNULL ((1))
357 rpl_fseek (FILE *fp, long offset, int whence)
359 # if @REPLACE_FSEEKO@
360 return rpl_fseeko (fp, offset, whence);
362 return fseeko (fp, offset, whence);
366 #elif defined GNULIB_POSIXCHECK
367 # define _GL_FSEEK_WARN /* Category 1, above. */
370 # if HAVE_RAW_DECL_FSEEKO
371 _GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
372 "use gnulib module fseeko for portability");
376 #ifdef _GL_FSEEK_WARN
377 # undef _GL_FSEEK_WARN
378 /* Here, either fseek is undefined (but C89 guarantees that it is
379 declared), or it is defined as rpl_fseek (declared above). */
380 _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
381 "on 32-bit platforms - "
382 "use fseeko function for handling of large files");
386 /* ftell, ftello. See the comments on fseek/fseeko. */
389 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
390 # define _GL_FTELL_WARN /* Category 2, above. */
394 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
396 # define ftell rpl_ftell
398 _GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1)));
399 _GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
401 _GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
403 _GL_CXXALIASWARN (ftell);
407 # if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES
408 # define _GL_FTELL_WARN /* Category 3, above. */
411 # if @REPLACE_FTELLO@
412 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
414 # define ftello rpl_ftello
416 _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
417 _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
420 _GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
422 _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
424 _GL_CXXALIASWARN (ftello);
425 # if (@REPLACE_FTELLO@ || !@HAVE_FTELLO@) && !@GNULIB_FTELL@
426 /* Provide an ftell function that is consistent with ftello. */
427 /* In order to avoid that ftell gets defined as a macro here, the
428 developer can request the 'ftell' module. */
430 # define ftell rpl_ftell
431 static inline long _GL_ARG_NONNULL ((1))
434 # if @REPLACE_FTELLO@
435 return rpl_ftello (f);
441 #elif defined GNULIB_POSIXCHECK
442 # define _GL_FTELL_WARN /* Category 1, above. */
445 # if HAVE_RAW_DECL_FTELLO
446 _GL_WARN_ON_USE (ftello, "ftello is unportable - "
447 "use gnulib module ftello for portability");
451 #ifdef _GL_FTELL_WARN
452 # undef _GL_FTELL_WARN
453 /* Here, either ftell is undefined (but C89 guarantees that it is
454 declared), or it is defined as rpl_ftell (declared above). */
455 _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
456 "on 32-bit platforms - "
457 "use ftello function for handling of large files");
462 # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
463 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
465 # define fwrite rpl_fwrite
467 _GL_FUNCDECL_RPL (fwrite, size_t,
468 (const void *ptr, size_t s, size_t n, FILE *stream)
469 _GL_ARG_NONNULL ((1, 4)));
470 _GL_CXXALIAS_RPL (fwrite, size_t,
471 (const void *ptr, size_t s, size_t n, FILE *stream));
473 _GL_CXXALIAS_SYS (fwrite, size_t,
474 (const void *ptr, size_t s, size_t n, FILE *stream));
476 _GL_CXXALIASWARN (fwrite);
479 #if @GNULIB_GETDELIM@
480 /* Read input, up to (and including) the next occurrence of DELIMITER, from
481 STREAM, store it in *LINEPTR (and NUL-terminate it).
482 *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
483 bytes of space. It is realloc'd as necessary.
484 Return the number of bytes read and stored at *LINEPTR (not including the
485 NUL terminator), or -1 on error or EOF. */
486 # if @REPLACE_GETDELIM@
487 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
489 # define getdelim rpl_getdelim
491 _GL_FUNCDECL_RPL (getdelim, ssize_t,
492 (char **lineptr, size_t *linesize, int delimiter,
494 _GL_ARG_NONNULL ((1, 2, 4)));
495 _GL_CXXALIAS_RPL (getdelim, ssize_t,
496 (char **lineptr, size_t *linesize, int delimiter,
499 # if !@HAVE_DECL_GETDELIM@
500 _GL_FUNCDECL_SYS (getdelim, ssize_t,
501 (char **lineptr, size_t *linesize, int delimiter,
503 _GL_ARG_NONNULL ((1, 2, 4)));
505 _GL_CXXALIAS_SYS (getdelim, ssize_t,
506 (char **lineptr, size_t *linesize, int delimiter,
509 _GL_CXXALIASWARN (getdelim);
510 #elif defined GNULIB_POSIXCHECK
512 # if HAVE_RAW_DECL_GETDELIM
513 _GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
514 "use gnulib module getdelim for portability");
519 /* Read a line, up to (and including) the next newline, from STREAM, store it
520 in *LINEPTR (and NUL-terminate it).
521 *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
522 bytes of space. It is realloc'd as necessary.
523 Return the number of bytes read and stored at *LINEPTR (not including the
524 NUL terminator), or -1 on error or EOF. */
525 # if @REPLACE_GETLINE@
526 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
528 # define getline rpl_getline
530 _GL_FUNCDECL_RPL (getline, ssize_t,
531 (char **lineptr, size_t *linesize, FILE *stream)
532 _GL_ARG_NONNULL ((1, 2, 3)));
533 _GL_CXXALIAS_RPL (getline, ssize_t,
534 (char **lineptr, size_t *linesize, FILE *stream));
536 # if !@HAVE_DECL_GETLINE@
537 _GL_FUNCDECL_SYS (getline, ssize_t,
538 (char **lineptr, size_t *linesize, FILE *stream)
539 _GL_ARG_NONNULL ((1, 2, 3)));
541 _GL_CXXALIAS_SYS (getline, ssize_t,
542 (char **lineptr, size_t *linesize, FILE *stream));
544 # if @HAVE_DECL_GETLINE@
545 _GL_CXXALIASWARN (getline);
547 #elif defined GNULIB_POSIXCHECK
549 # if HAVE_RAW_DECL_GETLINE
550 _GL_WARN_ON_USE (getline, "getline is unportable - "
551 "use gnulib module getline for portability");
555 #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
557 /* Grow an obstack with formatted output. Return the number of
558 bytes added to OBS. No trailing nul byte is added, and the
559 object should be closed with obstack_finish before use. Upon
560 memory allocation error, call obstack_alloc_failed_handler. Upon
561 other error, return -1. */
562 # if @REPLACE_OBSTACK_PRINTF@
563 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
564 # define obstack_printf rpl_obstack_printf
566 _GL_FUNCDECL_RPL (obstack_printf, int,
567 (struct obstack *obs, const char *format, ...)
568 __attribute__ ((__format__ (__printf__, 2, 3)))
569 _GL_ARG_NONNULL ((1, 2)));
570 _GL_CXXALIAS_RPL (obstack_printf, int,
571 (struct obstack *obs, const char *format, ...));
573 # if !@HAVE_DECL_OBSTACK_PRINTF@
574 _GL_FUNCDECL_SYS (obstack_printf, int,
575 (struct obstack *obs, const char *format, ...)
576 __attribute__ ((__format__ (__printf__, 2, 3)))
577 _GL_ARG_NONNULL ((1, 2)));
579 _GL_CXXALIAS_SYS (obstack_printf, int,
580 (struct obstack *obs, const char *format, ...));
582 _GL_CXXALIASWARN (obstack_printf);
583 # if @REPLACE_OBSTACK_PRINTF@
584 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
585 # define obstack_vprintf rpl_obstack_vprintf
587 _GL_FUNCDECL_RPL (obstack_vprintf, int,
588 (struct obstack *obs, const char *format, va_list args)
589 __attribute__ ((__format__ (__printf__, 2, 0)))
590 _GL_ARG_NONNULL ((1, 2)));
591 _GL_CXXALIAS_RPL (obstack_vprintf, int,
592 (struct obstack *obs, const char *format, va_list args));
594 # if !@HAVE_DECL_OBSTACK_PRINTF@
595 _GL_FUNCDECL_SYS (obstack_vprintf, int,
596 (struct obstack *obs, const char *format, va_list args)
597 __attribute__ ((__format__ (__printf__, 2, 0)))
598 _GL_ARG_NONNULL ((1, 2)));
600 _GL_CXXALIAS_SYS (obstack_vprintf, int,
601 (struct obstack *obs, const char *format, va_list args));
603 _GL_CXXALIASWARN (obstack_vprintf);
607 /* Print a message to standard error, describing the value of ERRNO,
608 (if STRING is not NULL and not empty) prefixed with STRING and ": ",
609 and terminated with a newline. */
610 # if @REPLACE_PERROR@
611 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
612 # define perror rpl_perror
614 _GL_FUNCDECL_RPL (perror, void, (const char *string));
615 _GL_CXXALIAS_RPL (perror, void, (const char *string));
617 _GL_CXXALIAS_SYS (perror, void, (const char *string));
619 _GL_CXXALIASWARN (perror);
620 #elif defined GNULIB_POSIXCHECK
622 /* Assume perror is always declared. */
623 _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
624 "use gnulib module perror for portability");
629 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
631 # define popen rpl_popen
633 _GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode)
634 _GL_ARG_NONNULL ((1, 2)));
635 _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
637 _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
639 _GL_CXXALIASWARN (popen);
640 #elif defined GNULIB_POSIXCHECK
642 # if HAVE_RAW_DECL_POPEN
643 _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
644 "use gnulib module popen or pipe for more portability");
648 #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
649 # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
650 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
651 # if defined __GNUC__
652 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
653 /* Don't break __attribute__((format(printf,M,N))). */
654 # define printf __printf__
656 _GL_FUNCDECL_RPL_1 (__printf__, int,
657 (const char *format, ...)
658 __asm__ (@ASM_SYMBOL_PREFIX@
659 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
660 __attribute__ ((__format__ (__printf__, 1, 2)))
661 _GL_ARG_NONNULL ((1)));
662 _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
664 _GL_FUNCDECL_RPL (printf, int,
665 (const char *format, ...)
666 __attribute__ ((__format__ (__printf__, 1, 2)))
667 _GL_ARG_NONNULL ((1)));
668 _GL_CXXALIAS_RPL (printf, int, (const char *format, ...));
670 # define GNULIB_overrides_printf 1
672 _GL_CXXALIAS_SYS (printf, int, (const char *format, ...));
674 _GL_CXXALIASWARN (printf);
676 #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
677 # if !GNULIB_overrides_printf
680 /* Assume printf is always declared. */
681 _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
682 "use gnulib module printf-posix for portable "
687 # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
688 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
690 # define putc rpl_fputc
692 _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
693 _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
695 _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
697 _GL_CXXALIASWARN (putc);
701 # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
702 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
704 # define putchar rpl_putchar
706 _GL_FUNCDECL_RPL (putchar, int, (int c));
707 _GL_CXXALIAS_RPL (putchar, int, (int c));
709 _GL_CXXALIAS_SYS (putchar, int, (int c));
711 _GL_CXXALIASWARN (putchar);
715 # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
716 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
718 # define puts rpl_puts
720 _GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1)));
721 _GL_CXXALIAS_RPL (puts, int, (const char *string));
723 _GL_CXXALIAS_SYS (puts, int, (const char *string));
725 _GL_CXXALIASWARN (puts);
729 # if @REPLACE_REMOVE@
730 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
732 # define remove rpl_remove
734 _GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1)));
735 _GL_CXXALIAS_RPL (remove, int, (const char *name));
737 _GL_CXXALIAS_SYS (remove, int, (const char *name));
739 _GL_CXXALIASWARN (remove);
740 #elif defined GNULIB_POSIXCHECK
742 /* Assume remove is always declared. */
743 _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
744 "use gnulib module remove for more portability");
748 # if @REPLACE_RENAME@
749 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
751 # define rename rpl_rename
753 _GL_FUNCDECL_RPL (rename, int,
754 (const char *old_filename, const char *new_filename)
755 _GL_ARG_NONNULL ((1, 2)));
756 _GL_CXXALIAS_RPL (rename, int,
757 (const char *old_filename, const char *new_filename));
759 _GL_CXXALIAS_SYS (rename, int,
760 (const char *old_filename, const char *new_filename));
762 _GL_CXXALIASWARN (rename);
763 #elif defined GNULIB_POSIXCHECK
765 /* Assume rename is always declared. */
766 _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
767 "use gnulib module rename for more portability");
770 #if @GNULIB_RENAMEAT@
771 # if @REPLACE_RENAMEAT@
772 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
774 # define renameat rpl_renameat
776 _GL_FUNCDECL_RPL (renameat, int,
777 (int fd1, char const *file1, int fd2, char const *file2)
778 _GL_ARG_NONNULL ((2, 4)));
779 _GL_CXXALIAS_RPL (renameat, int,
780 (int fd1, char const *file1, int fd2, char const *file2));
782 # if !@HAVE_RENAMEAT@
783 _GL_FUNCDECL_SYS (renameat, int,
784 (int fd1, char const *file1, int fd2, char const *file2)
785 _GL_ARG_NONNULL ((2, 4)));
787 _GL_CXXALIAS_SYS (renameat, int,
788 (int fd1, char const *file1, int fd2, char const *file2));
790 _GL_CXXALIASWARN (renameat);
791 #elif defined GNULIB_POSIXCHECK
793 # if HAVE_RAW_DECL_RENAMEAT
794 _GL_WARN_ON_USE (renameat, "renameat is not portable - "
795 "use gnulib module renameat for portability");
799 #if @GNULIB_SNPRINTF@
800 # if @REPLACE_SNPRINTF@
801 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
802 # define snprintf rpl_snprintf
804 _GL_FUNCDECL_RPL (snprintf, int,
805 (char *str, size_t size, const char *format, ...)
806 __attribute__ ((__format__ (__printf__, 3, 4)))
807 _GL_ARG_NONNULL ((3)));
808 _GL_CXXALIAS_RPL (snprintf, int,
809 (char *str, size_t size, const char *format, ...));
811 # if !@HAVE_DECL_SNPRINTF@
812 _GL_FUNCDECL_SYS (snprintf, int,
813 (char *str, size_t size, const char *format, ...)
814 __attribute__ ((__format__ (__printf__, 3, 4)))
815 _GL_ARG_NONNULL ((3)));
817 _GL_CXXALIAS_SYS (snprintf, int,
818 (char *str, size_t size, const char *format, ...));
820 _GL_CXXALIASWARN (snprintf);
821 #elif defined GNULIB_POSIXCHECK
823 # if HAVE_RAW_DECL_SNPRINTF
824 _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
825 "use gnulib module snprintf for portability");
829 /* Some people would argue that sprintf should be handled like gets
830 (for example, OpenBSD issues a link warning for both functions),
831 since both can cause security holes due to buffer overruns.
832 However, we believe that sprintf can be used safely, and is more
833 efficient than snprintf in those safe cases; and as proof of our
834 belief, we use sprintf in several gnulib modules. So this header
835 intentionally avoids adding a warning to sprintf except when
836 GNULIB_POSIXCHECK is defined. */
838 #if @GNULIB_SPRINTF_POSIX@
839 # if @REPLACE_SPRINTF@
840 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
841 # define sprintf rpl_sprintf
843 _GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...)
844 __attribute__ ((__format__ (__printf__, 2, 3)))
845 _GL_ARG_NONNULL ((1, 2)));
846 _GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...));
848 _GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...));
850 _GL_CXXALIASWARN (sprintf);
851 #elif defined GNULIB_POSIXCHECK
853 /* Assume sprintf is always declared. */
854 _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
855 "use gnulib module sprintf-posix for portable "
860 # if @REPLACE_TMPFILE@
861 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
862 # define tmpfile rpl_tmpfile
864 _GL_FUNCDECL_RPL (tmpfile, FILE *, (void));
865 _GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
867 _GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
869 _GL_CXXALIASWARN (tmpfile);
870 #elif defined GNULIB_POSIXCHECK
872 # if HAVE_RAW_DECL_TMPFILE
873 _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
874 "use gnulib module tmpfile for portability");
878 #if @GNULIB_VASPRINTF@
879 /* Write formatted output to a string dynamically allocated with malloc().
880 If the memory allocation succeeds, store the address of the string in
881 *RESULT and return the number of resulting bytes, excluding the trailing
882 NUL. Upon memory allocation error, or some other error, return -1. */
883 # if @REPLACE_VASPRINTF@
884 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
885 # define asprintf rpl_asprintf
887 _GL_FUNCDECL_RPL (asprintf, int,
888 (char **result, const char *format, ...)
889 __attribute__ ((__format__ (__printf__, 2, 3)))
890 _GL_ARG_NONNULL ((1, 2)));
891 _GL_CXXALIAS_RPL (asprintf, int,
892 (char **result, const char *format, ...));
894 # if !@HAVE_VASPRINTF@
895 _GL_FUNCDECL_SYS (asprintf, int,
896 (char **result, const char *format, ...)
897 __attribute__ ((__format__ (__printf__, 2, 3)))
898 _GL_ARG_NONNULL ((1, 2)));
900 _GL_CXXALIAS_SYS (asprintf, int,
901 (char **result, const char *format, ...));
903 _GL_CXXALIASWARN (asprintf);
904 # if @REPLACE_VASPRINTF@
905 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
906 # define vasprintf rpl_vasprintf
908 _GL_FUNCDECL_RPL (vasprintf, int,
909 (char **result, const char *format, va_list args)
910 __attribute__ ((__format__ (__printf__, 2, 0)))
911 _GL_ARG_NONNULL ((1, 2)));
912 _GL_CXXALIAS_RPL (vasprintf, int,
913 (char **result, const char *format, va_list args));
915 # if !@HAVE_VASPRINTF@
916 _GL_FUNCDECL_SYS (vasprintf, int,
917 (char **result, const char *format, va_list args)
918 __attribute__ ((__format__ (__printf__, 2, 0)))
919 _GL_ARG_NONNULL ((1, 2)));
921 _GL_CXXALIAS_SYS (vasprintf, int,
922 (char **result, const char *format, va_list args));
924 _GL_CXXALIASWARN (vasprintf);
927 #if @GNULIB_VDPRINTF@
928 # if @REPLACE_VDPRINTF@
929 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
930 # define vdprintf rpl_vdprintf
932 _GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args)
933 __attribute__ ((__format__ (__printf__, 2, 0)))
934 _GL_ARG_NONNULL ((2)));
935 _GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args));
937 # if !@HAVE_VDPRINTF@
938 _GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args)
939 __attribute__ ((__format__ (__printf__, 2, 0)))
940 _GL_ARG_NONNULL ((2)));
942 /* Need to cast, because on Solaris, the third parameter will likely be
944 _GL_CXXALIAS_SYS_CAST (vdprintf, int,
945 (int fd, const char *format, va_list args));
947 _GL_CXXALIASWARN (vdprintf);
948 #elif defined GNULIB_POSIXCHECK
950 # if HAVE_RAW_DECL_VDPRINTF
951 _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
952 "use gnulib module vdprintf for portability");
956 #if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
957 # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
958 || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
959 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
960 # define vfprintf rpl_vfprintf
962 # define GNULIB_overrides_vfprintf 1
963 _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
964 __attribute__ ((__format__ (__printf__, 2, 0)))
965 _GL_ARG_NONNULL ((1, 2)));
966 _GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args));
968 /* Need to cast, because on Solaris, the third parameter is
970 and GCC's fixincludes did not change this to __gnuc_va_list. */
971 _GL_CXXALIAS_SYS_CAST (vfprintf, int,
972 (FILE *fp, const char *format, va_list args));
974 _GL_CXXALIASWARN (vfprintf);
976 #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
977 # if !GNULIB_overrides_vfprintf
980 /* Assume vfprintf is always declared. */
981 _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
982 "use gnulib module vfprintf-posix for portable "
986 #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
987 # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
988 || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
989 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
990 # define vprintf rpl_vprintf
992 # define GNULIB_overrides_vprintf 1
993 _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
994 __attribute__ ((__format__ (__printf__, 1, 0)))
995 _GL_ARG_NONNULL ((1)));
996 _GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args));
998 /* Need to cast, because on Solaris, the second parameter is
1000 and GCC's fixincludes did not change this to __gnuc_va_list. */
1001 _GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args));
1003 _GL_CXXALIASWARN (vprintf);
1005 #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1006 # if !GNULIB_overrides_vprintf
1009 /* Assume vprintf is always declared. */
1010 _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
1011 "use gnulib module vprintf-posix for portable "
1012 "POSIX compliance");
1015 #if @GNULIB_VSNPRINTF@
1016 # if @REPLACE_VSNPRINTF@
1017 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1018 # define vsnprintf rpl_vsnprintf
1020 _GL_FUNCDECL_RPL (vsnprintf, int,
1021 (char *str, size_t size, const char *format, va_list args)
1022 __attribute__ ((__format__ (__printf__, 3, 0)))
1023 _GL_ARG_NONNULL ((3)));
1024 _GL_CXXALIAS_RPL (vsnprintf, int,
1025 (char *str, size_t size, const char *format, va_list args));
1027 # if !@HAVE_DECL_VSNPRINTF@
1028 _GL_FUNCDECL_SYS (vsnprintf, int,
1029 (char *str, size_t size, const char *format, va_list args)
1030 __attribute__ ((__format__ (__printf__, 3, 0)))
1031 _GL_ARG_NONNULL ((3)));
1033 _GL_CXXALIAS_SYS (vsnprintf, int,
1034 (char *str, size_t size, const char *format, va_list args));
1036 _GL_CXXALIASWARN (vsnprintf);
1037 #elif defined GNULIB_POSIXCHECK
1039 # if HAVE_RAW_DECL_VSNPRINTF
1040 _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
1041 "use gnulib module vsnprintf for portability");
1045 #if @GNULIB_VSPRINTF_POSIX@
1046 # if @REPLACE_VSPRINTF@
1047 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1048 # define vsprintf rpl_vsprintf
1050 _GL_FUNCDECL_RPL (vsprintf, int,
1051 (char *str, const char *format, va_list args)
1052 __attribute__ ((__format__ (__printf__, 2, 0)))
1053 _GL_ARG_NONNULL ((1, 2)));
1054 _GL_CXXALIAS_RPL (vsprintf, int,
1055 (char *str, const char *format, va_list args));
1057 /* Need to cast, because on Solaris, the third parameter is
1059 and GCC's fixincludes did not change this to __gnuc_va_list. */
1060 _GL_CXXALIAS_SYS_CAST (vsprintf, int,
1061 (char *str, const char *format, va_list args));
1063 _GL_CXXALIASWARN (vsprintf);
1064 #elif defined GNULIB_POSIXCHECK
1066 /* Assume vsprintf is always declared. */
1067 _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
1068 "use gnulib module vsprintf-posix for portable "
1069 "POSIX compliance");
1073 #endif /* _GL_STDIO_H */
1074 #endif /* _GL_STDIO_H */