]> git.cworth.org Git - tar/blob - gnu/stdio.in.h
88b368be322aad6675d08a68c9043427cab3d9de
[tar] / gnu / stdio.in.h
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* A GNU-like <stdio.h>.
4
5    Copyright (C) 2004, 2007-2010 Free Software Foundation, Inc.
6
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)
10    any later version.
11
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.
16
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.  */
20
21 #if __GNUC__ >= 3
22 @PRAGMA_SYSTEM_HEADER@
23 #endif
24
25 #if defined __need_FILE || defined __need___FILE
26 /* Special invocation convention inside glibc header files.  */
27
28 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
29
30 #else
31 /* Normal invocation convention.  */
32
33 #ifndef _GL_STDIO_H
34
35 /* The include_next requires a split double-inclusion guard.  */
36 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
37
38 #ifndef _GL_STDIO_H
39 #define _GL_STDIO_H
40
41 /* Get va_list.  Needed on many systems, including glibc 2.8.  */
42 #include <stdarg.h>
43
44 #include <stddef.h>
45
46 /* Get off_t and ssize_t.  Needed on many systems, including glibc 2.8.  */
47 #include <sys/types.h>
48
49 #ifndef __attribute__
50 /* The __attribute__ feature is available in gcc versions 2.5 and later.
51    The __-protected variants of the attributes 'format' and 'printf' are
52    accepted by gcc versions 2.6.4 (effectively 2.7) and later.
53    We enable __attribute__ only if these are supported too, because
54    gnulib and libintl do '#define printf __printf__' when they override
55    the 'printf' function.  */
56 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
57 #  define __attribute__(Spec)   /* empty */
58 # endif
59 #endif
60
61
62 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
63
64 /* The definition of _GL_ARG_NONNULL is copied here.  */
65
66 /* The definition of _GL_WARN_ON_USE is copied here.  */
67
68
69 #if @GNULIB_DPRINTF@
70 # if @REPLACE_DPRINTF@
71 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
72 #   define dprintf rpl_dprintf
73 #  endif
74 _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...)
75                                 __attribute__ ((__format__ (__printf__, 2, 3)))
76                                 _GL_ARG_NONNULL ((2)));
77 _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...));
78 # else
79 #  if !@HAVE_DPRINTF@
80 _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...)
81                                 __attribute__ ((__format__ (__printf__, 2, 3)))
82                                 _GL_ARG_NONNULL ((2)));
83 #  endif
84 _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...));
85 # endif
86 _GL_CXXALIASWARN (dprintf);
87 #elif defined GNULIB_POSIXCHECK
88 # undef dprintf
89 # if HAVE_RAW_DECL_DPRINTF
90 _GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
91                  "use gnulib module dprintf for portability");
92 # endif
93 #endif
94
95 #if @GNULIB_FCLOSE@
96 /* Close STREAM and its underlying file descriptor.  */
97 # if @REPLACE_FCLOSE@
98 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
99 #   define fclose rpl_fclose
100 #  endif
101 _GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
102 _GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
103 # else
104 _GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
105 # endif
106 _GL_CXXALIASWARN (fclose);
107 #elif defined GNULIB_POSIXCHECK
108 # undef fclose
109 /* Assume fclose is always declared.  */
110 _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
111                  "use gnulib module fclose for portable POSIX compliance");
112 #endif
113
114 #if @GNULIB_FFLUSH@
115 /* Flush all pending data on STREAM according to POSIX rules.  Both
116    output and seekable input streams are supported.
117    Note! LOSS OF DATA can occur if fflush is applied on an input stream
118    that is _not_seekable_ or on an update stream that is _not_seekable_
119    and in which the most recent operation was input.  Seekability can
120    be tested with lseek(fileno(fp),0,SEEK_CUR).  */
121 # if @REPLACE_FFLUSH@
122 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
123 #   define fflush rpl_fflush
124 #  endif
125 _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream));
126 _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
127 # else
128 _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
129 # endif
130 _GL_CXXALIASWARN (fflush);
131 #elif defined GNULIB_POSIXCHECK
132 # undef fflush
133 /* Assume fflush is always declared.  */
134 _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
135                  "use gnulib module fflush for portable POSIX compliance");
136 #endif
137
138 /* It is very rare that the developer ever has full control of stdin,
139    so any use of gets warrants an unconditional warning.  Assume it is
140    always declared, since it is required by C89.  */
141 #undef gets
142 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
143
144 #if @GNULIB_FOPEN@
145 # if @REPLACE_FOPEN@
146 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
147 #   undef fopen
148 #   define fopen rpl_fopen
149 #  endif
150 _GL_FUNCDECL_RPL (fopen, FILE *, (const char *filename, const char *mode)
151                                  _GL_ARG_NONNULL ((1, 2)));
152 _GL_CXXALIAS_RPL (fopen, FILE *, (const char *filename, const char *mode));
153 # else
154 _GL_CXXALIAS_SYS (fopen, FILE *, (const char *filename, const char *mode));
155 # endif
156 _GL_CXXALIASWARN (fopen);
157 #elif defined GNULIB_POSIXCHECK
158 # undef fopen
159 /* Assume fopen is always declared.  */
160 _GL_WARN_ON_USE (fopen, "fopen on Win32 platforms is not POSIX compatible - "
161                  "use gnulib module fopen for portability");
162 #endif
163
164 #if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
165 # if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
166      || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
167 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
168 #   define fprintf rpl_fprintf
169 #  endif
170 #  define GNULIB_overrides_fprintf 1
171 _GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
172                                 __attribute__ ((__format__ (__printf__, 2, 3)))
173                                 _GL_ARG_NONNULL ((1, 2)));
174 _GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...));
175 # else
176 _GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...));
177 # endif
178 _GL_CXXALIASWARN (fprintf);
179 #endif
180 #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
181 # if !GNULIB_overrides_fprintf
182 #  undef fprintf
183 # endif
184 /* Assume fprintf is always declared.  */
185 _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
186                  "use gnulib module fprintf-posix for portable "
187                  "POSIX compliance");
188 #endif
189
190 #if @GNULIB_FPURGE@
191 /* Discard all pending buffered I/O data on STREAM.
192    STREAM must not be wide-character oriented.
193    When discarding pending output, the file position is set back to where it
194    was before the write calls.  When discarding pending input, the file
195    position is advanced to match the end of the previously read input.
196    Return 0 if successful.  Upon error, return -1 and set errno.  */
197 # if @REPLACE_FPURGE@
198 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
199 #   define fpurge rpl_fpurge
200 #  endif
201 _GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
202 _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream));
203 # else
204 #  if !@HAVE_DECL_FPURGE@
205 _GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
206 #  endif
207 _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream));
208 # endif
209 _GL_CXXALIASWARN (fpurge);
210 #elif defined GNULIB_POSIXCHECK
211 # undef fpurge
212 # if HAVE_RAW_DECL_FPURGE
213 _GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
214                  "use gnulib module fpurge for portability");
215 # endif
216 #endif
217
218 #if @GNULIB_FPUTC@
219 # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
220 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
221 #   undef fputc
222 #   define fputc rpl_fputc
223 #  endif
224 _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
225 _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
226 # else
227 _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
228 # endif
229 _GL_CXXALIASWARN (fputc);
230 #endif
231
232 #if @GNULIB_FPUTS@
233 # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
234 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
235 #   undef fputs
236 #   define fputs rpl_fputs
237 #  endif
238 _GL_FUNCDECL_RPL (fputs, int, (const char *string, FILE *stream)
239                               _GL_ARG_NONNULL ((1, 2)));
240 _GL_CXXALIAS_RPL (fputs, int, (const char *string, FILE *stream));
241 # else
242 _GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream));
243 # endif
244 _GL_CXXALIASWARN (fputs);
245 #endif
246
247 #if @GNULIB_FREOPEN@
248 # if @REPLACE_FREOPEN@
249 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
250 #   undef freopen
251 #   define freopen rpl_freopen
252 #  endif
253 _GL_FUNCDECL_RPL (freopen, FILE *,
254                   (const char *filename, const char *mode, FILE *stream)
255                   _GL_ARG_NONNULL ((2, 3)));
256 _GL_CXXALIAS_RPL (freopen, FILE *,
257                   (const char *filename, const char *mode, FILE *stream));
258 # else
259 _GL_CXXALIAS_SYS (freopen, FILE *,
260                   (const char *filename, const char *mode, FILE *stream));
261 # endif
262 _GL_CXXALIASWARN (freopen);
263 #elif defined GNULIB_POSIXCHECK
264 # undef freopen
265 /* Assume freopen is always declared.  */
266 _GL_WARN_ON_USE (freopen, "freopen on Win32 platforms is not POSIX compatible - "
267                  "use gnulib module freopen for portability");
268 #endif
269
270
271 /* Set up the following warnings, based on which modules are in use.
272    GNU Coding Standards discourage the use of fseek, since it imposes
273    an arbitrary limitation on some 32-bit hosts.  Remember that the
274    fseek module depends on the fseeko module, so we only have three
275    cases to consider:
276
277    1. The developer is not using either module.  Issue a warning under
278    GNULIB_POSIXCHECK for both functions, to remind them that both
279    functions have bugs on some systems.  _GL_NO_LARGE_FILES has no
280    impact on this warning.
281
282    2. The developer is using both modules.  They may be unaware of the
283    arbitrary limitations of fseek, so issue a warning under
284    GNULIB_POSIXCHECK.  On the other hand, they may be using both
285    modules intentionally, so the developer can define
286    _GL_NO_LARGE_FILES in the compilation units where the use of fseek
287    is safe, to silence the warning.
288
289    3. The developer is using the fseeko module, but not fseek.  Gnulib
290    guarantees that fseek will still work around platform bugs in that
291    case, but we presume that the developer is aware of the pitfalls of
292    fseek and was trying to avoid it, so issue a warning even when
293    GNULIB_POSIXCHECK is undefined.  Again, _GL_NO_LARGE_FILES can be
294    defined to silence the warning in particular compilation units.
295    In C++ compilations with GNULIB_NAMESPACE, in order to avoid that
296    fseek gets defined as a macro, it is recommended that the developer
297    uses the fseek module, even if he is not calling the fseek function.
298
299    Most gnulib clients that perform stream operations should fall into
300    category 3.  */
301
302 #if @GNULIB_FSEEK@
303 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
304 #  define _GL_FSEEK_WARN /* Category 2, above.  */
305 #  undef fseek
306 # endif
307 # if @REPLACE_FSEEK@
308 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
309 #   undef fseek
310 #   define fseek rpl_fseek
311 #  endif
312 _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence)
313                               _GL_ARG_NONNULL ((1)));
314 _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
315 # else
316 _GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence));
317 # endif
318 _GL_CXXALIASWARN (fseek);
319 #endif
320
321 #if @GNULIB_FSEEKO@
322 # if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES
323 #  define _GL_FSEEK_WARN /* Category 3, above.  */
324 #  undef fseek
325 # endif
326 # if @REPLACE_FSEEKO@
327 /* Provide fseek, fseeko functions that are aware of a preceding
328    fflush(), and which detect pipes.  */
329 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
330 #   undef fseeko
331 #   define fseeko rpl_fseeko
332 #  endif
333 _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
334                                _GL_ARG_NONNULL ((1)));
335 #  if !@GNULIB_FSEEK@
336     /* In order to avoid that fseek gets defined as a macro here, the
337        developer can request the 'fseek' module.  */
338 #   undef fseek
339 #   define fseek rpl_fseek
340 static inline int _GL_ARG_NONNULL ((1))
341 rpl_fseek (FILE *fp, long offset, int whence)
342 {
343   return fseeko (fp, offset, whence);
344 }
345 #  endif
346 _GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
347 # else
348 _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
349 # endif
350 _GL_CXXALIASWARN (fseeko);
351 #elif defined GNULIB_POSIXCHECK
352 # define _GL_FSEEK_WARN /* Category 1, above.  */
353 # undef fseek
354 # undef fseeko
355 # if HAVE_RAW_DECL_FSEEKO
356 _GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
357                  "use gnulib module fseeko for portability");
358 # endif
359 #endif
360
361 #ifdef _GL_FSEEK_WARN
362 # undef _GL_FSEEK_WARN
363 /* Here, either fseek is undefined (but C89 guarantees that it is
364    declared), or it is defined as rpl_fseek (declared above).  */
365 _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
366                  "on 32-bit platforms - "
367                  "use fseeko function for handling of large files");
368 #endif
369
370
371 /* ftell, ftello.  See the comments on fseek/fseeko.  */
372
373 #if @GNULIB_FTELL@
374 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
375 #  define _GL_FTELL_WARN /* Category 2, above.  */
376 #  undef ftell
377 # endif
378 # if @REPLACE_FTELL@
379 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
380 #   undef ftell
381 #   define ftell rpl_ftell
382 #  endif
383 _GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1)));
384 _GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
385 # else
386 _GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
387 # endif
388 _GL_CXXALIASWARN (ftell);
389 #endif
390
391 #if @GNULIB_FTELLO@
392 # if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES
393 #  define _GL_FTELL_WARN /* Category 3, above.  */
394 #  undef ftell
395 # endif
396 # if @REPLACE_FTELLO@
397 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
398 #   undef ftello
399 #   define ftello rpl_ftello
400 #  endif
401 _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
402 #  if !@GNULIB_FTELL@
403     /* In order to avoid that ftell gets defined as a macro here, the
404        developer can request the 'ftell' module.  */
405 #   undef ftell
406 #   define ftell rpl_ftell
407 static inline long _GL_ARG_NONNULL ((1))
408 rpl_ftell (FILE *f)
409 {
410   return ftello (f);
411 }
412 #  endif
413 _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
414 # else
415 _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
416 # endif
417 _GL_CXXALIASWARN (ftello);
418 #elif defined GNULIB_POSIXCHECK
419 # define _GL_FTELL_WARN /* Category 1, above.  */
420 # undef ftell
421 # undef ftello
422 # if HAVE_RAW_DECL_FTELLO
423 _GL_WARN_ON_USE (ftello, "ftello is unportable - "
424                  "use gnulib module ftello for portability");
425 # endif
426 #endif
427
428 #ifdef _GL_FTELL_WARN
429 # undef _GL_FTELL_WARN
430 /* Here, either ftell is undefined (but C89 guarantees that it is
431    declared), or it is defined as rpl_ftell (declared above).  */
432 _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
433                  "on 32-bit platforms - "
434                  "use ftello function for handling of large files");
435 #endif
436
437
438 #if @GNULIB_FWRITE@
439 # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
440 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
441 #   undef fwrite
442 #   define fwrite rpl_fwrite
443 #  endif
444 _GL_FUNCDECL_RPL (fwrite, size_t,
445                   (const void *ptr, size_t s, size_t n, FILE *stream)
446                   _GL_ARG_NONNULL ((1, 4)));
447 _GL_CXXALIAS_RPL (fwrite, size_t,
448                   (const void *ptr, size_t s, size_t n, FILE *stream));
449 # else
450 _GL_CXXALIAS_SYS (fwrite, size_t,
451                   (const void *ptr, size_t s, size_t n, FILE *stream));
452 # endif
453 _GL_CXXALIASWARN (fwrite);
454 #endif
455
456 #if @GNULIB_GETDELIM@
457 /* Read input, up to (and including) the next occurrence of DELIMITER, from
458    STREAM, store it in *LINEPTR (and NUL-terminate it).
459    *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
460    bytes of space.  It is realloc'd as necessary.
461    Return the number of bytes read and stored at *LINEPTR (not including the
462    NUL terminator), or -1 on error or EOF.  */
463 # if @REPLACE_GETDELIM@
464 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
465 #   undef getdelim
466 #   define getdelim rpl_getdelim
467 #  endif
468 _GL_FUNCDECL_RPL (getdelim, ssize_t,
469                   (char **lineptr, size_t *linesize, int delimiter,
470                    FILE *stream)
471                   _GL_ARG_NONNULL ((1, 2, 4)));
472 _GL_CXXALIAS_RPL (getdelim, ssize_t,
473                   (char **lineptr, size_t *linesize, int delimiter,
474                    FILE *stream));
475 # else
476 #  if !@HAVE_DECL_GETDELIM@
477 _GL_FUNCDECL_SYS (getdelim, ssize_t,
478                   (char **lineptr, size_t *linesize, int delimiter,
479                    FILE *stream)
480                   _GL_ARG_NONNULL ((1, 2, 4)));
481 #  endif
482 _GL_CXXALIAS_SYS (getdelim, ssize_t,
483                   (char **lineptr, size_t *linesize, int delimiter,
484                    FILE *stream));
485 # endif
486 _GL_CXXALIASWARN (getdelim);
487 #elif defined GNULIB_POSIXCHECK
488 # undef getdelim
489 # if HAVE_RAW_DECL_GETDELIM
490 _GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
491                  "use gnulib module getdelim for portability");
492 # endif
493 #endif
494
495 #if @GNULIB_GETLINE@
496 /* Read a line, up to (and including) the next newline, from STREAM, store it
497    in *LINEPTR (and NUL-terminate it).
498    *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
499    bytes of space.  It is realloc'd as necessary.
500    Return the number of bytes read and stored at *LINEPTR (not including the
501    NUL terminator), or -1 on error or EOF.  */
502 # if @REPLACE_GETLINE@
503 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
504 #   undef getline
505 #   define getline rpl_getline
506 #  endif
507 _GL_FUNCDECL_RPL (getline, ssize_t,
508                   (char **lineptr, size_t *linesize, FILE *stream)
509                   _GL_ARG_NONNULL ((1, 2, 3)));
510 _GL_CXXALIAS_RPL (getline, ssize_t,
511                   (char **lineptr, size_t *linesize, FILE *stream));
512 # else
513 #  if !@HAVE_DECL_GETLINE@
514 _GL_FUNCDECL_SYS (getline, ssize_t,
515                   (char **lineptr, size_t *linesize, FILE *stream)
516                   _GL_ARG_NONNULL ((1, 2, 3)));
517 #  endif
518 _GL_CXXALIAS_SYS (getline, ssize_t,
519                   (char **lineptr, size_t *linesize, FILE *stream));
520 # endif
521 _GL_CXXALIASWARN (getline);
522 #elif defined GNULIB_POSIXCHECK
523 # undef getline
524 # if HAVE_RAW_DECL_GETLINE
525 _GL_WARN_ON_USE (getline, "getline is unportable - "
526                  "use gnulib module getline for portability");
527 # endif
528 #endif
529
530 #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
531 struct obstack;
532 /* Grow an obstack with formatted output.  Return the number of
533    bytes added to OBS.  No trailing nul byte is added, and the
534    object should be closed with obstack_finish before use.  Upon
535    memory allocation error, call obstack_alloc_failed_handler.  Upon
536    other error, return -1.  */
537 # if @REPLACE_OBSTACK_PRINTF@
538 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
539 #   define obstack_printf rpl_obstack_printf
540 #  endif
541 _GL_FUNCDECL_RPL (obstack_printf, int,
542                   (struct obstack *obs, const char *format, ...)
543                   __attribute__ ((__format__ (__printf__, 2, 3)))
544                   _GL_ARG_NONNULL ((1, 2)));
545 _GL_CXXALIAS_RPL (obstack_printf, int,
546                   (struct obstack *obs, const char *format, ...));
547 # else
548 #  if !@HAVE_DECL_OBSTACK_PRINTF@
549 _GL_FUNCDECL_SYS (obstack_printf, int,
550                   (struct obstack *obs, const char *format, ...)
551                   __attribute__ ((__format__ (__printf__, 2, 3)))
552                   _GL_ARG_NONNULL ((1, 2)));
553 #  endif
554 _GL_CXXALIAS_SYS (obstack_printf, int,
555                   (struct obstack *obs, const char *format, ...));
556 # endif
557 _GL_CXXALIASWARN (obstack_printf);
558 # if @REPLACE_OBSTACK_PRINTF@
559 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
560 #   define obstack_vprintf rpl_obstack_vprintf
561 #  endif
562 _GL_FUNCDECL_RPL (obstack_vprintf, int,
563                   (struct obstack *obs, const char *format, va_list args)
564                   __attribute__ ((__format__ (__printf__, 2, 0)))
565                   _GL_ARG_NONNULL ((1, 2)));
566 _GL_CXXALIAS_RPL (obstack_vprintf, int,
567                   (struct obstack *obs, const char *format, va_list args));
568 # else
569 #  if !@HAVE_DECL_OBSTACK_PRINTF@
570 _GL_FUNCDECL_SYS (obstack_vprintf, int,
571                   (struct obstack *obs, const char *format, va_list args)
572                   __attribute__ ((__format__ (__printf__, 2, 0)))
573                   _GL_ARG_NONNULL ((1, 2)));
574 #  endif
575 _GL_CXXALIAS_SYS (obstack_vprintf, int,
576                   (struct obstack *obs, const char *format, va_list args));
577 # endif
578 _GL_CXXALIASWARN (obstack_vprintf);
579 #endif
580
581 #if @GNULIB_PERROR@
582 /* Print a message to standard error, describing the value of ERRNO,
583    (if STRING is not NULL and not empty) prefixed with STRING and ": ",
584    and terminated with a newline.  */
585 # if @REPLACE_PERROR@
586 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
587 #   define perror rpl_perror
588 #  endif
589 _GL_FUNCDECL_RPL (perror, void, (const char *string));
590 _GL_CXXALIAS_RPL (perror, void, (const char *string));
591 # else
592 _GL_CXXALIAS_SYS (perror, void, (const char *string));
593 # endif
594 _GL_CXXALIASWARN (perror);
595 #elif defined GNULIB_POSIXCHECK
596 # undef perror
597 /* Assume perror is always declared.  */
598 _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
599                  "use gnulib module perror for portability");
600 #endif
601
602 #if @GNULIB_POPEN@
603 # if @REPLACE_POPEN@
604 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
605 #   undef popen
606 #   define popen rpl_popen
607 #  endif
608 _GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode)
609                                  _GL_ARG_NONNULL ((1, 2)));
610 _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
611 # else
612 _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
613 # endif
614 _GL_CXXALIASWARN (popen);
615 #elif defined GNULIB_POSIXCHECK
616 # undef popen
617 # if HAVE_RAW_DECL_POPEN
618 _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
619                  "use gnulib module popen or pipe for more portability");
620 # endif
621 #endif
622
623 #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
624 # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
625      || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
626 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
627 /* Don't break __attribute__((format(printf,M,N))).  */
628 #   define printf __printf__
629 #  endif
630 #  define GNULIB_overrides_printf 1
631 _GL_FUNCDECL_RPL_1 (__printf__, int,
632                     (const char *format, ...)
633                     __attribute__ ((__format__ (__printf__, 1, 2)))
634                     _GL_ARG_NONNULL ((1)));
635 _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
636 # else
637 _GL_CXXALIAS_SYS (printf, int, (const char *format, ...));
638 # endif
639 _GL_CXXALIASWARN (printf);
640 #endif
641 #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
642 # if !GNULIB_overrides_printf
643 #  undef printf
644 # endif
645 /* Assume printf is always declared.  */
646 _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
647                  "use gnulib module printf-posix for portable "
648                  "POSIX compliance");
649 #endif
650
651 #if @GNULIB_PUTC@
652 # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
653 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
654 #   undef putc
655 #   define putc rpl_fputc
656 #  endif
657 _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
658 _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
659 # else
660 _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
661 # endif
662 _GL_CXXALIASWARN (putc);
663 #endif
664
665 #if @GNULIB_PUTCHAR@
666 # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
667 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
668 #   undef putchar
669 #   define putchar rpl_putchar
670 #  endif
671 _GL_FUNCDECL_RPL (putchar, int, (int c));
672 _GL_CXXALIAS_RPL (putchar, int, (int c));
673 # else
674 _GL_CXXALIAS_SYS (putchar, int, (int c));
675 # endif
676 _GL_CXXALIASWARN (putchar);
677 #endif
678
679 #if @GNULIB_PUTS@
680 # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
681 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
682 #   undef puts
683 #   define puts rpl_puts
684 #  endif
685 _GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1)));
686 _GL_CXXALIAS_RPL (puts, int, (const char *string));
687 # else
688 _GL_CXXALIAS_SYS (puts, int, (const char *string));
689 # endif
690 _GL_CXXALIASWARN (puts);
691 #endif
692
693 #if @GNULIB_REMOVE@
694 # if @REPLACE_REMOVE@
695 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
696 #   undef remove
697 #   define remove rpl_remove
698 #  endif
699 _GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1)));
700 _GL_CXXALIAS_RPL (remove, int, (const char *name));
701 # else
702 _GL_CXXALIAS_SYS (remove, int, (const char *name));
703 # endif
704 _GL_CXXALIASWARN (remove);
705 #elif defined GNULIB_POSIXCHECK
706 # undef remove
707 /* Assume remove is always declared.  */
708 _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
709                  "use gnulib module remove for more portability");
710 #endif
711
712 #if @GNULIB_RENAME@
713 # if @REPLACE_RENAME@
714 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
715 #   undef rename
716 #   define rename rpl_rename
717 #  endif
718 _GL_FUNCDECL_RPL (rename, int,
719                   (const char *old_filename, const char *new_filename)
720                   _GL_ARG_NONNULL ((1, 2)));
721 _GL_CXXALIAS_RPL (rename, int,
722                   (const char *old_filename, const char *new_filename));
723 # else
724 _GL_CXXALIAS_SYS (rename, int,
725                   (const char *old_filename, const char *new_filename));
726 # endif
727 _GL_CXXALIASWARN (rename);
728 #elif defined GNULIB_POSIXCHECK
729 # undef rename
730 /* Assume rename is always declared.  */
731 _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
732                  "use gnulib module rename for more portability");
733 #endif
734
735 #if @GNULIB_RENAMEAT@
736 # if @REPLACE_RENAMEAT@
737 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
738 #   undef renameat
739 #   define renameat rpl_renameat
740 #  endif
741 _GL_FUNCDECL_RPL (renameat, int,
742                   (int fd1, char const *file1, int fd2, char const *file2)
743                   _GL_ARG_NONNULL ((2, 4)));
744 _GL_CXXALIAS_RPL (renameat, int,
745                   (int fd1, char const *file1, int fd2, char const *file2));
746 # else
747 #  if !@HAVE_RENAMEAT@
748 _GL_FUNCDECL_SYS (renameat, int,
749                   (int fd1, char const *file1, int fd2, char const *file2)
750                   _GL_ARG_NONNULL ((2, 4)));
751 #  endif
752 _GL_CXXALIAS_SYS (renameat, int,
753                   (int fd1, char const *file1, int fd2, char const *file2));
754 # endif
755 _GL_CXXALIASWARN (renameat);
756 #elif defined GNULIB_POSIXCHECK
757 # undef renameat
758 # if HAVE_RAW_DECL_RENAMEAT
759 _GL_WARN_ON_USE (renameat, "renameat is not portable - "
760                  "use gnulib module renameat for portability");
761 # endif
762 #endif
763
764 #if @GNULIB_SNPRINTF@
765 # if @REPLACE_SNPRINTF@
766 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
767 #   define snprintf rpl_snprintf
768 #  endif
769 _GL_FUNCDECL_RPL (snprintf, int,
770                   (char *str, size_t size, const char *format, ...)
771                   __attribute__ ((__format__ (__printf__, 3, 4)))
772                   _GL_ARG_NONNULL ((3)));
773 _GL_CXXALIAS_RPL (snprintf, int,
774                   (char *str, size_t size, const char *format, ...));
775 # else
776 #  if !@HAVE_DECL_SNPRINTF@
777 _GL_FUNCDECL_SYS (snprintf, int,
778                   (char *str, size_t size, const char *format, ...)
779                   __attribute__ ((__format__ (__printf__, 3, 4)))
780                   _GL_ARG_NONNULL ((3)));
781 #  endif
782 _GL_CXXALIAS_SYS (snprintf, int,
783                   (char *str, size_t size, const char *format, ...));
784 # endif
785 _GL_CXXALIASWARN (snprintf);
786 #elif defined GNULIB_POSIXCHECK
787 # undef snprintf
788 # if HAVE_RAW_DECL_SNPRINTF
789 _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
790                  "use gnulib module snprintf for portability");
791 # endif
792 #endif
793
794 /* Some people would argue that sprintf should be handled like gets
795    (for example, OpenBSD issues a link warning for both functions),
796    since both can cause security holes due to buffer overruns.
797    However, we believe that sprintf can be used safely, and is more
798    efficient than snprintf in those safe cases; and as proof of our
799    belief, we use sprintf in several gnulib modules.  So this header
800    intentionally avoids adding a warning to sprintf except when
801    GNULIB_POSIXCHECK is defined.  */
802
803 #if @GNULIB_SPRINTF_POSIX@
804 # if @REPLACE_SPRINTF@
805 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
806 #   define sprintf rpl_sprintf
807 #  endif
808 _GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...)
809                                 __attribute__ ((__format__ (__printf__, 2, 3)))
810                                 _GL_ARG_NONNULL ((1, 2)));
811 _GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...));
812 # else
813 _GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...));
814 # endif
815 _GL_CXXALIASWARN (sprintf);
816 #elif defined GNULIB_POSIXCHECK
817 # undef sprintf
818 /* Assume sprintf is always declared.  */
819 _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
820                  "use gnulib module sprintf-posix for portable "
821                  "POSIX compliance");
822 #endif
823
824 #if @GNULIB_VASPRINTF@
825 /* Write formatted output to a string dynamically allocated with malloc().
826    If the memory allocation succeeds, store the address of the string in
827    *RESULT and return the number of resulting bytes, excluding the trailing
828    NUL.  Upon memory allocation error, or some other error, return -1.  */
829 # if @REPLACE_VASPRINTF@
830 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
831 #   define asprintf rpl_asprintf
832 #  endif
833 _GL_FUNCDECL_RPL (asprintf, int,
834                   (char **result, const char *format, ...)
835                   __attribute__ ((__format__ (__printf__, 2, 3)))
836                   _GL_ARG_NONNULL ((1, 2)));
837 _GL_CXXALIAS_RPL (asprintf, int,
838                   (char **result, const char *format, ...));
839 # else
840 #  if !@HAVE_VASPRINTF@
841 _GL_FUNCDECL_SYS (asprintf, int,
842                   (char **result, const char *format, ...)
843                   __attribute__ ((__format__ (__printf__, 2, 3)))
844                   _GL_ARG_NONNULL ((1, 2)));
845 #  endif
846 _GL_CXXALIAS_SYS (asprintf, int,
847                   (char **result, const char *format, ...));
848 # endif
849 _GL_CXXALIASWARN (asprintf);
850 # if @REPLACE_VASPRINTF@
851 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
852 #   define vasprintf rpl_vasprintf
853 #  endif
854 _GL_FUNCDECL_RPL (vasprintf, int,
855                   (char **result, const char *format, va_list args)
856                   __attribute__ ((__format__ (__printf__, 2, 0)))
857                   _GL_ARG_NONNULL ((1, 2)));
858 _GL_CXXALIAS_RPL (vasprintf, int,
859                   (char **result, const char *format, va_list args));
860 # else
861 #  if !@HAVE_VASPRINTF@
862 _GL_FUNCDECL_SYS (vasprintf, int,
863                   (char **result, const char *format, va_list args)
864                   __attribute__ ((__format__ (__printf__, 2, 0)))
865                   _GL_ARG_NONNULL ((1, 2)));
866 #  endif
867 _GL_CXXALIAS_SYS (vasprintf, int,
868                   (char **result, const char *format, va_list args));
869 # endif
870 _GL_CXXALIASWARN (vasprintf);
871 #endif
872
873 #if @GNULIB_VDPRINTF@
874 # if @REPLACE_VDPRINTF@
875 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
876 #   define vdprintf rpl_vdprintf
877 #  endif
878 _GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args)
879                                  __attribute__ ((__format__ (__printf__, 2, 0)))
880                                  _GL_ARG_NONNULL ((2)));
881 _GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args));
882 # else
883 #  if !@HAVE_VDPRINTF@
884 _GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args)
885                                  __attribute__ ((__format__ (__printf__, 2, 0)))
886                                  _GL_ARG_NONNULL ((2)));
887 #  endif
888 _GL_CXXALIAS_SYS (vdprintf, int, (int fd, const char *format, va_list args));
889 # endif
890 _GL_CXXALIASWARN (vdprintf);
891 #elif defined GNULIB_POSIXCHECK
892 # undef vdprintf
893 # if HAVE_RAW_DECL_VDPRINTF
894 _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
895                  "use gnulib module vdprintf for portability");
896 # endif
897 #endif
898
899 #if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
900 # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
901      || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
902 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
903 #   define vfprintf rpl_vfprintf
904 #  endif
905 #  define GNULIB_overrides_vfprintf 1
906 _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
907                                  __attribute__ ((__format__ (__printf__, 2, 0)))
908                                  _GL_ARG_NONNULL ((1, 2)));
909 _GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args));
910 # else
911 _GL_CXXALIAS_SYS (vfprintf, int, (FILE *fp, const char *format, va_list args));
912 # endif
913 _GL_CXXALIASWARN (vfprintf);
914 #endif
915 #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
916 # if !GNULIB_overrides_vfprintf
917 #  undef vfprintf
918 # endif
919 /* Assume vfprintf is always declared.  */
920 _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
921                  "use gnulib module vfprintf-posix for portable "
922                       "POSIX compliance");
923 #endif
924
925 #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
926 # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
927      || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
928 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
929 #   define vprintf rpl_vprintf
930 #  endif
931 #  define GNULIB_overrides_vprintf 1
932 _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
933                                 __attribute__ ((__format__ (__printf__, 1, 0)))
934                                 _GL_ARG_NONNULL ((1)));
935 _GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args));
936 # else
937 _GL_CXXALIAS_SYS (vprintf, int, (const char *format, va_list args));
938 # endif
939 _GL_CXXALIASWARN (vprintf);
940 #endif
941 #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
942 # if !GNULIB_overrides_vprintf
943 #  undef vprintf
944 # endif
945 /* Assume vprintf is always declared.  */
946 _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
947                  "use gnulib module vprintf-posix for portable "
948                  "POSIX compliance");
949 #endif
950
951 #if @GNULIB_VSNPRINTF@
952 # if @REPLACE_VSNPRINTF@
953 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
954 #   define vsnprintf rpl_vsnprintf
955 #  endif
956 _GL_FUNCDECL_RPL (vsnprintf, int,
957                   (char *str, size_t size, const char *format, va_list args)
958                   __attribute__ ((__format__ (__printf__, 3, 0)))
959                   _GL_ARG_NONNULL ((3)));
960 _GL_CXXALIAS_RPL (vsnprintf, int,
961                   (char *str, size_t size, const char *format, va_list args));
962 # else
963 #  if !@HAVE_DECL_VSNPRINTF@
964 _GL_FUNCDECL_SYS (vsnprintf, int,
965                   (char *str, size_t size, const char *format, va_list args)
966                   __attribute__ ((__format__ (__printf__, 3, 0)))
967                   _GL_ARG_NONNULL ((3)));
968 #  endif
969 _GL_CXXALIAS_SYS (vsnprintf, int,
970                   (char *str, size_t size, const char *format, va_list args));
971 # endif
972 _GL_CXXALIASWARN (vsnprintf);
973 #elif defined GNULIB_POSIXCHECK
974 # undef vsnprintf
975 # if HAVE_RAW_DECL_VSNPRINTF
976 _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
977                  "use gnulib module vsnprintf for portability");
978 # endif
979 #endif
980
981 #if @GNULIB_VSPRINTF_POSIX@
982 # if @REPLACE_VSPRINTF@
983 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
984 #   define vsprintf rpl_vsprintf
985 #  endif
986 _GL_FUNCDECL_RPL (vsprintf, int,
987                   (char *str, const char *format, va_list args)
988                   __attribute__ ((__format__ (__printf__, 2, 0)))
989                   _GL_ARG_NONNULL ((1, 2)));
990 _GL_CXXALIAS_RPL (vsprintf, int,
991                   (char *str, const char *format, va_list args));
992 # else
993 _GL_CXXALIAS_SYS (vsprintf, int,
994                   (char *str, const char *format, va_list args));
995 # endif
996 _GL_CXXALIASWARN (vsprintf);
997 #elif defined GNULIB_POSIXCHECK
998 # undef vsprintf
999 /* Assume vsprintf is always declared.  */
1000 _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
1001                  "use gnulib module vsprintf-posix for portable "
1002                       "POSIX compliance");
1003 #endif
1004
1005
1006 #endif /* _GL_STDIO_H */
1007 #endif /* _GL_STDIO_H */
1008 #endif