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 #if @HAVE_INCLUDE_NEXT@
23 # include_next <stdio.h>
25 # include @ABSOLUTE_STDIO_H@
29 /* Normal invocation convention. */
33 /* The include_next requires a split double-inclusion guard. */
34 #if @HAVE_INCLUDE_NEXT@
35 # include_next <stdio.h>
37 # include @ABSOLUTE_STDIO_H@
46 #if (@GNULIB_FSEEKO@ && @REPLACE_FSEEKO@) || (@GNULIB_FTELLO@ && @REPLACE_FTELLO@)
48 # include <sys/types.h>
52 /* This feature is available in gcc versions 2.5 and later. */
53 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
54 # define __attribute__(Spec) /* empty */
56 /* The __-protected variants of `format' and `printf' attributes
57 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
58 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
59 # define __format__ format
60 # define __printf__ printf
65 /* The definition of GL_LINK_WARNING is copied here. */
73 #if @GNULIB_FPRINTF_POSIX@
74 # if @REPLACE_FPRINTF@
75 # define fprintf rpl_fprintf
76 extern int fprintf (FILE *fp
, const char *format
, ...)
77 __attribute__ ((__format__ (__printf__
, 2, 3)));
79 #elif defined GNULIB_POSIXCHECK
82 (GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \
83 "use gnulib module fprintf-posix for portable " \
84 "POSIX compliance"), \
88 #if @GNULIB_VFPRINTF_POSIX@
89 # if @REPLACE_VFPRINTF@
90 # define vfprintf rpl_vfprintf
91 extern int vfprintf (FILE *fp
, const char *format
, va_list args
)
92 __attribute__ ((__format__ (__printf__
, 2, 0)));
94 #elif defined GNULIB_POSIXCHECK
96 # define vfprintf(s,f,a) \
97 (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \
98 "use gnulib module vfprintf-posix for portable " \
99 "POSIX compliance"), \
103 #if @GNULIB_PRINTF_POSIX@
104 # if @REPLACE_PRINTF@
105 /* Don't break __attribute__((format(printf,M,N))). */
106 # define printf __printf__
107 extern int printf (const char *format
, ...)
108 __attribute__ ((__format__ (__printf__
, 1, 2)));
110 #elif defined GNULIB_POSIXCHECK
113 (GL_LINK_WARNING ("printf is not always POSIX compliant - " \
114 "use gnulib module printf-posix for portable " \
115 "POSIX compliance"), \
117 /* Don't break __attribute__((format(printf,M,N))). */
118 # define format(kind,m,n) format (__##kind##__, m, n)
119 # define __format__(kind,m,n) __format__ (__##kind##__, m, n)
120 # define ____printf____ __printf__
121 # define ____scanf____ __scanf__
122 # define ____strftime____ __strftime__
123 # define ____strfmon____ __strfmon__
126 #if @GNULIB_VPRINTF_POSIX@
127 # if @REPLACE_VPRINTF@
128 # define vprintf rpl_vprintf
129 extern int vprintf (const char *format
, va_list args
)
130 __attribute__ ((__format__ (__printf__
, 1, 0)));
132 #elif defined GNULIB_POSIXCHECK
134 # define vprintf(f,a) \
135 (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \
136 "use gnulib module vprintf-posix for portable " \
137 "POSIX compliance"), \
141 #if @GNULIB_SNPRINTF@
142 # if @REPLACE_SNPRINTF@
143 # define snprintf rpl_snprintf
145 # if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
146 extern int snprintf (char *str
, size_t size
, const char *format
, ...)
147 __attribute__ ((__format__ (__printf__
, 3, 4)));
149 #elif defined GNULIB_POSIXCHECK
152 (GL_LINK_WARNING ("snprintf is unportable - " \
153 "use gnulib module snprintf for portability"), \
157 #if @GNULIB_VSNPRINTF@
158 # if @REPLACE_VSNPRINTF@
159 # define vsnprintf rpl_vsnprintf
161 # if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
162 extern int vsnprintf (char *str
, size_t size
, const char *format
, va_list args
)
163 __attribute__ ((__format__ (__printf__
, 3, 0)));
165 #elif defined GNULIB_POSIXCHECK
167 # define vsnprintf(b,s,f,a) \
168 (GL_LINK_WARNING ("vsnprintf is unportable - " \
169 "use gnulib module vsnprintf for portability"), \
170 vsnprintf (b, s, f, a))
173 #if @GNULIB_SPRINTF_POSIX@
174 # if @REPLACE_SPRINTF@
175 # define sprintf rpl_sprintf
176 extern int sprintf (char *str
, const char *format
, ...)
177 __attribute__ ((__format__ (__printf__
, 2, 3)));
179 #elif defined GNULIB_POSIXCHECK
182 (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \
183 "use gnulib module sprintf-posix for portable " \
184 "POSIX compliance"), \
188 #if @GNULIB_VSPRINTF_POSIX@
189 # if @REPLACE_VSPRINTF@
190 # define vsprintf rpl_vsprintf
191 extern int vsprintf (char *str
, const char *format
, va_list args
)
192 __attribute__ ((__format__ (__printf__
, 2, 0)));
194 #elif defined GNULIB_POSIXCHECK
196 # define vsprintf(b,f,a) \
197 (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \
198 "use gnulib module vsprintf-posix for portable " \
199 "POSIX compliance"), \
203 #if @GNULIB_VASPRINTF@
204 # if @REPLACE_VASPRINTF@
205 # define asprintf rpl_asprintf
206 # define vasprintf rpl_vasprintf
208 # if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@
209 /* Write formatted output to a string dynamically allocated with malloc().
210 If the memory allocation succeeds, store the address of the string in
211 *RESULT and return the number of resulting bytes, excluding the trailing
212 NUL. Upon memory allocation error, or some other error, return -1. */
213 extern int asprintf (char **result
, const char *format
, ...)
214 __attribute__ ((__format__ (__printf__
, 2, 3)));
215 extern int vasprintf (char **result
, const char *format
, va_list args
)
216 __attribute__ ((__format__ (__printf__
, 2, 0)));
221 # if @REPLACE_FSEEKO@
222 /* Provide fseek, fseeko functions that are aware of a preceding
223 fflush(), and which detect pipes. */
224 # define fseeko rpl_fseeko
225 extern int fseeko (FILE *fp
, off_t offset
, int whence
);
226 # define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence)
228 #elif defined GNULIB_POSIXCHECK
230 # define fseeko(f,o,w) \
231 (GL_LINK_WARNING ("fseeko is unportable - " \
232 "use gnulib module fseeko for portability"), \
236 #if @GNULIB_FSEEK@ && @REPLACE_FSEEK@
237 extern int rpl_fseek (FILE *fp
, long offset
, int whence
);
239 # if defined GNULIB_POSIXCHECK
240 # define fseek(f,o,w) \
241 (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
242 "on 32-bit platforms - " \
243 "use fseeko function for handling of large files"), \
246 # define fseek rpl_fseek
248 #elif defined GNULIB_POSIXCHECK
250 # define fseek(f,o,w) \
251 (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
252 "on 32-bit platforms - " \
253 "use fseeko function for handling of large files"), \
259 # if @REPLACE_FTELLO@
260 # define ftello rpl_ftello
261 extern off_t
ftello (FILE *fp
);
262 # define ftell(fp) ftello (fp)
264 #elif defined GNULIB_POSIXCHECK
267 (GL_LINK_WARNING ("ftello is unportable - " \
268 "use gnulib module ftello for portability"), \
272 #if @GNULIB_FTELL@ && @REPLACE_FTELL@
273 extern long rpl_ftell (FILE *fp
);
275 # if GNULIB_POSIXCHECK
277 (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
278 "on 32-bit platforms - " \
279 "use ftello function for handling of large files"), \
282 # define ftell rpl_ftell
284 #elif defined GNULIB_POSIXCHECK
287 (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
288 "on 32-bit platforms - " \
289 "use ftello function for handling of large files"), \
295 # if @REPLACE_FFLUSH@
296 # define fflush rpl_fflush
297 /* Flush all pending data on STREAM according to POSIX rules. Both
298 output and seekable input streams are supported.
299 Note! LOSS OF DATA can occur if fflush is applied on an input stream
300 that is _not_seekable_ or on an update stream that is _not_seekable_
301 and in which the most recent operation was input. Seekability can
302 be tested with lseek(fileno(fp),0,SEEK_CUR). */
303 extern int fflush (FILE *gl_stream
);
305 #elif defined GNULIB_POSIXCHECK
308 (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \
309 "use gnulib module fflush for portable " \
310 "POSIX compliance"), \
318 #endif /* _GL_STDIO_H */
319 #endif /* _GL_STDIO_H */