lib/stdio.in.h: Fix typo.
[gnulib.git] / lib / stdio.in.h
1 /* A GNU-like <stdio.h>.
2
3    Copyright (C) 2004, 2007-2010 Free Software Foundation, Inc.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2, or (at your option)
8    any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18
19 #if __GNUC__ >= 3
20 @PRAGMA_SYSTEM_HEADER@
21 #endif
22
23 #if defined __need_FILE || defined __need___FILE
24 /* Special invocation convention inside glibc header files.  */
25
26 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
27
28 #else
29 /* Normal invocation convention.  */
30
31 #ifndef _GL_STDIO_H
32
33 /* The include_next requires a split double-inclusion guard.  */
34 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
35
36 #ifndef _GL_STDIO_H
37 #define _GL_STDIO_H
38
39 /* Get va_list.  Needed on many systems, including glibc 2.8.  */
40 #include <stdarg.h>
41
42 #include <stddef.h>
43
44 /* Get off_t and ssize_t.  Needed on many systems, including glibc 2.8.  */
45 #include <sys/types.h>
46
47 #ifndef __attribute__
48 /* This feature is available in gcc versions 2.5 and later.  */
49 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
50 #  define __attribute__(Spec) /* empty */
51 # endif
52 /* The __-protected variants of `format' and `printf' attributes
53    are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
54 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
55 #  define __format__ format
56 #  define __printf__ printf
57 # endif
58 #endif
59
60
61 /* The definition of GL_LINK_WARNING is copied here.  */
62
63 /* The definition of _GL_ARG_NONNULL is copied here.  */
64
65 /* The definition of _GL_WARN_ON_USE is copied here.  */
66
67
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71
72 #if @GNULIB_DPRINTF@
73 # if @REPLACE_DPRINTF@
74 #  define dprintf rpl_dprintf
75 # endif
76 # if @REPLACE_DPRINTF@ || !@HAVE_DPRINTF@
77 extern int dprintf (int fd, const char *format, ...)
78        __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((2));
79 # endif
80 #elif defined GNULIB_POSIXCHECK
81 # undef dprintf
82 # define dprintf \
83     (GL_LINK_WARNING ("dprintf is unportable - " \
84                       "use gnulib module dprintf for portability"), \
85      dprintf)
86 #endif
87
88 #if @GNULIB_FCLOSE@
89 # if @REPLACE_FCLOSE@
90 #  define fclose rpl_fclose
91   /* Close STREAM and its underlying file descriptor.  */
92 extern int fclose (FILE *stream) _GL_ARG_NONNULL ((1));
93 # endif
94 #elif defined GNULIB_POSIXCHECK
95 # undef fclose
96 # define fclose(f) \
97    (GL_LINK_WARNING ("fclose is not always POSIX compliant - " \
98                      "use gnulib module fclose for portable " \
99                      "POSIX compliance"), \
100     fclose (f))
101 #endif
102
103 #if @GNULIB_FFLUSH@
104 # if @REPLACE_FFLUSH@
105 #  define fflush rpl_fflush
106   /* Flush all pending data on STREAM according to POSIX rules.  Both
107      output and seekable input streams are supported.
108      Note! LOSS OF DATA can occur if fflush is applied on an input stream
109      that is _not_seekable_ or on an update stream that is _not_seekable_
110      and in which the most recent operation was input.  Seekability can
111      be tested with lseek(fileno(fp),0,SEEK_CUR).  */
112   extern int fflush (FILE *gl_stream);
113 # endif
114 #elif defined GNULIB_POSIXCHECK
115 # undef fflush
116 # define fflush(f) \
117    (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \
118                      "use gnulib module fflush for portable " \
119                      "POSIX compliance"), \
120     fflush (f))
121 #endif
122
123 /* It is very rare that the developer ever has full control of stdin,
124    so any use of gets warrants an unconditional warning.  Assume it is
125    always declared, since it is required by C89.  */
126 #undef gets
127 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
128
129 #if @GNULIB_FOPEN@
130 # if @REPLACE_FOPEN@
131 #  undef fopen
132 #  define fopen rpl_fopen
133 extern FILE * fopen (const char *filename, const char *mode)
134      _GL_ARG_NONNULL ((1, 2));
135 # endif
136 #elif defined GNULIB_POSIXCHECK
137 # undef fopen
138 # define fopen(f,m) \
139    (GL_LINK_WARNING ("fopen on Win32 platforms is not POSIX compatible - " \
140                      "use gnulib module fopen for portability"), \
141     fopen (f, m))
142 #endif
143
144 #if @GNULIB_FPRINTF_POSIX@
145 # if @REPLACE_FPRINTF@
146 #  define fprintf rpl_fprintf
147 extern int fprintf (FILE *fp, const char *format, ...)
148        __attribute__ ((__format__ (__printf__, 2, 3)))
149        _GL_ARG_NONNULL ((1, 2));
150 # endif
151 #elif @GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
152 # define fprintf rpl_fprintf
153 extern int fprintf (FILE *fp, const char *format, ...)
154        __attribute__ ((__format__ (__printf__, 2, 3)))
155        _GL_ARG_NONNULL ((1, 2));
156 #elif defined GNULIB_POSIXCHECK
157 # undef fprintf
158 # define fprintf \
159     (GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \
160                       "use gnulib module fprintf-posix for portable " \
161                       "POSIX compliance"), \
162      fprintf)
163 #endif
164
165 #if @GNULIB_FPURGE@
166 # if @REPLACE_FPURGE@
167 #  define fpurge rpl_fpurge
168 # endif
169 # if @REPLACE_FPURGE@ || !@HAVE_DECL_FPURGE@
170   /* Discard all pending buffered I/O data on STREAM.
171      STREAM must not be wide-character oriented.
172      When discarding pending output, the file position is set back to where it
173      was before the write calls.  When discarding pending input, the file
174      position is advanced to match the end of the previously read input.
175      Return 0 if successful.  Upon error, return -1 and set errno.  */
176   extern int fpurge (FILE *gl_stream) _GL_ARG_NONNULL ((1));
177 # endif
178 #elif defined GNULIB_POSIXCHECK
179 # undef fpurge
180 # define fpurge(f) \
181    (GL_LINK_WARNING ("fpurge is not always present - " \
182                      "use gnulib module fpurge for portability"), \
183     fpurge (f))
184 #endif
185
186 #if @GNULIB_FPUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
187 # undef fputc
188 # define fputc rpl_fputc
189 extern int fputc (int c, FILE *stream) _GL_ARG_NONNULL ((2));
190 #endif
191
192 #if @GNULIB_FPUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
193 # undef fputs
194 # define fputs rpl_fputs
195 extern int fputs (const char *string, FILE *stream) _GL_ARG_NONNULL ((1, 2));
196 #endif
197
198 #if @GNULIB_FREOPEN@
199 # if @REPLACE_FREOPEN@
200 #  undef freopen
201 #  define freopen rpl_freopen
202 extern FILE * freopen (const char *filename, const char *mode, FILE *stream)
203      _GL_ARG_NONNULL ((2, 3));
204 # endif
205 #elif defined GNULIB_POSIXCHECK
206 # undef freopen
207 # define freopen(f,m,s) \
208    (GL_LINK_WARNING ("freopen on Win32 platforms is not POSIX compatible - " \
209                      "use gnulib module freopen for portability"), \
210     freopen (f, m, s))
211 #endif
212
213 /* Set up the following warnings, based on which modules are in use.
214    GNU Coding Standards discourage the use of fseek, since it imposes
215    an arbitrary limitation on some 32-bit hosts.  Remember that the
216    fseek module depends on the fseeko module, so we only have three
217    cases to consider:
218
219    1. The developer is not using either module.  Issue a warning under
220    GNULIB_POSIXCHECK for both functions, to remind them that both
221    functions have bugs on some systems.  _GL_NO_LARGE_FILES has no
222    impact on this warning.
223
224    2. The developer is using both modules.  They may be unaware of the
225    arbitrary limitations of fseek, so issue a warning under
226    GNULIB_POSIXCHECK.  On the other hand, they may be using both
227    modules intentionally, so the developer can define
228    _GL_NO_LARGE_FILES in the compilation units where the use of fseek
229    is safe, to silence the warning.
230
231    3. The developer is using the fseeko module, but not fseek.  Gnulib
232    guarantees that fseek will still work around platform bugs in that
233    case, but we presume that the developer is aware of the pitfalls of
234    fseek and was trying to avoid it, so issue a warning even when
235    GNULIB_POSIXCHECK is undefined.  Again, _GL_NO_LARGE_FILES can be
236    defined to silence the warning in particular compilation units.
237
238    Most gnulib clients that perform stream operations should fall into
239    category three.  */
240
241 #if @GNULIB_FSEEK@
242 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
243 #  define _GL_FSEEK_WARN /* Category 2, above.  */
244 #  undef fseek
245 # endif
246 # if @REPLACE_FSEEK@
247 #  undef fseek
248 #  define fseek rpl_fseek
249 extern int fseek (FILE *fp, long offset, int whence) _GL_ARG_NONNULL ((1));
250 # endif
251 #endif
252
253 #if @GNULIB_FSEEKO@
254 # if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES
255 #  define _GL_FSEEK_WARN /* Category 3, above.  */
256 #  undef fseek
257 # endif
258 # if @REPLACE_FSEEKO@
259 /* Provide fseek, fseeko functions that are aware of a preceding
260    fflush(), and which detect pipes.  */
261 #  undef fseeko
262 #  define fseeko rpl_fseeko
263 extern int fseeko (FILE *fp, off_t offset, int whence) _GL_ARG_NONNULL ((1));
264 #  if !@GNULIB_FSEEK@
265 #   undef fseek
266 #   define fseek rpl_fseek
267 static inline int _GL_ARG_NONNULL ((1))
268 rpl_fseek (FILE *fp, long offset, int whence)
269 {
270   return fseeko (fp, offset, whence);
271 }
272 #  endif
273 # endif
274 #elif defined GNULIB_POSIXCHECK
275 # define _GL_FSEEK_WARN /* Category 1, above.  */
276 # undef fseek
277 # undef fseeko
278 # if HAVE_RAW_DECL_FSEEKO
279 _GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
280                  "use gnulib module fseeko for portability");
281 # endif
282 #endif
283
284 #ifdef _GL_FSEEK_WARN
285 # undef _GL_FSEEK_WARN
286 /* Here, either fseek is undefined (but C89 guarantees that it is
287    declared), or it is defined as rpl_fseek (declared above).  */
288 _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
289                  "on 32-bit platforms - "
290                  "use fseeko function for handling of large files");
291 #endif
292
293 /* See the comments on fseek/fseeko.  */
294
295 #if @GNULIB_FTELL@
296 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
297 #  define _GL_FTELL_WARN /* Category 2, above.  */
298 #  undef ftell
299 # endif
300 # if @REPLACE_FTELL@
301 #  undef ftell
302 #  define ftell rpl_ftell
303 extern long ftell (FILE *fp) _GL_ARG_NONNULL ((1));
304 # endif
305 #endif
306
307 #if @GNULIB_FTELLO@
308 # if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES
309 #  define _GL_FTELL_WARN /* Category 3, above.  */
310 #  undef ftell
311 # endif
312 # if @REPLACE_FTELLO@
313 #  undef ftello
314 #  define ftello rpl_ftello
315 extern off_t ftello (FILE *fp) _GL_ARG_NONNULL ((1));
316 #  if !@GNULIB_FTELL@
317 #   undef ftell
318 #   define ftell rpl_ftell
319 static inline long _GL_ARG_NONNULL ((1))
320 rpl_ftell (FILE *f)
321 {
322   return ftello (f);
323 }
324 #  endif
325 # endif
326 #elif defined GNULIB_POSIXCHECK
327 # define _GL_FTELL_WARN /* Category 1, above.  */
328 # undef ftell
329 # undef ftello
330 # if HAVE_RAW_DECL_FTELLO
331 _GL_WARN_ON_USE (ftello, "ftello is unportable - "
332                  "use gnulib module ftello for portability");
333 # endif
334 #endif
335
336 #ifdef _GL_FTELL_WARN
337 # undef _GL_FTELL_WARN
338 /* Here, either ftell is undefined (but C89 guarantees that it is
339    declared), or it is defined as rpl_ftell (declared above).  */
340 _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
341                  "on 32-bit platforms - "
342                  "use ftello function for handling of large files");
343 #endif
344
345 #if @GNULIB_FWRITE@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
346 # undef fwrite
347 # define fwrite rpl_fwrite
348 extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
349      _GL_ARG_NONNULL ((1, 4));
350 #endif
351
352 #if @GNULIB_GETDELIM@
353 # if !@HAVE_DECL_GETDELIM@
354 /* Read input, up to (and including) the next occurrence of DELIMITER, from
355    STREAM, store it in *LINEPTR (and NUL-terminate it).
356    *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
357    bytes of space.  It is realloc'd as necessary.
358    Return the number of bytes read and stored at *LINEPTR (not including the
359    NUL terminator), or -1 on error or EOF.  */
360 extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
361                          FILE *stream)
362      _GL_ARG_NONNULL ((1, 2, 4));
363 # endif
364 #elif defined GNULIB_POSIXCHECK
365 # undef getdelim
366 # define getdelim(l, s, d, f)                                       \
367   (GL_LINK_WARNING ("getdelim is unportable - "                     \
368                     "use gnulib module getdelim for portability"),  \
369    getdelim (l, s, d, f))
370 #endif
371
372 #if @GNULIB_GETLINE@
373 # if @REPLACE_GETLINE@
374 #  undef getline
375 #  define getline rpl_getline
376 # endif
377 # if !@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@
378 /* Read a line, up to (and including) the next newline, from STREAM, store it
379    in *LINEPTR (and NUL-terminate it).
380    *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
381    bytes of space.  It is realloc'd as necessary.
382    Return the number of bytes read and stored at *LINEPTR (not including the
383    NUL terminator), or -1 on error or EOF.  */
384 extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream)
385      _GL_ARG_NONNULL ((1, 2, 3));
386 # endif
387 #elif defined GNULIB_POSIXCHECK
388 # undef getline
389 # define getline(l, s, f)                                               \
390   (GL_LINK_WARNING ("getline is unportable - "                          \
391                     "use gnulib module getline for portability"),       \
392    getline (l, s, f))
393 #endif
394
395 #if @GNULIB_OBSTACK_PRINTF@
396 # if @REPLACE_OBSTACK_PRINTF@
397 #  define obstack_printf rpl_osbtack_printf
398 #  define obstack_vprintf rpl_obstack_vprintf
399 # endif
400 # if @REPLACE_OBSTACK_PRINTF@ || !@HAVE_DECL_OBSTACK_PRINTF@
401   struct obstack;
402   /* Grow an obstack with formatted output.  Return the number of
403      bytes added to OBS.  No trailing nul byte is added, and the
404      object should be closed with obstack_finish before use.  Upon
405      memory allocation error, call obstack_alloc_failed_handler.  Upon
406      other error, return -1.  */
407   extern int obstack_printf (struct obstack *obs, const char *format, ...)
408     __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2));
409   extern int obstack_vprintf (struct obstack *obs, const char *format,
410                               va_list args)
411     __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2));
412 # endif
413 #endif
414
415 #if @GNULIB_PERROR@
416 # if @REPLACE_PERROR@
417 #  define perror rpl_perror
418 /* Print a message to standard error, describing the value of ERRNO,
419    (if STRING is not NULL and not empty) prefixed with STRING and ": ",
420    and terminated with a newline.  */
421 extern void perror (const char *string);
422 # endif
423 #elif defined GNULIB_POSIXCHECK
424 # undef perror
425 # define perror(s) \
426     (GL_LINK_WARNING ("perror is not always POSIX compliant - " \
427                       "use gnulib module perror for portability"), \
428      perror (s))
429 #endif
430
431 #if @GNULIB_POPEN@
432 # if @REPLACE_POPEN@
433 #  undef popen
434 #  define popen rpl_popen
435 extern FILE *popen (const char *cmd, const char *mode)
436      _GL_ARG_NONNULL ((1, 2));
437 # endif
438 #elif defined GNULIB_POSIXCHECK
439 # undef popen
440 # define popen(c,m) \
441    (GL_LINK_WARNING ("popen is buggy on some platforms - " \
442                      "use gnulib module popen or pipe for more portability"), \
443     popen (c, m))
444 #endif
445
446 #if @GNULIB_PRINTF_POSIX@
447 # if @REPLACE_PRINTF@
448 /* Don't break __attribute__((format(printf,M,N))).  */
449 #  define printf __printf__
450 extern int printf (const char *format, ...)
451        __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1));
452 # endif
453 #elif @GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
454 /* Don't break __attribute__((format(printf,M,N))).  */
455 # define printf __printf__
456 extern int printf (const char *format, ...)
457        __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1));
458 #elif defined GNULIB_POSIXCHECK
459 # undef printf
460 # define printf \
461     (GL_LINK_WARNING ("printf is not always POSIX compliant - " \
462                       "use gnulib module printf-posix for portable " \
463                       "POSIX compliance"), \
464      printf)
465 /* Don't break __attribute__((format(printf,M,N))).  */
466 # define format(kind,m,n) format (__##kind##__, m, n)
467 # define __format__(kind,m,n) __format__ (__##kind##__, m, n)
468 # define ____printf____ __printf__
469 # define ____scanf____ __scanf__
470 # define ____strftime____ __strftime__
471 # define ____strfmon____ __strfmon__
472 #endif
473
474 #if @GNULIB_PUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
475 # undef putc
476 # define putc rpl_fputc
477 extern int putc (int c, FILE *stream) _GL_ARG_NONNULL ((2));
478 #endif
479
480 #if @GNULIB_PUTCHAR@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
481 # undef putchar
482 # define putchar rpl_putchar
483 extern int putchar (int c);
484 #endif
485
486 #if @GNULIB_PUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
487 # undef puts
488 # define puts rpl_puts
489 extern int puts (const char *string) _GL_ARG_NONNULL ((1));
490 #endif
491
492 #if @GNULIB_REMOVE@
493 # if @REPLACE_REMOVE@
494 #  undef remove
495 #  define remove rpl_remove
496 extern int remove (const char *name) _GL_ARG_NONNULL ((1));
497 # endif
498 #elif defined GNULIB_POSIXCHECK
499 # undef remove
500 # define remove(n)                                         \
501    (GL_LINK_WARNING ("remove cannot handle directories on some platforms - " \
502                      "use gnulib module remove for more portability"), \
503     remove (n))
504 #endif
505
506 #if @GNULIB_RENAME@
507 # if @REPLACE_RENAME@
508 #  undef rename
509 #  define rename rpl_rename
510 extern int rename (const char *old_filename, const char *new_filename)
511      _GL_ARG_NONNULL ((1, 2));
512 # endif
513 #elif defined GNULIB_POSIXCHECK
514 # undef rename
515 # define rename(o,n)                                       \
516    (GL_LINK_WARNING ("rename is buggy on some platforms - " \
517                      "use gnulib module rename for more portability"), \
518     rename (o, n))
519 #endif
520
521 #if @GNULIB_RENAMEAT@
522 # if @REPLACE_RENAMEAT@
523 #  undef renameat
524 #  define renameat rpl_renameat
525 # endif
526 # if !@HAVE_RENAMEAT@ || @REPLACE_RENAMEAT@
527 extern int renameat (int fd1, char const *file1, int fd2, char const *file2)
528      _GL_ARG_NONNULL ((2, 4));
529 # endif
530 #elif defined GNULIB_POSIXCHECK
531 # undef renameat
532 # define renameat(d1,f1,d2,f2)             \
533     (GL_LINK_WARNING ("renameat is not portable - " \
534                       "use gnulib module renameat for portability"), \
535      renameat (d1, f1, d2, f2))
536 #endif
537
538 #if @GNULIB_SNPRINTF@
539 # if @REPLACE_SNPRINTF@
540 #  define snprintf rpl_snprintf
541 # endif
542 # if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
543 extern int snprintf (char *str, size_t size, const char *format, ...)
544        __attribute__ ((__format__ (__printf__, 3, 4)))
545        _GL_ARG_NONNULL ((3));
546 # endif
547 #elif defined GNULIB_POSIXCHECK
548 # undef snprintf
549 # define snprintf \
550     (GL_LINK_WARNING ("snprintf is unportable - " \
551                       "use gnulib module snprintf for portability"), \
552      snprintf)
553 #endif
554
555 /* Some people would argue that sprintf should be handled like gets
556    (for example, OpenBSD issues a link warning for both functions),
557    since both can cause security holes due to buffer overruns.
558    However, we believe that sprintf can be used safely, and is more
559    efficient than snprintf in those safe cases; and as proof of our
560    belief, we use sprintf in several gnulib modules.  So this header
561    intentionally avoids adding a warning to sprintf except when
562    GNULIB_POSIXCHECK is defined.  */
563
564 #if @GNULIB_SPRINTF_POSIX@
565 # if @REPLACE_SPRINTF@
566 #  define sprintf rpl_sprintf
567 extern int sprintf (char *str, const char *format, ...)
568        __attribute__ ((__format__ (__printf__, 2, 3)))
569        _GL_ARG_NONNULL ((1, 2));
570 # endif
571 #elif defined GNULIB_POSIXCHECK
572 # undef sprintf
573 # define sprintf \
574     (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \
575                       "use gnulib module sprintf-posix for portable " \
576                       "POSIX compliance"), \
577      sprintf)
578 #endif
579
580 #if @GNULIB_VASPRINTF@
581 # if @REPLACE_VASPRINTF@
582 #  define asprintf rpl_asprintf
583 #  define vasprintf rpl_vasprintf
584 # endif
585 # if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@
586   /* Write formatted output to a string dynamically allocated with malloc().
587      If the memory allocation succeeds, store the address of the string in
588      *RESULT and return the number of resulting bytes, excluding the trailing
589      NUL.  Upon memory allocation error, or some other error, return -1.  */
590   extern int asprintf (char **result, const char *format, ...)
591     __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2));
592   extern int vasprintf (char **result, const char *format, va_list args)
593     __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2));
594 # endif
595 #endif
596
597 #if @GNULIB_VDPRINTF@
598 # if @REPLACE_VDPRINTF@
599 #  define vdprintf rpl_vdprintf
600 # endif
601 # if @REPLACE_VDPRINTF@ || !@HAVE_VDPRINTF@
602 extern int vdprintf (int fd, const char *format, va_list args)
603        __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((2));
604 # endif
605 #elif defined GNULIB_POSIXCHECK
606 # undef vdprintf
607 # define vdprintf(d,f,a) \
608     (GL_LINK_WARNING ("vdprintf is unportable - " \
609                       "use gnulib module vdprintf for portability"), \
610      vdprintf (d, f, a))
611 #endif
612
613 #if @GNULIB_VFPRINTF_POSIX@
614 # if @REPLACE_VFPRINTF@
615 #  define vfprintf rpl_vfprintf
616 extern int vfprintf (FILE *fp, const char *format, va_list args)
617        __attribute__ ((__format__ (__printf__, 2, 0)))
618        _GL_ARG_NONNULL ((1, 2));
619 # endif
620 #elif @GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
621 # define vfprintf rpl_vfprintf
622 extern int vfprintf (FILE *fp, const char *format, va_list args)
623        __attribute__ ((__format__ (__printf__, 2, 0)))
624        _GL_ARG_NONNULL ((1, 2));
625 #elif defined GNULIB_POSIXCHECK
626 # undef vfprintf
627 # define vfprintf(s,f,a) \
628     (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \
629                       "use gnulib module vfprintf-posix for portable " \
630                       "POSIX compliance"), \
631      vfprintf (s, f, a))
632 #endif
633
634 #if @GNULIB_VPRINTF_POSIX@
635 # if @REPLACE_VPRINTF@
636 #  define vprintf rpl_vprintf
637 extern int vprintf (const char *format, va_list args)
638        __attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1));
639 # endif
640 #elif @GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
641 # define vprintf rpl_vprintf
642 extern int vprintf (const char *format, va_list args)
643        __attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1));
644 #elif defined GNULIB_POSIXCHECK
645 # undef vprintf
646 # define vprintf(f,a) \
647     (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \
648                       "use gnulib module vprintf-posix for portable " \
649                       "POSIX compliance"), \
650      vprintf (f, a))
651 #endif
652
653 #if @GNULIB_VSNPRINTF@
654 # if @REPLACE_VSNPRINTF@
655 #  define vsnprintf rpl_vsnprintf
656 # endif
657 # if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
658 extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
659        __attribute__ ((__format__ (__printf__, 3, 0)))
660        _GL_ARG_NONNULL ((3));
661 # endif
662 #elif defined GNULIB_POSIXCHECK
663 # undef vsnprintf
664 # define vsnprintf(b,s,f,a) \
665     (GL_LINK_WARNING ("vsnprintf is unportable - " \
666                       "use gnulib module vsnprintf for portability"), \
667      vsnprintf (b, s, f, a))
668 #endif
669
670 #if @GNULIB_VSPRINTF_POSIX@
671 # if @REPLACE_VSPRINTF@
672 #  define vsprintf rpl_vsprintf
673 extern int vsprintf (char *str, const char *format, va_list args)
674        __attribute__ ((__format__ (__printf__, 2, 0)))
675        _GL_ARG_NONNULL ((1, 2));
676 # endif
677 #elif defined GNULIB_POSIXCHECK
678 # undef vsprintf
679 # define vsprintf(b,f,a) \
680     (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \
681                       "use gnulib module vsprintf-posix for portable " \
682                       "POSIX compliance"), \
683      vsprintf (b, f, a))
684 #endif
685
686 #ifdef __cplusplus
687 }
688 #endif
689
690 #endif /* _GL_STDIO_H */
691 #endif /* _GL_STDIO_H */
692 #endif