diff options
Diffstat (limited to 'gl/stdio.in.h')
-rw-r--r-- | gl/stdio.in.h | 382 |
1 files changed, 382 insertions, 0 deletions
diff --git a/gl/stdio.in.h b/gl/stdio.in.h new file mode 100644 index 00000000..434fa8e7 --- /dev/null +++ b/gl/stdio.in.h | |||
@@ -0,0 +1,382 @@ | |||
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 3, or (at your option) | ||
8 | any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software Foundation, | ||
17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
18 | |||
19 | #if defined __need_FILE || defined __need___FILE | ||
20 | /* Special invocation convention inside glibc header files. */ | ||
21 | |||
22 | #@INCLUDE_NEXT@ @NEXT_STDIO_H@ | ||
23 | |||
24 | #else | ||
25 | /* Normal invocation convention. */ | ||
26 | |||
27 | #ifndef _GL_STDIO_H | ||
28 | |||
29 | /* The include_next requires a split double-inclusion guard. */ | ||
30 | #@INCLUDE_NEXT@ @NEXT_STDIO_H@ | ||
31 | |||
32 | #ifndef _GL_STDIO_H | ||
33 | #define _GL_STDIO_H | ||
34 | |||
35 | #include <stdarg.h> | ||
36 | #include <stddef.h> | ||
37 | |||
38 | #if (@GNULIB_FSEEKO@ && @REPLACE_FSEEKO@) \ | ||
39 | || (@GNULIB_FTELLO@ && @REPLACE_FTELLO@) \ | ||
40 | || (@GNULIB_GETDELIM@ && !@HAVE_DECL_GETDELIM@) \ | ||
41 | || (@GNULIB_GETLINE@ && (!@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@)) | ||
42 | /* Get off_t and ssize_t. */ | ||
43 | # include <sys/types.h> | ||
44 | #endif | ||
45 | |||
46 | #ifndef __attribute__ | ||
47 | /* This feature is available in gcc versions 2.5 and later. */ | ||
48 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) | ||
49 | # define __attribute__(Spec) /* empty */ | ||
50 | # endif | ||
51 | /* The __-protected variants of `format' and `printf' attributes | ||
52 | are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ | ||
53 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) | ||
54 | # define __format__ format | ||
55 | # define __printf__ printf | ||
56 | # endif | ||
57 | #endif | ||
58 | |||
59 | |||
60 | /* The definition of GL_LINK_WARNING is copied here. */ | ||
61 | |||
62 | |||
63 | #ifdef __cplusplus | ||
64 | extern "C" { | ||
65 | #endif | ||
66 | |||
67 | |||
68 | #if @GNULIB_FPRINTF_POSIX@ | ||
69 | # if @REPLACE_FPRINTF@ | ||
70 | # define fprintf rpl_fprintf | ||
71 | extern int fprintf (FILE *fp, const char *format, ...) | ||
72 | __attribute__ ((__format__ (__printf__, 2, 3))); | ||
73 | # endif | ||
74 | #elif defined GNULIB_POSIXCHECK | ||
75 | # undef fprintf | ||
76 | # define fprintf \ | ||
77 | (GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \ | ||
78 | "use gnulib module fprintf-posix for portable " \ | ||
79 | "POSIX compliance"), \ | ||
80 | fprintf) | ||
81 | #endif | ||
82 | |||
83 | #if @GNULIB_VFPRINTF_POSIX@ | ||
84 | # if @REPLACE_VFPRINTF@ | ||
85 | # define vfprintf rpl_vfprintf | ||
86 | extern int vfprintf (FILE *fp, const char *format, va_list args) | ||
87 | __attribute__ ((__format__ (__printf__, 2, 0))); | ||
88 | # endif | ||
89 | #elif defined GNULIB_POSIXCHECK | ||
90 | # undef vfprintf | ||
91 | # define vfprintf(s,f,a) \ | ||
92 | (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \ | ||
93 | "use gnulib module vfprintf-posix for portable " \ | ||
94 | "POSIX compliance"), \ | ||
95 | vfprintf (s, f, a)) | ||
96 | #endif | ||
97 | |||
98 | #if @GNULIB_PRINTF_POSIX@ | ||
99 | # if @REPLACE_PRINTF@ | ||
100 | /* Don't break __attribute__((format(printf,M,N))). */ | ||
101 | # define printf __printf__ | ||
102 | extern int printf (const char *format, ...) | ||
103 | __attribute__ ((__format__ (__printf__, 1, 2))); | ||
104 | # endif | ||
105 | #elif defined GNULIB_POSIXCHECK | ||
106 | # undef printf | ||
107 | # define printf \ | ||
108 | (GL_LINK_WARNING ("printf is not always POSIX compliant - " \ | ||
109 | "use gnulib module printf-posix for portable " \ | ||
110 | "POSIX compliance"), \ | ||
111 | printf) | ||
112 | /* Don't break __attribute__((format(printf,M,N))). */ | ||
113 | # define format(kind,m,n) format (__##kind##__, m, n) | ||
114 | # define __format__(kind,m,n) __format__ (__##kind##__, m, n) | ||
115 | # define ____printf____ __printf__ | ||
116 | # define ____scanf____ __scanf__ | ||
117 | # define ____strftime____ __strftime__ | ||
118 | # define ____strfmon____ __strfmon__ | ||
119 | #endif | ||
120 | |||
121 | #if @GNULIB_VPRINTF_POSIX@ | ||
122 | # if @REPLACE_VPRINTF@ | ||
123 | # define vprintf rpl_vprintf | ||
124 | extern int vprintf (const char *format, va_list args) | ||
125 | __attribute__ ((__format__ (__printf__, 1, 0))); | ||
126 | # endif | ||
127 | #elif defined GNULIB_POSIXCHECK | ||
128 | # undef vprintf | ||
129 | # define vprintf(f,a) \ | ||
130 | (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \ | ||
131 | "use gnulib module vprintf-posix for portable " \ | ||
132 | "POSIX compliance"), \ | ||
133 | vprintf (f, a)) | ||
134 | #endif | ||
135 | |||
136 | #if @GNULIB_SNPRINTF@ | ||
137 | # if @REPLACE_SNPRINTF@ | ||
138 | # define snprintf rpl_snprintf | ||
139 | # endif | ||
140 | # if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@ | ||
141 | extern int snprintf (char *str, size_t size, const char *format, ...) | ||
142 | __attribute__ ((__format__ (__printf__, 3, 4))); | ||
143 | # endif | ||
144 | #elif defined GNULIB_POSIXCHECK | ||
145 | # undef snprintf | ||
146 | # define snprintf \ | ||
147 | (GL_LINK_WARNING ("snprintf is unportable - " \ | ||
148 | "use gnulib module snprintf for portability"), \ | ||
149 | snprintf) | ||
150 | #endif | ||
151 | |||
152 | #if @GNULIB_VSNPRINTF@ | ||
153 | # if @REPLACE_VSNPRINTF@ | ||
154 | # define vsnprintf rpl_vsnprintf | ||
155 | # endif | ||
156 | # if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@ | ||
157 | extern int vsnprintf (char *str, size_t size, const char *format, va_list args) | ||
158 | __attribute__ ((__format__ (__printf__, 3, 0))); | ||
159 | # endif | ||
160 | #elif defined GNULIB_POSIXCHECK | ||
161 | # undef vsnprintf | ||
162 | # define vsnprintf(b,s,f,a) \ | ||
163 | (GL_LINK_WARNING ("vsnprintf is unportable - " \ | ||
164 | "use gnulib module vsnprintf for portability"), \ | ||
165 | vsnprintf (b, s, f, a)) | ||
166 | #endif | ||
167 | |||
168 | #if @GNULIB_SPRINTF_POSIX@ | ||
169 | # if @REPLACE_SPRINTF@ | ||
170 | # define sprintf rpl_sprintf | ||
171 | extern int sprintf (char *str, const char *format, ...) | ||
172 | __attribute__ ((__format__ (__printf__, 2, 3))); | ||
173 | # endif | ||
174 | #elif defined GNULIB_POSIXCHECK | ||
175 | # undef sprintf | ||
176 | # define sprintf \ | ||
177 | (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \ | ||
178 | "use gnulib module sprintf-posix for portable " \ | ||
179 | "POSIX compliance"), \ | ||
180 | sprintf) | ||
181 | #endif | ||
182 | |||
183 | #if @GNULIB_VSPRINTF_POSIX@ | ||
184 | # if @REPLACE_VSPRINTF@ | ||
185 | # define vsprintf rpl_vsprintf | ||
186 | extern int vsprintf (char *str, const char *format, va_list args) | ||
187 | __attribute__ ((__format__ (__printf__, 2, 0))); | ||
188 | # endif | ||
189 | #elif defined GNULIB_POSIXCHECK | ||
190 | # undef vsprintf | ||
191 | # define vsprintf(b,f,a) \ | ||
192 | (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \ | ||
193 | "use gnulib module vsprintf-posix for portable " \ | ||
194 | "POSIX compliance"), \ | ||
195 | vsprintf (b, f, a)) | ||
196 | #endif | ||
197 | |||
198 | #if @GNULIB_VASPRINTF@ | ||
199 | # if @REPLACE_VASPRINTF@ | ||
200 | # define asprintf rpl_asprintf | ||
201 | # define vasprintf rpl_vasprintf | ||
202 | # endif | ||
203 | # if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@ | ||
204 | /* Write formatted output to a string dynamically allocated with malloc(). | ||
205 | If the memory allocation succeeds, store the address of the string in | ||
206 | *RESULT and return the number of resulting bytes, excluding the trailing | ||
207 | NUL. Upon memory allocation error, or some other error, return -1. */ | ||
208 | extern int asprintf (char **result, const char *format, ...) | ||
209 | __attribute__ ((__format__ (__printf__, 2, 3))); | ||
210 | extern int vasprintf (char **result, const char *format, va_list args) | ||
211 | __attribute__ ((__format__ (__printf__, 2, 0))); | ||
212 | # endif | ||
213 | #endif | ||
214 | |||
215 | #if @GNULIB_FOPEN@ | ||
216 | # if @REPLACE_FOPEN@ | ||
217 | # define fopen rpl_fopen | ||
218 | extern FILE * fopen (const char *filename, const char *mode); | ||
219 | # endif | ||
220 | #elif defined GNULIB_POSIXCHECK | ||
221 | # undef fopen | ||
222 | # define fopen(f,m) \ | ||
223 | (GL_LINK_WARNING ("fopen on Win32 platforms is not POSIX compatible - " \ | ||
224 | "use gnulib module fopen for portability"), \ | ||
225 | fopen (f, m)) | ||
226 | #endif | ||
227 | |||
228 | #if @GNULIB_FREOPEN@ | ||
229 | # if @REPLACE_FREOPEN@ | ||
230 | # define freopen rpl_freopen | ||
231 | extern FILE * freopen (const char *filename, const char *mode, FILE *stream); | ||
232 | # endif | ||
233 | #elif defined GNULIB_POSIXCHECK | ||
234 | # undef freopen | ||
235 | # define freopen(f,m,s) \ | ||
236 | (GL_LINK_WARNING ("freopen on Win32 platforms is not POSIX compatible - " \ | ||
237 | "use gnulib module freopen for portability"), \ | ||
238 | freopen (f, m, s)) | ||
239 | #endif | ||
240 | |||
241 | #if @GNULIB_FSEEKO@ | ||
242 | # if @REPLACE_FSEEKO@ | ||
243 | /* Provide fseek, fseeko functions that are aware of a preceding | ||
244 | fflush(), and which detect pipes. */ | ||
245 | # define fseeko rpl_fseeko | ||
246 | extern int fseeko (FILE *fp, off_t offset, int whence); | ||
247 | # define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence) | ||
248 | # endif | ||
249 | #elif defined GNULIB_POSIXCHECK | ||
250 | # undef fseeko | ||
251 | # define fseeko(f,o,w) \ | ||
252 | (GL_LINK_WARNING ("fseeko is unportable - " \ | ||
253 | "use gnulib module fseeko for portability"), \ | ||
254 | fseeko (f, o, w)) | ||
255 | #endif | ||
256 | |||
257 | #if @GNULIB_FSEEK@ && @REPLACE_FSEEK@ | ||
258 | extern int rpl_fseek (FILE *fp, long offset, int whence); | ||
259 | # undef fseek | ||
260 | # if defined GNULIB_POSIXCHECK | ||
261 | # define fseek(f,o,w) \ | ||
262 | (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \ | ||
263 | "on 32-bit platforms - " \ | ||
264 | "use fseeko function for handling of large files"), \ | ||
265 | rpl_fseek (f, o, w)) | ||
266 | # else | ||
267 | # define fseek rpl_fseek | ||
268 | # endif | ||
269 | #elif defined GNULIB_POSIXCHECK | ||
270 | # ifndef fseek | ||
271 | # define fseek(f,o,w) \ | ||
272 | (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \ | ||
273 | "on 32-bit platforms - " \ | ||
274 | "use fseeko function for handling of large files"), \ | ||
275 | fseek (f, o, w)) | ||
276 | # endif | ||
277 | #endif | ||
278 | |||
279 | #if @GNULIB_FTELLO@ | ||
280 | # if @REPLACE_FTELLO@ | ||
281 | # define ftello rpl_ftello | ||
282 | extern off_t ftello (FILE *fp); | ||
283 | # define ftell(fp) ftello (fp) | ||
284 | # endif | ||
285 | #elif defined GNULIB_POSIXCHECK | ||
286 | # undef ftello | ||
287 | # define ftello(f) \ | ||
288 | (GL_LINK_WARNING ("ftello is unportable - " \ | ||
289 | "use gnulib module ftello for portability"), \ | ||
290 | ftello (f)) | ||
291 | #endif | ||
292 | |||
293 | #if @GNULIB_FTELL@ && @REPLACE_FTELL@ | ||
294 | extern long rpl_ftell (FILE *fp); | ||
295 | # undef ftell | ||
296 | # if GNULIB_POSIXCHECK | ||
297 | # define ftell(f) \ | ||
298 | (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \ | ||
299 | "on 32-bit platforms - " \ | ||
300 | "use ftello function for handling of large files"), \ | ||
301 | rpl_ftell (f)) | ||
302 | # else | ||
303 | # define ftell rpl_ftell | ||
304 | # endif | ||
305 | #elif defined GNULIB_POSIXCHECK | ||
306 | # ifndef ftell | ||
307 | # define ftell(f) \ | ||
308 | (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \ | ||
309 | "on 32-bit platforms - " \ | ||
310 | "use ftello function for handling of large files"), \ | ||
311 | ftell (f)) | ||
312 | # endif | ||
313 | #endif | ||
314 | |||
315 | #if @GNULIB_FFLUSH@ | ||
316 | # if @REPLACE_FFLUSH@ | ||
317 | # define fflush rpl_fflush | ||
318 | /* Flush all pending data on STREAM according to POSIX rules. Both | ||
319 | output and seekable input streams are supported. | ||
320 | Note! LOSS OF DATA can occur if fflush is applied on an input stream | ||
321 | that is _not_seekable_ or on an update stream that is _not_seekable_ | ||
322 | and in which the most recent operation was input. Seekability can | ||
323 | be tested with lseek(fileno(fp),0,SEEK_CUR). */ | ||
324 | extern int fflush (FILE *gl_stream); | ||
325 | # endif | ||
326 | #elif defined GNULIB_POSIXCHECK | ||
327 | # undef fflush | ||
328 | # define fflush(f) \ | ||
329 | (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \ | ||
330 | "use gnulib module fflush for portable " \ | ||
331 | "POSIX compliance"), \ | ||
332 | fflush (f)) | ||
333 | #endif | ||
334 | |||
335 | #if @GNULIB_GETDELIM@ | ||
336 | # if !@HAVE_DECL_GETDELIM@ | ||
337 | /* Read input, up to (and including) the next occurrence of DELIMITER, from | ||
338 | STREAM, store it in *LINEPTR (and NUL-terminate it). | ||
339 | *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE | ||
340 | bytes of space. It is realloc'd as necessary. | ||
341 | Return the number of bytes read and stored at *LINEPTR (not including the | ||
342 | NUL terminator), or -1 on error or EOF. */ | ||
343 | extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter, | ||
344 | FILE *stream); | ||
345 | # endif | ||
346 | #elif defined GNULIB_POSIXCHECK | ||
347 | # undef getdelim | ||
348 | # define getdelim(l, s, d, f) \ | ||
349 | (GL_LINK_WARNING ("getdelim is unportable - " \ | ||
350 | "use gnulib module getdelim for portability"), \ | ||
351 | getdelim (l, s, d, f)) | ||
352 | #endif | ||
353 | |||
354 | #if @GNULIB_GETLINE@ | ||
355 | # if @REPLACE_GETLINE@ | ||
356 | # undef getline | ||
357 | # define getline rpl_getline | ||
358 | # endif | ||
359 | # if !@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@ | ||
360 | /* Read a line, up to (and including) the next newline, from STREAM, store it | ||
361 | in *LINEPTR (and NUL-terminate it). | ||
362 | *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE | ||
363 | bytes of space. It is realloc'd as necessary. | ||
364 | Return the number of bytes read and stored at *LINEPTR (not including the | ||
365 | NUL terminator), or -1 on error or EOF. */ | ||
366 | extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream); | ||
367 | # endif | ||
368 | #elif defined GNULIB_POSIXCHECK | ||
369 | # undef getline | ||
370 | # define getline(l, s, f) \ | ||
371 | (GL_LINK_WARNING ("getline is unportable - " \ | ||
372 | "use gnulib module getline for portability"), \ | ||
373 | getline (l, s, f)) | ||
374 | #endif | ||
375 | |||
376 | #ifdef __cplusplus | ||
377 | } | ||
378 | #endif | ||
379 | |||
380 | #endif /* _GL_STDIO_H */ | ||
381 | #endif /* _GL_STDIO_H */ | ||
382 | #endif | ||