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