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. */
31 #if @HAVE_INCLUDE_NEXT@
32 # include_next <stdio.h>
38 #if ! @HAVE_INCLUDE_NEXT@
39 # include @ABSOLUTE_STDIO_H@
45 #if (@GNULIB_FSEEKO@ && @REPLACE_FSEEKO@) || (@GNULIB_FTELLO@ && @REPLACE_FTELLO@)
47 # include <sys/types.h>
51 /* This feature is available in gcc versions 2.5 and later. */
52 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
53 # define __attribute__(Spec) /* empty */
55 /* The __-protected variants of `format' and `printf' attributes
56 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
57 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
58 # define __format__ format
59 # define __printf__ printf
64 /* The definition of GL_LINK_WARNING is copied here. */
72 #if @GNULIB_FPRINTF_POSIX@
73 # if @REPLACE_FPRINTF@
74 # define fprintf rpl_fprintf
75 extern int fprintf (FILE *fp, const char *format, ...)
76 __attribute__ ((__format__ (__printf__, 2, 3)));
78 #elif defined GNULIB_POSIXCHECK
81 (GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \
82 "use gnulib module fprintf-posix for portable " \
83 "POSIX compliance"), \
87 #if @GNULIB_VFPRINTF_POSIX@
88 # if @REPLACE_VFPRINTF@
89 # define vfprintf rpl_vfprintf
90 extern int vfprintf (FILE *fp, const char *format, va_list args)
91 __attribute__ ((__format__ (__printf__, 2, 0)));
93 #elif defined GNULIB_POSIXCHECK
95 # define vfprintf(s,f,a) \
96 (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \
97 "use gnulib module vfprintf-posix for portable " \
98 "POSIX compliance"), \
102 #if @GNULIB_PRINTF_POSIX@
103 # if @REPLACE_PRINTF@
104 /* Don't break __attribute__((format(printf,M,N))). */
105 # define printf __printf__
106 extern int printf (const char *format, ...)
107 __attribute__ ((__format__ (__printf__, 1, 2)));
109 #elif defined GNULIB_POSIXCHECK
112 (GL_LINK_WARNING ("printf is not always POSIX compliant - " \
113 "use gnulib module printf-posix for portable " \
114 "POSIX compliance"), \
116 /* Don't break __attribute__((format(printf,M,N))). */
117 # define format(kind,m,n) format (__##kind##__, m, n)
118 # define __format__(kind,m,n) __format__ (__##kind##__, m, n)
119 # define ____printf____ __printf__
120 # define ____scanf____ __scanf__
121 # define ____strftime____ __strftime__
122 # define ____strfmon____ __strfmon__
125 #if @GNULIB_VPRINTF_POSIX@
126 # if @REPLACE_VPRINTF@
127 # define vprintf rpl_vprintf
128 extern int vprintf (const char *format, va_list args)
129 __attribute__ ((__format__ (__printf__, 1, 0)));
131 #elif defined GNULIB_POSIXCHECK
133 # define vprintf(f,a) \
134 (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \
135 "use gnulib module vprintf-posix for portable " \
136 "POSIX compliance"), \
140 #if @GNULIB_SNPRINTF@
141 # if @REPLACE_SNPRINTF@
142 # define snprintf rpl_snprintf
144 # if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
145 extern int snprintf (char *str, size_t size, const char *format, ...)
146 __attribute__ ((__format__ (__printf__, 3, 4)));
148 #elif defined GNULIB_POSIXCHECK
151 (GL_LINK_WARNING ("snprintf is unportable - " \
152 "use gnulib module snprintf for portability"), \
156 #if @GNULIB_VSNPRINTF@
157 # if @REPLACE_VSNPRINTF@
158 # define vsnprintf rpl_vsnprintf
160 # if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
161 extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
162 __attribute__ ((__format__ (__printf__, 3, 0)));
164 #elif defined GNULIB_POSIXCHECK
166 # define vsnprintf(b,s,f,a) \
167 (GL_LINK_WARNING ("vsnprintf is unportable - " \
168 "use gnulib module vsnprintf for portability"), \
169 vsnprintf (b, s, f, a))
172 #if @GNULIB_SPRINTF_POSIX@
173 # if @REPLACE_SPRINTF@
174 # define sprintf rpl_sprintf
175 extern int sprintf (char *str, const char *format, ...)
176 __attribute__ ((__format__ (__printf__, 2, 3)));
178 #elif defined GNULIB_POSIXCHECK
181 (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \
182 "use gnulib module sprintf-posix for portable " \
183 "POSIX compliance"), \
187 #if @GNULIB_VSPRINTF_POSIX@
188 # if @REPLACE_VSPRINTF@
189 # define vsprintf rpl_vsprintf
190 extern int vsprintf (char *str, const char *format, va_list args)
191 __attribute__ ((__format__ (__printf__, 2, 0)));
193 #elif defined GNULIB_POSIXCHECK
195 # define vsprintf(b,f,a) \
196 (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \
197 "use gnulib module vsprintf-posix for portable " \
198 "POSIX compliance"), \
202 #if @GNULIB_VASPRINTF@
203 # if @REPLACE_VASPRINTF@
204 # define asprintf rpl_asprintf
205 # define vasprintf rpl_vasprintf
207 # if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@
208 /* Write formatted output to a string dynamically allocated with malloc().
209 If the memory allocation succeeds, store the address of the string in
210 *RESULT and return the number of resulting bytes, excluding the trailing
211 NUL. Upon memory allocation error, or some other error, return -1. */
212 extern int asprintf (char **result, const char *format, ...)
213 __attribute__ ((__format__ (__printf__, 2, 3)));
214 extern int vasprintf (char **result, const char *format, va_list args)
215 __attribute__ ((__format__ (__printf__, 2, 0)));
220 # if @REPLACE_FSEEKO@
221 /* Provide fseek, fseeko functions that are aware of a preceding
222 fflush(), and which detect pipes. */
223 # define fseeko rpl_fseeko
224 extern int fseeko (FILE *fp, off_t offset, int whence);
225 # define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence)
227 #elif defined GNULIB_POSIXCHECK
229 # define fseeko(f,o,w) \
230 (GL_LINK_WARNING ("fseeko is unportable - " \
231 "use gnulib module fseeko for portability"), \
235 #if @GNULIB_FSEEK@ && @REPLACE_FSEEK@
236 extern int rpl_fseek (FILE *fp, long offset, int whence);
238 # if defined GNULIB_POSIXCHECK
239 # define fseek(f,o,w) \
240 (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
241 "on 32-bit platforms - " \
242 "use fseeko function for handling of large files"), \
245 # define fseek rpl_fseek
247 #elif defined GNULIB_POSIXCHECK
249 # define fseek(f,o,w) \
250 (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
251 "on 32-bit platforms - " \
252 "use fseeko function for handling of large files"), \
258 # if @REPLACE_FTELLO@
259 # define ftello rpl_ftello
260 extern off_t ftello (FILE *fp);
261 # define ftell(fp) ftello (fp)
263 #elif defined GNULIB_POSIXCHECK
266 (GL_LINK_WARNING ("ftello is unportable - " \
267 "use gnulib module ftello for portability"), \
271 #if @GNULIB_FTELL@ && @REPLACE_FTELL@
272 extern long rpl_ftell (FILE *fp);
274 # if GNULIB_POSIXCHECK
276 (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
277 "on 32-bit platforms - " \
278 "use ftello function for handling of large files"), \
281 # define ftell rpl_ftell
283 #elif defined GNULIB_POSIXCHECK
286 (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
287 "on 32-bit platforms - " \
288 "use ftello function for handling of large files"), \
294 # if @REPLACE_FFLUSH@
295 # define fflush rpl_fflush
296 /* Flush all pending data on STREAM according to POSIX rules. Both
297 output and seekable input streams are supported.
298 Note! LOSS OF DATA can occur if fflush is applied on an input stream
299 that is _not_seekable_ or on an update stream that is _not_seekable_
300 and in which the most recent operation was input. Seekability can
301 be tested with lseek(fileno(fp),0,SEEK_CUR). */
302 extern int fflush (FILE *gl_stream);
304 #elif defined GNULIB_POSIXCHECK
307 (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \
308 "use gnulib module fflush for portable " \
309 "POSIX compliance"), \
317 #endif /* _GL_STDIO_H */