Commit | Line | Data |
---|---|---|
c4b681fd LC |
1 | /* A GNU-like <stdio.h>. |
2 | ||
61cd9dc9 | 3 | Copyright (C) 2004, 2007-2010 Free Software Foundation, Inc. |
c4b681fd LC |
4 | |
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU Lesser 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 Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser 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 __GNUC__ >= 3 | |
20 | @PRAGMA_SYSTEM_HEADER@ | |
21 | #endif | |
0f00f2c3 | 22 | @PRAGMA_COLUMNS@ |
c4b681fd LC |
23 | |
24 | #if defined __need_FILE || defined __need___FILE | |
25 | /* Special invocation convention inside glibc header files. */ | |
26 | ||
27 | #@INCLUDE_NEXT@ @NEXT_STDIO_H@ | |
28 | ||
29 | #else | |
30 | /* Normal invocation convention. */ | |
31 | ||
32 | #ifndef _GL_STDIO_H | |
33 | ||
34 | /* The include_next requires a split double-inclusion guard. */ | |
35 | #@INCLUDE_NEXT@ @NEXT_STDIO_H@ | |
36 | ||
37 | #ifndef _GL_STDIO_H | |
38 | #define _GL_STDIO_H | |
39 | ||
61cd9dc9 | 40 | /* Get va_list. Needed on many systems, including glibc 2.8. */ |
c4b681fd | 41 | #include <stdarg.h> |
61cd9dc9 | 42 | |
c4b681fd LC |
43 | #include <stddef.h> |
44 | ||
61cd9dc9 LC |
45 | /* Get off_t and ssize_t. Needed on many systems, including glibc 2.8. */ |
46 | #include <sys/types.h> | |
c4b681fd LC |
47 | |
48 | #ifndef __attribute__ | |
61cd9dc9 LC |
49 | /* The __attribute__ feature is available in gcc versions 2.5 and later. |
50 | The __-protected variants of the attributes 'format' and 'printf' are | |
51 | accepted by gcc versions 2.6.4 (effectively 2.7) and later. | |
52 | We enable __attribute__ only if these are supported too, because | |
53 | gnulib and libintl do '#define printf __printf__' when they override | |
54 | the 'printf' function. */ | |
c4b681fd | 55 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) |
61cd9dc9 | 56 | # define __attribute__(Spec) /* empty */ |
c4b681fd LC |
57 | # endif |
58 | #endif | |
59 | ||
0f00f2c3 LC |
60 | /* Solaris 10 declares renameat in <unistd.h>, not in <stdio.h>. */ |
61 | /* But in any case avoid namespace pollution on glibc systems. */ | |
62 | #if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \ | |
63 | && ! defined __GLIBC__ | |
64 | # include <unistd.h> | |
65 | #endif | |
66 | ||
c4b681fd | 67 | |
f4c79b3c LC |
68 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
69 | ||
1cd4fffc LC |
70 | /* The definition of _GL_ARG_NONNULL is copied here. */ |
71 | ||
61cd9dc9 LC |
72 | /* The definition of _GL_WARN_ON_USE is copied here. */ |
73 | ||
a927b6c1 LC |
74 | /* Macros for stringification. */ |
75 | #define _GL_STDIO_STRINGIZE(token) #token | |
76 | #define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token) | |
77 | ||
c4b681fd | 78 | |
c4b681fd LC |
79 | #if @GNULIB_DPRINTF@ |
80 | # if @REPLACE_DPRINTF@ | |
f4c79b3c LC |
81 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
82 | # define dprintf rpl_dprintf | |
83 | # endif | |
84 | _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...) | |
85 | __attribute__ ((__format__ (__printf__, 2, 3))) | |
86 | _GL_ARG_NONNULL ((2))); | |
87 | _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...)); | |
88 | # else | |
89 | # if !@HAVE_DPRINTF@ | |
90 | _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...) | |
91 | __attribute__ ((__format__ (__printf__, 2, 3))) | |
92 | _GL_ARG_NONNULL ((2))); | |
93 | # endif | |
94 | _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...)); | |
c4b681fd | 95 | # endif |
f4c79b3c | 96 | _GL_CXXALIASWARN (dprintf); |
c4b681fd LC |
97 | #elif defined GNULIB_POSIXCHECK |
98 | # undef dprintf | |
61cd9dc9 LC |
99 | # if HAVE_RAW_DECL_DPRINTF |
100 | _GL_WARN_ON_USE (dprintf, "dprintf is unportable - " | |
101 | "use gnulib module dprintf for portability"); | |
102 | # endif | |
c4b681fd LC |
103 | #endif |
104 | ||
8912421c | 105 | #if @GNULIB_FCLOSE@ |
f4c79b3c | 106 | /* Close STREAM and its underlying file descriptor. */ |
8912421c | 107 | # if @REPLACE_FCLOSE@ |
f4c79b3c LC |
108 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
109 | # define fclose rpl_fclose | |
110 | # endif | |
111 | _GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); | |
112 | _GL_CXXALIAS_RPL (fclose, int, (FILE *stream)); | |
113 | # else | |
114 | _GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); | |
c4b681fd | 115 | # endif |
f4c79b3c | 116 | _GL_CXXALIASWARN (fclose); |
c4b681fd | 117 | #elif defined GNULIB_POSIXCHECK |
8912421c | 118 | # undef fclose |
61cd9dc9 LC |
119 | /* Assume fclose is always declared. */ |
120 | _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - " | |
121 | "use gnulib module fclose for portable POSIX compliance"); | |
c4b681fd LC |
122 | #endif |
123 | ||
8912421c | 124 | #if @GNULIB_FFLUSH@ |
f4c79b3c LC |
125 | /* Flush all pending data on STREAM according to POSIX rules. Both |
126 | output and seekable input streams are supported. | |
127 | Note! LOSS OF DATA can occur if fflush is applied on an input stream | |
128 | that is _not_seekable_ or on an update stream that is _not_seekable_ | |
129 | and in which the most recent operation was input. Seekability can | |
130 | be tested with lseek(fileno(fp),0,SEEK_CUR). */ | |
8912421c | 131 | # if @REPLACE_FFLUSH@ |
f4c79b3c LC |
132 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
133 | # define fflush rpl_fflush | |
134 | # endif | |
135 | _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream)); | |
136 | _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream)); | |
137 | # else | |
138 | _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream)); | |
c4b681fd | 139 | # endif |
f4c79b3c | 140 | _GL_CXXALIASWARN (fflush); |
8912421c LC |
141 | #elif defined GNULIB_POSIXCHECK |
142 | # undef fflush | |
61cd9dc9 LC |
143 | /* Assume fflush is always declared. */ |
144 | _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - " | |
145 | "use gnulib module fflush for portable POSIX compliance"); | |
c4b681fd LC |
146 | #endif |
147 | ||
61cd9dc9 LC |
148 | /* It is very rare that the developer ever has full control of stdin, |
149 | so any use of gets warrants an unconditional warning. Assume it is | |
150 | always declared, since it is required by C89. */ | |
151 | #undef gets | |
152 | _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); | |
153 | ||
c4b681fd LC |
154 | #if @GNULIB_FOPEN@ |
155 | # if @REPLACE_FOPEN@ | |
f4c79b3c LC |
156 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
157 | # undef fopen | |
158 | # define fopen rpl_fopen | |
159 | # endif | |
160 | _GL_FUNCDECL_RPL (fopen, FILE *, (const char *filename, const char *mode) | |
161 | _GL_ARG_NONNULL ((1, 2))); | |
162 | _GL_CXXALIAS_RPL (fopen, FILE *, (const char *filename, const char *mode)); | |
163 | # else | |
164 | _GL_CXXALIAS_SYS (fopen, FILE *, (const char *filename, const char *mode)); | |
c4b681fd | 165 | # endif |
f4c79b3c | 166 | _GL_CXXALIASWARN (fopen); |
c4b681fd LC |
167 | #elif defined GNULIB_POSIXCHECK |
168 | # undef fopen | |
61cd9dc9 LC |
169 | /* Assume fopen is always declared. */ |
170 | _GL_WARN_ON_USE (fopen, "fopen on Win32 platforms is not POSIX compatible - " | |
171 | "use gnulib module fopen for portability"); | |
c4b681fd LC |
172 | #endif |
173 | ||
f4c79b3c LC |
174 | #if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@ |
175 | # if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \ | |
176 | || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) | |
177 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
178 | # define fprintf rpl_fprintf | |
179 | # endif | |
180 | # define GNULIB_overrides_fprintf 1 | |
181 | _GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...) | |
182 | __attribute__ ((__format__ (__printf__, 2, 3))) | |
183 | _GL_ARG_NONNULL ((1, 2))); | |
184 | _GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...)); | |
185 | # else | |
186 | _GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...)); | |
187 | # endif | |
188 | _GL_CXXALIASWARN (fprintf); | |
189 | #endif | |
190 | #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK | |
191 | # if !GNULIB_overrides_fprintf | |
192 | # undef fprintf | |
8912421c | 193 | # endif |
61cd9dc9 LC |
194 | /* Assume fprintf is always declared. */ |
195 | _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - " | |
196 | "use gnulib module fprintf-posix for portable " | |
197 | "POSIX compliance"); | |
8912421c LC |
198 | #endif |
199 | ||
200 | #if @GNULIB_FPURGE@ | |
f4c79b3c LC |
201 | /* Discard all pending buffered I/O data on STREAM. |
202 | STREAM must not be wide-character oriented. | |
203 | When discarding pending output, the file position is set back to where it | |
204 | was before the write calls. When discarding pending input, the file | |
205 | position is advanced to match the end of the previously read input. | |
206 | Return 0 if successful. Upon error, return -1 and set errno. */ | |
8912421c | 207 | # if @REPLACE_FPURGE@ |
f4c79b3c LC |
208 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
209 | # define fpurge rpl_fpurge | |
210 | # endif | |
211 | _GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); | |
212 | _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream)); | |
213 | # else | |
214 | # if !@HAVE_DECL_FPURGE@ | |
215 | _GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); | |
216 | # endif | |
217 | _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream)); | |
8912421c | 218 | # endif |
f4c79b3c | 219 | _GL_CXXALIASWARN (fpurge); |
8912421c LC |
220 | #elif defined GNULIB_POSIXCHECK |
221 | # undef fpurge | |
61cd9dc9 LC |
222 | # if HAVE_RAW_DECL_FPURGE |
223 | _GL_WARN_ON_USE (fpurge, "fpurge is not always present - " | |
224 | "use gnulib module fpurge for portability"); | |
225 | # endif | |
8912421c LC |
226 | #endif |
227 | ||
f4c79b3c LC |
228 | #if @GNULIB_FPUTC@ |
229 | # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | |
230 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
231 | # undef fputc | |
232 | # define fputc rpl_fputc | |
233 | # endif | |
234 | _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); | |
235 | _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream)); | |
236 | # else | |
237 | _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream)); | |
238 | # endif | |
239 | _GL_CXXALIASWARN (fputc); | |
8912421c LC |
240 | #endif |
241 | ||
f4c79b3c LC |
242 | #if @GNULIB_FPUTS@ |
243 | # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | |
244 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
245 | # undef fputs | |
246 | # define fputs rpl_fputs | |
247 | # endif | |
248 | _GL_FUNCDECL_RPL (fputs, int, (const char *string, FILE *stream) | |
249 | _GL_ARG_NONNULL ((1, 2))); | |
250 | _GL_CXXALIAS_RPL (fputs, int, (const char *string, FILE *stream)); | |
251 | # else | |
252 | _GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream)); | |
253 | # endif | |
254 | _GL_CXXALIASWARN (fputs); | |
8912421c LC |
255 | #endif |
256 | ||
c4b681fd LC |
257 | #if @GNULIB_FREOPEN@ |
258 | # if @REPLACE_FREOPEN@ | |
f4c79b3c LC |
259 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
260 | # undef freopen | |
261 | # define freopen rpl_freopen | |
262 | # endif | |
263 | _GL_FUNCDECL_RPL (freopen, FILE *, | |
264 | (const char *filename, const char *mode, FILE *stream) | |
265 | _GL_ARG_NONNULL ((2, 3))); | |
266 | _GL_CXXALIAS_RPL (freopen, FILE *, | |
267 | (const char *filename, const char *mode, FILE *stream)); | |
268 | # else | |
269 | _GL_CXXALIAS_SYS (freopen, FILE *, | |
270 | (const char *filename, const char *mode, FILE *stream)); | |
271 | # endif | |
272 | _GL_CXXALIASWARN (freopen); | |
c4b681fd LC |
273 | #elif defined GNULIB_POSIXCHECK |
274 | # undef freopen | |
61cd9dc9 | 275 | /* Assume freopen is always declared. */ |
0f00f2c3 LC |
276 | _GL_WARN_ON_USE (freopen, |
277 | "freopen on Win32 platforms is not POSIX compatible - " | |
61cd9dc9 LC |
278 | "use gnulib module freopen for portability"); |
279 | #endif | |
280 | ||
f4c79b3c | 281 | |
61cd9dc9 LC |
282 | /* Set up the following warnings, based on which modules are in use. |
283 | GNU Coding Standards discourage the use of fseek, since it imposes | |
284 | an arbitrary limitation on some 32-bit hosts. Remember that the | |
285 | fseek module depends on the fseeko module, so we only have three | |
286 | cases to consider: | |
287 | ||
288 | 1. The developer is not using either module. Issue a warning under | |
289 | GNULIB_POSIXCHECK for both functions, to remind them that both | |
290 | functions have bugs on some systems. _GL_NO_LARGE_FILES has no | |
291 | impact on this warning. | |
292 | ||
293 | 2. The developer is using both modules. They may be unaware of the | |
294 | arbitrary limitations of fseek, so issue a warning under | |
295 | GNULIB_POSIXCHECK. On the other hand, they may be using both | |
296 | modules intentionally, so the developer can define | |
297 | _GL_NO_LARGE_FILES in the compilation units where the use of fseek | |
298 | is safe, to silence the warning. | |
299 | ||
300 | 3. The developer is using the fseeko module, but not fseek. Gnulib | |
301 | guarantees that fseek will still work around platform bugs in that | |
302 | case, but we presume that the developer is aware of the pitfalls of | |
303 | fseek and was trying to avoid it, so issue a warning even when | |
304 | GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be | |
305 | defined to silence the warning in particular compilation units. | |
f4c79b3c LC |
306 | In C++ compilations with GNULIB_NAMESPACE, in order to avoid that |
307 | fseek gets defined as a macro, it is recommended that the developer | |
308 | uses the fseek module, even if he is not calling the fseek function. | |
61cd9dc9 LC |
309 | |
310 | Most gnulib clients that perform stream operations should fall into | |
f4c79b3c | 311 | category 3. */ |
61cd9dc9 LC |
312 | |
313 | #if @GNULIB_FSEEK@ | |
314 | # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES | |
315 | # define _GL_FSEEK_WARN /* Category 2, above. */ | |
316 | # undef fseek | |
317 | # endif | |
318 | # if @REPLACE_FSEEK@ | |
f4c79b3c LC |
319 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
320 | # undef fseek | |
321 | # define fseek rpl_fseek | |
322 | # endif | |
323 | _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence) | |
324 | _GL_ARG_NONNULL ((1))); | |
325 | _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence)); | |
326 | # else | |
327 | _GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence)); | |
c4b681fd | 328 | # endif |
f4c79b3c | 329 | _GL_CXXALIASWARN (fseek); |
c4b681fd LC |
330 | #endif |
331 | ||
8912421c | 332 | #if @GNULIB_FSEEKO@ |
61cd9dc9 LC |
333 | # if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES |
334 | # define _GL_FSEEK_WARN /* Category 3, above. */ | |
335 | # undef fseek | |
336 | # endif | |
8912421c | 337 | # if @REPLACE_FSEEKO@ |
a927b6c1 LC |
338 | /* Provide an fseeko function that is aware of a preceding fflush(), and which |
339 | detects pipes. */ | |
f4c79b3c LC |
340 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
341 | # undef fseeko | |
342 | # define fseeko rpl_fseeko | |
343 | # endif | |
344 | _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence) | |
345 | _GL_ARG_NONNULL ((1))); | |
a927b6c1 LC |
346 | _GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)); |
347 | # else | |
348 | # if ! @HAVE_FSEEKO@ | |
349 | _GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence) | |
350 | _GL_ARG_NONNULL ((1))); | |
351 | # endif | |
352 | _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)); | |
353 | # endif | |
354 | _GL_CXXALIASWARN (fseeko); | |
355 | # if (@REPLACE_FSEEKO@ || !@HAVE_FSEEKO@) && !@GNULIB_FSEEK@ | |
356 | /* Provide an fseek function that is consistent with fseeko. */ | |
357 | /* In order to avoid that fseek gets defined as a macro here, the | |
358 | developer can request the 'fseek' module. */ | |
359 | # undef fseek | |
360 | # define fseek rpl_fseek | |
61cd9dc9 LC |
361 | static inline int _GL_ARG_NONNULL ((1)) |
362 | rpl_fseek (FILE *fp, long offset, int whence) | |
363 | { | |
a927b6c1 LC |
364 | # if @REPLACE_FSEEKO@ |
365 | return rpl_fseeko (fp, offset, whence); | |
366 | # else | |
61cd9dc9 | 367 | return fseeko (fp, offset, whence); |
8912421c | 368 | # endif |
a927b6c1 | 369 | } |
c4b681fd LC |
370 | # endif |
371 | #elif defined GNULIB_POSIXCHECK | |
61cd9dc9 LC |
372 | # define _GL_FSEEK_WARN /* Category 1, above. */ |
373 | # undef fseek | |
8912421c | 374 | # undef fseeko |
61cd9dc9 LC |
375 | # if HAVE_RAW_DECL_FSEEKO |
376 | _GL_WARN_ON_USE (fseeko, "fseeko is unportable - " | |
377 | "use gnulib module fseeko for portability"); | |
378 | # endif | |
c4b681fd LC |
379 | #endif |
380 | ||
61cd9dc9 LC |
381 | #ifdef _GL_FSEEK_WARN |
382 | # undef _GL_FSEEK_WARN | |
383 | /* Here, either fseek is undefined (but C89 guarantees that it is | |
384 | declared), or it is defined as rpl_fseek (declared above). */ | |
385 | _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB " | |
386 | "on 32-bit platforms - " | |
387 | "use fseeko function for handling of large files"); | |
388 | #endif | |
389 | ||
f4c79b3c LC |
390 | |
391 | /* ftell, ftello. See the comments on fseek/fseeko. */ | |
61cd9dc9 LC |
392 | |
393 | #if @GNULIB_FTELL@ | |
394 | # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES | |
395 | # define _GL_FTELL_WARN /* Category 2, above. */ | |
396 | # undef ftell | |
8912421c | 397 | # endif |
61cd9dc9 | 398 | # if @REPLACE_FTELL@ |
f4c79b3c LC |
399 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
400 | # undef ftell | |
401 | # define ftell rpl_ftell | |
402 | # endif | |
403 | _GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1))); | |
404 | _GL_CXXALIAS_RPL (ftell, long, (FILE *fp)); | |
405 | # else | |
406 | _GL_CXXALIAS_SYS (ftell, long, (FILE *fp)); | |
8912421c | 407 | # endif |
f4c79b3c | 408 | _GL_CXXALIASWARN (ftell); |
8912421c LC |
409 | #endif |
410 | ||
411 | #if @GNULIB_FTELLO@ | |
61cd9dc9 LC |
412 | # if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES |
413 | # define _GL_FTELL_WARN /* Category 3, above. */ | |
414 | # undef ftell | |
415 | # endif | |
8912421c | 416 | # if @REPLACE_FTELLO@ |
f4c79b3c LC |
417 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
418 | # undef ftello | |
419 | # define ftello rpl_ftello | |
420 | # endif | |
421 | _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); | |
a927b6c1 LC |
422 | _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); |
423 | # else | |
424 | # if ! @HAVE_FTELLO@ | |
425 | _GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); | |
426 | # endif | |
427 | _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); | |
428 | # endif | |
429 | _GL_CXXALIASWARN (ftello); | |
430 | # if (@REPLACE_FTELLO@ || !@HAVE_FTELLO@) && !@GNULIB_FTELL@ | |
431 | /* Provide an ftell function that is consistent with ftello. */ | |
432 | /* In order to avoid that ftell gets defined as a macro here, the | |
433 | developer can request the 'ftell' module. */ | |
434 | # undef ftell | |
435 | # define ftell rpl_ftell | |
61cd9dc9 LC |
436 | static inline long _GL_ARG_NONNULL ((1)) |
437 | rpl_ftell (FILE *f) | |
438 | { | |
a927b6c1 LC |
439 | # if @REPLACE_FTELLO@ |
440 | return rpl_ftello (f); | |
441 | # else | |
61cd9dc9 | 442 | return ftello (f); |
8912421c | 443 | # endif |
a927b6c1 | 444 | } |
8912421c LC |
445 | # endif |
446 | #elif defined GNULIB_POSIXCHECK | |
61cd9dc9 LC |
447 | # define _GL_FTELL_WARN /* Category 1, above. */ |
448 | # undef ftell | |
8912421c | 449 | # undef ftello |
61cd9dc9 LC |
450 | # if HAVE_RAW_DECL_FTELLO |
451 | _GL_WARN_ON_USE (ftello, "ftello is unportable - " | |
452 | "use gnulib module ftello for portability"); | |
453 | # endif | |
454 | #endif | |
455 | ||
456 | #ifdef _GL_FTELL_WARN | |
457 | # undef _GL_FTELL_WARN | |
458 | /* Here, either ftell is undefined (but C89 guarantees that it is | |
459 | declared), or it is defined as rpl_ftell (declared above). */ | |
460 | _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB " | |
461 | "on 32-bit platforms - " | |
462 | "use ftello function for handling of large files"); | |
c4b681fd LC |
463 | #endif |
464 | ||
f4c79b3c LC |
465 | |
466 | #if @GNULIB_FWRITE@ | |
467 | # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | |
468 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
469 | # undef fwrite | |
470 | # define fwrite rpl_fwrite | |
471 | # endif | |
472 | _GL_FUNCDECL_RPL (fwrite, size_t, | |
473 | (const void *ptr, size_t s, size_t n, FILE *stream) | |
474 | _GL_ARG_NONNULL ((1, 4))); | |
475 | _GL_CXXALIAS_RPL (fwrite, size_t, | |
476 | (const void *ptr, size_t s, size_t n, FILE *stream)); | |
477 | # else | |
478 | _GL_CXXALIAS_SYS (fwrite, size_t, | |
479 | (const void *ptr, size_t s, size_t n, FILE *stream)); | |
480 | # endif | |
481 | _GL_CXXALIASWARN (fwrite); | |
c4b681fd LC |
482 | #endif |
483 | ||
484 | #if @GNULIB_GETDELIM@ | |
c4b681fd LC |
485 | /* Read input, up to (and including) the next occurrence of DELIMITER, from |
486 | STREAM, store it in *LINEPTR (and NUL-terminate it). | |
487 | *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE | |
488 | bytes of space. It is realloc'd as necessary. | |
489 | Return the number of bytes read and stored at *LINEPTR (not including the | |
490 | NUL terminator), or -1 on error or EOF. */ | |
f4c79b3c LC |
491 | # if @REPLACE_GETDELIM@ |
492 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
493 | # undef getdelim | |
494 | # define getdelim rpl_getdelim | |
495 | # endif | |
496 | _GL_FUNCDECL_RPL (getdelim, ssize_t, | |
497 | (char **lineptr, size_t *linesize, int delimiter, | |
498 | FILE *stream) | |
499 | _GL_ARG_NONNULL ((1, 2, 4))); | |
500 | _GL_CXXALIAS_RPL (getdelim, ssize_t, | |
501 | (char **lineptr, size_t *linesize, int delimiter, | |
502 | FILE *stream)); | |
503 | # else | |
504 | # if !@HAVE_DECL_GETDELIM@ | |
505 | _GL_FUNCDECL_SYS (getdelim, ssize_t, | |
506 | (char **lineptr, size_t *linesize, int delimiter, | |
507 | FILE *stream) | |
508 | _GL_ARG_NONNULL ((1, 2, 4))); | |
509 | # endif | |
510 | _GL_CXXALIAS_SYS (getdelim, ssize_t, | |
511 | (char **lineptr, size_t *linesize, int delimiter, | |
512 | FILE *stream)); | |
c4b681fd | 513 | # endif |
f4c79b3c | 514 | _GL_CXXALIASWARN (getdelim); |
c4b681fd LC |
515 | #elif defined GNULIB_POSIXCHECK |
516 | # undef getdelim | |
61cd9dc9 LC |
517 | # if HAVE_RAW_DECL_GETDELIM |
518 | _GL_WARN_ON_USE (getdelim, "getdelim is unportable - " | |
519 | "use gnulib module getdelim for portability"); | |
520 | # endif | |
c4b681fd LC |
521 | #endif |
522 | ||
523 | #if @GNULIB_GETLINE@ | |
c4b681fd LC |
524 | /* Read a line, up to (and including) the next newline, from STREAM, store it |
525 | in *LINEPTR (and NUL-terminate it). | |
526 | *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE | |
527 | bytes of space. It is realloc'd as necessary. | |
528 | Return the number of bytes read and stored at *LINEPTR (not including the | |
529 | NUL terminator), or -1 on error or EOF. */ | |
f4c79b3c LC |
530 | # if @REPLACE_GETLINE@ |
531 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
532 | # undef getline | |
533 | # define getline rpl_getline | |
534 | # endif | |
535 | _GL_FUNCDECL_RPL (getline, ssize_t, | |
536 | (char **lineptr, size_t *linesize, FILE *stream) | |
537 | _GL_ARG_NONNULL ((1, 2, 3))); | |
538 | _GL_CXXALIAS_RPL (getline, ssize_t, | |
539 | (char **lineptr, size_t *linesize, FILE *stream)); | |
540 | # else | |
541 | # if !@HAVE_DECL_GETLINE@ | |
542 | _GL_FUNCDECL_SYS (getline, ssize_t, | |
543 | (char **lineptr, size_t *linesize, FILE *stream) | |
544 | _GL_ARG_NONNULL ((1, 2, 3))); | |
545 | # endif | |
546 | _GL_CXXALIAS_SYS (getline, ssize_t, | |
547 | (char **lineptr, size_t *linesize, FILE *stream)); | |
c4b681fd | 548 | # endif |
a927b6c1 | 549 | # if @HAVE_DECL_GETLINE@ |
f4c79b3c | 550 | _GL_CXXALIASWARN (getline); |
a927b6c1 | 551 | # endif |
c4b681fd LC |
552 | #elif defined GNULIB_POSIXCHECK |
553 | # undef getline | |
61cd9dc9 LC |
554 | # if HAVE_RAW_DECL_GETLINE |
555 | _GL_WARN_ON_USE (getline, "getline is unportable - " | |
556 | "use gnulib module getline for portability"); | |
557 | # endif | |
c4b681fd LC |
558 | #endif |
559 | ||
61cd9dc9 | 560 | #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ |
f4c79b3c LC |
561 | struct obstack; |
562 | /* Grow an obstack with formatted output. Return the number of | |
563 | bytes added to OBS. No trailing nul byte is added, and the | |
564 | object should be closed with obstack_finish before use. Upon | |
565 | memory allocation error, call obstack_alloc_failed_handler. Upon | |
566 | other error, return -1. */ | |
8912421c | 567 | # if @REPLACE_OBSTACK_PRINTF@ |
f4c79b3c LC |
568 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
569 | # define obstack_printf rpl_obstack_printf | |
570 | # endif | |
571 | _GL_FUNCDECL_RPL (obstack_printf, int, | |
572 | (struct obstack *obs, const char *format, ...) | |
573 | __attribute__ ((__format__ (__printf__, 2, 3))) | |
574 | _GL_ARG_NONNULL ((1, 2))); | |
575 | _GL_CXXALIAS_RPL (obstack_printf, int, | |
576 | (struct obstack *obs, const char *format, ...)); | |
577 | # else | |
578 | # if !@HAVE_DECL_OBSTACK_PRINTF@ | |
579 | _GL_FUNCDECL_SYS (obstack_printf, int, | |
580 | (struct obstack *obs, const char *format, ...) | |
581 | __attribute__ ((__format__ (__printf__, 2, 3))) | |
582 | _GL_ARG_NONNULL ((1, 2))); | |
583 | # endif | |
584 | _GL_CXXALIAS_SYS (obstack_printf, int, | |
585 | (struct obstack *obs, const char *format, ...)); | |
8912421c | 586 | # endif |
f4c79b3c LC |
587 | _GL_CXXALIASWARN (obstack_printf); |
588 | # if @REPLACE_OBSTACK_PRINTF@ | |
589 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
590 | # define obstack_vprintf rpl_obstack_vprintf | |
591 | # endif | |
592 | _GL_FUNCDECL_RPL (obstack_vprintf, int, | |
593 | (struct obstack *obs, const char *format, va_list args) | |
594 | __attribute__ ((__format__ (__printf__, 2, 0))) | |
595 | _GL_ARG_NONNULL ((1, 2))); | |
596 | _GL_CXXALIAS_RPL (obstack_vprintf, int, | |
597 | (struct obstack *obs, const char *format, va_list args)); | |
598 | # else | |
599 | # if !@HAVE_DECL_OBSTACK_PRINTF@ | |
600 | _GL_FUNCDECL_SYS (obstack_vprintf, int, | |
601 | (struct obstack *obs, const char *format, va_list args) | |
602 | __attribute__ ((__format__ (__printf__, 2, 0))) | |
603 | _GL_ARG_NONNULL ((1, 2))); | |
604 | # endif | |
605 | _GL_CXXALIAS_SYS (obstack_vprintf, int, | |
606 | (struct obstack *obs, const char *format, va_list args)); | |
8912421c | 607 | # endif |
f4c79b3c | 608 | _GL_CXXALIASWARN (obstack_vprintf); |
8912421c LC |
609 | #endif |
610 | ||
c4b681fd | 611 | #if @GNULIB_PERROR@ |
c4b681fd LC |
612 | /* Print a message to standard error, describing the value of ERRNO, |
613 | (if STRING is not NULL and not empty) prefixed with STRING and ": ", | |
614 | and terminated with a newline. */ | |
f4c79b3c LC |
615 | # if @REPLACE_PERROR@ |
616 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
617 | # define perror rpl_perror | |
618 | # endif | |
619 | _GL_FUNCDECL_RPL (perror, void, (const char *string)); | |
620 | _GL_CXXALIAS_RPL (perror, void, (const char *string)); | |
621 | # else | |
622 | _GL_CXXALIAS_SYS (perror, void, (const char *string)); | |
c4b681fd | 623 | # endif |
f4c79b3c | 624 | _GL_CXXALIASWARN (perror); |
c4b681fd LC |
625 | #elif defined GNULIB_POSIXCHECK |
626 | # undef perror | |
61cd9dc9 LC |
627 | /* Assume perror is always declared. */ |
628 | _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - " | |
629 | "use gnulib module perror for portability"); | |
c4b681fd LC |
630 | #endif |
631 | ||
8912421c LC |
632 | #if @GNULIB_POPEN@ |
633 | # if @REPLACE_POPEN@ | |
f4c79b3c LC |
634 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
635 | # undef popen | |
636 | # define popen rpl_popen | |
637 | # endif | |
638 | _GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode) | |
639 | _GL_ARG_NONNULL ((1, 2))); | |
640 | _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); | |
641 | # else | |
642 | _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); | |
8912421c | 643 | # endif |
f4c79b3c | 644 | _GL_CXXALIASWARN (popen); |
8912421c LC |
645 | #elif defined GNULIB_POSIXCHECK |
646 | # undef popen | |
61cd9dc9 LC |
647 | # if HAVE_RAW_DECL_POPEN |
648 | _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " | |
649 | "use gnulib module popen or pipe for more portability"); | |
650 | # endif | |
8912421c LC |
651 | #endif |
652 | ||
f4c79b3c LC |
653 | #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ |
654 | # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ | |
655 | || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) | |
a927b6c1 LC |
656 | # if defined __GNUC__ |
657 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
8912421c | 658 | /* Don't break __attribute__((format(printf,M,N))). */ |
a927b6c1 LC |
659 | # define printf __printf__ |
660 | # endif | |
f4c79b3c LC |
661 | _GL_FUNCDECL_RPL_1 (__printf__, int, |
662 | (const char *format, ...) | |
a927b6c1 LC |
663 | __asm__ (@ASM_SYMBOL_PREFIX@ |
664 | _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) | |
f4c79b3c LC |
665 | __attribute__ ((__format__ (__printf__, 1, 2))) |
666 | _GL_ARG_NONNULL ((1))); | |
667 | _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...)); | |
a927b6c1 LC |
668 | # else |
669 | _GL_FUNCDECL_RPL (printf, int, | |
670 | (const char *format, ...) | |
671 | __attribute__ ((__format__ (__printf__, 1, 2))) | |
672 | _GL_ARG_NONNULL ((1))); | |
9157d901 | 673 | _GL_CXXALIAS_RPL (printf, int, (const char *format, ...)); |
a927b6c1 LC |
674 | # endif |
675 | # define GNULIB_overrides_printf 1 | |
f4c79b3c LC |
676 | # else |
677 | _GL_CXXALIAS_SYS (printf, int, (const char *format, ...)); | |
678 | # endif | |
679 | _GL_CXXALIASWARN (printf); | |
680 | #endif | |
681 | #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK | |
682 | # if !GNULIB_overrides_printf | |
683 | # undef printf | |
8912421c | 684 | # endif |
61cd9dc9 LC |
685 | /* Assume printf is always declared. */ |
686 | _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - " | |
687 | "use gnulib module printf-posix for portable " | |
688 | "POSIX compliance"); | |
8912421c LC |
689 | #endif |
690 | ||
f4c79b3c LC |
691 | #if @GNULIB_PUTC@ |
692 | # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | |
693 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
694 | # undef putc | |
695 | # define putc rpl_fputc | |
696 | # endif | |
697 | _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); | |
698 | _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream)); | |
699 | # else | |
700 | _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream)); | |
701 | # endif | |
702 | _GL_CXXALIASWARN (putc); | |
8912421c LC |
703 | #endif |
704 | ||
f4c79b3c LC |
705 | #if @GNULIB_PUTCHAR@ |
706 | # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | |
707 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
708 | # undef putchar | |
709 | # define putchar rpl_putchar | |
710 | # endif | |
711 | _GL_FUNCDECL_RPL (putchar, int, (int c)); | |
712 | _GL_CXXALIAS_RPL (putchar, int, (int c)); | |
713 | # else | |
714 | _GL_CXXALIAS_SYS (putchar, int, (int c)); | |
715 | # endif | |
716 | _GL_CXXALIASWARN (putchar); | |
8912421c LC |
717 | #endif |
718 | ||
f4c79b3c LC |
719 | #if @GNULIB_PUTS@ |
720 | # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | |
721 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
722 | # undef puts | |
723 | # define puts rpl_puts | |
724 | # endif | |
725 | _GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1))); | |
726 | _GL_CXXALIAS_RPL (puts, int, (const char *string)); | |
727 | # else | |
728 | _GL_CXXALIAS_SYS (puts, int, (const char *string)); | |
729 | # endif | |
730 | _GL_CXXALIASWARN (puts); | |
8912421c LC |
731 | #endif |
732 | ||
733 | #if @GNULIB_REMOVE@ | |
734 | # if @REPLACE_REMOVE@ | |
f4c79b3c LC |
735 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
736 | # undef remove | |
737 | # define remove rpl_remove | |
738 | # endif | |
739 | _GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1))); | |
740 | _GL_CXXALIAS_RPL (remove, int, (const char *name)); | |
741 | # else | |
742 | _GL_CXXALIAS_SYS (remove, int, (const char *name)); | |
8912421c | 743 | # endif |
f4c79b3c | 744 | _GL_CXXALIASWARN (remove); |
8912421c LC |
745 | #elif defined GNULIB_POSIXCHECK |
746 | # undef remove | |
61cd9dc9 LC |
747 | /* Assume remove is always declared. */ |
748 | _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - " | |
749 | "use gnulib module remove for more portability"); | |
8912421c LC |
750 | #endif |
751 | ||
752 | #if @GNULIB_RENAME@ | |
753 | # if @REPLACE_RENAME@ | |
f4c79b3c LC |
754 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
755 | # undef rename | |
756 | # define rename rpl_rename | |
757 | # endif | |
758 | _GL_FUNCDECL_RPL (rename, int, | |
759 | (const char *old_filename, const char *new_filename) | |
760 | _GL_ARG_NONNULL ((1, 2))); | |
761 | _GL_CXXALIAS_RPL (rename, int, | |
762 | (const char *old_filename, const char *new_filename)); | |
763 | # else | |
764 | _GL_CXXALIAS_SYS (rename, int, | |
765 | (const char *old_filename, const char *new_filename)); | |
766 | # endif | |
767 | _GL_CXXALIASWARN (rename); | |
8912421c LC |
768 | #elif defined GNULIB_POSIXCHECK |
769 | # undef rename | |
61cd9dc9 LC |
770 | /* Assume rename is always declared. */ |
771 | _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - " | |
772 | "use gnulib module rename for more portability"); | |
8912421c LC |
773 | #endif |
774 | ||
775 | #if @GNULIB_RENAMEAT@ | |
776 | # if @REPLACE_RENAMEAT@ | |
f4c79b3c LC |
777 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
778 | # undef renameat | |
779 | # define renameat rpl_renameat | |
780 | # endif | |
781 | _GL_FUNCDECL_RPL (renameat, int, | |
782 | (int fd1, char const *file1, int fd2, char const *file2) | |
783 | _GL_ARG_NONNULL ((2, 4))); | |
784 | _GL_CXXALIAS_RPL (renameat, int, | |
785 | (int fd1, char const *file1, int fd2, char const *file2)); | |
786 | # else | |
787 | # if !@HAVE_RENAMEAT@ | |
788 | _GL_FUNCDECL_SYS (renameat, int, | |
789 | (int fd1, char const *file1, int fd2, char const *file2) | |
790 | _GL_ARG_NONNULL ((2, 4))); | |
791 | # endif | |
792 | _GL_CXXALIAS_SYS (renameat, int, | |
793 | (int fd1, char const *file1, int fd2, char const *file2)); | |
8912421c | 794 | # endif |
f4c79b3c | 795 | _GL_CXXALIASWARN (renameat); |
8912421c LC |
796 | #elif defined GNULIB_POSIXCHECK |
797 | # undef renameat | |
61cd9dc9 LC |
798 | # if HAVE_RAW_DECL_RENAMEAT |
799 | _GL_WARN_ON_USE (renameat, "renameat is not portable - " | |
800 | "use gnulib module renameat for portability"); | |
801 | # endif | |
8912421c LC |
802 | #endif |
803 | ||
804 | #if @GNULIB_SNPRINTF@ | |
805 | # if @REPLACE_SNPRINTF@ | |
f4c79b3c LC |
806 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
807 | # define snprintf rpl_snprintf | |
808 | # endif | |
809 | _GL_FUNCDECL_RPL (snprintf, int, | |
810 | (char *str, size_t size, const char *format, ...) | |
811 | __attribute__ ((__format__ (__printf__, 3, 4))) | |
812 | _GL_ARG_NONNULL ((3))); | |
813 | _GL_CXXALIAS_RPL (snprintf, int, | |
814 | (char *str, size_t size, const char *format, ...)); | |
815 | # else | |
816 | # if !@HAVE_DECL_SNPRINTF@ | |
817 | _GL_FUNCDECL_SYS (snprintf, int, | |
818 | (char *str, size_t size, const char *format, ...) | |
819 | __attribute__ ((__format__ (__printf__, 3, 4))) | |
820 | _GL_ARG_NONNULL ((3))); | |
821 | # endif | |
822 | _GL_CXXALIAS_SYS (snprintf, int, | |
823 | (char *str, size_t size, const char *format, ...)); | |
8912421c | 824 | # endif |
f4c79b3c | 825 | _GL_CXXALIASWARN (snprintf); |
8912421c LC |
826 | #elif defined GNULIB_POSIXCHECK |
827 | # undef snprintf | |
61cd9dc9 LC |
828 | # if HAVE_RAW_DECL_SNPRINTF |
829 | _GL_WARN_ON_USE (snprintf, "snprintf is unportable - " | |
830 | "use gnulib module snprintf for portability"); | |
831 | # endif | |
8912421c LC |
832 | #endif |
833 | ||
61cd9dc9 LC |
834 | /* Some people would argue that sprintf should be handled like gets |
835 | (for example, OpenBSD issues a link warning for both functions), | |
836 | since both can cause security holes due to buffer overruns. | |
837 | However, we believe that sprintf can be used safely, and is more | |
838 | efficient than snprintf in those safe cases; and as proof of our | |
839 | belief, we use sprintf in several gnulib modules. So this header | |
840 | intentionally avoids adding a warning to sprintf except when | |
841 | GNULIB_POSIXCHECK is defined. */ | |
842 | ||
8912421c LC |
843 | #if @GNULIB_SPRINTF_POSIX@ |
844 | # if @REPLACE_SPRINTF@ | |
f4c79b3c LC |
845 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
846 | # define sprintf rpl_sprintf | |
847 | # endif | |
848 | _GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...) | |
849 | __attribute__ ((__format__ (__printf__, 2, 3))) | |
850 | _GL_ARG_NONNULL ((1, 2))); | |
851 | _GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...)); | |
852 | # else | |
853 | _GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...)); | |
854 | # endif | |
855 | _GL_CXXALIASWARN (sprintf); | |
8912421c LC |
856 | #elif defined GNULIB_POSIXCHECK |
857 | # undef sprintf | |
61cd9dc9 LC |
858 | /* Assume sprintf is always declared. */ |
859 | _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - " | |
860 | "use gnulib module sprintf-posix for portable " | |
861 | "POSIX compliance"); | |
8912421c LC |
862 | #endif |
863 | ||
a927b6c1 LC |
864 | #if @GNULIB_TMPFILE@ |
865 | # if @REPLACE_TMPFILE@ | |
866 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
867 | # define tmpfile rpl_tmpfile | |
868 | # endif | |
869 | _GL_FUNCDECL_RPL (tmpfile, FILE *, (void)); | |
870 | _GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); | |
871 | # else | |
872 | _GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); | |
873 | # endif | |
874 | _GL_CXXALIASWARN (tmpfile); | |
875 | #elif defined GNULIB_POSIXCHECK | |
876 | # undef tmpfile | |
877 | # if HAVE_RAW_DECL_TMPFILE | |
878 | _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " | |
879 | "use gnulib module tmpfile for portability"); | |
880 | # endif | |
881 | #endif | |
882 | ||
8912421c | 883 | #if @GNULIB_VASPRINTF@ |
f4c79b3c LC |
884 | /* Write formatted output to a string dynamically allocated with malloc(). |
885 | If the memory allocation succeeds, store the address of the string in | |
886 | *RESULT and return the number of resulting bytes, excluding the trailing | |
887 | NUL. Upon memory allocation error, or some other error, return -1. */ | |
8912421c | 888 | # if @REPLACE_VASPRINTF@ |
f4c79b3c LC |
889 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
890 | # define asprintf rpl_asprintf | |
891 | # endif | |
892 | _GL_FUNCDECL_RPL (asprintf, int, | |
893 | (char **result, const char *format, ...) | |
894 | __attribute__ ((__format__ (__printf__, 2, 3))) | |
895 | _GL_ARG_NONNULL ((1, 2))); | |
896 | _GL_CXXALIAS_RPL (asprintf, int, | |
897 | (char **result, const char *format, ...)); | |
898 | # else | |
899 | # if !@HAVE_VASPRINTF@ | |
900 | _GL_FUNCDECL_SYS (asprintf, int, | |
901 | (char **result, const char *format, ...) | |
902 | __attribute__ ((__format__ (__printf__, 2, 3))) | |
903 | _GL_ARG_NONNULL ((1, 2))); | |
904 | # endif | |
905 | _GL_CXXALIAS_SYS (asprintf, int, | |
906 | (char **result, const char *format, ...)); | |
8912421c | 907 | # endif |
f4c79b3c LC |
908 | _GL_CXXALIASWARN (asprintf); |
909 | # if @REPLACE_VASPRINTF@ | |
910 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
911 | # define vasprintf rpl_vasprintf | |
912 | # endif | |
913 | _GL_FUNCDECL_RPL (vasprintf, int, | |
914 | (char **result, const char *format, va_list args) | |
915 | __attribute__ ((__format__ (__printf__, 2, 0))) | |
916 | _GL_ARG_NONNULL ((1, 2))); | |
917 | _GL_CXXALIAS_RPL (vasprintf, int, | |
918 | (char **result, const char *format, va_list args)); | |
919 | # else | |
920 | # if !@HAVE_VASPRINTF@ | |
921 | _GL_FUNCDECL_SYS (vasprintf, int, | |
922 | (char **result, const char *format, va_list args) | |
923 | __attribute__ ((__format__ (__printf__, 2, 0))) | |
924 | _GL_ARG_NONNULL ((1, 2))); | |
925 | # endif | |
926 | _GL_CXXALIAS_SYS (vasprintf, int, | |
927 | (char **result, const char *format, va_list args)); | |
8912421c | 928 | # endif |
f4c79b3c | 929 | _GL_CXXALIASWARN (vasprintf); |
8912421c LC |
930 | #endif |
931 | ||
932 | #if @GNULIB_VDPRINTF@ | |
933 | # if @REPLACE_VDPRINTF@ | |
f4c79b3c LC |
934 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
935 | # define vdprintf rpl_vdprintf | |
936 | # endif | |
937 | _GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args) | |
938 | __attribute__ ((__format__ (__printf__, 2, 0))) | |
939 | _GL_ARG_NONNULL ((2))); | |
940 | _GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args)); | |
941 | # else | |
942 | # if !@HAVE_VDPRINTF@ | |
943 | _GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args) | |
944 | __attribute__ ((__format__ (__printf__, 2, 0))) | |
945 | _GL_ARG_NONNULL ((2))); | |
946 | # endif | |
a927b6c1 LC |
947 | /* Need to cast, because on Solaris, the third parameter will likely be |
948 | __va_list args. */ | |
949 | _GL_CXXALIAS_SYS_CAST (vdprintf, int, | |
950 | (int fd, const char *format, va_list args)); | |
8912421c | 951 | # endif |
f4c79b3c | 952 | _GL_CXXALIASWARN (vdprintf); |
8912421c LC |
953 | #elif defined GNULIB_POSIXCHECK |
954 | # undef vdprintf | |
61cd9dc9 LC |
955 | # if HAVE_RAW_DECL_VDPRINTF |
956 | _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - " | |
957 | "use gnulib module vdprintf for portability"); | |
958 | # endif | |
8912421c LC |
959 | #endif |
960 | ||
f4c79b3c LC |
961 | #if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@ |
962 | # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \ | |
963 | || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) | |
964 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
965 | # define vfprintf rpl_vfprintf | |
966 | # endif | |
967 | # define GNULIB_overrides_vfprintf 1 | |
968 | _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args) | |
969 | __attribute__ ((__format__ (__printf__, 2, 0))) | |
970 | _GL_ARG_NONNULL ((1, 2))); | |
971 | _GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)); | |
972 | # else | |
a927b6c1 LC |
973 | /* Need to cast, because on Solaris, the third parameter is |
974 | __va_list args | |
975 | and GCC's fixincludes did not change this to __gnuc_va_list. */ | |
976 | _GL_CXXALIAS_SYS_CAST (vfprintf, int, | |
977 | (FILE *fp, const char *format, va_list args)); | |
f4c79b3c LC |
978 | # endif |
979 | _GL_CXXALIASWARN (vfprintf); | |
980 | #endif | |
981 | #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK | |
982 | # if !GNULIB_overrides_vfprintf | |
983 | # undef vfprintf | |
8912421c | 984 | # endif |
61cd9dc9 LC |
985 | /* Assume vfprintf is always declared. */ |
986 | _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - " | |
987 | "use gnulib module vfprintf-posix for portable " | |
988 | "POSIX compliance"); | |
8912421c LC |
989 | #endif |
990 | ||
f4c79b3c LC |
991 | #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@ |
992 | # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \ | |
993 | || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) | |
994 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
995 | # define vprintf rpl_vprintf | |
996 | # endif | |
997 | # define GNULIB_overrides_vprintf 1 | |
998 | _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args) | |
999 | __attribute__ ((__format__ (__printf__, 1, 0))) | |
1000 | _GL_ARG_NONNULL ((1))); | |
1001 | _GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args)); | |
1002 | # else | |
a927b6c1 LC |
1003 | /* Need to cast, because on Solaris, the second parameter is |
1004 | __va_list args | |
1005 | and GCC's fixincludes did not change this to __gnuc_va_list. */ | |
1006 | _GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args)); | |
f4c79b3c LC |
1007 | # endif |
1008 | _GL_CXXALIASWARN (vprintf); | |
1009 | #endif | |
1010 | #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK | |
1011 | # if !GNULIB_overrides_vprintf | |
1012 | # undef vprintf | |
8912421c | 1013 | # endif |
61cd9dc9 LC |
1014 | /* Assume vprintf is always declared. */ |
1015 | _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - " | |
1016 | "use gnulib module vprintf-posix for portable " | |
1017 | "POSIX compliance"); | |
8912421c LC |
1018 | #endif |
1019 | ||
1020 | #if @GNULIB_VSNPRINTF@ | |
1021 | # if @REPLACE_VSNPRINTF@ | |
f4c79b3c LC |
1022 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
1023 | # define vsnprintf rpl_vsnprintf | |
1024 | # endif | |
1025 | _GL_FUNCDECL_RPL (vsnprintf, int, | |
1026 | (char *str, size_t size, const char *format, va_list args) | |
1027 | __attribute__ ((__format__ (__printf__, 3, 0))) | |
1028 | _GL_ARG_NONNULL ((3))); | |
1029 | _GL_CXXALIAS_RPL (vsnprintf, int, | |
1030 | (char *str, size_t size, const char *format, va_list args)); | |
1031 | # else | |
1032 | # if !@HAVE_DECL_VSNPRINTF@ | |
1033 | _GL_FUNCDECL_SYS (vsnprintf, int, | |
1034 | (char *str, size_t size, const char *format, va_list args) | |
1035 | __attribute__ ((__format__ (__printf__, 3, 0))) | |
1036 | _GL_ARG_NONNULL ((3))); | |
1037 | # endif | |
1038 | _GL_CXXALIAS_SYS (vsnprintf, int, | |
1039 | (char *str, size_t size, const char *format, va_list args)); | |
8912421c | 1040 | # endif |
f4c79b3c | 1041 | _GL_CXXALIASWARN (vsnprintf); |
8912421c LC |
1042 | #elif defined GNULIB_POSIXCHECK |
1043 | # undef vsnprintf | |
61cd9dc9 LC |
1044 | # if HAVE_RAW_DECL_VSNPRINTF |
1045 | _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - " | |
1046 | "use gnulib module vsnprintf for portability"); | |
1047 | # endif | |
8912421c LC |
1048 | #endif |
1049 | ||
1050 | #if @GNULIB_VSPRINTF_POSIX@ | |
1051 | # if @REPLACE_VSPRINTF@ | |
f4c79b3c LC |
1052 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
1053 | # define vsprintf rpl_vsprintf | |
1054 | # endif | |
1055 | _GL_FUNCDECL_RPL (vsprintf, int, | |
1056 | (char *str, const char *format, va_list args) | |
1057 | __attribute__ ((__format__ (__printf__, 2, 0))) | |
1058 | _GL_ARG_NONNULL ((1, 2))); | |
1059 | _GL_CXXALIAS_RPL (vsprintf, int, | |
1060 | (char *str, const char *format, va_list args)); | |
1061 | # else | |
a927b6c1 LC |
1062 | /* Need to cast, because on Solaris, the third parameter is |
1063 | __va_list args | |
1064 | and GCC's fixincludes did not change this to __gnuc_va_list. */ | |
1065 | _GL_CXXALIAS_SYS_CAST (vsprintf, int, | |
1066 | (char *str, const char *format, va_list args)); | |
f4c79b3c LC |
1067 | # endif |
1068 | _GL_CXXALIASWARN (vsprintf); | |
8912421c LC |
1069 | #elif defined GNULIB_POSIXCHECK |
1070 | # undef vsprintf | |
61cd9dc9 LC |
1071 | /* Assume vsprintf is always declared. */ |
1072 | _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - " | |
1073 | "use gnulib module vsprintf-posix for portable " | |
1074 | "POSIX compliance"); | |
8912421c LC |
1075 | #endif |
1076 | ||
c4b681fd LC |
1077 | |
1078 | #endif /* _GL_STDIO_H */ | |
1079 | #endif /* _GL_STDIO_H */ | |
1080 | #endif |