Branch data Line data Source code
1 : : /* Define ISO C stdio on top of C++ iostreams.
2 : : Copyright (C) 1991-2025 Free Software Foundation, Inc.
3 : : Copyright The GNU Toolchain Authors.
4 : : This file is part of the GNU C Library.
5 : :
6 : : The GNU C Library is free software; you can redistribute it and/or
7 : : modify it under the terms of the GNU Lesser General Public
8 : : License as published by the Free Software Foundation; either
9 : : version 2.1 of the License, or (at your option) any later version.
10 : :
11 : : The GNU C Library is distributed in the hope that it will be useful,
12 : : but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 : : Lesser General Public License for more details.
15 : :
16 : : You should have received a copy of the GNU Lesser General Public
17 : : License along with the GNU C Library; if not, see
18 : : <https://www.gnu.org/licenses/>. */
19 : :
20 : : /*
21 : : * ISO C99 Standard: 7.19 Input/output <stdio.h>
22 : : */
23 : :
24 : : #ifndef _STDIO_H
25 : : #define _STDIO_H 1
26 : :
27 : : #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
28 : : #include <bits/libc-header-start.h>
29 : :
30 : : __BEGIN_DECLS
31 : :
32 : : #define __need_size_t
33 : : #define __need_NULL
34 : : #include <stddef.h>
35 : :
36 : : #define __need___va_list
37 : : #include <stdarg.h>
38 : :
39 : : #include <bits/types.h>
40 : : #include <bits/types/__fpos_t.h>
41 : : #include <bits/types/__fpos64_t.h>
42 : : #include <bits/types/__FILE.h>
43 : : #include <bits/types/FILE.h>
44 : : #include <bits/types/struct_FILE.h>
45 : :
46 : : #ifdef __USE_MISC
47 : : # include <bits/types/cookie_io_functions_t.h>
48 : : #endif
49 : :
50 : : #if defined __USE_XOPEN || defined __USE_XOPEN2K8
51 : : # ifdef __GNUC__
52 : : # ifndef _VA_LIST_DEFINED
53 : : typedef __gnuc_va_list va_list;
54 : : # define _VA_LIST_DEFINED
55 : : # endif
56 : : # else
57 : : # include <stdarg.h>
58 : : # endif
59 : : #endif
60 : :
61 : : #if defined __USE_UNIX98 || defined __USE_XOPEN2K
62 : : # ifndef __off_t_defined
63 : : # ifndef __USE_FILE_OFFSET64
64 : : typedef __off_t off_t;
65 : : # else
66 : : typedef __off64_t off_t;
67 : : # endif
68 : : # define __off_t_defined
69 : : # endif
70 : : # if defined __USE_LARGEFILE64 && !defined __off64_t_defined
71 : : typedef __off64_t off64_t;
72 : : # define __off64_t_defined
73 : : # endif
74 : : #endif
75 : :
76 : : #ifdef __USE_XOPEN2K8
77 : : # ifndef __ssize_t_defined
78 : : typedef __ssize_t ssize_t;
79 : : # define __ssize_t_defined
80 : : # endif
81 : : #endif
82 : :
83 : : /* The type of the second argument to `fgetpos' and `fsetpos'. */
84 : : #ifndef __USE_FILE_OFFSET64
85 : : typedef __fpos_t fpos_t;
86 : : #else
87 : : typedef __fpos64_t fpos_t;
88 : : #endif
89 : : #ifdef __USE_LARGEFILE64
90 : : typedef __fpos64_t fpos64_t;
91 : : #endif
92 : :
93 : : /* The possibilities for the third argument to `setvbuf'. */
94 : : #define _IOFBF 0 /* Fully buffered. */
95 : : #define _IOLBF 1 /* Line buffered. */
96 : : #define _IONBF 2 /* No buffering. */
97 : :
98 : :
99 : : /* Default buffer size. */
100 : : #define BUFSIZ 8192
101 : :
102 : :
103 : : /* The value returned by fgetc and similar functions to indicate the
104 : : end of the file. */
105 : : #define EOF (-1)
106 : :
107 : :
108 : : /* The possibilities for the third argument to `fseek'.
109 : : These values should not be changed. */
110 : : #define SEEK_SET 0 /* Seek from beginning of file. */
111 : : #define SEEK_CUR 1 /* Seek from current position. */
112 : : #define SEEK_END 2 /* Seek from end of file. */
113 : : #ifdef __USE_GNU
114 : : # define SEEK_DATA 3 /* Seek to next data. */
115 : : # define SEEK_HOLE 4 /* Seek to next hole. */
116 : : #endif
117 : :
118 : :
119 : : #if defined __USE_MISC || defined __USE_XOPEN
120 : : /* Default path prefix for `tempnam' and `tmpnam'. */
121 : : # define P_tmpdir "/tmp"
122 : : #endif
123 : :
124 : : #define L_tmpnam 20
125 : : #define TMP_MAX 238328
126 : :
127 : : /* Get the values:
128 : : FILENAME_MAX Maximum length of a filename. */
129 : : #include <bits/stdio_lim.h>
130 : :
131 : : #ifdef __USE_POSIX
132 : : # define L_ctermid 9
133 : : # if !defined __USE_XOPEN2K || defined __USE_GNU
134 : : # define L_cuserid 9
135 : : # endif
136 : : #endif
137 : :
138 : : #undef FOPEN_MAX
139 : : #define FOPEN_MAX 16
140 : :
141 : :
142 : : #if __GLIBC_USE (ISOC23)
143 : : /* Maximum length of printf output for a NaN. */
144 : : # define _PRINTF_NAN_LEN_MAX 4
145 : : #endif
146 : :
147 : :
148 : : /* Standard streams. */
149 : : extern FILE *stdin; /* Standard input stream. */
150 : : extern FILE *stdout; /* Standard output stream. */
151 : : extern FILE *stderr; /* Standard error output stream. */
152 : : /* C89/C99 say they're macros. Make them happy. */
153 : : #define stdin stdin
154 : : #define stdout stdout
155 : : #define stderr stderr
156 : :
157 : : /* Remove file FILENAME. */
158 : : extern int remove (const char *__filename) __THROW;
159 : : /* Rename file OLD to NEW. */
160 : : extern int rename (const char *__old, const char *__new) __THROW;
161 : :
162 : : #ifdef __USE_ATFILE
163 : : /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
164 : : extern int renameat (int __oldfd, const char *__old, int __newfd,
165 : : const char *__new) __THROW;
166 : : #endif
167 : :
168 : : #ifdef __USE_GNU
169 : : /* Flags for renameat2. */
170 : : # define RENAME_NOREPLACE (1 << 0)
171 : : # define RENAME_EXCHANGE (1 << 1)
172 : : # define RENAME_WHITEOUT (1 << 2)
173 : :
174 : : /* Rename file OLD relative to OLDFD to NEW relative to NEWFD, with
175 : : additional flags. */
176 : : extern int renameat2 (int __oldfd, const char *__old, int __newfd,
177 : : const char *__new, unsigned int __flags) __THROW;
178 : : #endif
179 : :
180 : : /* Close STREAM.
181 : :
182 : : This function is a possible cancellation point and therefore not
183 : : marked with __THROW. */
184 : : extern int fclose (FILE *__stream) __nonnull ((1));
185 : :
186 : : #undef __attr_dealloc_fclose
187 : : #define __attr_dealloc_fclose __attr_dealloc (fclose, 1)
188 : :
189 : : /* Create a temporary file and open it read/write.
190 : :
191 : : This function is a possible cancellation point and therefore not
192 : : marked with __THROW. */
193 : : #ifndef __USE_FILE_OFFSET64
194 : : extern FILE *tmpfile (void)
195 : : __attribute_malloc__ __attr_dealloc_fclose __wur;
196 : : #else
197 : : # ifdef __REDIRECT
198 : : extern FILE *__REDIRECT (tmpfile, (void), tmpfile64)
199 : : __attribute_malloc__ __attr_dealloc_fclose __wur;
200 : : # else
201 : : # define tmpfile tmpfile64
202 : : # endif
203 : : #endif
204 : :
205 : : #ifdef __USE_LARGEFILE64
206 : : extern FILE *tmpfile64 (void)
207 : : __attribute_malloc__ __attr_dealloc_fclose __wur;
208 : : #endif
209 : :
210 : : /* Generate a temporary filename. */
211 : : extern char *tmpnam (char[L_tmpnam]) __THROW __wur;
212 : :
213 : : #ifdef __USE_MISC
214 : : /* This is the reentrant variant of `tmpnam'. The only difference is
215 : : that it does not allow S to be NULL. */
216 : : extern char *tmpnam_r (char __s[L_tmpnam]) __THROW __wur;
217 : : #endif
218 : :
219 : :
220 : : #if defined __USE_MISC || defined __USE_XOPEN
221 : : /* Generate a unique temporary filename using up to five characters of PFX
222 : : if it is not NULL. The directory to put this file in is searched for
223 : : as follows: First the environment variable "TMPDIR" is checked.
224 : : If it contains the name of a writable directory, that directory is used.
225 : : If not and if DIR is not NULL, that value is checked. If that fails,
226 : : P_tmpdir is tried and finally "/tmp". The storage for the filename
227 : : is allocated by `malloc'. */
228 : : extern char *tempnam (const char *__dir, const char *__pfx)
229 : : __THROW __attribute_malloc__ __wur __attr_dealloc_free;
230 : : #endif
231 : :
232 : : /* Flush STREAM, or all streams if STREAM is NULL.
233 : :
234 : : This function is a possible cancellation point and therefore not
235 : : marked with __THROW. */
236 : : extern int fflush (FILE *__stream);
237 : :
238 : : #ifdef __USE_MISC
239 : : /* Faster versions when locking is not required.
240 : :
241 : : This function is not part of POSIX and therefore no official
242 : : cancellation point. But due to similarity with an POSIX interface
243 : : or due to the implementation it is a cancellation point and
244 : : therefore not marked with __THROW. */
245 : : extern int fflush_unlocked (FILE *__stream);
246 : : #endif
247 : :
248 : : #ifdef __USE_GNU
249 : : /* Close all streams.
250 : :
251 : : This function is not part of POSIX and therefore no official
252 : : cancellation point. But due to similarity with an POSIX interface
253 : : or due to the implementation it is a cancellation point and
254 : : therefore not marked with __THROW. */
255 : : extern int fcloseall (void);
256 : : #endif
257 : :
258 : :
259 : : #ifndef __USE_FILE_OFFSET64
260 : : /* Open a file and create a new stream for it.
261 : :
262 : : This function is a possible cancellation point and therefore not
263 : : marked with __THROW. */
264 : : extern FILE *fopen (const char *__restrict __filename,
265 : : const char *__restrict __modes)
266 : : __attribute_malloc__ __attr_dealloc_fclose __wur;
267 : : /* Open a file, replacing an existing stream with it.
268 : :
269 : : This function is a possible cancellation point and therefore not
270 : : marked with __THROW. */
271 : : extern FILE *freopen (const char *__restrict __filename,
272 : : const char *__restrict __modes,
273 : : FILE *__restrict __stream) __wur __nonnull ((3));
274 : : #else
275 : : # ifdef __REDIRECT
276 : : extern FILE *__REDIRECT (fopen, (const char *__restrict __filename,
277 : : const char *__restrict __modes), fopen64)
278 : : __attribute_malloc__ __attr_dealloc_fclose __wur;
279 : : extern FILE *__REDIRECT (freopen, (const char *__restrict __filename,
280 : : const char *__restrict __modes,
281 : : FILE *__restrict __stream), freopen64)
282 : : __wur __nonnull ((3));
283 : : # else
284 : : # define fopen fopen64
285 : : # define freopen freopen64
286 : : # endif
287 : : #endif
288 : : #ifdef __USE_LARGEFILE64
289 : : extern FILE *fopen64 (const char *__restrict __filename,
290 : : const char *__restrict __modes)
291 : : __attribute_malloc__ __attr_dealloc_fclose __wur;
292 : : extern FILE *freopen64 (const char *__restrict __filename,
293 : : const char *__restrict __modes,
294 : : FILE *__restrict __stream) __wur __nonnull ((3));
295 : : #endif
296 : :
297 : : #ifdef __USE_POSIX
298 : : /* Create a new stream that refers to an existing system file descriptor. */
299 : : extern FILE *fdopen (int __fd, const char *__modes) __THROW
300 : : __attribute_malloc__ __attr_dealloc_fclose __wur;
301 : : #endif
302 : :
303 : : #ifdef __USE_MISC
304 : : /* Create a new stream that refers to the given magic cookie,
305 : : and uses the given functions for input and output. */
306 : : extern FILE *fopencookie (void *__restrict __magic_cookie,
307 : : const char *__restrict __modes,
308 : : cookie_io_functions_t __io_funcs) __THROW
309 : : __attribute_malloc__ __attr_dealloc_fclose __wur;
310 : : #endif
311 : :
312 : : #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
313 : : /* Create a new stream that refers to a memory buffer. */
314 : : extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
315 : : __THROW __attribute_malloc__ __attr_dealloc_fclose __wur;
316 : :
317 : : /* Open a stream that writes into a malloc'd buffer that is expanded as
318 : : necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
319 : : and the number of characters written on fflush or fclose. */
320 : : extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW
321 : : __attribute_malloc__ __attr_dealloc_fclose __wur;
322 : :
323 : : #ifdef _WCHAR_H
324 : : /* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces
325 : : a wide character string. Declared here only to add attribute malloc
326 : : and only if <wchar.h> has been previously #included. */
327 : : extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW
328 : : __attribute_malloc__ __attr_dealloc_fclose;
329 : : # endif
330 : : #endif
331 : :
332 : : /* If BUF is NULL, make STREAM unbuffered.
333 : : Else make it use buffer BUF, of size BUFSIZ. */
334 : : extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW
335 : : __nonnull ((1));
336 : : /* Make STREAM use buffering mode MODE.
337 : : If BUF is not NULL, use N bytes of it for buffering;
338 : : else allocate an internal buffer N bytes long. */
339 : : extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
340 : : int __modes, size_t __n) __THROW __nonnull ((1));
341 : :
342 : : #ifdef __USE_MISC
343 : : /* If BUF is NULL, make STREAM unbuffered.
344 : : Else make it use SIZE bytes of BUF for buffering. */
345 : : extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
346 : : size_t __size) __THROW __nonnull ((1));
347 : :
348 : : /* Make STREAM line-buffered. */
349 : : extern void setlinebuf (FILE *__stream) __THROW __nonnull ((1));
350 : : #endif
351 : :
352 : :
353 : : /* Write formatted output to STREAM.
354 : :
355 : : This function is a possible cancellation point and therefore not
356 : : marked with __THROW. */
357 : : extern int fprintf (FILE *__restrict __stream,
358 : : const char *__restrict __format, ...) __nonnull ((1));
359 : : /* Write formatted output to stdout.
360 : :
361 : : This function is a possible cancellation point and therefore not
362 : : marked with __THROW. */
363 : 0 : extern int printf (const char *__restrict __format, ...);
364 : : /* Write formatted output to S. */
365 : : extern int sprintf (char *__restrict __s,
366 : : const char *__restrict __format, ...) __THROWNL;
367 : :
368 : : /* Write formatted output to S from argument list ARG.
369 : :
370 : : This function is a possible cancellation point and therefore not
371 : : marked with __THROW. */
372 : : extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
373 : : __gnuc_va_list __arg) __nonnull ((1));
374 : : /* Write formatted output to stdout from argument list ARG.
375 : :
376 : : This function is a possible cancellation point and therefore not
377 : : marked with __THROW. */
378 : : extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);
379 : : /* Write formatted output to S from argument list ARG. */
380 : : extern int vsprintf (char *__restrict __s, const char *__restrict __format,
381 : : __gnuc_va_list __arg) __THROWNL;
382 : :
383 : : #if defined __USE_ISOC99 || defined __USE_UNIX98
384 : : /* Maximum chars of output to write in MAXLEN. */
385 : 24 : extern int snprintf (char *__restrict __s, size_t __maxlen,
386 : : const char *__restrict __format, ...)
387 : : __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));
388 : :
389 : 24 : extern int vsnprintf (char *__restrict __s, size_t __maxlen,
390 : : const char *__restrict __format, __gnuc_va_list __arg)
391 : : __THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));
392 : : #endif
393 : :
394 : : #if defined (__USE_MISC) || __GLIBC_USE (LIB_EXT2)
395 : : /* Write formatted output to a string dynamically allocated with `malloc'.
396 : : Store the address of the string in *PTR. */
397 : : extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,
398 : : __gnuc_va_list __arg)
399 : : __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
400 : : extern int __asprintf (char **__restrict __ptr,
401 : : const char *__restrict __fmt, ...)
402 : : __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
403 : : extern int asprintf (char **__restrict __ptr,
404 : : const char *__restrict __fmt, ...)
405 : : __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
406 : : #endif
407 : :
408 : : #ifdef __USE_XOPEN2K8
409 : : /* Write formatted output to a file descriptor. */
410 : : extern int vdprintf (int __fd, const char *__restrict __fmt,
411 : : __gnuc_va_list __arg)
412 : : __attribute__ ((__format__ (__printf__, 2, 0)));
413 : : extern int dprintf (int __fd, const char *__restrict __fmt, ...)
414 : : __attribute__ ((__format__ (__printf__, 2, 3)));
415 : : #endif
416 : :
417 : :
418 : : /* Read formatted input from STREAM.
419 : :
420 : : This function is a possible cancellation point and therefore not
421 : : marked with __THROW. */
422 : : extern int fscanf (FILE *__restrict __stream,
423 : : const char *__restrict __format, ...) __wur __nonnull ((1));
424 : : /* Read formatted input from stdin.
425 : :
426 : : This function is a possible cancellation point and therefore not
427 : : marked with __THROW. */
428 : : extern int scanf (const char *__restrict __format, ...) __wur;
429 : : /* Read formatted input from S. */
430 : : extern int sscanf (const char *__restrict __s,
431 : : const char *__restrict __format, ...) __THROW;
432 : :
433 : : /* For historical reasons, the C99-compliant versions of the scanf
434 : : functions are at alternative names. When __LDBL_COMPAT or
435 : : __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI are in effect, this is handled in
436 : : bits/stdio-ldbl.h. */
437 : : #include <bits/floatn.h>
438 : : #if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \
439 : : && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
440 : : # if __GLIBC_USE (C23_STRTOL)
441 : : # ifdef __REDIRECT
442 : : extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
443 : : const char *__restrict __format, ...),
444 : : __isoc23_fscanf) __wur __nonnull ((1));
445 : : extern int __REDIRECT (scanf, (const char *__restrict __format, ...),
446 : : __isoc23_scanf) __wur;
447 : : extern int __REDIRECT_NTH (sscanf, (const char *__restrict __s,
448 : : const char *__restrict __format, ...),
449 : : __isoc23_sscanf);
450 : : # else
451 : : extern int __isoc23_fscanf (FILE *__restrict __stream,
452 : : const char *__restrict __format, ...) __wur
453 : : __nonnull ((1));
454 : : extern int __isoc23_scanf (const char *__restrict __format, ...) __wur;
455 : : extern int __isoc23_sscanf (const char *__restrict __s,
456 : : const char *__restrict __format, ...) __THROW;
457 : : # define fscanf __isoc23_fscanf
458 : : # define scanf __isoc23_scanf
459 : : # define sscanf __isoc23_sscanf
460 : : # endif
461 : : # else
462 : : # ifdef __REDIRECT
463 : : extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
464 : : const char *__restrict __format, ...),
465 : : __isoc99_fscanf) __wur __nonnull ((1));
466 : : extern int __REDIRECT (scanf, (const char *__restrict __format, ...),
467 : : __isoc99_scanf) __wur;
468 : : extern int __REDIRECT_NTH (sscanf, (const char *__restrict __s,
469 : : const char *__restrict __format, ...),
470 : : __isoc99_sscanf);
471 : : # else
472 : : extern int __isoc99_fscanf (FILE *__restrict __stream,
473 : : const char *__restrict __format, ...) __wur
474 : : __nonnull ((1));
475 : : extern int __isoc99_scanf (const char *__restrict __format, ...) __wur;
476 : : extern int __isoc99_sscanf (const char *__restrict __s,
477 : : const char *__restrict __format, ...) __THROW;
478 : : # define fscanf __isoc99_fscanf
479 : : # define scanf __isoc99_scanf
480 : : # define sscanf __isoc99_sscanf
481 : : # endif
482 : : # endif
483 : : #endif
484 : :
485 : : #ifdef __USE_ISOC99
486 : : /* Read formatted input from S into argument list ARG.
487 : :
488 : : This function is a possible cancellation point and therefore not
489 : : marked with __THROW. */
490 : : extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
491 : : __gnuc_va_list __arg)
492 : : __attribute__ ((__format__ (__scanf__, 2, 0))) __wur __nonnull ((1));
493 : :
494 : : /* Read formatted input from stdin into argument list ARG.
495 : :
496 : : This function is a possible cancellation point and therefore not
497 : : marked with __THROW. */
498 : : extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)
499 : : __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
500 : :
501 : : /* Read formatted input from S into argument list ARG. */
502 : : extern int vsscanf (const char *__restrict __s,
503 : : const char *__restrict __format, __gnuc_va_list __arg)
504 : : __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
505 : :
506 : : /* Same redirection as above for the v*scanf family. */
507 : : # if !__GLIBC_USE (DEPRECATED_SCANF)
508 : : # if __GLIBC_USE (C23_STRTOL)
509 : : # if defined __REDIRECT && !defined __LDBL_COMPAT \
510 : : && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
511 : : extern int __REDIRECT (vfscanf,
512 : : (FILE *__restrict __s,
513 : : const char *__restrict __format, __gnuc_va_list __arg),
514 : : __isoc23_vfscanf)
515 : : __attribute__ ((__format__ (__scanf__, 2, 0))) __wur __nonnull ((1));
516 : : extern int __REDIRECT (vscanf, (const char *__restrict __format,
517 : : __gnuc_va_list __arg), __isoc23_vscanf)
518 : : __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
519 : : extern int __REDIRECT_NTH (vsscanf,
520 : : (const char *__restrict __s,
521 : : const char *__restrict __format,
522 : : __gnuc_va_list __arg), __isoc23_vsscanf)
523 : : __attribute__ ((__format__ (__scanf__, 2, 0)));
524 : : # elif !defined __REDIRECT
525 : : extern int __isoc23_vfscanf (FILE *__restrict __s,
526 : : const char *__restrict __format,
527 : : __gnuc_va_list __arg) __wur __nonnull ((1));
528 : : extern int __isoc23_vscanf (const char *__restrict __format,
529 : : __gnuc_va_list __arg) __wur;
530 : : extern int __isoc23_vsscanf (const char *__restrict __s,
531 : : const char *__restrict __format,
532 : : __gnuc_va_list __arg) __THROW;
533 : : # define vfscanf __isoc23_vfscanf
534 : : # define vscanf __isoc23_vscanf
535 : : # define vsscanf __isoc23_vsscanf
536 : : # endif
537 : : # else
538 : : # if defined __REDIRECT && !defined __LDBL_COMPAT \
539 : : && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
540 : : extern int __REDIRECT (vfscanf,
541 : : (FILE *__restrict __s,
542 : : const char *__restrict __format, __gnuc_va_list __arg),
543 : : __isoc99_vfscanf)
544 : : __attribute__ ((__format__ (__scanf__, 2, 0))) __wur __nonnull ((1));
545 : : extern int __REDIRECT (vscanf, (const char *__restrict __format,
546 : : __gnuc_va_list __arg), __isoc99_vscanf)
547 : : __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
548 : : extern int __REDIRECT_NTH (vsscanf,
549 : : (const char *__restrict __s,
550 : : const char *__restrict __format,
551 : : __gnuc_va_list __arg), __isoc99_vsscanf)
552 : : __attribute__ ((__format__ (__scanf__, 2, 0)));
553 : : # elif !defined __REDIRECT
554 : : extern int __isoc99_vfscanf (FILE *__restrict __s,
555 : : const char *__restrict __format,
556 : : __gnuc_va_list __arg) __wur __nonnull ((1));
557 : : extern int __isoc99_vscanf (const char *__restrict __format,
558 : : __gnuc_va_list __arg) __wur;
559 : : extern int __isoc99_vsscanf (const char *__restrict __s,
560 : : const char *__restrict __format,
561 : : __gnuc_va_list __arg) __THROW;
562 : : # define vfscanf __isoc99_vfscanf
563 : : # define vscanf __isoc99_vscanf
564 : : # define vsscanf __isoc99_vsscanf
565 : : # endif
566 : : # endif
567 : : # endif
568 : : #endif /* Use ISO C9x. */
569 : :
570 : :
571 : : /* Read a character from STREAM.
572 : :
573 : : These functions are possible cancellation points and therefore not
574 : : marked with __THROW. */
575 : : extern int fgetc (FILE *__stream) __nonnull ((1));
576 : : extern int getc (FILE *__stream) __nonnull ((1));
577 : :
578 : : /* Read a character from stdin.
579 : :
580 : : This function is a possible cancellation point and therefore not
581 : : marked with __THROW. */
582 : : extern int getchar (void);
583 : :
584 : : #ifdef __USE_POSIX199506
585 : : /* These are defined in POSIX.1:1996.
586 : :
587 : : These functions are possible cancellation points and therefore not
588 : : marked with __THROW. */
589 : : extern int getc_unlocked (FILE *__stream) __nonnull ((1));
590 : : extern int getchar_unlocked (void);
591 : : #endif /* Use POSIX. */
592 : :
593 : : #ifdef __USE_MISC
594 : : /* Faster version when locking is not necessary.
595 : :
596 : : This function is not part of POSIX and therefore no official
597 : : cancellation point. But due to similarity with an POSIX interface
598 : : or due to the implementation it is a cancellation point and
599 : : therefore not marked with __THROW. */
600 : : extern int fgetc_unlocked (FILE *__stream) __nonnull ((1));
601 : : #endif /* Use MISC. */
602 : :
603 : :
604 : : /* Write a character to STREAM.
605 : :
606 : : These functions are possible cancellation points and therefore not
607 : : marked with __THROW.
608 : :
609 : : These functions is a possible cancellation point and therefore not
610 : : marked with __THROW. */
611 : : extern int fputc (int __c, FILE *__stream) __nonnull ((2));
612 : : extern int putc (int __c, FILE *__stream) __nonnull ((2));
613 : :
614 : : /* Write a character to stdout.
615 : :
616 : : This function is a possible cancellation point and therefore not
617 : : marked with __THROW. */
618 : : extern int putchar (int __c);
619 : :
620 : : #ifdef __USE_MISC
621 : : /* Faster version when locking is not necessary.
622 : :
623 : : This function is not part of POSIX and therefore no official
624 : : cancellation point. But due to similarity with an POSIX interface
625 : : or due to the implementation it is a cancellation point and
626 : : therefore not marked with __THROW. */
627 : : extern int fputc_unlocked (int __c, FILE *__stream) __nonnull ((2));
628 : : #endif /* Use MISC. */
629 : :
630 : : #ifdef __USE_POSIX199506
631 : : /* These are defined in POSIX.1:1996.
632 : :
633 : : These functions are possible cancellation points and therefore not
634 : : marked with __THROW. */
635 : : extern int putc_unlocked (int __c, FILE *__stream) __nonnull ((2));
636 : : extern int putchar_unlocked (int __c);
637 : : #endif /* Use POSIX. */
638 : :
639 : :
640 : : #if defined __USE_MISC \
641 : : || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
642 : : /* Get a word (int) from STREAM. */
643 : : extern int getw (FILE *__stream) __nonnull ((1));
644 : :
645 : : /* Write a word (int) to STREAM. */
646 : : extern int putw (int __w, FILE *__stream) __nonnull ((2));
647 : : #endif
648 : :
649 : :
650 : : /* Get a newline-terminated string of finite length from STREAM.
651 : :
652 : : This function is a possible cancellation point and therefore not
653 : : marked with __THROW. */
654 : : extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
655 : : __wur __fortified_attr_access (__write_only__, 1, 2) __nonnull ((3));
656 : :
657 : : #if __GLIBC_USE (DEPRECATED_GETS)
658 : : /* Get a newline-terminated string from stdin, removing the newline.
659 : :
660 : : This function is impossible to use safely. It has been officially
661 : : removed from ISO C11 and ISO C++14, and we have also removed it
662 : : from the _GNU_SOURCE feature list. It remains available when
663 : : explicitly using an old ISO C, Unix, or POSIX standard.
664 : :
665 : : This function is a possible cancellation point and therefore not
666 : : marked with __THROW. */
667 : : extern char *gets (char *__s) __wur __attribute_deprecated__;
668 : : #endif
669 : :
670 : : #ifdef __USE_GNU
671 : : /* This function does the same as `fgets' but does not lock the stream.
672 : :
673 : : This function is not part of POSIX and therefore no official
674 : : cancellation point. But due to similarity with an POSIX interface
675 : : or due to the implementation it is a cancellation point and
676 : : therefore not marked with __THROW. */
677 : : extern char *fgets_unlocked (char *__restrict __s, int __n,
678 : : FILE *__restrict __stream) __wur
679 : : __fortified_attr_access (__write_only__, 1, 2) __nonnull ((3));
680 : : #endif
681 : :
682 : :
683 : : #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
684 : : /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
685 : : (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
686 : : NULL), pointing to *N characters of space. It is realloc'd as
687 : : necessary. Returns the number of characters read (not including the
688 : : null terminator), or -1 on error or EOF. */
689 : : extern __ssize_t __getdelim (char **__restrict __lineptr,
690 : : size_t *__restrict __n, int __delimiter,
691 : : FILE *__restrict __stream) __wur __nonnull ((4));
692 : : extern __ssize_t getdelim (char **__restrict __lineptr,
693 : : size_t *__restrict __n, int __delimiter,
694 : : FILE *__restrict __stream) __wur __nonnull ((4));
695 : :
696 : : /* Like `getdelim', but reads up to a newline. */
697 : : extern __ssize_t getline (char **__restrict __lineptr,
698 : : size_t *__restrict __n,
699 : : FILE *__restrict __stream) __wur __nonnull ((3));
700 : : #endif
701 : :
702 : :
703 : : /* Write a string to STREAM.
704 : :
705 : : This function is a possible cancellation point and therefore not
706 : : marked with __THROW. */
707 : : extern int fputs (const char *__restrict __s, FILE *__restrict __stream)
708 : : __nonnull ((2));
709 : :
710 : : /* Write a string, followed by a newline, to stdout.
711 : :
712 : : This function is a possible cancellation point and therefore not
713 : : marked with __THROW. */
714 : 4 : extern int puts (const char *__s);
715 : :
716 : :
717 : : /* Push a character back onto the input buffer of STREAM.
718 : :
719 : : This function is a possible cancellation point and therefore not
720 : : marked with __THROW. */
721 : : extern int ungetc (int __c, FILE *__stream) __nonnull ((2));
722 : :
723 : :
724 : : /* Read chunks of generic data from STREAM.
725 : :
726 : : This function is a possible cancellation point and therefore not
727 : : marked with __THROW. */
728 : : extern size_t fread (void *__restrict __ptr, size_t __size,
729 : : size_t __n, FILE *__restrict __stream) __wur
730 : : __nonnull((4));
731 : : /* Write chunks of generic data to STREAM.
732 : :
733 : : This function is a possible cancellation point and therefore not
734 : : marked with __THROW. */
735 : : extern size_t fwrite (const void *__restrict __ptr, size_t __size,
736 : : size_t __n, FILE *__restrict __s) __nonnull((4));
737 : :
738 : : #ifdef __USE_GNU
739 : : /* This function does the same as `fputs' but does not lock the stream.
740 : :
741 : : This function is not part of POSIX and therefore no official
742 : : cancellation point. But due to similarity with an POSIX interface
743 : : or due to the implementation it is a cancellation point and
744 : : therefore not marked with __THROW. */
745 : : extern int fputs_unlocked (const char *__restrict __s,
746 : : FILE *__restrict __stream) __nonnull ((2));
747 : : #endif
748 : :
749 : : #ifdef __USE_MISC
750 : : /* Faster versions when locking is not necessary.
751 : :
752 : : These functions are not part of POSIX and therefore no official
753 : : cancellation point. But due to similarity with an POSIX interface
754 : : or due to the implementation they are cancellation points and
755 : : therefore not marked with __THROW. */
756 : : extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
757 : : size_t __n, FILE *__restrict __stream) __wur
758 : : __nonnull ((4));
759 : : extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
760 : : size_t __n, FILE *__restrict __stream)
761 : : __nonnull ((4));
762 : : #endif
763 : :
764 : :
765 : : /* Seek to a certain position on STREAM.
766 : :
767 : : This function is a possible cancellation point and therefore not
768 : : marked with __THROW. */
769 : : extern int fseek (FILE *__stream, long int __off, int __whence)
770 : : __nonnull ((1));
771 : : /* Return the current position of STREAM.
772 : :
773 : : This function is a possible cancellation point and therefore not
774 : : marked with __THROW. */
775 : : extern long int ftell (FILE *__stream) __wur __nonnull ((1));
776 : : /* Rewind to the beginning of STREAM.
777 : :
778 : : This function is a possible cancellation point and therefore not
779 : : marked with __THROW. */
780 : : extern void rewind (FILE *__stream) __nonnull ((1));
781 : :
782 : : /* The Single Unix Specification, Version 2, specifies an alternative,
783 : : more adequate interface for the two functions above which deal with
784 : : file offset. `long int' is not the right type. These definitions
785 : : are originally defined in the Large File Support API. */
786 : :
787 : : #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
788 : : # ifndef __USE_FILE_OFFSET64
789 : : /* Seek to a certain position on STREAM.
790 : :
791 : : This function is a possible cancellation point and therefore not
792 : : marked with __THROW. */
793 : : extern int fseeko (FILE *__stream, __off_t __off, int __whence)
794 : : __nonnull ((1));
795 : : /* Return the current position of STREAM.
796 : :
797 : : This function is a possible cancellation point and therefore not
798 : : marked with __THROW. */
799 : : extern __off_t ftello (FILE *__stream) __wur __nonnull ((1));
800 : : # else
801 : : # ifdef __REDIRECT
802 : : extern int __REDIRECT (fseeko,
803 : : (FILE *__stream, __off64_t __off, int __whence),
804 : : fseeko64) __nonnull ((1));
805 : : extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64)
806 : : __nonnull ((1));
807 : : # else
808 : : # define fseeko fseeko64
809 : : # define ftello ftello64
810 : : # endif
811 : : # endif
812 : : #endif
813 : :
814 : : #ifndef __USE_FILE_OFFSET64
815 : : /* Get STREAM's position.
816 : :
817 : : This function is a possible cancellation point and therefore not
818 : : marked with __THROW. */
819 : : extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos)
820 : : __nonnull ((1));
821 : : /* Set STREAM's position.
822 : :
823 : : This function is a possible cancellation point and therefore not
824 : : marked with __THROW. */
825 : : extern int fsetpos (FILE *__stream, const fpos_t *__pos) __nonnull ((1));
826 : : #else
827 : : # ifdef __REDIRECT
828 : : extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
829 : : fpos_t *__restrict __pos), fgetpos64)
830 : : __nonnull ((1));
831 : : extern int __REDIRECT (fsetpos,
832 : : (FILE *__stream, const fpos_t *__pos), fsetpos64)
833 : : __nonnull ((1));
834 : : # else
835 : : # define fgetpos fgetpos64
836 : : # define fsetpos fsetpos64
837 : : # endif
838 : : #endif
839 : :
840 : : #ifdef __USE_LARGEFILE64
841 : : extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence)
842 : : __nonnull ((1));
843 : : extern __off64_t ftello64 (FILE *__stream) __wur __nonnull ((1));
844 : : extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos)
845 : : __nonnull ((1));
846 : : extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos) __nonnull ((1));
847 : : #endif
848 : :
849 : : /* Clear the error and EOF indicators for STREAM. */
850 : : extern void clearerr (FILE *__stream) __THROW __nonnull ((1));
851 : : /* Return the EOF indicator for STREAM. */
852 : : extern int feof (FILE *__stream) __THROW __wur __nonnull ((1));
853 : : /* Return the error indicator for STREAM. */
854 : : extern int ferror (FILE *__stream) __THROW __wur __nonnull ((1));
855 : :
856 : : #ifdef __USE_MISC
857 : : /* Faster versions when locking is not required. */
858 : : extern void clearerr_unlocked (FILE *__stream) __THROW __nonnull ((1));
859 : : extern int feof_unlocked (FILE *__stream) __THROW __wur __nonnull ((1));
860 : : extern int ferror_unlocked (FILE *__stream) __THROW __wur __nonnull ((1));
861 : : #endif
862 : :
863 : :
864 : : /* Print a message describing the meaning of the value of errno.
865 : :
866 : : This function is a possible cancellation point and therefore not
867 : : marked with __THROW. */
868 : : extern void perror (const char *__s) __COLD;
869 : :
870 : :
871 : : #ifdef __USE_POSIX
872 : : /* Return the system file descriptor for STREAM. */
873 : : extern int fileno (FILE *__stream) __THROW __wur __nonnull ((1));
874 : : #endif /* Use POSIX. */
875 : :
876 : : #ifdef __USE_MISC
877 : : /* Faster version when locking is not required. */
878 : : extern int fileno_unlocked (FILE *__stream) __THROW __wur __nonnull ((1));
879 : : #endif
880 : :
881 : :
882 : : #ifdef __USE_POSIX2
883 : : /* Close a stream opened by popen and return the status of its child.
884 : :
885 : : This function is a possible cancellation point and therefore not
886 : : marked with __THROW. */
887 : : extern int pclose (FILE *__stream) __nonnull ((1));
888 : :
889 : : /* Create a new stream connected to a pipe running the given command.
890 : :
891 : : This function is a possible cancellation point and therefore not
892 : : marked with __THROW. */
893 : : extern FILE *popen (const char *__command, const char *__modes)
894 : : __attribute_malloc__ __attr_dealloc (pclose, 1) __wur;
895 : :
896 : : #endif
897 : :
898 : :
899 : : #ifdef __USE_POSIX
900 : : /* Return the name of the controlling terminal. */
901 : : extern char *ctermid (char *__s) __THROW
902 : : __attr_access ((__write_only__, 1));
903 : : #endif /* Use POSIX. */
904 : :
905 : :
906 : : #if (defined __USE_XOPEN && !defined __USE_XOPEN2K) || defined __USE_GNU
907 : : /* Return the name of the current user. */
908 : : extern char *cuserid (char *__s)
909 : : __attr_access ((__write_only__, 1));
910 : : #endif /* Use X/Open, but not issue 6. */
911 : :
912 : :
913 : : #ifdef __USE_GNU
914 : : struct obstack; /* See <obstack.h>. */
915 : :
916 : : /* Write formatted output to an obstack. */
917 : : extern int obstack_printf (struct obstack *__restrict __obstack,
918 : : const char *__restrict __format, ...)
919 : : __THROWNL __attribute__ ((__format__ (__printf__, 2, 3)));
920 : : extern int obstack_vprintf (struct obstack *__restrict __obstack,
921 : : const char *__restrict __format,
922 : : __gnuc_va_list __args)
923 : : __THROWNL __attribute__ ((__format__ (__printf__, 2, 0)));
924 : : #endif /* Use GNU. */
925 : :
926 : :
927 : : #ifdef __USE_POSIX199506
928 : : /* These are defined in POSIX.1:1996. */
929 : :
930 : : /* Acquire ownership of STREAM. */
931 : : extern void flockfile (FILE *__stream) __THROW __nonnull ((1));
932 : :
933 : : /* Try to acquire ownership of STREAM but do not block if it is not
934 : : possible. */
935 : : extern int ftrylockfile (FILE *__stream) __THROW __wur __nonnull ((1));
936 : :
937 : : /* Relinquish the ownership granted for STREAM. */
938 : : extern void funlockfile (FILE *__stream) __THROW __nonnull ((1));
939 : : #endif /* POSIX */
940 : :
941 : : #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
942 : : /* X/Open Issues 1-5 required getopt to be declared in this
943 : : header. It was removed in Issue 6. GNU follows Issue 6. */
944 : : # include <bits/getopt_posix.h>
945 : : #endif
946 : :
947 : : /* Slow-path routines used by the optimized inline functions in
948 : : bits/stdio.h. */
949 : : extern int __uflow (FILE *);
950 : : extern int __overflow (FILE *, int);
951 : :
952 : : #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
953 : : /* Declare all functions from bits/stdio2-decl.h first. */
954 : : # include <bits/stdio2-decl.h>
955 : : #endif
956 : :
957 : : /* The following headers provide asm redirections. These redirections must
958 : : appear before the first usage of these functions, e.g. in bits/stdio.h. */
959 : : #if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
960 : : # include <bits/stdio-ldbl.h>
961 : : #endif
962 : :
963 : : /* If we are compiling with optimizing read this file. It contains
964 : : several optimizing inline functions and macros. */
965 : : #ifdef __USE_EXTERN_INLINES
966 : : # include <bits/stdio.h>
967 : : #endif
968 : : #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
969 : : /* Now include the function definitions and redirects too. */
970 : : # include <bits/stdio2.h>
971 : : #endif
972 : :
973 : : __END_DECLS
974 : :
975 : : #endif /* <stdio.h> included. */
|