Makeconfig: sandwich gnulib-tests between libc/ld linking of tests
[glibc.git] / libio / stdio.h
blob18e29752c4289cd8e9ce55d7138c7df8fd818482
1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991-2020 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 /* Create a temporary file and open it read/write.
170 This function is a possible cancellation point and therefore not
171 marked with __THROW. */
172 #ifndef __USE_FILE_OFFSET64
173 extern FILE *tmpfile (void) __wur;
174 #else
175 # ifdef __REDIRECT
176 extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;
177 # else
178 # define tmpfile tmpfile64
179 # endif
180 #endif
182 #ifdef __USE_LARGEFILE64
183 extern FILE *tmpfile64 (void) __wur;
184 #endif
186 /* Generate a temporary filename. */
187 extern char *tmpnam (char *__s) __THROW __wur;
189 #ifdef __USE_MISC
190 /* This is the reentrant variant of `tmpnam'. The only difference is
191 that it does not allow S to be NULL. */
192 extern char *tmpnam_r (char *__s) __THROW __wur;
193 #endif
196 #if defined __USE_MISC || defined __USE_XOPEN
197 /* Generate a unique temporary filename using up to five characters of PFX
198 if it is not NULL. The directory to put this file in is searched for
199 as follows: First the environment variable "TMPDIR" is checked.
200 If it contains the name of a writable directory, that directory is used.
201 If not and if DIR is not NULL, that value is checked. If that fails,
202 P_tmpdir is tried and finally "/tmp". The storage for the filename
203 is allocated by `malloc'. */
204 extern char *tempnam (const char *__dir, const char *__pfx)
205 __THROW __attribute_malloc__ __wur;
206 #endif
209 /* Close STREAM.
211 This function is a possible cancellation point and therefore not
212 marked with __THROW. */
213 extern int fclose (FILE *__stream);
214 /* Flush STREAM, or all streams if STREAM is NULL.
216 This function is a possible cancellation point and therefore not
217 marked with __THROW. */
218 extern int fflush (FILE *__stream);
220 #ifdef __USE_MISC
221 /* Faster versions when locking is not required.
223 This function is not part of POSIX and therefore no official
224 cancellation point. But due to similarity with an POSIX interface
225 or due to the implementation it is a cancellation point and
226 therefore not marked with __THROW. */
227 extern int fflush_unlocked (FILE *__stream);
228 #endif
230 #ifdef __USE_GNU
231 /* Close all streams.
233 This function is not part of POSIX and therefore no official
234 cancellation point. But due to similarity with an POSIX interface
235 or due to the implementation it is a cancellation point and
236 therefore not marked with __THROW. */
237 extern int fcloseall (void);
238 #endif
241 #ifndef __USE_FILE_OFFSET64
242 /* Open a file and create a new stream for it.
244 This function is a possible cancellation point and therefore not
245 marked with __THROW. */
246 extern FILE *fopen (const char *__restrict __filename,
247 const char *__restrict __modes) __wur;
248 /* Open a file, replacing an existing stream with it.
250 This function is a possible cancellation point and therefore not
251 marked with __THROW. */
252 extern FILE *freopen (const char *__restrict __filename,
253 const char *__restrict __modes,
254 FILE *__restrict __stream) __wur;
255 #else
256 # ifdef __REDIRECT
257 extern FILE *__REDIRECT (fopen, (const char *__restrict __filename,
258 const char *__restrict __modes), fopen64)
259 __wur;
260 extern FILE *__REDIRECT (freopen, (const char *__restrict __filename,
261 const char *__restrict __modes,
262 FILE *__restrict __stream), freopen64)
263 __wur;
264 # else
265 # define fopen fopen64
266 # define freopen freopen64
267 # endif
268 #endif
269 #ifdef __USE_LARGEFILE64
270 extern FILE *fopen64 (const char *__restrict __filename,
271 const char *__restrict __modes) __wur;
272 extern FILE *freopen64 (const char *__restrict __filename,
273 const char *__restrict __modes,
274 FILE *__restrict __stream) __wur;
275 #endif
277 #ifdef __USE_POSIX
278 /* Create a new stream that refers to an existing system file descriptor. */
279 extern FILE *fdopen (int __fd, const char *__modes) __THROW __wur;
280 #endif
282 #ifdef __USE_GNU
283 /* Create a new stream that refers to the given magic cookie,
284 and uses the given functions for input and output. */
285 extern FILE *fopencookie (void *__restrict __magic_cookie,
286 const char *__restrict __modes,
287 cookie_io_functions_t __io_funcs) __THROW __wur;
288 #endif
290 #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
291 /* Create a new stream that refers to a memory buffer. */
292 extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
293 __THROW __wur;
295 /* Open a stream that writes into a malloc'd buffer that is expanded as
296 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
297 and the number of characters written on fflush or fclose. */
298 extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;
299 #endif
302 /* If BUF is NULL, make STREAM unbuffered.
303 Else make it use buffer BUF, of size BUFSIZ. */
304 extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
305 /* Make STREAM use buffering mode MODE.
306 If BUF is not NULL, use N bytes of it for buffering;
307 else allocate an internal buffer N bytes long. */
308 extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
309 int __modes, size_t __n) __THROW;
311 #ifdef __USE_MISC
312 /* If BUF is NULL, make STREAM unbuffered.
313 Else make it use SIZE bytes of BUF for buffering. */
314 extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
315 size_t __size) __THROW;
317 /* Make STREAM line-buffered. */
318 extern void setlinebuf (FILE *__stream) __THROW;
319 #endif
322 /* Write formatted output to STREAM.
324 This function is a possible cancellation point and therefore not
325 marked with __THROW. */
326 extern int fprintf (FILE *__restrict __stream,
327 const char *__restrict __format, ...);
328 /* Write formatted output to stdout.
330 This function is a possible cancellation point and therefore not
331 marked with __THROW. */
332 extern int printf (const char *__restrict __format, ...);
333 /* Write formatted output to S. */
334 extern int sprintf (char *__restrict __s,
335 const char *__restrict __format, ...) __THROWNL;
337 /* Write formatted output to S from argument list ARG.
339 This function is a possible cancellation point and therefore not
340 marked with __THROW. */
341 extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
342 __gnuc_va_list __arg);
343 /* Write formatted output to stdout from argument list ARG.
345 This function is a possible cancellation point and therefore not
346 marked with __THROW. */
347 extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);
348 /* Write formatted output to S from argument list ARG. */
349 extern int vsprintf (char *__restrict __s, const char *__restrict __format,
350 __gnuc_va_list __arg) __THROWNL;
352 #if defined __USE_ISOC99 || defined __USE_UNIX98
353 /* Maximum chars of output to write in MAXLEN. */
354 extern int snprintf (char *__restrict __s, size_t __maxlen,
355 const char *__restrict __format, ...)
356 __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));
358 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
359 const char *__restrict __format, __gnuc_va_list __arg)
360 __THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));
361 #endif
363 #if __GLIBC_USE (LIB_EXT2)
364 /* Write formatted output to a string dynamically allocated with `malloc'.
365 Store the address of the string in *PTR. */
366 extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,
367 __gnuc_va_list __arg)
368 __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
369 extern int __asprintf (char **__restrict __ptr,
370 const char *__restrict __fmt, ...)
371 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
372 extern int asprintf (char **__restrict __ptr,
373 const char *__restrict __fmt, ...)
374 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
375 #endif
377 #ifdef __USE_XOPEN2K8
378 /* Write formatted output to a file descriptor. */
379 extern int vdprintf (int __fd, const char *__restrict __fmt,
380 __gnuc_va_list __arg)
381 __attribute__ ((__format__ (__printf__, 2, 0)));
382 extern int dprintf (int __fd, const char *__restrict __fmt, ...)
383 __attribute__ ((__format__ (__printf__, 2, 3)));
384 #endif
387 /* Read formatted input from STREAM.
389 This function is a possible cancellation point and therefore not
390 marked with __THROW. */
391 extern int fscanf (FILE *__restrict __stream,
392 const char *__restrict __format, ...) __wur;
393 /* Read formatted input from stdin.
395 This function is a possible cancellation point and therefore not
396 marked with __THROW. */
397 extern int scanf (const char *__restrict __format, ...) __wur;
398 /* Read formatted input from S. */
399 extern int sscanf (const char *__restrict __s,
400 const char *__restrict __format, ...) __THROW;
402 /* For historical reasons, the C99-compliant versions of the scanf
403 functions are at alternative names. When __LDBL_COMPAT or
404 __LONG_DOUBLE_USES_FLOAT128 are in effect, this is handled in
405 bits/stdio-ldbl.h. */
406 #include <bits/floatn.h>
407 #if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \
408 && __LONG_DOUBLE_USES_FLOAT128 == 0
409 # ifdef __REDIRECT
410 extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
411 const char *__restrict __format, ...),
412 __isoc99_fscanf) __wur;
413 extern int __REDIRECT (scanf, (const char *__restrict __format, ...),
414 __isoc99_scanf) __wur;
415 extern int __REDIRECT_NTH (sscanf, (const char *__restrict __s,
416 const char *__restrict __format, ...),
417 __isoc99_sscanf);
418 # else
419 extern int __isoc99_fscanf (FILE *__restrict __stream,
420 const char *__restrict __format, ...) __wur;
421 extern int __isoc99_scanf (const char *__restrict __format, ...) __wur;
422 extern int __isoc99_sscanf (const char *__restrict __s,
423 const char *__restrict __format, ...) __THROW;
424 # define fscanf __isoc99_fscanf
425 # define scanf __isoc99_scanf
426 # define sscanf __isoc99_sscanf
427 # endif
428 #endif
430 #ifdef __USE_ISOC99
431 /* Read formatted input from S into argument list ARG.
433 This function is a possible cancellation point and therefore not
434 marked with __THROW. */
435 extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
436 __gnuc_va_list __arg)
437 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
439 /* Read formatted input from stdin into argument list ARG.
441 This function is a possible cancellation point and therefore not
442 marked with __THROW. */
443 extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)
444 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
446 /* Read formatted input from S into argument list ARG. */
447 extern int vsscanf (const char *__restrict __s,
448 const char *__restrict __format, __gnuc_va_list __arg)
449 __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
451 /* Same redirection as above for the v*scanf family. */
452 # if !__GLIBC_USE (DEPRECATED_SCANF)
453 # if defined __REDIRECT && !defined __LDBL_COMPAT \
454 && __LONG_DOUBLE_USES_FLOAT128 == 0
455 extern int __REDIRECT (vfscanf,
456 (FILE *__restrict __s,
457 const char *__restrict __format, __gnuc_va_list __arg),
458 __isoc99_vfscanf)
459 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
460 extern int __REDIRECT (vscanf, (const char *__restrict __format,
461 __gnuc_va_list __arg), __isoc99_vscanf)
462 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
463 extern int __REDIRECT_NTH (vsscanf,
464 (const char *__restrict __s,
465 const char *__restrict __format,
466 __gnuc_va_list __arg), __isoc99_vsscanf)
467 __attribute__ ((__format__ (__scanf__, 2, 0)));
468 # elif !defined __REDIRECT
469 extern int __isoc99_vfscanf (FILE *__restrict __s,
470 const char *__restrict __format,
471 __gnuc_va_list __arg) __wur;
472 extern int __isoc99_vscanf (const char *__restrict __format,
473 __gnuc_va_list __arg) __wur;
474 extern int __isoc99_vsscanf (const char *__restrict __s,
475 const char *__restrict __format,
476 __gnuc_va_list __arg) __THROW;
477 # define vfscanf __isoc99_vfscanf
478 # define vscanf __isoc99_vscanf
479 # define vsscanf __isoc99_vsscanf
480 # endif
481 # endif
482 #endif /* Use ISO C9x. */
485 /* Read a character from STREAM.
487 These functions are possible cancellation points and therefore not
488 marked with __THROW. */
489 extern int fgetc (FILE *__stream);
490 extern int getc (FILE *__stream);
492 /* Read a character from stdin.
494 This function is a possible cancellation point and therefore not
495 marked with __THROW. */
496 extern int getchar (void);
498 #ifdef __USE_POSIX199506
499 /* These are defined in POSIX.1:1996.
501 These functions are possible cancellation points and therefore not
502 marked with __THROW. */
503 extern int getc_unlocked (FILE *__stream);
504 extern int getchar_unlocked (void);
505 #endif /* Use POSIX. */
507 #ifdef __USE_MISC
508 /* Faster version when locking is not necessary.
510 This function is not part of POSIX and therefore no official
511 cancellation point. But due to similarity with an POSIX interface
512 or due to the implementation it is a cancellation point and
513 therefore not marked with __THROW. */
514 extern int fgetc_unlocked (FILE *__stream);
515 #endif /* Use MISC. */
518 /* Write a character to STREAM.
520 These functions are possible cancellation points and therefore not
521 marked with __THROW.
523 These functions is a possible cancellation point and therefore not
524 marked with __THROW. */
525 extern int fputc (int __c, FILE *__stream);
526 extern int putc (int __c, FILE *__stream);
528 /* Write a character to stdout.
530 This function is a possible cancellation point and therefore not
531 marked with __THROW. */
532 extern int putchar (int __c);
534 #ifdef __USE_MISC
535 /* Faster version when locking is not necessary.
537 This function is not part of POSIX and therefore no official
538 cancellation point. But due to similarity with an POSIX interface
539 or due to the implementation it is a cancellation point and
540 therefore not marked with __THROW. */
541 extern int fputc_unlocked (int __c, FILE *__stream);
542 #endif /* Use MISC. */
544 #ifdef __USE_POSIX199506
545 /* These are defined in POSIX.1:1996.
547 These functions are possible cancellation points and therefore not
548 marked with __THROW. */
549 extern int putc_unlocked (int __c, FILE *__stream);
550 extern int putchar_unlocked (int __c);
551 #endif /* Use POSIX. */
554 #if defined __USE_MISC \
555 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
556 /* Get a word (int) from STREAM. */
557 extern int getw (FILE *__stream);
559 /* Write a word (int) to STREAM. */
560 extern int putw (int __w, FILE *__stream);
561 #endif
564 /* Get a newline-terminated string of finite length from STREAM.
566 This function is a possible cancellation point and therefore not
567 marked with __THROW. */
568 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
569 __wur;
571 #if __GLIBC_USE (DEPRECATED_GETS)
572 /* Get a newline-terminated string from stdin, removing the newline.
574 This function is impossible to use safely. It has been officially
575 removed from ISO C11 and ISO C++14, and we have also removed it
576 from the _GNU_SOURCE feature list. It remains available when
577 explicitly using an old ISO C, Unix, or POSIX standard.
579 This function is a possible cancellation point and therefore not
580 marked with __THROW. */
581 extern char *gets (char *__s) __wur __attribute_deprecated__;
582 #endif
584 #ifdef __USE_GNU
585 /* This function does the same as `fgets' but does not lock the stream.
587 This function is not part of POSIX and therefore no official
588 cancellation point. But due to similarity with an POSIX interface
589 or due to the implementation it is a cancellation point and
590 therefore not marked with __THROW. */
591 extern char *fgets_unlocked (char *__restrict __s, int __n,
592 FILE *__restrict __stream) __wur;
593 #endif
596 #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
597 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
598 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
599 NULL), pointing to *N characters of space. It is realloc'd as
600 necessary. Returns the number of characters read (not including the
601 null terminator), or -1 on error or EOF.
603 These functions are 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 they are cancellation points and
606 therefore not marked with __THROW. */
607 extern __ssize_t __getdelim (char **__restrict __lineptr,
608 size_t *__restrict __n, int __delimiter,
609 FILE *__restrict __stream) __wur;
610 extern __ssize_t getdelim (char **__restrict __lineptr,
611 size_t *__restrict __n, int __delimiter,
612 FILE *__restrict __stream) __wur;
614 /* Like `getdelim', but reads up to a newline.
616 This function is not part of POSIX and therefore no official
617 cancellation point. But due to similarity with an POSIX interface
618 or due to the implementation it is a cancellation point and
619 therefore not marked with __THROW. */
620 extern __ssize_t getline (char **__restrict __lineptr,
621 size_t *__restrict __n,
622 FILE *__restrict __stream) __wur;
623 #endif
626 /* Write a string to STREAM.
628 This function is a possible cancellation point and therefore not
629 marked with __THROW. */
630 extern int fputs (const char *__restrict __s, FILE *__restrict __stream);
632 /* Write a string, followed by a newline, to stdout.
634 This function is a possible cancellation point and therefore not
635 marked with __THROW. */
636 extern int puts (const char *__s);
639 /* Push a character back onto the input buffer of STREAM.
641 This function is a possible cancellation point and therefore not
642 marked with __THROW. */
643 extern int ungetc (int __c, FILE *__stream);
646 /* Read chunks of generic data from STREAM.
648 This function is a possible cancellation point and therefore not
649 marked with __THROW. */
650 extern size_t fread (void *__restrict __ptr, size_t __size,
651 size_t __n, FILE *__restrict __stream) __wur;
652 /* Write chunks of generic data to STREAM.
654 This function is a possible cancellation point and therefore not
655 marked with __THROW. */
656 extern size_t fwrite (const void *__restrict __ptr, size_t __size,
657 size_t __n, FILE *__restrict __s);
659 #ifdef __USE_GNU
660 /* This function does the same as `fputs' but does not lock the stream.
662 This function is not part of POSIX and therefore no official
663 cancellation point. But due to similarity with an POSIX interface
664 or due to the implementation it is a cancellation point and
665 therefore not marked with __THROW. */
666 extern int fputs_unlocked (const char *__restrict __s,
667 FILE *__restrict __stream);
668 #endif
670 #ifdef __USE_MISC
671 /* Faster versions when locking is not necessary.
673 These functions are not part of POSIX and therefore no official
674 cancellation point. But due to similarity with an POSIX interface
675 or due to the implementation they are cancellation points and
676 therefore not marked with __THROW. */
677 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
678 size_t __n, FILE *__restrict __stream) __wur;
679 extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
680 size_t __n, FILE *__restrict __stream);
681 #endif
684 /* Seek to a certain position on STREAM.
686 This function is a possible cancellation point and therefore not
687 marked with __THROW. */
688 extern int fseek (FILE *__stream, long int __off, int __whence);
689 /* Return the current position of STREAM.
691 This function is a possible cancellation point and therefore not
692 marked with __THROW. */
693 extern long int ftell (FILE *__stream) __wur;
694 /* Rewind to the beginning of STREAM.
696 This function is a possible cancellation point and therefore not
697 marked with __THROW. */
698 extern void rewind (FILE *__stream);
700 /* The Single Unix Specification, Version 2, specifies an alternative,
701 more adequate interface for the two functions above which deal with
702 file offset. `long int' is not the right type. These definitions
703 are originally defined in the Large File Support API. */
705 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
706 # ifndef __USE_FILE_OFFSET64
707 /* Seek to a certain position on STREAM.
709 This function is a possible cancellation point and therefore not
710 marked with __THROW. */
711 extern int fseeko (FILE *__stream, __off_t __off, int __whence);
712 /* Return the current position of STREAM.
714 This function is a possible cancellation point and therefore not
715 marked with __THROW. */
716 extern __off_t ftello (FILE *__stream) __wur;
717 # else
718 # ifdef __REDIRECT
719 extern int __REDIRECT (fseeko,
720 (FILE *__stream, __off64_t __off, int __whence),
721 fseeko64);
722 extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
723 # else
724 # define fseeko fseeko64
725 # define ftello ftello64
726 # endif
727 # endif
728 #endif
730 #ifndef __USE_FILE_OFFSET64
731 /* Get STREAM's position.
733 This function is a possible cancellation point and therefore not
734 marked with __THROW. */
735 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
736 /* Set STREAM's position.
738 This function is a possible cancellation point and therefore not
739 marked with __THROW. */
740 extern int fsetpos (FILE *__stream, const fpos_t *__pos);
741 #else
742 # ifdef __REDIRECT
743 extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
744 fpos_t *__restrict __pos), fgetpos64);
745 extern int __REDIRECT (fsetpos,
746 (FILE *__stream, const fpos_t *__pos), fsetpos64);
747 # else
748 # define fgetpos fgetpos64
749 # define fsetpos fsetpos64
750 # endif
751 #endif
753 #ifdef __USE_LARGEFILE64
754 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
755 extern __off64_t ftello64 (FILE *__stream) __wur;
756 extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
757 extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos);
758 #endif
760 /* Clear the error and EOF indicators for STREAM. */
761 extern void clearerr (FILE *__stream) __THROW;
762 /* Return the EOF indicator for STREAM. */
763 extern int feof (FILE *__stream) __THROW __wur;
764 /* Return the error indicator for STREAM. */
765 extern int ferror (FILE *__stream) __THROW __wur;
767 #ifdef __USE_MISC
768 /* Faster versions when locking is not required. */
769 extern void clearerr_unlocked (FILE *__stream) __THROW;
770 extern int feof_unlocked (FILE *__stream) __THROW __wur;
771 extern int ferror_unlocked (FILE *__stream) __THROW __wur;
772 #endif
775 /* Print a message describing the meaning of the value of errno.
777 This function is a possible cancellation point and therefore not
778 marked with __THROW. */
779 extern void perror (const char *__s);
781 /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
782 are available on this system. Even if available, these variables
783 should not be used directly. The `strerror' function provides
784 all the necessary functionality. */
785 #include <bits/sys_errlist.h>
788 #ifdef __USE_POSIX
789 /* Return the system file descriptor for STREAM. */
790 extern int fileno (FILE *__stream) __THROW __wur;
791 #endif /* Use POSIX. */
793 #ifdef __USE_MISC
794 /* Faster version when locking is not required. */
795 extern int fileno_unlocked (FILE *__stream) __THROW __wur;
796 #endif
799 #ifdef __USE_POSIX2
800 /* Create a new stream connected to a pipe running the given command.
802 This function is a possible cancellation point and therefore not
803 marked with __THROW. */
804 extern FILE *popen (const char *__command, const char *__modes) __wur;
806 /* Close a stream opened by popen and return the status of its child.
808 This function is a possible cancellation point and therefore not
809 marked with __THROW. */
810 extern int pclose (FILE *__stream);
811 #endif
814 #ifdef __USE_POSIX
815 /* Return the name of the controlling terminal. */
816 extern char *ctermid (char *__s) __THROW;
817 #endif /* Use POSIX. */
820 #if (defined __USE_XOPEN && !defined __USE_XOPEN2K) || defined __USE_GNU
821 /* Return the name of the current user. */
822 extern char *cuserid (char *__s);
823 #endif /* Use X/Open, but not issue 6. */
826 #ifdef __USE_GNU
827 struct obstack; /* See <obstack.h>. */
829 /* Write formatted output to an obstack. */
830 extern int obstack_printf (struct obstack *__restrict __obstack,
831 const char *__restrict __format, ...)
832 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3)));
833 extern int obstack_vprintf (struct obstack *__restrict __obstack,
834 const char *__restrict __format,
835 __gnuc_va_list __args)
836 __THROWNL __attribute__ ((__format__ (__printf__, 2, 0)));
837 #endif /* Use GNU. */
840 #ifdef __USE_POSIX199506
841 /* These are defined in POSIX.1:1996. */
843 /* Acquire ownership of STREAM. */
844 extern void flockfile (FILE *__stream) __THROW;
846 /* Try to acquire ownership of STREAM but do not block if it is not
847 possible. */
848 extern int ftrylockfile (FILE *__stream) __THROW __wur;
850 /* Relinquish the ownership granted for STREAM. */
851 extern void funlockfile (FILE *__stream) __THROW;
852 #endif /* POSIX */
854 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
855 /* X/Open Issues 1-5 required getopt to be declared in this
856 header. It was removed in Issue 6. GNU follows Issue 6. */
857 # include <bits/getopt_posix.h>
858 #endif
860 /* Slow-path routines used by the optimized inline functions in
861 bits/stdio.h. */
862 extern int __uflow (FILE *);
863 extern int __overflow (FILE *, int);
865 /* If we are compiling with optimizing read this file. It contains
866 several optimizing inline functions and macros. */
867 #ifdef __USE_EXTERN_INLINES
868 # include <bits/stdio.h>
869 #endif
870 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
871 # include <bits/stdio2.h>
872 #endif
874 #include <bits/floatn.h>
875 #if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
876 # include <bits/stdio-ldbl.h>
877 #endif
879 __END_DECLS
881 #endif /* <stdio.h> included. */