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