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