New module 'posix_spawnattr_getschedparam'.
[pspp] / lib / stdio.in.h
1 /* A GNU-like <stdio.h>.
2
3    Copyright (C) 2004, 2007-2008 Free Software Foundation, Inc.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2, or (at your option)
8    any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18
19 @PRAGMA_SYSTEM_HEADER@
20
21 #if defined __need_FILE || defined __need___FILE
22 /* Special invocation convention inside glibc header files.  */
23
24 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
25
26 #else
27 /* Normal invocation convention.  */
28
29 #ifndef _GL_STDIO_H
30
31 /* The include_next requires a split double-inclusion guard.  */
32 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
33
34 #ifndef _GL_STDIO_H
35 #define _GL_STDIO_H
36
37 #include <stdarg.h>
38 #include <stddef.h>
39
40 #if (@GNULIB_FSEEKO@ && @REPLACE_FSEEKO@) \
41   || (@GNULIB_FTELLO@ && @REPLACE_FTELLO@) \
42   || (@GNULIB_GETDELIM@ && !@HAVE_DECL_GETDELIM@) \
43   || (@GNULIB_GETLINE@ && (!@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@))
44 /* Get off_t and ssize_t.  */
45 # include <sys/types.h>
46 #endif
47
48 #ifndef __attribute__
49 /* This feature is available in gcc versions 2.5 and later.  */
50 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
51 #  define __attribute__(Spec) /* empty */
52 # endif
53 /* The __-protected variants of `format' and `printf' attributes
54    are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
55 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
56 #  define __format__ format
57 #  define __printf__ printf
58 # endif
59 #endif
60
61
62 /* The definition of GL_LINK_WARNING is copied here.  */
63
64
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68
69
70 #if @GNULIB_FPRINTF_POSIX@
71 # if @REPLACE_FPRINTF@
72 #  define fprintf rpl_fprintf
73 extern int fprintf (FILE *fp, const char *format, ...)
74        __attribute__ ((__format__ (__printf__, 2, 3)));
75 # endif
76 #elif @GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
77 # define fprintf rpl_fprintf
78 extern int fprintf (FILE *fp, const char *format, ...)
79        __attribute__ ((__format__ (__printf__, 2, 3)));
80 #elif defined GNULIB_POSIXCHECK
81 # undef fprintf
82 # define fprintf \
83     (GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \
84                       "use gnulib module fprintf-posix for portable " \
85                       "POSIX compliance"), \
86      fprintf)
87 #endif
88
89 #if @GNULIB_VFPRINTF_POSIX@
90 # if @REPLACE_VFPRINTF@
91 #  define vfprintf rpl_vfprintf
92 extern int vfprintf (FILE *fp, const char *format, va_list args)
93        __attribute__ ((__format__ (__printf__, 2, 0)));
94 # endif
95 #elif @GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
96 # define vfprintf rpl_vfprintf
97 extern int vfprintf (FILE *fp, const char *format, va_list args)
98        __attribute__ ((__format__ (__printf__, 2, 0)));
99 #elif defined GNULIB_POSIXCHECK
100 # undef vfprintf
101 # define vfprintf(s,f,a) \
102     (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \
103                       "use gnulib module vfprintf-posix for portable " \
104                       "POSIX compliance"), \
105      vfprintf (s, f, a))
106 #endif
107
108 #if @GNULIB_PRINTF_POSIX@
109 # if @REPLACE_PRINTF@
110 /* Don't break __attribute__((format(printf,M,N))).  */
111 #  define printf __printf__
112 extern int printf (const char *format, ...)
113        __attribute__ ((__format__ (__printf__, 1, 2)));
114 # endif
115 #elif @GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
116 /* Don't break __attribute__((format(printf,M,N))).  */
117 # define printf __printf__
118 extern int printf (const char *format, ...)
119        __attribute__ ((__format__ (__printf__, 1, 2)));
120 #elif defined GNULIB_POSIXCHECK
121 # undef printf
122 # define printf \
123     (GL_LINK_WARNING ("printf is not always POSIX compliant - " \
124                       "use gnulib module printf-posix for portable " \
125                       "POSIX compliance"), \
126      printf)
127 /* Don't break __attribute__((format(printf,M,N))).  */
128 # define format(kind,m,n) format (__##kind##__, m, n)
129 # define __format__(kind,m,n) __format__ (__##kind##__, m, n)
130 # define ____printf____ __printf__
131 # define ____scanf____ __scanf__
132 # define ____strftime____ __strftime__
133 # define ____strfmon____ __strfmon__
134 #endif
135
136 #if @GNULIB_VPRINTF_POSIX@
137 # if @REPLACE_VPRINTF@
138 #  define vprintf rpl_vprintf
139 extern int vprintf (const char *format, va_list args)
140        __attribute__ ((__format__ (__printf__, 1, 0)));
141 # endif
142 #elif @GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
143 # define vprintf rpl_vprintf
144 extern int vprintf (const char *format, va_list args)
145        __attribute__ ((__format__ (__printf__, 1, 0)));
146 #elif defined GNULIB_POSIXCHECK
147 # undef vprintf
148 # define vprintf(f,a) \
149     (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \
150                       "use gnulib module vprintf-posix for portable " \
151                       "POSIX compliance"), \
152      vprintf (f, a))
153 #endif
154
155 #if @GNULIB_SNPRINTF@
156 # if @REPLACE_SNPRINTF@
157 #  define snprintf rpl_snprintf
158 # endif
159 # if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
160 extern int snprintf (char *str, size_t size, const char *format, ...)
161        __attribute__ ((__format__ (__printf__, 3, 4)));
162 # endif
163 #elif defined GNULIB_POSIXCHECK
164 # undef snprintf
165 # define snprintf \
166     (GL_LINK_WARNING ("snprintf is unportable - " \
167                       "use gnulib module snprintf for portability"), \
168      snprintf)
169 #endif
170
171 #if @GNULIB_VSNPRINTF@
172 # if @REPLACE_VSNPRINTF@
173 #  define vsnprintf rpl_vsnprintf
174 # endif
175 # if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
176 extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
177        __attribute__ ((__format__ (__printf__, 3, 0)));
178 # endif
179 #elif defined GNULIB_POSIXCHECK
180 # undef vsnprintf
181 # define vsnprintf(b,s,f,a) \
182     (GL_LINK_WARNING ("vsnprintf is unportable - " \
183                       "use gnulib module vsnprintf for portability"), \
184      vsnprintf (b, s, f, a))
185 #endif
186
187 #if @GNULIB_SPRINTF_POSIX@
188 # if @REPLACE_SPRINTF@
189 #  define sprintf rpl_sprintf
190 extern int sprintf (char *str, const char *format, ...)
191        __attribute__ ((__format__ (__printf__, 2, 3)));
192 # endif
193 #elif defined GNULIB_POSIXCHECK
194 # undef sprintf
195 # define sprintf \
196     (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \
197                       "use gnulib module sprintf-posix for portable " \
198                       "POSIX compliance"), \
199      sprintf)
200 #endif
201
202 #if @GNULIB_VSPRINTF_POSIX@
203 # if @REPLACE_VSPRINTF@
204 #  define vsprintf rpl_vsprintf
205 extern int vsprintf (char *str, const char *format, va_list args)
206        __attribute__ ((__format__ (__printf__, 2, 0)));
207 # endif
208 #elif defined GNULIB_POSIXCHECK
209 # undef vsprintf
210 # define vsprintf(b,f,a) \
211     (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \
212                       "use gnulib module vsprintf-posix for portable " \
213                       "POSIX compliance"), \
214      vsprintf (b, f, a))
215 #endif
216
217 #if @GNULIB_VASPRINTF@
218 # if @REPLACE_VASPRINTF@
219 #  define asprintf rpl_asprintf
220 #  define vasprintf rpl_vasprintf
221 # endif
222 # if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@
223   /* Write formatted output to a string dynamically allocated with malloc().
224      If the memory allocation succeeds, store the address of the string in
225      *RESULT and return the number of resulting bytes, excluding the trailing
226      NUL.  Upon memory allocation error, or some other error, return -1.  */
227   extern int asprintf (char **result, const char *format, ...)
228     __attribute__ ((__format__ (__printf__, 2, 3)));
229   extern int vasprintf (char **result, const char *format, va_list args)
230     __attribute__ ((__format__ (__printf__, 2, 0)));
231 # endif
232 #endif
233
234 #if @GNULIB_OBSTACK_PRINTF@
235 # if @REPLACE_OBSTACK_PRINTF@
236 #  define obstack_printf rpl_osbtack_printf
237 #  define obstack_vprintf rpl_obstack_vprintf
238 # endif
239 # if @REPLACE_OBSTACK_PRINTF@ || !@HAVE_DECL_OBSTACK_PRINTF@
240   struct obstack;
241   /* Grow an obstack with formatted output.  Return the number of
242      bytes added to OBS.  No trailing nul byte is added, and the
243      object should be closed with obstack_finish before use.  Upon
244      memory allocation error, call obstack_alloc_failed_handler.  Upon
245      other error, return -1.  */
246   extern int obstack_printf (struct obstack *obs, const char *format, ...)
247     __attribute__ ((__format__ (__printf__, 2, 3)));
248   extern int obstack_vprintf (struct obstack *obs, const char *format,
249                               va_list args)
250     __attribute__ ((__format__ (__printf__, 2, 0)));
251 # endif
252 #endif
253
254 #if @GNULIB_FOPEN@
255 # if @REPLACE_FOPEN@
256 #  define fopen rpl_fopen
257 extern FILE * fopen (const char *filename, const char *mode);
258 # endif
259 #elif defined GNULIB_POSIXCHECK
260 # undef fopen
261 # define fopen(f,m) \
262    (GL_LINK_WARNING ("fopen on Win32 platforms is not POSIX compatible - " \
263                      "use gnulib module fopen for portability"), \
264     fopen (f, m))
265 #endif
266
267 #if @GNULIB_FREOPEN@
268 # if @REPLACE_FREOPEN@
269 #  define freopen rpl_freopen
270 extern FILE * freopen (const char *filename, const char *mode, FILE *stream);
271 # endif
272 #elif defined GNULIB_POSIXCHECK
273 # undef freopen
274 # define freopen(f,m,s) \
275    (GL_LINK_WARNING ("freopen on Win32 platforms is not POSIX compatible - " \
276                      "use gnulib module freopen for portability"), \
277     freopen (f, m, s))
278 #endif
279
280 #if @GNULIB_FSEEKO@
281 # if @REPLACE_FSEEKO@
282 /* Provide fseek, fseeko functions that are aware of a preceding
283    fflush(), and which detect pipes.  */
284 #  define fseeko rpl_fseeko
285 extern int fseeko (FILE *fp, off_t offset, int whence);
286 #  define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence)
287 # endif
288 #elif defined GNULIB_POSIXCHECK
289 # undef fseeko
290 # define fseeko(f,o,w) \
291    (GL_LINK_WARNING ("fseeko is unportable - " \
292                      "use gnulib module fseeko for portability"), \
293     fseeko (f, o, w))
294 #endif
295
296 #if @GNULIB_FSEEK@ && @REPLACE_FSEEK@
297 extern int rpl_fseek (FILE *fp, long offset, int whence);
298 # undef fseek
299 # if defined GNULIB_POSIXCHECK
300 #  define fseek(f,o,w) \
301      (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
302                        "on 32-bit platforms - " \
303                        "use fseeko function for handling of large files"), \
304       rpl_fseek (f, o, w))
305 # else
306 #  define fseek rpl_fseek
307 # endif
308 #elif defined GNULIB_POSIXCHECK
309 # ifndef fseek
310 #  define fseek(f,o,w) \
311      (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
312                        "on 32-bit platforms - " \
313                        "use fseeko function for handling of large files"), \
314       fseek (f, o, w))
315 # endif
316 #endif
317
318 #if @GNULIB_FTELLO@
319 # if @REPLACE_FTELLO@
320 #  define ftello rpl_ftello
321 extern off_t ftello (FILE *fp);
322 #  define ftell(fp) ftello (fp)
323 # endif
324 #elif defined GNULIB_POSIXCHECK
325 # undef ftello
326 # define ftello(f) \
327    (GL_LINK_WARNING ("ftello is unportable - " \
328                      "use gnulib module ftello for portability"), \
329     ftello (f))
330 #endif
331
332 #if @GNULIB_FTELL@ && @REPLACE_FTELL@
333 extern long rpl_ftell (FILE *fp);
334 # undef ftell
335 # if GNULIB_POSIXCHECK
336 #  define ftell(f) \
337      (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
338                        "on 32-bit platforms - " \
339                        "use ftello function for handling of large files"), \
340       rpl_ftell (f))
341 # else
342 #  define ftell rpl_ftell
343 # endif
344 #elif defined GNULIB_POSIXCHECK
345 # ifndef ftell
346 #  define ftell(f) \
347      (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
348                        "on 32-bit platforms - " \
349                        "use ftello function for handling of large files"), \
350       ftell (f))
351 # endif
352 #endif
353
354 #if @GNULIB_FFLUSH@
355 # if @REPLACE_FFLUSH@
356 #  define fflush rpl_fflush
357   /* Flush all pending data on STREAM according to POSIX rules.  Both
358      output and seekable input streams are supported.
359      Note! LOSS OF DATA can occur if fflush is applied on an input stream
360      that is _not_seekable_ or on an update stream that is _not_seekable_
361      and in which the most recent operation was input.  Seekability can
362      be tested with lseek(fileno(fp),0,SEEK_CUR).  */
363   extern int fflush (FILE *gl_stream);
364 # endif
365 #elif defined GNULIB_POSIXCHECK
366 # undef fflush
367 # define fflush(f) \
368    (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \
369                      "use gnulib module fflush for portable " \
370                      "POSIX compliance"), \
371     fflush (f))
372 #endif
373
374 #if @GNULIB_FPUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
375 # undef fputc
376 # define fputc rpl_fputc
377 extern int fputc (int c, FILE *stream);
378 #endif
379
380 #if @GNULIB_PUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
381 # undef putc
382 # define putc rpl_fputc
383 extern int putc (int c, FILE *stream);
384 #endif
385
386 #if @GNULIB_PUTCHAR@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
387 # undef putchar
388 # define putchar rpl_putchar
389 extern int putchar (int c);
390 #endif
391
392 #if @GNULIB_FPUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
393 # undef fputs
394 # define fputs rpl_fputs
395 extern int fputs (const char *string, FILE *stream);
396 #endif
397
398 #if @GNULIB_PUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
399 # undef puts
400 # define puts rpl_puts
401 extern int puts (const char *string);
402 #endif
403
404 #if @GNULIB_FWRITE@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
405 # undef fwrite
406 # define fwrite rpl_fwrite
407 extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream);
408 #endif
409
410 #if @GNULIB_GETDELIM@
411 # if !@HAVE_DECL_GETDELIM@
412 /* Read input, up to (and including) the next occurrence of DELIMITER, from
413    STREAM, store it in *LINEPTR (and NUL-terminate it).
414    *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
415    bytes of space.  It is realloc'd as necessary.
416    Return the number of bytes read and stored at *LINEPTR (not including the
417    NUL terminator), or -1 on error or EOF.  */
418 extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
419                          FILE *stream);
420 # endif
421 #elif defined GNULIB_POSIXCHECK
422 # undef getdelim
423 # define getdelim(l, s, d, f)                                       \
424   (GL_LINK_WARNING ("getdelim is unportable - "                     \
425                     "use gnulib module getdelim for portability"),  \
426    getdelim (l, s, d, f))
427 #endif
428
429 #if @GNULIB_GETLINE@
430 # if @REPLACE_GETLINE@
431 #  undef getline
432 #  define getline rpl_getline
433 # endif
434 # if !@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@
435 /* Read a line, up to (and including) the next newline, from STREAM, store it
436    in *LINEPTR (and NUL-terminate it).
437    *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
438    bytes of space.  It is realloc'd as necessary.
439    Return the number of bytes read and stored at *LINEPTR (not including the
440    NUL terminator), or -1 on error or EOF.  */
441 extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream);
442 # endif
443 #elif defined GNULIB_POSIXCHECK
444 # undef getline
445 # define getline(l, s, f)                                               \
446   (GL_LINK_WARNING ("getline is unportable - "                          \
447                     "use gnulib module getline for portability"),       \
448    getline (l, s, f))
449 #endif
450
451 #if @GNULIB_PERROR@
452 # if @REPLACE_PERROR@
453 #  define perror rpl_perror
454 /* Print a message to standard error, describing the value of ERRNO,
455    (if STRING is not NULL and not empty) prefixed with STRING and ": ",
456    and terminated with a newline.  */
457 extern void perror (const char *string);
458 # endif
459 #elif defined GNULIB_POSIXCHECK
460 # undef perror
461 # define perror(s) \
462     (GL_LINK_WARNING ("perror is not always POSIX compliant - " \
463                       "use gnulib module perror for portability"), \
464      perror (s))
465 #endif
466
467 #ifdef __cplusplus
468 }
469 #endif
470
471 #endif /* _GL_STDIO_H */
472 #endif /* _GL_STDIO_H */
473 #endif