65d3ea14cd2aefd71c68c9ab0b8e0678b68106cb
[platform/upstream/diffutils.git] / lib / 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-2011 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 @PRAGMA_COLUMNS@
25
26 #if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H
27 /* Special invocation convention:
28    - Inside glibc header files.
29    - On OSF/1 5.1 we have a sequence of nested includes
30      <stdio.h> -> <getopt.h> -> <ctype.h> -> <sys/localedef.h> ->
31      <sys/lc_core.h> -> <nl_types.h> -> <mesg.h> -> <stdio.h>.
32      In this situation, the functions are not yet declared, therefore we cannot
33      provide the C++ aliases.  */
34
35 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
36
37 #else
38 /* Normal invocation convention.  */
39
40 #ifndef _@GUARD_PREFIX@_STDIO_H
41
42 #define _GL_ALREADY_INCLUDING_STDIO_H
43
44 /* The include_next requires a split double-inclusion guard.  */
45 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
46
47 #undef _GL_ALREADY_INCLUDING_STDIO_H
48
49 #ifndef _@GUARD_PREFIX@_STDIO_H
50 #define _@GUARD_PREFIX@_STDIO_H
51
52 /* Get va_list.  Needed on many systems, including glibc 2.8.  */
53 #include <stdarg.h>
54
55 #include <stddef.h>
56
57 /* Get off_t and ssize_t.  Needed on many systems, including glibc 2.8
58    and eglibc 2.11.2.  */
59 #include <sys/types.h>
60
61 /* The __attribute__ feature is available in gcc versions 2.5 and later.
62    The __-protected variants of the attributes 'format' and 'printf' are
63    accepted by gcc versions 2.6.4 (effectively 2.7) and later.
64    We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
65    gnulib and libintl do '#define printf __printf__' when they override
66    the 'printf' function.  */
67 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
68 # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
69 #else
70 # define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
71 #endif
72
73 /* _GL_ATTRIBUTE_FORMAT_PRINTF
74    indicates to GCC that the function takes a format string and arguments,
75    where the format string directives are the ones standardized by ISO C99
76    and POSIX.  */
77 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
78 # define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
79    _GL_ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument))
80 #else
81 # define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
82    _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
83 #endif
84
85 /* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF,
86    except that it indicates to GCC that the supported format string directives
87    are the ones of the system printf(), rather than the ones standardized by
88    ISO C99 and POSIX.  */
89 #define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
90   _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
91
92 /* _GL_ATTRIBUTE_FORMAT_SCANF
93    indicates to GCC that the function takes a format string and arguments,
94    where the format string directives are the ones standardized by ISO C99
95    and POSIX.  */
96 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
97 # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
98    _GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument))
99 #else
100 # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
101    _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
102 #endif
103
104 /* _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_SCANF,
105    except that it indicates to GCC that the supported format string directives
106    are the ones of the system scanf(), rather than the ones standardized by
107    ISO C99 and POSIX.  */
108 #define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
109   _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
110
111 /* Solaris 10 declares renameat in <unistd.h>, not in <stdio.h>.  */
112 /* But in any case avoid namespace pollution on glibc systems.  */
113 #if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \
114     && ! defined __GLIBC__
115 # include <unistd.h>
116 #endif
117
118
119 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
120
121 /* The definition of _GL_ARG_NONNULL is copied here.  */
122
123 /* The definition of _GL_WARN_ON_USE is copied here.  */
124
125 /* Macros for stringification.  */
126 #define _GL_STDIO_STRINGIZE(token) #token
127 #define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
128
129
130 #if @GNULIB_DPRINTF@
131 # if @REPLACE_DPRINTF@
132 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
133 #   define dprintf rpl_dprintf
134 #  endif
135 _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...)
136                                 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
137                                 _GL_ARG_NONNULL ((2)));
138 _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...));
139 # else
140 #  if !@HAVE_DPRINTF@
141 _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...)
142                                 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
143                                 _GL_ARG_NONNULL ((2)));
144 #  endif
145 _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...));
146 # endif
147 _GL_CXXALIASWARN (dprintf);
148 #elif defined GNULIB_POSIXCHECK
149 # undef dprintf
150 # if HAVE_RAW_DECL_DPRINTF
151 _GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
152                  "use gnulib module dprintf for portability");
153 # endif
154 #endif
155
156 #if @GNULIB_FCLOSE@
157 /* Close STREAM and its underlying file descriptor.  */
158 # if @REPLACE_FCLOSE@
159 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
160 #   define fclose rpl_fclose
161 #  endif
162 _GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
163 _GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
164 # else
165 _GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
166 # endif
167 _GL_CXXALIASWARN (fclose);
168 #elif defined GNULIB_POSIXCHECK
169 # undef fclose
170 /* Assume fclose is always declared.  */
171 _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
172                  "use gnulib module fclose for portable POSIX compliance");
173 #endif
174
175 #if @GNULIB_FFLUSH@
176 /* Flush all pending data on STREAM according to POSIX rules.  Both
177    output and seekable input streams are supported.
178    Note! LOSS OF DATA can occur if fflush is applied on an input stream
179    that is _not_seekable_ or on an update stream that is _not_seekable_
180    and in which the most recent operation was input.  Seekability can
181    be tested with lseek(fileno(fp),0,SEEK_CUR).  */
182 # if @REPLACE_FFLUSH@
183 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
184 #   define fflush rpl_fflush
185 #  endif
186 _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream));
187 _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
188 # else
189 _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
190 # endif
191 _GL_CXXALIASWARN (fflush);
192 #elif defined GNULIB_POSIXCHECK
193 # undef fflush
194 /* Assume fflush is always declared.  */
195 _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
196                  "use gnulib module fflush for portable POSIX compliance");
197 #endif
198
199 #if @GNULIB_FGETC@
200 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
201 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
202 #   undef fgetc
203 #   define fgetc rpl_fgetc
204 #  endif
205 _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
206 _GL_CXXALIAS_RPL (fgetc, int, (FILE *stream));
207 # else
208 _GL_CXXALIAS_SYS (fgetc, int, (FILE *stream));
209 # endif
210 _GL_CXXALIASWARN (fgetc);
211 #endif
212
213 #if @GNULIB_FGETS@
214 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
215 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
216 #   undef fgets
217 #   define fgets rpl_fgets
218 #  endif
219 _GL_FUNCDECL_RPL (fgets, char *, (char *s, int n, FILE *stream)
220                                  _GL_ARG_NONNULL ((1, 3)));
221 _GL_CXXALIAS_RPL (fgets, char *, (char *s, int n, FILE *stream));
222 # else
223 _GL_CXXALIAS_SYS (fgets, char *, (char *s, int n, FILE *stream));
224 # endif
225 _GL_CXXALIASWARN (fgets);
226 #endif
227
228 #if @GNULIB_FOPEN@
229 # if @REPLACE_FOPEN@
230 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
231 #   undef fopen
232 #   define fopen rpl_fopen
233 #  endif
234 _GL_FUNCDECL_RPL (fopen, FILE *, (const char *filename, const char *mode)
235                                  _GL_ARG_NONNULL ((1, 2)));
236 _GL_CXXALIAS_RPL (fopen, FILE *, (const char *filename, const char *mode));
237 # else
238 _GL_CXXALIAS_SYS (fopen, FILE *, (const char *filename, const char *mode));
239 # endif
240 _GL_CXXALIASWARN (fopen);
241 #elif defined GNULIB_POSIXCHECK
242 # undef fopen
243 /* Assume fopen is always declared.  */
244 _GL_WARN_ON_USE (fopen, "fopen on Win32 platforms is not POSIX compatible - "
245                  "use gnulib module fopen for portability");
246 #endif
247
248 #if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
249 # if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
250      || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
251 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
252 #   define fprintf rpl_fprintf
253 #  endif
254 #  define GNULIB_overrides_fprintf 1
255 #  if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
256 _GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
257                                 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
258                                 _GL_ARG_NONNULL ((1, 2)));
259 #  else
260 _GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
261                                 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
262                                 _GL_ARG_NONNULL ((1, 2)));
263 #  endif
264 _GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...));
265 # else
266 _GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...));
267 # endif
268 _GL_CXXALIASWARN (fprintf);
269 #endif
270 #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
271 # if !GNULIB_overrides_fprintf
272 #  undef fprintf
273 # endif
274 /* Assume fprintf is always declared.  */
275 _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
276                  "use gnulib module fprintf-posix for portable "
277                  "POSIX compliance");
278 #endif
279
280 #if @GNULIB_FPURGE@
281 /* Discard all pending buffered I/O data on STREAM.
282    STREAM must not be wide-character oriented.
283    When discarding pending output, the file position is set back to where it
284    was before the write calls.  When discarding pending input, the file
285    position is advanced to match the end of the previously read input.
286    Return 0 if successful.  Upon error, return -1 and set errno.  */
287 # if @REPLACE_FPURGE@
288 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
289 #   define fpurge rpl_fpurge
290 #  endif
291 _GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
292 _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream));
293 # else
294 #  if !@HAVE_DECL_FPURGE@
295 _GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
296 #  endif
297 _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream));
298 # endif
299 _GL_CXXALIASWARN (fpurge);
300 #elif defined GNULIB_POSIXCHECK
301 # undef fpurge
302 # if HAVE_RAW_DECL_FPURGE
303 _GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
304                  "use gnulib module fpurge for portability");
305 # endif
306 #endif
307
308 #if @GNULIB_FPUTC@
309 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
310 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
311 #   undef fputc
312 #   define fputc rpl_fputc
313 #  endif
314 _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
315 _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
316 # else
317 _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
318 # endif
319 _GL_CXXALIASWARN (fputc);
320 #endif
321
322 #if @GNULIB_FPUTS@
323 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
324 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
325 #   undef fputs
326 #   define fputs rpl_fputs
327 #  endif
328 _GL_FUNCDECL_RPL (fputs, int, (const char *string, FILE *stream)
329                               _GL_ARG_NONNULL ((1, 2)));
330 _GL_CXXALIAS_RPL (fputs, int, (const char *string, FILE *stream));
331 # else
332 _GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream));
333 # endif
334 _GL_CXXALIASWARN (fputs);
335 #endif
336
337 #if @GNULIB_FREAD@
338 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
339 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
340 #   undef fread
341 #   define fread rpl_fread
342 #  endif
343 _GL_FUNCDECL_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)
344                                  _GL_ARG_NONNULL ((4)));
345 _GL_CXXALIAS_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream));
346 # else
347 _GL_CXXALIAS_SYS (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream));
348 # endif
349 _GL_CXXALIASWARN (fread);
350 #endif
351
352 #if @GNULIB_FREOPEN@
353 # if @REPLACE_FREOPEN@
354 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
355 #   undef freopen
356 #   define freopen rpl_freopen
357 #  endif
358 _GL_FUNCDECL_RPL (freopen, FILE *,
359                   (const char *filename, const char *mode, FILE *stream)
360                   _GL_ARG_NONNULL ((2, 3)));
361 _GL_CXXALIAS_RPL (freopen, FILE *,
362                   (const char *filename, const char *mode, FILE *stream));
363 # else
364 _GL_CXXALIAS_SYS (freopen, FILE *,
365                   (const char *filename, const char *mode, FILE *stream));
366 # endif
367 _GL_CXXALIASWARN (freopen);
368 #elif defined GNULIB_POSIXCHECK
369 # undef freopen
370 /* Assume freopen is always declared.  */
371 _GL_WARN_ON_USE (freopen,
372                  "freopen on Win32 platforms is not POSIX compatible - "
373                  "use gnulib module freopen for portability");
374 #endif
375
376 #if @GNULIB_FSCANF@
377 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
378 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
379 #   undef fscanf
380 #   define fscanf rpl_fscanf
381 #  endif
382 _GL_FUNCDECL_RPL (fscanf, int, (FILE *stream, const char *format, ...)
383                                _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3)
384                                _GL_ARG_NONNULL ((1, 2)));
385 _GL_CXXALIAS_RPL (fscanf, int, (FILE *stream, const char *format, ...));
386 # else
387 _GL_CXXALIAS_SYS (fscanf, int, (FILE *stream, const char *format, ...));
388 # endif
389 _GL_CXXALIASWARN (fscanf);
390 #endif
391
392
393 /* Set up the following warnings, based on which modules are in use.
394    GNU Coding Standards discourage the use of fseek, since it imposes
395    an arbitrary limitation on some 32-bit hosts.  Remember that the
396    fseek module depends on the fseeko module, so we only have three
397    cases to consider:
398
399    1. The developer is not using either module.  Issue a warning under
400    GNULIB_POSIXCHECK for both functions, to remind them that both
401    functions have bugs on some systems.  _GL_NO_LARGE_FILES has no
402    impact on this warning.
403
404    2. The developer is using both modules.  They may be unaware of the
405    arbitrary limitations of fseek, so issue a warning under
406    GNULIB_POSIXCHECK.  On the other hand, they may be using both
407    modules intentionally, so the developer can define
408    _GL_NO_LARGE_FILES in the compilation units where the use of fseek
409    is safe, to silence the warning.
410
411    3. The developer is using the fseeko module, but not fseek.  Gnulib
412    guarantees that fseek will still work around platform bugs in that
413    case, but we presume that the developer is aware of the pitfalls of
414    fseek and was trying to avoid it, so issue a warning even when
415    GNULIB_POSIXCHECK is undefined.  Again, _GL_NO_LARGE_FILES can be
416    defined to silence the warning in particular compilation units.
417    In C++ compilations with GNULIB_NAMESPACE, in order to avoid that
418    fseek gets defined as a macro, it is recommended that the developer
419    uses the fseek module, even if he is not calling the fseek function.
420
421    Most gnulib clients that perform stream operations should fall into
422    category 3.  */
423
424 #if @GNULIB_FSEEK@
425 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
426 #  define _GL_FSEEK_WARN /* Category 2, above.  */
427 #  undef fseek
428 # endif
429 # if @REPLACE_FSEEK@
430 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
431 #   undef fseek
432 #   define fseek rpl_fseek
433 #  endif
434 _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence)
435                               _GL_ARG_NONNULL ((1)));
436 _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
437 # else
438 _GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence));
439 # endif
440 _GL_CXXALIASWARN (fseek);
441 #endif
442
443 #if @GNULIB_FSEEKO@
444 # if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES
445 #  define _GL_FSEEK_WARN /* Category 3, above.  */
446 #  undef fseek
447 # endif
448 # if @REPLACE_FSEEKO@
449 /* Provide an fseeko function that is aware of a preceding fflush(), and which
450    detects pipes.  */
451 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
452 #   undef fseeko
453 #   define fseeko rpl_fseeko
454 #  endif
455 _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
456                                _GL_ARG_NONNULL ((1)));
457 _GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
458 # else
459 #  if ! @HAVE_DECL_FSEEKO@
460 _GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)
461                                _GL_ARG_NONNULL ((1)));
462 #  endif
463 _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
464 # endif
465 _GL_CXXALIASWARN (fseeko);
466 #elif defined GNULIB_POSIXCHECK
467 # define _GL_FSEEK_WARN /* Category 1, above.  */
468 # undef fseek
469 # undef fseeko
470 # if HAVE_RAW_DECL_FSEEKO
471 _GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
472                  "use gnulib module fseeko for portability");
473 # endif
474 #endif
475
476 #ifdef _GL_FSEEK_WARN
477 # undef _GL_FSEEK_WARN
478 /* Here, either fseek is undefined (but C89 guarantees that it is
479    declared), or it is defined as rpl_fseek (declared above).  */
480 _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
481                  "on 32-bit platforms - "
482                  "use fseeko function for handling of large files");
483 #endif
484
485
486 /* ftell, ftello.  See the comments on fseek/fseeko.  */
487
488 #if @GNULIB_FTELL@
489 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
490 #  define _GL_FTELL_WARN /* Category 2, above.  */
491 #  undef ftell
492 # endif
493 # if @REPLACE_FTELL@
494 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
495 #   undef ftell
496 #   define ftell rpl_ftell
497 #  endif
498 _GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1)));
499 _GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
500 # else
501 _GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
502 # endif
503 _GL_CXXALIASWARN (ftell);
504 #endif
505
506 #if @GNULIB_FTELLO@
507 # if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES
508 #  define _GL_FTELL_WARN /* Category 3, above.  */
509 #  undef ftell
510 # endif
511 # if @REPLACE_FTELLO@
512 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
513 #   undef ftello
514 #   define ftello rpl_ftello
515 #  endif
516 _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
517 _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
518 # else
519 #  if ! @HAVE_DECL_FTELLO@
520 _GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
521 #  endif
522 _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
523 # endif
524 _GL_CXXALIASWARN (ftello);
525 #elif defined GNULIB_POSIXCHECK
526 # define _GL_FTELL_WARN /* Category 1, above.  */
527 # undef ftell
528 # undef ftello
529 # if HAVE_RAW_DECL_FTELLO
530 _GL_WARN_ON_USE (ftello, "ftello is unportable - "
531                  "use gnulib module ftello for portability");
532 # endif
533 #endif
534
535 #ifdef _GL_FTELL_WARN
536 # undef _GL_FTELL_WARN
537 /* Here, either ftell is undefined (but C89 guarantees that it is
538    declared), or it is defined as rpl_ftell (declared above).  */
539 _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
540                  "on 32-bit platforms - "
541                  "use ftello function for handling of large files");
542 #endif
543
544
545 #if @GNULIB_FWRITE@
546 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
547 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
548 #   undef fwrite
549 #   define fwrite rpl_fwrite
550 #  endif
551 _GL_FUNCDECL_RPL (fwrite, size_t,
552                   (const void *ptr, size_t s, size_t n, FILE *stream)
553                   _GL_ARG_NONNULL ((1, 4)));
554 _GL_CXXALIAS_RPL (fwrite, size_t,
555                   (const void *ptr, size_t s, size_t n, FILE *stream));
556 # else
557 _GL_CXXALIAS_SYS (fwrite, size_t,
558                   (const void *ptr, size_t s, size_t n, FILE *stream));
559
560 /* Work around glibc bug 11959
561    <http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>,
562    which sometimes causes an unwanted diagnostic for fwrite calls.
563    This affects only function declaration attributes, so it's not
564    needed for C++.  */
565 #  if !defined __cplusplus && 0 < __USE_FORTIFY_LEVEL
566 static inline size_t _GL_ARG_NONNULL ((1, 4))
567 rpl_fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
568 {
569   size_t r = fwrite (ptr, s, n, stream);
570   (void) r;
571   return r;
572 }
573 #   undef fwrite
574 #   define fwrite rpl_fwrite
575 #  endif
576 # endif
577 _GL_CXXALIASWARN (fwrite);
578 #endif
579
580 #if @GNULIB_GETC@
581 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
582 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
583 #   undef getc
584 #   define getc rpl_fgetc
585 #  endif
586 _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
587 _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream));
588 # else
589 _GL_CXXALIAS_SYS (getc, int, (FILE *stream));
590 # endif
591 _GL_CXXALIASWARN (getc);
592 #endif
593
594 #if @GNULIB_GETCHAR@
595 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
596 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
597 #   undef getchar
598 #   define getchar rpl_getchar
599 #  endif
600 _GL_FUNCDECL_RPL (getchar, int, (void));
601 _GL_CXXALIAS_RPL (getchar, int, (void));
602 # else
603 _GL_CXXALIAS_SYS (getchar, int, (void));
604 # endif
605 _GL_CXXALIASWARN (getchar);
606 #endif
607
608 #if @GNULIB_GETDELIM@
609 /* Read input, up to (and including) the next occurrence of DELIMITER, from
610    STREAM, store it in *LINEPTR (and NUL-terminate it).
611    *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
612    bytes of space.  It is realloc'd as necessary.
613    Return the number of bytes read and stored at *LINEPTR (not including the
614    NUL terminator), or -1 on error or EOF.  */
615 # if @REPLACE_GETDELIM@
616 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
617 #   undef getdelim
618 #   define getdelim rpl_getdelim
619 #  endif
620 _GL_FUNCDECL_RPL (getdelim, ssize_t,
621                   (char **lineptr, size_t *linesize, int delimiter,
622                    FILE *stream)
623                   _GL_ARG_NONNULL ((1, 2, 4)));
624 _GL_CXXALIAS_RPL (getdelim, ssize_t,
625                   (char **lineptr, size_t *linesize, int delimiter,
626                    FILE *stream));
627 # else
628 #  if !@HAVE_DECL_GETDELIM@
629 _GL_FUNCDECL_SYS (getdelim, ssize_t,
630                   (char **lineptr, size_t *linesize, int delimiter,
631                    FILE *stream)
632                   _GL_ARG_NONNULL ((1, 2, 4)));
633 #  endif
634 _GL_CXXALIAS_SYS (getdelim, ssize_t,
635                   (char **lineptr, size_t *linesize, int delimiter,
636                    FILE *stream));
637 # endif
638 _GL_CXXALIASWARN (getdelim);
639 #elif defined GNULIB_POSIXCHECK
640 # undef getdelim
641 # if HAVE_RAW_DECL_GETDELIM
642 _GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
643                  "use gnulib module getdelim for portability");
644 # endif
645 #endif
646
647 #if @GNULIB_GETLINE@
648 /* Read a line, up to (and including) the next newline, from STREAM, store it
649    in *LINEPTR (and NUL-terminate it).
650    *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
651    bytes of space.  It is realloc'd as necessary.
652    Return the number of bytes read and stored at *LINEPTR (not including the
653    NUL terminator), or -1 on error or EOF.  */
654 # if @REPLACE_GETLINE@
655 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
656 #   undef getline
657 #   define getline rpl_getline
658 #  endif
659 _GL_FUNCDECL_RPL (getline, ssize_t,
660                   (char **lineptr, size_t *linesize, FILE *stream)
661                   _GL_ARG_NONNULL ((1, 2, 3)));
662 _GL_CXXALIAS_RPL (getline, ssize_t,
663                   (char **lineptr, size_t *linesize, FILE *stream));
664 # else
665 #  if !@HAVE_DECL_GETLINE@
666 _GL_FUNCDECL_SYS (getline, ssize_t,
667                   (char **lineptr, size_t *linesize, FILE *stream)
668                   _GL_ARG_NONNULL ((1, 2, 3)));
669 #  endif
670 _GL_CXXALIAS_SYS (getline, ssize_t,
671                   (char **lineptr, size_t *linesize, FILE *stream));
672 # endif
673 # if @HAVE_DECL_GETLINE@
674 _GL_CXXALIASWARN (getline);
675 # endif
676 #elif defined GNULIB_POSIXCHECK
677 # undef getline
678 # if HAVE_RAW_DECL_GETLINE
679 _GL_WARN_ON_USE (getline, "getline is unportable - "
680                  "use gnulib module getline for portability");
681 # endif
682 #endif
683
684 #if @GNULIB_GETS@
685 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
686 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
687 #   undef gets
688 #   define gets rpl_gets
689 #  endif
690 _GL_FUNCDECL_RPL (gets, char *, (char *s) _GL_ARG_NONNULL ((1)));
691 _GL_CXXALIAS_RPL (gets, char *, (char *s));
692 # else
693 _GL_CXXALIAS_SYS (gets, char *, (char *s));
694 #  undef gets
695 # endif
696 _GL_CXXALIASWARN (gets);
697 /* It is very rare that the developer ever has full control of stdin,
698    so any use of gets warrants an unconditional warning.  Assume it is
699    always declared, since it is required by C89.  */
700 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
701 #endif
702
703
704 #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
705 struct obstack;
706 /* Grow an obstack with formatted output.  Return the number of
707    bytes added to OBS.  No trailing nul byte is added, and the
708    object should be closed with obstack_finish before use.  Upon
709    memory allocation error, call obstack_alloc_failed_handler.  Upon
710    other error, return -1.  */
711 # if @REPLACE_OBSTACK_PRINTF@
712 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
713 #   define obstack_printf rpl_obstack_printf
714 #  endif
715 _GL_FUNCDECL_RPL (obstack_printf, int,
716                   (struct obstack *obs, const char *format, ...)
717                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
718                   _GL_ARG_NONNULL ((1, 2)));
719 _GL_CXXALIAS_RPL (obstack_printf, int,
720                   (struct obstack *obs, const char *format, ...));
721 # else
722 #  if !@HAVE_DECL_OBSTACK_PRINTF@
723 _GL_FUNCDECL_SYS (obstack_printf, int,
724                   (struct obstack *obs, const char *format, ...)
725                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
726                   _GL_ARG_NONNULL ((1, 2)));
727 #  endif
728 _GL_CXXALIAS_SYS (obstack_printf, int,
729                   (struct obstack *obs, const char *format, ...));
730 # endif
731 _GL_CXXALIASWARN (obstack_printf);
732 # if @REPLACE_OBSTACK_PRINTF@
733 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
734 #   define obstack_vprintf rpl_obstack_vprintf
735 #  endif
736 _GL_FUNCDECL_RPL (obstack_vprintf, int,
737                   (struct obstack *obs, const char *format, va_list args)
738                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
739                   _GL_ARG_NONNULL ((1, 2)));
740 _GL_CXXALIAS_RPL (obstack_vprintf, int,
741                   (struct obstack *obs, const char *format, va_list args));
742 # else
743 #  if !@HAVE_DECL_OBSTACK_PRINTF@
744 _GL_FUNCDECL_SYS (obstack_vprintf, int,
745                   (struct obstack *obs, const char *format, va_list args)
746                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
747                   _GL_ARG_NONNULL ((1, 2)));
748 #  endif
749 _GL_CXXALIAS_SYS (obstack_vprintf, int,
750                   (struct obstack *obs, const char *format, va_list args));
751 # endif
752 _GL_CXXALIASWARN (obstack_vprintf);
753 #endif
754
755 #if @GNULIB_PERROR@
756 /* Print a message to standard error, describing the value of ERRNO,
757    (if STRING is not NULL and not empty) prefixed with STRING and ": ",
758    and terminated with a newline.  */
759 # if @REPLACE_PERROR@
760 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
761 #   define perror rpl_perror
762 #  endif
763 _GL_FUNCDECL_RPL (perror, void, (const char *string));
764 _GL_CXXALIAS_RPL (perror, void, (const char *string));
765 # else
766 _GL_CXXALIAS_SYS (perror, void, (const char *string));
767 # endif
768 _GL_CXXALIASWARN (perror);
769 #elif defined GNULIB_POSIXCHECK
770 # undef perror
771 /* Assume perror is always declared.  */
772 _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
773                  "use gnulib module perror for portability");
774 #endif
775
776 #if @GNULIB_POPEN@
777 # if @REPLACE_POPEN@
778 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
779 #   undef popen
780 #   define popen rpl_popen
781 #  endif
782 _GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode)
783                                  _GL_ARG_NONNULL ((1, 2)));
784 _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
785 # else
786 _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
787 # endif
788 _GL_CXXALIASWARN (popen);
789 #elif defined GNULIB_POSIXCHECK
790 # undef popen
791 # if HAVE_RAW_DECL_POPEN
792 _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
793                  "use gnulib module popen or pipe for more portability");
794 # endif
795 #endif
796
797 #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
798 # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
799      || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
800 #  if defined __GNUC__
801 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
802 /* Don't break __attribute__((format(printf,M,N))).  */
803 #    define printf __printf__
804 #   endif
805 #   if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
806 _GL_FUNCDECL_RPL_1 (__printf__, int,
807                     (const char *format, ...)
808                     __asm__ (@ASM_SYMBOL_PREFIX@
809                              _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
810                     _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
811                     _GL_ARG_NONNULL ((1)));
812 #   else
813 _GL_FUNCDECL_RPL_1 (__printf__, int,
814                     (const char *format, ...)
815                     __asm__ (@ASM_SYMBOL_PREFIX@
816                              _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
817                     _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
818                     _GL_ARG_NONNULL ((1)));
819 #   endif
820 _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
821 #  else
822 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
823 #    define printf rpl_printf
824 #   endif
825 _GL_FUNCDECL_RPL (printf, int,
826                   (const char *format, ...)
827                   _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
828                   _GL_ARG_NONNULL ((1)));
829 _GL_CXXALIAS_RPL (printf, int, (const char *format, ...));
830 #  endif
831 #  define GNULIB_overrides_printf 1
832 # else
833 _GL_CXXALIAS_SYS (printf, int, (const char *format, ...));
834 # endif
835 _GL_CXXALIASWARN (printf);
836 #endif
837 #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
838 # if !GNULIB_overrides_printf
839 #  undef printf
840 # endif
841 /* Assume printf is always declared.  */
842 _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
843                  "use gnulib module printf-posix for portable "
844                  "POSIX compliance");
845 #endif
846
847 #if @GNULIB_PUTC@
848 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
849 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
850 #   undef putc
851 #   define putc rpl_fputc
852 #  endif
853 _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
854 _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
855 # else
856 _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
857 # endif
858 _GL_CXXALIASWARN (putc);
859 #endif
860
861 #if @GNULIB_PUTCHAR@
862 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
863 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
864 #   undef putchar
865 #   define putchar rpl_putchar
866 #  endif
867 _GL_FUNCDECL_RPL (putchar, int, (int c));
868 _GL_CXXALIAS_RPL (putchar, int, (int c));
869 # else
870 _GL_CXXALIAS_SYS (putchar, int, (int c));
871 # endif
872 _GL_CXXALIASWARN (putchar);
873 #endif
874
875 #if @GNULIB_PUTS@
876 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
877 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
878 #   undef puts
879 #   define puts rpl_puts
880 #  endif
881 _GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1)));
882 _GL_CXXALIAS_RPL (puts, int, (const char *string));
883 # else
884 _GL_CXXALIAS_SYS (puts, int, (const char *string));
885 # endif
886 _GL_CXXALIASWARN (puts);
887 #endif
888
889 #if @GNULIB_REMOVE@
890 # if @REPLACE_REMOVE@
891 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
892 #   undef remove
893 #   define remove rpl_remove
894 #  endif
895 _GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1)));
896 _GL_CXXALIAS_RPL (remove, int, (const char *name));
897 # else
898 _GL_CXXALIAS_SYS (remove, int, (const char *name));
899 # endif
900 _GL_CXXALIASWARN (remove);
901 #elif defined GNULIB_POSIXCHECK
902 # undef remove
903 /* Assume remove is always declared.  */
904 _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
905                  "use gnulib module remove for more portability");
906 #endif
907
908 #if @GNULIB_RENAME@
909 # if @REPLACE_RENAME@
910 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
911 #   undef rename
912 #   define rename rpl_rename
913 #  endif
914 _GL_FUNCDECL_RPL (rename, int,
915                   (const char *old_filename, const char *new_filename)
916                   _GL_ARG_NONNULL ((1, 2)));
917 _GL_CXXALIAS_RPL (rename, int,
918                   (const char *old_filename, const char *new_filename));
919 # else
920 _GL_CXXALIAS_SYS (rename, int,
921                   (const char *old_filename, const char *new_filename));
922 # endif
923 _GL_CXXALIASWARN (rename);
924 #elif defined GNULIB_POSIXCHECK
925 # undef rename
926 /* Assume rename is always declared.  */
927 _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
928                  "use gnulib module rename for more portability");
929 #endif
930
931 #if @GNULIB_RENAMEAT@
932 # if @REPLACE_RENAMEAT@
933 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
934 #   undef renameat
935 #   define renameat rpl_renameat
936 #  endif
937 _GL_FUNCDECL_RPL (renameat, int,
938                   (int fd1, char const *file1, int fd2, char const *file2)
939                   _GL_ARG_NONNULL ((2, 4)));
940 _GL_CXXALIAS_RPL (renameat, int,
941                   (int fd1, char const *file1, int fd2, char const *file2));
942 # else
943 #  if !@HAVE_RENAMEAT@
944 _GL_FUNCDECL_SYS (renameat, int,
945                   (int fd1, char const *file1, int fd2, char const *file2)
946                   _GL_ARG_NONNULL ((2, 4)));
947 #  endif
948 _GL_CXXALIAS_SYS (renameat, int,
949                   (int fd1, char const *file1, int fd2, char const *file2));
950 # endif
951 _GL_CXXALIASWARN (renameat);
952 #elif defined GNULIB_POSIXCHECK
953 # undef renameat
954 # if HAVE_RAW_DECL_RENAMEAT
955 _GL_WARN_ON_USE (renameat, "renameat is not portable - "
956                  "use gnulib module renameat for portability");
957 # endif
958 #endif
959
960 #if @GNULIB_SCANF@
961 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
962 #  if defined __GNUC__
963 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
964 #    undef scanf
965 /* Don't break __attribute__((format(scanf,M,N))).  */
966 #    define scanf __scanf__
967 #   endif
968 _GL_FUNCDECL_RPL_1 (__scanf__, int,
969                     (const char *format, ...)
970                     __asm__ (@ASM_SYMBOL_PREFIX@
971                              _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf))
972                     _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
973                     _GL_ARG_NONNULL ((1)));
974 _GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *format, ...));
975 #  else
976 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
977 #    undef scanf
978 #    define scanf rpl_scanf
979 #   endif
980 _GL_FUNCDECL_RPL (scanf, int, (const char *format, ...)
981                               _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
982                               _GL_ARG_NONNULL ((1)));
983 _GL_CXXALIAS_RPL (scanf, int, (const char *format, ...));
984 #  endif
985 # else
986 _GL_CXXALIAS_SYS (scanf, int, (const char *format, ...));
987 # endif
988 _GL_CXXALIASWARN (scanf);
989 #endif
990
991 #if @GNULIB_SNPRINTF@
992 # if @REPLACE_SNPRINTF@
993 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
994 #   define snprintf rpl_snprintf
995 #  endif
996 _GL_FUNCDECL_RPL (snprintf, int,
997                   (char *str, size_t size, const char *format, ...)
998                   _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
999                   _GL_ARG_NONNULL ((3)));
1000 _GL_CXXALIAS_RPL (snprintf, int,
1001                   (char *str, size_t size, const char *format, ...));
1002 # else
1003 #  if !@HAVE_DECL_SNPRINTF@
1004 _GL_FUNCDECL_SYS (snprintf, int,
1005                   (char *str, size_t size, const char *format, ...)
1006                   _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
1007                   _GL_ARG_NONNULL ((3)));
1008 #  endif
1009 _GL_CXXALIAS_SYS (snprintf, int,
1010                   (char *str, size_t size, const char *format, ...));
1011 # endif
1012 _GL_CXXALIASWARN (snprintf);
1013 #elif defined GNULIB_POSIXCHECK
1014 # undef snprintf
1015 # if HAVE_RAW_DECL_SNPRINTF
1016 _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
1017                  "use gnulib module snprintf for portability");
1018 # endif
1019 #endif
1020
1021 /* Some people would argue that sprintf should be handled like gets
1022    (for example, OpenBSD issues a link warning for both functions),
1023    since both can cause security holes due to buffer overruns.
1024    However, we believe that sprintf can be used safely, and is more
1025    efficient than snprintf in those safe cases; and as proof of our
1026    belief, we use sprintf in several gnulib modules.  So this header
1027    intentionally avoids adding a warning to sprintf except when
1028    GNULIB_POSIXCHECK is defined.  */
1029
1030 #if @GNULIB_SPRINTF_POSIX@
1031 # if @REPLACE_SPRINTF@
1032 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1033 #   define sprintf rpl_sprintf
1034 #  endif
1035 _GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...)
1036                                 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
1037                                 _GL_ARG_NONNULL ((1, 2)));
1038 _GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...));
1039 # else
1040 _GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...));
1041 # endif
1042 _GL_CXXALIASWARN (sprintf);
1043 #elif defined GNULIB_POSIXCHECK
1044 # undef sprintf
1045 /* Assume sprintf is always declared.  */
1046 _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
1047                  "use gnulib module sprintf-posix for portable "
1048                  "POSIX compliance");
1049 #endif
1050
1051 #if @GNULIB_TMPFILE@
1052 # if @REPLACE_TMPFILE@
1053 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1054 #   define tmpfile rpl_tmpfile
1055 #  endif
1056 _GL_FUNCDECL_RPL (tmpfile, FILE *, (void));
1057 _GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
1058 # else
1059 _GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
1060 # endif
1061 _GL_CXXALIASWARN (tmpfile);
1062 #elif defined GNULIB_POSIXCHECK
1063 # undef tmpfile
1064 # if HAVE_RAW_DECL_TMPFILE
1065 _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
1066                  "use gnulib module tmpfile for portability");
1067 # endif
1068 #endif
1069
1070 #if @GNULIB_VASPRINTF@
1071 /* Write formatted output to a string dynamically allocated with malloc().
1072    If the memory allocation succeeds, store the address of the string in
1073    *RESULT and return the number of resulting bytes, excluding the trailing
1074    NUL.  Upon memory allocation error, or some other error, return -1.  */
1075 # if @REPLACE_VASPRINTF@
1076 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1077 #   define asprintf rpl_asprintf
1078 #  endif
1079 _GL_FUNCDECL_RPL (asprintf, int,
1080                   (char **result, const char *format, ...)
1081                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
1082                   _GL_ARG_NONNULL ((1, 2)));
1083 _GL_CXXALIAS_RPL (asprintf, int,
1084                   (char **result, const char *format, ...));
1085 # else
1086 #  if !@HAVE_VASPRINTF@
1087 _GL_FUNCDECL_SYS (asprintf, int,
1088                   (char **result, const char *format, ...)
1089                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
1090                   _GL_ARG_NONNULL ((1, 2)));
1091 #  endif
1092 _GL_CXXALIAS_SYS (asprintf, int,
1093                   (char **result, const char *format, ...));
1094 # endif
1095 _GL_CXXALIASWARN (asprintf);
1096 # if @REPLACE_VASPRINTF@
1097 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1098 #   define vasprintf rpl_vasprintf
1099 #  endif
1100 _GL_FUNCDECL_RPL (vasprintf, int,
1101                   (char **result, const char *format, va_list args)
1102                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1103                   _GL_ARG_NONNULL ((1, 2)));
1104 _GL_CXXALIAS_RPL (vasprintf, int,
1105                   (char **result, const char *format, va_list args));
1106 # else
1107 #  if !@HAVE_VASPRINTF@
1108 _GL_FUNCDECL_SYS (vasprintf, int,
1109                   (char **result, const char *format, va_list args)
1110                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1111                   _GL_ARG_NONNULL ((1, 2)));
1112 #  endif
1113 _GL_CXXALIAS_SYS (vasprintf, int,
1114                   (char **result, const char *format, va_list args));
1115 # endif
1116 _GL_CXXALIASWARN (vasprintf);
1117 #endif
1118
1119 #if @GNULIB_VDPRINTF@
1120 # if @REPLACE_VDPRINTF@
1121 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1122 #   define vdprintf rpl_vdprintf
1123 #  endif
1124 _GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args)
1125                                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1126                                  _GL_ARG_NONNULL ((2)));
1127 _GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args));
1128 # else
1129 #  if !@HAVE_VDPRINTF@
1130 _GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args)
1131                                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1132                                  _GL_ARG_NONNULL ((2)));
1133 #  endif
1134 /* Need to cast, because on Solaris, the third parameter will likely be
1135                                                     __va_list args.  */
1136 _GL_CXXALIAS_SYS_CAST (vdprintf, int,
1137                        (int fd, const char *format, va_list args));
1138 # endif
1139 _GL_CXXALIASWARN (vdprintf);
1140 #elif defined GNULIB_POSIXCHECK
1141 # undef vdprintf
1142 # if HAVE_RAW_DECL_VDPRINTF
1143 _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
1144                  "use gnulib module vdprintf for portability");
1145 # endif
1146 #endif
1147
1148 #if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
1149 # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
1150      || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
1151 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1152 #   define vfprintf rpl_vfprintf
1153 #  endif
1154 #  define GNULIB_overrides_vfprintf 1
1155 #  if @GNULIB_VFPRINTF_POSIX@
1156 _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
1157                                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1158                                  _GL_ARG_NONNULL ((1, 2)));
1159 #  else
1160 _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
1161                                  _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
1162                                  _GL_ARG_NONNULL ((1, 2)));
1163 #  endif
1164 _GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args));
1165 # else
1166 /* Need to cast, because on Solaris, the third parameter is
1167                                                       __va_list args
1168    and GCC's fixincludes did not change this to __gnuc_va_list.  */
1169 _GL_CXXALIAS_SYS_CAST (vfprintf, int,
1170                        (FILE *fp, const char *format, va_list args));
1171 # endif
1172 _GL_CXXALIASWARN (vfprintf);
1173 #endif
1174 #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1175 # if !GNULIB_overrides_vfprintf
1176 #  undef vfprintf
1177 # endif
1178 /* Assume vfprintf is always declared.  */
1179 _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
1180                  "use gnulib module vfprintf-posix for portable "
1181                       "POSIX compliance");
1182 #endif
1183
1184 #if @GNULIB_VFSCANF@
1185 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
1186 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1187 #   undef vfscanf
1188 #   define vfscanf rpl_vfscanf
1189 #  endif
1190 _GL_FUNCDECL_RPL (vfscanf, int,
1191                   (FILE *stream, const char *format, va_list args)
1192                   _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
1193                   _GL_ARG_NONNULL ((1, 2)));
1194 _GL_CXXALIAS_RPL (vfscanf, int,
1195                   (FILE *stream, const char *format, va_list args));
1196 # else
1197 _GL_CXXALIAS_SYS (vfscanf, int,
1198                   (FILE *stream, const char *format, va_list args));
1199 # endif
1200 _GL_CXXALIASWARN (vfscanf);
1201 #endif
1202
1203 #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
1204 # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
1205      || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
1206 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1207 #   define vprintf rpl_vprintf
1208 #  endif
1209 #  define GNULIB_overrides_vprintf 1
1210 #  if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
1211 _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
1212                                 _GL_ATTRIBUTE_FORMAT_PRINTF (1, 0)
1213                                 _GL_ARG_NONNULL ((1)));
1214 #  else
1215 _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
1216                                 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
1217                                 _GL_ARG_NONNULL ((1)));
1218 #  endif
1219 _GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args));
1220 # else
1221 /* Need to cast, because on Solaris, the second parameter is
1222                                                           __va_list args
1223    and GCC's fixincludes did not change this to __gnuc_va_list.  */
1224 _GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args));
1225 # endif
1226 _GL_CXXALIASWARN (vprintf);
1227 #endif
1228 #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1229 # if !GNULIB_overrides_vprintf
1230 #  undef vprintf
1231 # endif
1232 /* Assume vprintf is always declared.  */
1233 _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
1234                  "use gnulib module vprintf-posix for portable "
1235                  "POSIX compliance");
1236 #endif
1237
1238 #if @GNULIB_VSCANF@
1239 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
1240 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1241 #   undef vscanf
1242 #   define vscanf rpl_vscanf
1243 #  endif
1244 _GL_FUNCDECL_RPL (vscanf, int, (const char *format, va_list args)
1245                                _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
1246                                _GL_ARG_NONNULL ((1)));
1247 _GL_CXXALIAS_RPL (vscanf, int, (const char *format, va_list args));
1248 # else
1249 _GL_CXXALIAS_SYS (vscanf, int, (const char *format, va_list args));
1250 # endif
1251 _GL_CXXALIASWARN (vscanf);
1252 #endif
1253
1254 #if @GNULIB_VSNPRINTF@
1255 # if @REPLACE_VSNPRINTF@
1256 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1257 #   define vsnprintf rpl_vsnprintf
1258 #  endif
1259 _GL_FUNCDECL_RPL (vsnprintf, int,
1260                   (char *str, size_t size, const char *format, va_list args)
1261                   _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
1262                   _GL_ARG_NONNULL ((3)));
1263 _GL_CXXALIAS_RPL (vsnprintf, int,
1264                   (char *str, size_t size, const char *format, va_list args));
1265 # else
1266 #  if !@HAVE_DECL_VSNPRINTF@
1267 _GL_FUNCDECL_SYS (vsnprintf, int,
1268                   (char *str, size_t size, const char *format, va_list args)
1269                   _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
1270                   _GL_ARG_NONNULL ((3)));
1271 #  endif
1272 _GL_CXXALIAS_SYS (vsnprintf, int,
1273                   (char *str, size_t size, const char *format, va_list args));
1274 # endif
1275 _GL_CXXALIASWARN (vsnprintf);
1276 #elif defined GNULIB_POSIXCHECK
1277 # undef vsnprintf
1278 # if HAVE_RAW_DECL_VSNPRINTF
1279 _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
1280                  "use gnulib module vsnprintf for portability");
1281 # endif
1282 #endif
1283
1284 #if @GNULIB_VSPRINTF_POSIX@
1285 # if @REPLACE_VSPRINTF@
1286 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1287 #   define vsprintf rpl_vsprintf
1288 #  endif
1289 _GL_FUNCDECL_RPL (vsprintf, int,
1290                   (char *str, const char *format, va_list args)
1291                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1292                   _GL_ARG_NONNULL ((1, 2)));
1293 _GL_CXXALIAS_RPL (vsprintf, int,
1294                   (char *str, const char *format, va_list args));
1295 # else
1296 /* Need to cast, because on Solaris, the third parameter is
1297                                                        __va_list args
1298    and GCC's fixincludes did not change this to __gnuc_va_list.  */
1299 _GL_CXXALIAS_SYS_CAST (vsprintf, int,
1300                        (char *str, const char *format, va_list args));
1301 # endif
1302 _GL_CXXALIASWARN (vsprintf);
1303 #elif defined GNULIB_POSIXCHECK
1304 # undef vsprintf
1305 /* Assume vsprintf is always declared.  */
1306 _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
1307                  "use gnulib module vsprintf-posix for portable "
1308                       "POSIX compliance");
1309 #endif
1310
1311
1312 #endif /* _@GUARD_PREFIX@_STDIO_H */
1313 #endif /* _@GUARD_PREFIX@_STDIO_H */
1314 #endif