1 /* A GNU-like <stdio.h>.
3 Copyright (C) 2004, 2007 Free Software Foundation, Inc.
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)
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.
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. */
19 #if defined __need_FILE || defined __need___FILE
20 /* Special invocation convention inside glibc header files. */
22 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
25 /* Normal invocation convention. */
29 /* The include_next requires a split double-inclusion guard. */
30 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
38 #if (@GNULIB_FSEEKO@ && @REPLACE_FSEEKO@) || (@GNULIB_FTELLO@ && @REPLACE_FTELLO@)
40 # include <sys/types.h>
44 /* This feature is available in gcc versions 2.5 and later. */
45 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
46 # define __attribute__(Spec) /* empty */
48 /* The __-protected variants of `format' and `printf' attributes
49 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
50 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
51 # define __format__ format
52 # define __printf__ printf
57 /* The definition of GL_LINK_WARNING is copied here. */
65 #if @GNULIB_FPRINTF_POSIX@
66 # if @REPLACE_FPRINTF@
67 # define fprintf rpl_fprintf
68 extern int fprintf (FILE *fp, const char *format, ...)
69 __attribute__ ((__format__ (__printf__, 2, 3)));
71 #elif defined GNULIB_POSIXCHECK
74 (GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \
75 "use gnulib module fprintf-posix for portable " \
76 "POSIX compliance"), \
80 #if @GNULIB_VFPRINTF_POSIX@
81 # if @REPLACE_VFPRINTF@
82 # define vfprintf rpl_vfprintf
83 extern int vfprintf (FILE *fp, const char *format, va_list args)
84 __attribute__ ((__format__ (__printf__, 2, 0)));
86 #elif defined GNULIB_POSIXCHECK
88 # define vfprintf(s,f,a) \
89 (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \
90 "use gnulib module vfprintf-posix for portable " \
91 "POSIX compliance"), \
95 #if @GNULIB_PRINTF_POSIX@
97 /* Don't break __attribute__((format(printf,M,N))). */
98 # define printf __printf__
99 extern int printf (const char *format, ...)
100 __attribute__ ((__format__ (__printf__, 1, 2)));
102 #elif defined GNULIB_POSIXCHECK
105 (GL_LINK_WARNING ("printf is not always POSIX compliant - " \
106 "use gnulib module printf-posix for portable " \
107 "POSIX compliance"), \
109 /* Don't break __attribute__((format(printf,M,N))). */
110 # define format(kind,m,n) format (__##kind##__, m, n)
111 # define __format__(kind,m,n) __format__ (__##kind##__, m, n)
112 # define ____printf____ __printf__
113 # define ____scanf____ __scanf__
114 # define ____strftime____ __strftime__
115 # define ____strfmon____ __strfmon__
118 #if @GNULIB_VPRINTF_POSIX@
119 # if @REPLACE_VPRINTF@
120 # define vprintf rpl_vprintf
121 extern int vprintf (const char *format, va_list args)
122 __attribute__ ((__format__ (__printf__, 1, 0)));
124 #elif defined GNULIB_POSIXCHECK
126 # define vprintf(f,a) \
127 (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \
128 "use gnulib module vprintf-posix for portable " \
129 "POSIX compliance"), \
133 #if @GNULIB_SNPRINTF@
134 # if @REPLACE_SNPRINTF@
135 # define snprintf rpl_snprintf
137 # if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
138 extern int snprintf (char *str, size_t size, const char *format, ...)
139 __attribute__ ((__format__ (__printf__, 3, 4)));
141 #elif defined GNULIB_POSIXCHECK
144 (GL_LINK_WARNING ("snprintf is unportable - " \
145 "use gnulib module snprintf for portability"), \
149 #if @GNULIB_VSNPRINTF@
150 # if @REPLACE_VSNPRINTF@
151 # define vsnprintf rpl_vsnprintf
153 # if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
154 extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
155 __attribute__ ((__format__ (__printf__, 3, 0)));
157 #elif defined GNULIB_POSIXCHECK
159 # define vsnprintf(b,s,f,a) \
160 (GL_LINK_WARNING ("vsnprintf is unportable - " \
161 "use gnulib module vsnprintf for portability"), \
162 vsnprintf (b, s, f, a))
165 #if @GNULIB_SPRINTF_POSIX@
166 # if @REPLACE_SPRINTF@
167 # define sprintf rpl_sprintf
168 extern int sprintf (char *str, const char *format, ...)
169 __attribute__ ((__format__ (__printf__, 2, 3)));
171 #elif defined GNULIB_POSIXCHECK
174 (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \
175 "use gnulib module sprintf-posix for portable " \
176 "POSIX compliance"), \
180 #if @GNULIB_VSPRINTF_POSIX@
181 # if @REPLACE_VSPRINTF@
182 # define vsprintf rpl_vsprintf
183 extern int vsprintf (char *str, const char *format, va_list args)
184 __attribute__ ((__format__ (__printf__, 2, 0)));
186 #elif defined GNULIB_POSIXCHECK
188 # define vsprintf(b,f,a) \
189 (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \
190 "use gnulib module vsprintf-posix for portable " \
191 "POSIX compliance"), \
195 #if @GNULIB_VASPRINTF@
196 # if @REPLACE_VASPRINTF@
197 # define asprintf rpl_asprintf
198 # define vasprintf rpl_vasprintf
200 # if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@
201 /* Write formatted output to a string dynamically allocated with malloc().
202 If the memory allocation succeeds, store the address of the string in
203 *RESULT and return the number of resulting bytes, excluding the trailing
204 NUL. Upon memory allocation error, or some other error, return -1. */
205 extern int asprintf (char **result, const char *format, ...)
206 __attribute__ ((__format__ (__printf__, 2, 3)));
207 extern int vasprintf (char **result, const char *format, va_list args)
208 __attribute__ ((__format__ (__printf__, 2, 0)));
213 # if @REPLACE_FSEEKO@
214 /* Provide fseek, fseeko functions that are aware of a preceding
215 fflush(), and which detect pipes. */
216 # define fseeko rpl_fseeko
217 extern int fseeko (FILE *fp, off_t offset, int whence);
218 # define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence)
220 #elif defined GNULIB_POSIXCHECK
222 # define fseeko(f,o,w) \
223 (GL_LINK_WARNING ("fseeko is unportable - " \
224 "use gnulib module fseeko for portability"), \
228 #if @GNULIB_FSEEK@ && @REPLACE_FSEEK@
229 extern int rpl_fseek (FILE *fp, long offset, int whence);
231 # if defined GNULIB_POSIXCHECK
232 # define fseek(f,o,w) \
233 (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
234 "on 32-bit platforms - " \
235 "use fseeko function for handling of large files"), \
238 # define fseek rpl_fseek
240 #elif defined GNULIB_POSIXCHECK
242 # define fseek(f,o,w) \
243 (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
244 "on 32-bit platforms - " \
245 "use fseeko function for handling of large files"), \
251 # if @REPLACE_FTELLO@
252 # define ftello rpl_ftello
253 extern off_t ftello (FILE *fp);
254 # define ftell(fp) ftello (fp)
256 #elif defined GNULIB_POSIXCHECK
259 (GL_LINK_WARNING ("ftello is unportable - " \
260 "use gnulib module ftello for portability"), \
264 #if @GNULIB_FTELL@ && @REPLACE_FTELL@
265 extern long rpl_ftell (FILE *fp);
267 # if GNULIB_POSIXCHECK
269 (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
270 "on 32-bit platforms - " \
271 "use ftello function for handling of large files"), \
274 # define ftell rpl_ftell
276 #elif defined GNULIB_POSIXCHECK
279 (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
280 "on 32-bit platforms - " \
281 "use ftello function for handling of large files"), \
287 # if @REPLACE_FFLUSH@
288 # define fflush rpl_fflush
289 /* Flush all pending data on STREAM according to POSIX rules. Both
290 output and seekable input streams are supported.
291 Note! LOSS OF DATA can occur if fflush is applied on an input stream
292 that is _not_seekable_ or on an update stream that is _not_seekable_
293 and in which the most recent operation was input. Seekability can
294 be tested with lseek(fileno(fp),0,SEEK_CUR). */
295 extern int fflush (FILE *gl_stream);
297 #elif defined GNULIB_POSIXCHECK
300 (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \
301 "use gnulib module fflush for portable " \
302 "POSIX compliance"), \
310 #endif /* _GL_STDIO_H */
311 #endif /* _GL_STDIO_H */