1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991, 1994-2011, 2012 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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 * ISO C99 Standard: 7.19 Input/output <stdio.h>
26 #if !defined __need_FILE && !defined __need___FILE
28 # include <features.h>
32 # define __need_size_t
36 # include <bits/types.h>
38 # define __need___FILE
39 #endif /* Don't need FILE. */
42 #if !defined __FILE_defined && defined __need_FILE
44 /* Define outside of namespace so the C++ is happy. */
48 /* The opaque type of streams. This is the definition used elsewhere. */
49 typedef struct _IO_FILE FILE;
51 #if defined __USE_LARGEFILE64 || defined __USE_SVID || defined __USE_POSIX \
52 || defined __USE_BSD || defined __USE_ISOC99 || defined __USE_XOPEN \
53 || defined __USE_POSIX2
54 __USING_NAMESPACE_STD(FILE)
57 # define __FILE_defined 1
58 #endif /* FILE not defined. */
62 #if !defined ____FILE_defined && defined __need___FILE
64 /* The opaque type of streams. This is the definition used elsewhere. */
65 typedef struct _IO_FILE __FILE;
67 # define ____FILE_defined 1
68 #endif /* __FILE not defined. */
73 #define _STDIO_USES_IOSTREAM
77 #if defined __USE_XOPEN || defined __USE_XOPEN2K8
79 # ifndef _VA_LIST_DEFINED
80 typedef _G_va_list va_list;
81 # define _VA_LIST_DEFINED
89 # ifndef __off_t_defined
90 # ifndef __USE_FILE_OFFSET64
91 typedef __off_t off_t;
93 typedef __off64_t off_t;
95 # define __off_t_defined
97 # if defined __USE_LARGEFILE64 && !defined __off64_t_defined
98 typedef __off64_t off64_t;
99 # define __off64_t_defined
102 # ifndef __ssize_t_defined
103 typedef __ssize_t ssize_t;
104 # define __ssize_t_defined
108 /* The type of the second argument to `fgetpos' and `fsetpos'. */
109 __BEGIN_NAMESPACE_STD
110 #ifndef __USE_FILE_OFFSET64
111 typedef _G_fpos_t fpos_t;
113 typedef _G_fpos64_t fpos_t;
116 #ifdef __USE_LARGEFILE64
117 typedef _G_fpos64_t fpos64_t;
120 /* The possibilities for the third argument to `setvbuf'. */
121 #define _IOFBF 0 /* Fully buffered. */
122 #define _IOLBF 1 /* Line buffered. */
123 #define _IONBF 2 /* No buffering. */
126 /* Default buffer size. */
128 # define BUFSIZ _IO_BUFSIZ
132 /* End of file character.
133 Some things throughout the library rely on this being -1. */
139 /* The possibilities for the third argument to `fseek'.
140 These values should not be changed. */
141 #define SEEK_SET 0 /* Seek from beginning of file. */
142 #define SEEK_CUR 1 /* Seek from current position. */
143 #define SEEK_END 2 /* Seek from end of file. */
145 # define SEEK_DATA 3 /* Seek to next data. */
146 # define SEEK_HOLE 4 /* Seek to next hole. */
150 #if defined __USE_SVID || defined __USE_XOPEN
151 /* Default path prefix for `tempnam' and `tmpnam'. */
152 # define P_tmpdir "/tmp"
157 L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
158 TMP_MAX The minimum number of unique filenames generated by tmpnam
159 (and tempnam when it uses tmpnam's name space),
160 or tempnam (the two are separate).
161 L_ctermid How long an array to pass to `ctermid'.
162 L_cuserid How long an array to pass to `cuserid'.
163 FOPEN_MAX Minimum number of files that can be open at once.
164 FILENAME_MAX Maximum length of a filename. */
165 #include <bits/stdio_lim.h>
168 /* Standard streams. */
169 extern struct _IO_FILE *stdin; /* Standard input stream. */
170 extern struct _IO_FILE *stdout; /* Standard output stream. */
171 extern struct _IO_FILE *stderr; /* Standard error output stream. */
172 /* C89/C99 say they're macros. Make them happy. */
174 #define stdout stdout
175 #define stderr stderr
177 __BEGIN_NAMESPACE_STD
178 /* Remove file FILENAME. */
179 extern int remove (const char *__filename) __THROW;
180 /* Rename file OLD to NEW. */
181 extern int rename (const char *__old, const char *__new) __THROW;
185 /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
186 extern int renameat (int __oldfd, const char *__old, int __newfd,
187 const char *__new) __THROW;
190 __BEGIN_NAMESPACE_STD
191 /* Create a temporary file and open it read/write.
193 This function is a possible cancellation point and therefore not
194 marked with __THROW. */
195 #ifndef __USE_FILE_OFFSET64
196 extern FILE *tmpfile (void) __wur;
199 extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;
201 # define tmpfile tmpfile64
205 #ifdef __USE_LARGEFILE64
206 extern FILE *tmpfile64 (void) __wur;
209 /* Generate a temporary filename. */
210 extern char *tmpnam (char *__s) __THROW __wur;
214 /* This is the reentrant variant of `tmpnam'. The only difference is
215 that it does not allow S to be NULL. */
216 extern char *tmpnam_r (char *__s) __THROW __wur;
220 #if defined __USE_SVID || defined __USE_XOPEN
221 /* Generate a unique temporary filename using up to five characters of PFX
222 if it is not NULL. The directory to put this file in is searched for
223 as follows: First the environment variable "TMPDIR" is checked.
224 If it contains the name of a writable directory, that directory is used.
225 If not and if DIR is not NULL, that value is checked. If that fails,
226 P_tmpdir is tried and finally "/tmp". The storage for the filename
227 is allocated by `malloc'. */
228 extern char *tempnam (const char *__dir, const char *__pfx)
229 __THROW __attribute_malloc__ __wur;
233 __BEGIN_NAMESPACE_STD
236 This function is a possible cancellation point and therefore not
237 marked with __THROW. */
238 extern int fclose (FILE *__stream);
239 /* Flush STREAM, or all streams if STREAM is NULL.
241 This function is a possible cancellation point and therefore not
242 marked with __THROW. */
243 extern int fflush (FILE *__stream);
247 /* Faster versions when locking is not required.
249 This function is not part of POSIX and therefore no official
250 cancellation point. But due to similarity with an POSIX interface
251 or due to the implementation it is a cancellation point and
252 therefore not marked with __THROW. */
253 extern int fflush_unlocked (FILE *__stream);
257 /* Close all streams.
259 This function is not part of POSIX and therefore no official
260 cancellation point. But due to similarity with an POSIX interface
261 or due to the implementation it is a cancellation point and
262 therefore not marked with __THROW. */
263 extern int fcloseall (void);
267 __BEGIN_NAMESPACE_STD
268 #ifndef __USE_FILE_OFFSET64
269 /* Open a file and create a new stream for it.
271 This function is a possible cancellation point and therefore not
272 marked with __THROW. */
273 extern FILE *fopen (const char *__restrict __filename,
274 const char *__restrict __modes) __wur;
275 /* Open a file, replacing an existing stream with it.
277 This function is a possible cancellation point and therefore not
278 marked with __THROW. */
279 extern FILE *freopen (const char *__restrict __filename,
280 const char *__restrict __modes,
281 FILE *__restrict __stream) __wur;
284 extern FILE *__REDIRECT (fopen, (const char *__restrict __filename,
285 const char *__restrict __modes), fopen64)
287 extern FILE *__REDIRECT (freopen, (const char *__restrict __filename,
288 const char *__restrict __modes,
289 FILE *__restrict __stream), freopen64)
292 # define fopen fopen64
293 # define freopen freopen64
297 #ifdef __USE_LARGEFILE64
298 extern FILE *fopen64 (const char *__restrict __filename,
299 const char *__restrict __modes) __wur;
300 extern FILE *freopen64 (const char *__restrict __filename,
301 const char *__restrict __modes,
302 FILE *__restrict __stream) __wur;
306 /* Create a new stream that refers to an existing system file descriptor. */
307 extern FILE *fdopen (int __fd, const char *__modes) __THROW __wur;
311 /* Create a new stream that refers to the given magic cookie,
312 and uses the given functions for input and output. */
313 extern FILE *fopencookie (void *__restrict __magic_cookie,
314 const char *__restrict __modes,
315 _IO_cookie_io_functions_t __io_funcs) __THROW __wur;
318 #ifdef __USE_XOPEN2K8
319 /* Create a new stream that refers to a memory buffer. */
320 extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
323 /* Open a stream that writes into a malloc'd buffer that is expanded as
324 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
325 and the number of characters written on fflush or fclose. */
326 extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;
330 __BEGIN_NAMESPACE_STD
331 /* If BUF is NULL, make STREAM unbuffered.
332 Else make it use buffer BUF, of size BUFSIZ. */
333 extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
334 /* Make STREAM use buffering mode MODE.
335 If BUF is not NULL, use N bytes of it for buffering;
336 else allocate an internal buffer N bytes long. */
337 extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
338 int __modes, size_t __n) __THROW;
342 /* If BUF is NULL, make STREAM unbuffered.
343 Else make it use SIZE bytes of BUF for buffering. */
344 extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
345 size_t __size) __THROW;
347 /* Make STREAM line-buffered. */
348 extern void setlinebuf (FILE *__stream) __THROW;
352 __BEGIN_NAMESPACE_STD
353 /* Write formatted output to STREAM.
355 This function is a possible cancellation point and therefore not
356 marked with __THROW. */
357 extern int fprintf (FILE *__restrict __stream,
358 const char *__restrict __format, ...);
359 /* Write formatted output to stdout.
361 This function is a possible cancellation point and therefore not
362 marked with __THROW. */
363 extern int printf (const char *__restrict __format, ...);
364 /* Write formatted output to S. */
365 extern int sprintf (char *__restrict __s,
366 const char *__restrict __format, ...) __THROWNL;
368 /* Write formatted output to S from argument list ARG.
370 This function is a possible cancellation point and therefore not
371 marked with __THROW. */
372 extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
374 /* Write formatted output to stdout from argument list ARG.
376 This function is a possible cancellation point and therefore not
377 marked with __THROW. */
378 extern int vprintf (const char *__restrict __format, _G_va_list __arg);
379 /* Write formatted output to S from argument list ARG. */
380 extern int vsprintf (char *__restrict __s, const char *__restrict __format,
381 _G_va_list __arg) __THROWNL;
384 #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
385 __BEGIN_NAMESPACE_C99
386 /* Maximum chars of output to write in MAXLEN. */
387 extern int snprintf (char *__restrict __s, size_t __maxlen,
388 const char *__restrict __format, ...)
389 __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));
391 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
392 const char *__restrict __format, _G_va_list __arg)
393 __THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));
398 /* Write formatted output to a string dynamically allocated with `malloc'.
399 Store the address of the string in *PTR. */
400 extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,
402 __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
403 extern int __asprintf (char **__restrict __ptr,
404 const char *__restrict __fmt, ...)
405 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
406 extern int asprintf (char **__restrict __ptr,
407 const char *__restrict __fmt, ...)
408 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
411 #ifdef __USE_XOPEN2K8
412 /* Write formatted output to a file descriptor.
414 These functions are not part of POSIX and therefore no official
415 cancellation point. But due to similarity with an POSIX interface
416 or due to the implementation they are cancellation points and
417 therefore not marked with __THROW. */
418 extern int vdprintf (int __fd, const char *__restrict __fmt,
420 __attribute__ ((__format__ (__printf__, 2, 0)));
421 extern int dprintf (int __fd, const char *__restrict __fmt, ...)
422 __attribute__ ((__format__ (__printf__, 2, 3)));
426 __BEGIN_NAMESPACE_STD
427 /* Read formatted input from STREAM.
429 This function is a possible cancellation point and therefore not
430 marked with __THROW. */
431 extern int fscanf (FILE *__restrict __stream,
432 const char *__restrict __format, ...) __wur;
433 /* Read formatted input from stdin.
435 This function is a possible cancellation point and therefore not
436 marked with __THROW. */
437 extern int scanf (const char *__restrict __format, ...) __wur;
438 /* Read formatted input from S. */
439 extern int sscanf (const char *__restrict __s,
440 const char *__restrict __format, ...) __THROW;
442 #if defined __USE_ISOC99 && !defined __USE_GNU \
443 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
444 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
446 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
447 GNU extension which conflicts with valid %a followed by letter
449 extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
450 const char *__restrict __format, ...),
451 __isoc99_fscanf) __wur;
452 extern int __REDIRECT (scanf, (const char *__restrict __format, ...),
453 __isoc99_scanf) __wur;
454 extern int __REDIRECT_NTH (sscanf, (const char *__restrict __s,
455 const char *__restrict __format, ...),
458 extern int __isoc99_fscanf (FILE *__restrict __stream,
459 const char *__restrict __format, ...) __wur;
460 extern int __isoc99_scanf (const char *__restrict __format, ...) __wur;
461 extern int __isoc99_sscanf (const char *__restrict __s,
462 const char *__restrict __format, ...) __THROW;
463 # define fscanf __isoc99_fscanf
464 # define scanf __isoc99_scanf
465 # define sscanf __isoc99_sscanf
472 __BEGIN_NAMESPACE_C99
473 /* Read formatted input from S into argument list ARG.
475 This function is a possible cancellation point and therefore not
476 marked with __THROW. */
477 extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
479 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
481 /* Read formatted input from stdin into argument list ARG.
483 This function is a possible cancellation point and therefore not
484 marked with __THROW. */
485 extern int vscanf (const char *__restrict __format, _G_va_list __arg)
486 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
488 /* Read formatted input from S into argument list ARG. */
489 extern int vsscanf (const char *__restrict __s,
490 const char *__restrict __format, _G_va_list __arg)
491 __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
493 # if !defined __USE_GNU \
494 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
495 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
497 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
498 GNU extension which conflicts with valid %a followed by letter
500 extern int __REDIRECT (vfscanf,
501 (FILE *__restrict __s,
502 const char *__restrict __format, _G_va_list __arg),
504 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
505 extern int __REDIRECT (vscanf, (const char *__restrict __format,
506 _G_va_list __arg), __isoc99_vscanf)
507 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
508 extern int __REDIRECT_NTH (vsscanf,
509 (const char *__restrict __s,
510 const char *__restrict __format,
511 _G_va_list __arg), __isoc99_vsscanf)
512 __attribute__ ((__format__ (__scanf__, 2, 0)));
514 extern int __isoc99_vfscanf (FILE *__restrict __s,
515 const char *__restrict __format,
516 _G_va_list __arg) __wur;
517 extern int __isoc99_vscanf (const char *__restrict __format,
518 _G_va_list __arg) __wur;
519 extern int __isoc99_vsscanf (const char *__restrict __s,
520 const char *__restrict __format,
521 _G_va_list __arg) __THROW;
522 # define vfscanf __isoc99_vfscanf
523 # define vscanf __isoc99_vscanf
524 # define vsscanf __isoc99_vsscanf
529 #endif /* Use ISO C9x. */
532 __BEGIN_NAMESPACE_STD
533 /* Read a character from STREAM.
535 These functions are possible cancellation points and therefore not
536 marked with __THROW. */
537 extern int fgetc (FILE *__stream);
538 extern int getc (FILE *__stream);
540 /* Read a character from stdin.
542 This function is a possible cancellation point and therefore not
543 marked with __THROW. */
544 extern int getchar (void);
547 /* The C standard explicitly says this is a macro, so we always do the
548 optimization for it. */
549 #define getc(_fp) _IO_getc (_fp)
551 #if defined __USE_POSIX || defined __USE_MISC
552 /* These are defined in POSIX.1:1996.
554 These functions are possible cancellation points and therefore not
555 marked with __THROW. */
556 extern int getc_unlocked (FILE *__stream);
557 extern int getchar_unlocked (void);
558 #endif /* Use POSIX or MISC. */
561 /* Faster version when locking is not necessary.
563 This function is not part of POSIX and therefore no official
564 cancellation point. But due to similarity with an POSIX interface
565 or due to the implementation it is a cancellation point and
566 therefore not marked with __THROW. */
567 extern int fgetc_unlocked (FILE *__stream);
568 #endif /* Use MISC. */
571 __BEGIN_NAMESPACE_STD
572 /* Write a character to STREAM.
574 These functions are possible cancellation points and therefore not
577 These functions is a possible cancellation point and therefore not
578 marked with __THROW. */
579 extern int fputc (int __c, FILE *__stream);
580 extern int putc (int __c, FILE *__stream);
582 /* Write a character to stdout.
584 This function is a possible cancellation point and therefore not
585 marked with __THROW. */
586 extern int putchar (int __c);
589 /* The C standard explicitly says this can be a macro,
590 so we always do the optimization for it. */
591 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
594 /* Faster version when locking is not necessary.
596 This function is not part of POSIX and therefore no official
597 cancellation point. But due to similarity with an POSIX interface
598 or due to the implementation it is a cancellation point and
599 therefore not marked with __THROW. */
600 extern int fputc_unlocked (int __c, FILE *__stream);
601 #endif /* Use MISC. */
603 #if defined __USE_POSIX || defined __USE_MISC
604 /* These are defined in POSIX.1:1996.
606 These functions are possible cancellation points and therefore not
607 marked with __THROW. */
608 extern int putc_unlocked (int __c, FILE *__stream);
609 extern int putchar_unlocked (int __c);
610 #endif /* Use POSIX or MISC. */
613 #if defined __USE_SVID || defined __USE_MISC \
614 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
615 /* Get a word (int) from STREAM. */
616 extern int getw (FILE *__stream);
618 /* Write a word (int) to STREAM. */
619 extern int putw (int __w, FILE *__stream);
623 __BEGIN_NAMESPACE_STD
624 /* Get a newline-terminated string of finite length from STREAM.
626 This function is a possible cancellation point and therefore not
627 marked with __THROW. */
628 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
631 #if !defined __USE_ISOC11 \
632 || (defined __cplusplus && __cplusplus <= 201103L && !defined __USE_GNU)
633 /* Get a newline-terminated string from stdin, removing the newline.
634 DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
636 The function has been officially removed in ISO C11. This opportunity
637 is used to also remove it from the GNU feature list. It is now only
638 available when explicitly using an old ISO C, Unix, or POSIX standard.
639 GCC defines _GNU_SOURCE when building C++ code and the function is still
640 in C++11, so it is also available for C++.
642 This function is a possible cancellation point and therefore not
643 marked with __THROW. */
644 extern char *gets (char *__s) __wur __attribute_deprecated__;
649 /* This function does the same as `fgets' but does not lock the stream.
651 This function is not part of POSIX and therefore no official
652 cancellation point. But due to similarity with an POSIX interface
653 or due to the implementation it is a cancellation point and
654 therefore not marked with __THROW. */
655 extern char *fgets_unlocked (char *__restrict __s, int __n,
656 FILE *__restrict __stream) __wur;
660 #ifdef __USE_XOPEN2K8
661 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
662 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
663 NULL), pointing to *N characters of space. It is realloc'd as
664 necessary. Returns the number of characters read (not including the
665 null terminator), or -1 on error or EOF.
667 These functions are not part of POSIX and therefore no official
668 cancellation point. But due to similarity with an POSIX interface
669 or due to the implementation they are cancellation points and
670 therefore not marked with __THROW. */
671 extern _IO_ssize_t __getdelim (char **__restrict __lineptr,
672 size_t *__restrict __n, int __delimiter,
673 FILE *__restrict __stream) __wur;
674 extern _IO_ssize_t getdelim (char **__restrict __lineptr,
675 size_t *__restrict __n, int __delimiter,
676 FILE *__restrict __stream) __wur;
678 /* Like `getdelim', but reads up to a newline.
680 This function is not part of POSIX and therefore no official
681 cancellation point. But due to similarity with an POSIX interface
682 or due to the implementation it is a cancellation point and
683 therefore not marked with __THROW. */
684 extern _IO_ssize_t getline (char **__restrict __lineptr,
685 size_t *__restrict __n,
686 FILE *__restrict __stream) __wur;
690 __BEGIN_NAMESPACE_STD
691 /* Write a string to STREAM.
693 This function is a possible cancellation point and therefore not
694 marked with __THROW. */
695 extern int fputs (const char *__restrict __s, FILE *__restrict __stream);
697 /* Write a string, followed by a newline, to stdout.
699 This function is a possible cancellation point and therefore not
700 marked with __THROW. */
701 extern int puts (const char *__s);
704 /* Push a character back onto the input buffer of STREAM.
706 This function is a possible cancellation point and therefore not
707 marked with __THROW. */
708 extern int ungetc (int __c, FILE *__stream);
711 /* Read chunks of generic data from STREAM.
713 This function is a possible cancellation point and therefore not
714 marked with __THROW. */
715 extern size_t fread (void *__restrict __ptr, size_t __size,
716 size_t __n, FILE *__restrict __stream) __wur;
717 /* Write chunks of generic data to STREAM.
719 This function is a possible cancellation point and therefore not
720 marked with __THROW. */
721 extern size_t fwrite (const void *__restrict __ptr, size_t __size,
722 size_t __n, FILE *__restrict __s) __wur;
726 /* This function does the same as `fputs' but does not lock the stream.
728 This function is not part of POSIX and therefore no official
729 cancellation point. But due to similarity with an POSIX interface
730 or due to the implementation it is a cancellation point and
731 therefore not marked with __THROW. */
732 extern int fputs_unlocked (const char *__restrict __s,
733 FILE *__restrict __stream);
737 /* Faster versions when locking is not necessary.
739 These functions are not part of POSIX and therefore no official
740 cancellation point. But due to similarity with an POSIX interface
741 or due to the implementation they are cancellation points and
742 therefore not marked with __THROW. */
743 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
744 size_t __n, FILE *__restrict __stream) __wur;
745 extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
746 size_t __n, FILE *__restrict __stream) __wur;
750 __BEGIN_NAMESPACE_STD
751 /* Seek to a certain position on STREAM.
753 This function is a possible cancellation point and therefore not
754 marked with __THROW. */
755 extern int fseek (FILE *__stream, long int __off, int __whence);
756 /* Return the current position of STREAM.
758 This function is a possible cancellation point and therefore not
759 marked with __THROW. */
760 extern long int ftell (FILE *__stream) __wur;
761 /* Rewind to the beginning of STREAM.
763 This function is a possible cancellation point and therefore not
764 marked with __THROW. */
765 extern void rewind (FILE *__stream);
768 /* The Single Unix Specification, Version 2, specifies an alternative,
769 more adequate interface for the two functions above which deal with
770 file offset. `long int' is not the right type. These definitions
771 are originally defined in the Large File Support API. */
773 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
774 # ifndef __USE_FILE_OFFSET64
775 /* Seek to a certain position on STREAM.
777 This function is a possible cancellation point and therefore not
778 marked with __THROW. */
779 extern int fseeko (FILE *__stream, __off_t __off, int __whence);
780 /* Return the current position of STREAM.
782 This function is a possible cancellation point and therefore not
783 marked with __THROW. */
784 extern __off_t ftello (FILE *__stream) __wur;
787 extern int __REDIRECT (fseeko,
788 (FILE *__stream, __off64_t __off, int __whence),
790 extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
792 # define fseeko fseeko64
793 # define ftello ftello64
798 __BEGIN_NAMESPACE_STD
799 #ifndef __USE_FILE_OFFSET64
800 /* Get STREAM's position.
802 This function is a possible cancellation point and therefore not
803 marked with __THROW. */
804 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
805 /* Set STREAM's position.
807 This function is a possible cancellation point and therefore not
808 marked with __THROW. */
809 extern int fsetpos (FILE *__stream, const fpos_t *__pos);
812 extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
813 fpos_t *__restrict __pos), fgetpos64);
814 extern int __REDIRECT (fsetpos,
815 (FILE *__stream, const fpos_t *__pos), fsetpos64);
817 # define fgetpos fgetpos64
818 # define fsetpos fsetpos64
823 #ifdef __USE_LARGEFILE64
824 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
825 extern __off64_t ftello64 (FILE *__stream) __wur;
826 extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
827 extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos);
830 __BEGIN_NAMESPACE_STD
831 /* Clear the error and EOF indicators for STREAM. */
832 extern void clearerr (FILE *__stream) __THROW;
833 /* Return the EOF indicator for STREAM. */
834 extern int feof (FILE *__stream) __THROW __wur;
835 /* Return the error indicator for STREAM. */
836 extern int ferror (FILE *__stream) __THROW __wur;
840 /* Faster versions when locking is not required. */
841 extern void clearerr_unlocked (FILE *__stream) __THROW;
842 extern int feof_unlocked (FILE *__stream) __THROW __wur;
843 extern int ferror_unlocked (FILE *__stream) __THROW __wur;
847 __BEGIN_NAMESPACE_STD
848 /* Print a message describing the meaning of the value of errno.
850 This function is a possible cancellation point and therefore not
851 marked with __THROW. */
852 extern void perror (const char *__s);
855 /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
856 are available on this system. Even if available, these variables
857 should not be used directly. The `strerror' function provides
858 all the necessary functionality. */
859 #include <bits/sys_errlist.h>
863 /* Return the system file descriptor for STREAM. */
864 extern int fileno (FILE *__stream) __THROW __wur;
865 #endif /* Use POSIX. */
868 /* Faster version when locking is not required. */
869 extern int fileno_unlocked (FILE *__stream) __THROW __wur;
873 #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
875 /* Create a new stream connected to a pipe running the given command.
877 This function is a possible cancellation point and therefore not
878 marked with __THROW. */
879 extern FILE *popen (const char *__command, const char *__modes) __wur;
881 /* Close a stream opened by popen and return the status of its child.
883 This function is a possible cancellation point and therefore not
884 marked with __THROW. */
885 extern int pclose (FILE *__stream);
890 /* Return the name of the controlling terminal. */
891 extern char *ctermid (char *__s) __THROW;
892 #endif /* Use POSIX. */
896 /* Return the name of the current user. */
897 extern char *cuserid (char *__s);
898 #endif /* Use X/Open, but not issue 6. */
902 struct obstack; /* See <obstack.h>. */
904 /* Write formatted output to an obstack. */
905 extern int obstack_printf (struct obstack *__restrict __obstack,
906 const char *__restrict __format, ...)
907 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3)));
908 extern int obstack_vprintf (struct obstack *__restrict __obstack,
909 const char *__restrict __format,
911 __THROWNL __attribute__ ((__format__ (__printf__, 2, 0)));
912 #endif /* Use GNU. */
915 #if defined __USE_POSIX || defined __USE_MISC
916 /* These are defined in POSIX.1:1996. */
918 /* Acquire ownership of STREAM. */
919 extern void flockfile (FILE *__stream) __THROW;
921 /* Try to acquire ownership of STREAM but do not block if it is not
923 extern int ftrylockfile (FILE *__stream) __THROW __wur;
925 /* Relinquish the ownership granted for STREAM. */
926 extern void funlockfile (FILE *__stream) __THROW;
927 #endif /* POSIX || misc */
929 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
930 /* The X/Open standard requires some functions and variables to be
931 declared here which do not belong into this header. But we have to
932 follow. In GNU mode we don't do this nonsense. */
933 # define __need_getopt
935 #endif /* X/Open, but not issue 6 and not for GNU. */
937 /* If we are compiling with optimizing read this file. It contains
938 several optimizing inline functions and macros. */
939 #ifdef __USE_EXTERN_INLINES
940 # include <bits/stdio.h>
942 #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
943 # include <bits/stdio2.h>
946 # include <bits/stdio-ldbl.h>
951 #endif /* <stdio.h> included. */
953 #endif /* !_STDIO_H */