1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991-2016 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 <http://www.gnu.org/licenses/>. */
20 * ISO C99 Standard: 7.19 Input/output <stdio.h>
25 #if !defined __need_FILE && !defined __need___FILE
27 # include <features.h>
31 # define __need_size_t
35 # include <bits/types.h>
37 # define __need___FILE
38 #endif /* Don't need FILE. */
41 #if !defined __FILE_defined && defined __need_FILE
43 /* Define outside of namespace so the C++ is happy. */
47 /* The opaque type of streams. This is the definition used elsewhere. */
48 typedef struct _IO_FILE
FILE;
50 #if defined __USE_LARGEFILE64 || defined __USE_POSIX \
51 || defined __USE_ISOC99 || defined __USE_XOPEN \
52 || defined __USE_POSIX2
53 __USING_NAMESPACE_STD(FILE)
56 # define __FILE_defined 1
57 #endif /* FILE not defined. */
61 #if !defined ____FILE_defined && defined __need___FILE
63 /* The opaque type of streams. This is the definition used elsewhere. */
64 typedef struct _IO_FILE __FILE
;
66 # define ____FILE_defined 1
67 #endif /* __FILE not defined. */
72 #define _STDIO_USES_IOSTREAM
76 #if defined __USE_XOPEN || defined __USE_XOPEN2K8
78 # ifndef _VA_LIST_DEFINED
79 typedef _G_va_list
va_list;
80 # define _VA_LIST_DEFINED
87 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
88 # ifndef __off_t_defined
89 # ifndef __USE_FILE_OFFSET64
90 typedef __off_t off_t
;
92 typedef __off64_t off_t
;
94 # define __off_t_defined
96 # if defined __USE_LARGEFILE64 && !defined __off64_t_defined
97 typedef __off64_t off64_t
;
98 # define __off64_t_defined
102 #ifdef __USE_XOPEN2K8
103 # ifndef __ssize_t_defined
104 typedef __ssize_t ssize_t
;
105 # define __ssize_t_defined
109 /* The type of the second argument to `fgetpos' and `fsetpos'. */
110 __BEGIN_NAMESPACE_STD
111 #ifndef __USE_FILE_OFFSET64
112 typedef _G_fpos_t
fpos_t;
114 typedef _G_fpos64_t
fpos_t;
117 #ifdef __USE_LARGEFILE64
118 typedef _G_fpos64_t fpos64_t
;
121 /* The possibilities for the third argument to `setvbuf'. */
122 #define _IOFBF 0 /* Fully buffered. */
123 #define _IOLBF 1 /* Line buffered. */
124 #define _IONBF 2 /* No buffering. */
127 /* Default buffer size. */
129 # define BUFSIZ _IO_BUFSIZ
133 /* End of file character.
134 Some things throughout the library rely on this being -1. */
140 /* The possibilities for the third argument to `fseek'.
141 These values should not be changed. */
142 #define SEEK_SET 0 /* Seek from beginning of file. */
143 #define SEEK_CUR 1 /* Seek from current position. */
144 #define SEEK_END 2 /* Seek from end of file. */
146 # define SEEK_DATA 3 /* Seek to next data. */
147 # define SEEK_HOLE 4 /* Seek to next hole. */
151 #if defined __USE_MISC || defined __USE_XOPEN
152 /* Default path prefix for `tempnam' and `tmpnam'. */
153 # define P_tmpdir "/tmp"
158 L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
159 TMP_MAX The minimum number of unique filenames generated by tmpnam
160 (and tempnam when it uses tmpnam's name space),
161 or tempnam (the two are separate).
162 L_ctermid How long an array to pass to `ctermid'.
163 L_cuserid How long an array to pass to `cuserid'.
164 FOPEN_MAX Minimum number of files that can be open at once.
165 FILENAME_MAX Maximum length of a filename. */
166 #include <bits/stdio_lim.h>
169 /* Standard streams. */
170 extern struct _IO_FILE
*stdin
; /* Standard input stream. */
171 extern struct _IO_FILE
*stdout
; /* Standard output stream. */
172 extern struct _IO_FILE
*stderr
; /* Standard error output stream. */
173 /* C89/C99 say they're macros. Make them happy. */
175 #define stdout stdout
176 #define stderr stderr
178 __BEGIN_NAMESPACE_STD
179 /* Remove file FILENAME. */
180 extern int remove (const char *__filename
) __THROW
;
181 /* Rename file OLD to NEW. */
182 extern int rename (const char *__old
, const char *__new
) __THROW
;
186 /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
187 extern int renameat (int __oldfd
, const char *__old
, int __newfd
,
188 const char *__new
) __THROW
;
191 __BEGIN_NAMESPACE_STD
192 /* Create a temporary file and open it read/write.
194 This function is a possible cancellation point and therefore not
195 marked with __THROW. */
196 #ifndef __USE_FILE_OFFSET64
197 extern FILE *tmpfile (void) __wur
;
200 extern FILE *__REDIRECT (tmpfile
, (void), tmpfile64
) __wur
;
202 # define tmpfile tmpfile64
206 #ifdef __USE_LARGEFILE64
207 extern FILE *tmpfile64 (void) __wur
;
210 /* Generate a temporary filename. */
211 extern char *tmpnam (char *__s
) __THROW __wur
;
215 /* This is the reentrant variant of `tmpnam'. The only difference is
216 that it does not allow S to be NULL. */
217 extern char *tmpnam_r (char *__s
) __THROW __wur
;
221 #if defined __USE_MISC || defined __USE_XOPEN
222 /* Generate a unique temporary filename using up to five characters of PFX
223 if it is not NULL. The directory to put this file in is searched for
224 as follows: First the environment variable "TMPDIR" is checked.
225 If it contains the name of a writable directory, that directory is used.
226 If not and if DIR is not NULL, that value is checked. If that fails,
227 P_tmpdir is tried and finally "/tmp". The storage for the filename
228 is allocated by `malloc'. */
229 extern char *tempnam (const char *__dir
, const char *__pfx
)
230 __THROW __attribute_malloc__ __wur
;
234 __BEGIN_NAMESPACE_STD
237 This function is a possible cancellation point and therefore not
238 marked with __THROW. */
239 extern int fclose (FILE *__stream
);
240 /* Flush STREAM, or all streams if STREAM is NULL.
242 This function is a possible cancellation point and therefore not
243 marked with __THROW. */
244 extern int fflush (FILE *__stream
);
248 /* Faster versions when locking is not required.
250 This function is not part of POSIX and therefore no official
251 cancellation point. But due to similarity with an POSIX interface
252 or due to the implementation it is a cancellation point and
253 therefore not marked with __THROW. */
254 extern int fflush_unlocked (FILE *__stream
);
258 /* Close all streams.
260 This function is not part of POSIX and therefore no official
261 cancellation point. But due to similarity with an POSIX interface
262 or due to the implementation it is a cancellation point and
263 therefore not marked with __THROW. */
264 extern int fcloseall (void);
268 __BEGIN_NAMESPACE_STD
269 #ifndef __USE_FILE_OFFSET64
270 /* Open a file and create a new stream for it.
272 This function is a possible cancellation point and therefore not
273 marked with __THROW. */
274 extern FILE *fopen (const char *__restrict __filename
,
275 const char *__restrict __modes
) __wur
;
276 /* Open a file, replacing an existing stream with it.
278 This function is a possible cancellation point and therefore not
279 marked with __THROW. */
280 extern FILE *freopen (const char *__restrict __filename
,
281 const char *__restrict __modes
,
282 FILE *__restrict __stream
) __wur
;
285 extern FILE *__REDIRECT (fopen
, (const char *__restrict __filename
,
286 const char *__restrict __modes
), fopen64
)
288 extern FILE *__REDIRECT (freopen
, (const char *__restrict __filename
,
289 const char *__restrict __modes
,
290 FILE *__restrict __stream
), freopen64
)
293 # define fopen fopen64
294 # define freopen freopen64
298 #ifdef __USE_LARGEFILE64
299 extern FILE *fopen64 (const char *__restrict __filename
,
300 const char *__restrict __modes
) __wur
;
301 extern FILE *freopen64 (const char *__restrict __filename
,
302 const char *__restrict __modes
,
303 FILE *__restrict __stream
) __wur
;
307 /* Create a new stream that refers to an existing system file descriptor. */
308 extern FILE *fdopen (int __fd
, const char *__modes
) __THROW __wur
;
312 /* Create a new stream that refers to the given magic cookie,
313 and uses the given functions for input and output. */
314 extern FILE *fopencookie (void *__restrict __magic_cookie
,
315 const char *__restrict __modes
,
316 _IO_cookie_io_functions_t __io_funcs
) __THROW __wur
;
319 #ifdef __USE_XOPEN2K8
320 /* Create a new stream that refers to a memory buffer. */
321 extern FILE *fmemopen (void *__s
, size_t __len
, const char *__modes
)
324 /* Open a stream that writes into a malloc'd buffer that is expanded as
325 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
326 and the number of characters written on fflush or fclose. */
327 extern FILE *open_memstream (char **__bufloc
, size_t *__sizeloc
) __THROW __wur
;
331 __BEGIN_NAMESPACE_STD
332 /* If BUF is NULL, make STREAM unbuffered.
333 Else make it use buffer BUF, of size BUFSIZ. */
334 extern void setbuf (FILE *__restrict __stream
, char *__restrict __buf
) __THROW
;
335 /* Make STREAM use buffering mode MODE.
336 If BUF is not NULL, use N bytes of it for buffering;
337 else allocate an internal buffer N bytes long. */
338 extern int setvbuf (FILE *__restrict __stream
, char *__restrict __buf
,
339 int __modes
, size_t __n
) __THROW
;
343 /* If BUF is NULL, make STREAM unbuffered.
344 Else make it use SIZE bytes of BUF for buffering. */
345 extern void setbuffer (FILE *__restrict __stream
, char *__restrict __buf
,
346 size_t __size
) __THROW
;
348 /* Make STREAM line-buffered. */
349 extern void setlinebuf (FILE *__stream
) __THROW
;
353 __BEGIN_NAMESPACE_STD
354 /* Write formatted output to STREAM.
356 This function is a possible cancellation point and therefore not
357 marked with __THROW. */
358 extern int fprintf (FILE *__restrict __stream
,
359 const char *__restrict __format
, ...);
360 /* Write formatted output to stdout.
362 This function is a possible cancellation point and therefore not
363 marked with __THROW. */
364 extern int printf (const char *__restrict __format
, ...);
365 /* Write formatted output to S. */
366 extern int sprintf (char *__restrict __s
,
367 const char *__restrict __format
, ...) __THROWNL
;
369 /* Write formatted output to S from argument list ARG.
371 This function is a possible cancellation point and therefore not
372 marked with __THROW. */
373 extern int vfprintf (FILE *__restrict __s
, const char *__restrict __format
,
375 /* Write formatted output to stdout from argument list ARG.
377 This function is a possible cancellation point and therefore not
378 marked with __THROW. */
379 extern int vprintf (const char *__restrict __format
, _G_va_list __arg
);
380 /* Write formatted output to S from argument list ARG. */
381 extern int vsprintf (char *__restrict __s
, const char *__restrict __format
,
382 _G_va_list __arg
) __THROWNL
;
385 #if defined __USE_ISOC99 || defined __USE_UNIX98
386 __BEGIN_NAMESPACE_C99
387 /* Maximum chars of output to write in MAXLEN. */
388 extern int snprintf (char *__restrict __s
, size_t __maxlen
,
389 const char *__restrict __format
, ...)
390 __THROWNL
__attribute__ ((__format__ (__printf__
, 3, 4)));
392 extern int vsnprintf (char *__restrict __s
, size_t __maxlen
,
393 const char *__restrict __format
, _G_va_list __arg
)
394 __THROWNL
__attribute__ ((__format__ (__printf__
, 3, 0)));
399 /* Write formatted output to a string dynamically allocated with `malloc'.
400 Store the address of the string in *PTR. */
401 extern int vasprintf (char **__restrict __ptr
, const char *__restrict __f
,
403 __THROWNL
__attribute__ ((__format__ (__printf__
, 2, 0))) __wur
;
404 extern int __asprintf (char **__restrict __ptr
,
405 const char *__restrict __fmt
, ...)
406 __THROWNL
__attribute__ ((__format__ (__printf__
, 2, 3))) __wur
;
407 extern int asprintf (char **__restrict __ptr
,
408 const char *__restrict __fmt
, ...)
409 __THROWNL
__attribute__ ((__format__ (__printf__
, 2, 3))) __wur
;
412 #ifdef __USE_XOPEN2K8
413 /* Write formatted output to a file descriptor. */
414 extern int vdprintf (int __fd
, const char *__restrict __fmt
,
416 __attribute__ ((__format__ (__printf__
, 2, 0)));
417 extern int dprintf (int __fd
, const char *__restrict __fmt
, ...)
418 __attribute__ ((__format__ (__printf__
, 2, 3)));
422 __BEGIN_NAMESPACE_STD
423 /* Read formatted input from STREAM.
425 This function is a possible cancellation point and therefore not
426 marked with __THROW. */
427 extern int fscanf (FILE *__restrict __stream
,
428 const char *__restrict __format
, ...) __wur
;
429 /* Read formatted input from stdin.
431 This function is a possible cancellation point and therefore not
432 marked with __THROW. */
433 extern int scanf (const char *__restrict __format
, ...) __wur
;
434 /* Read formatted input from S. */
435 extern int sscanf (const char *__restrict __s
,
436 const char *__restrict __format
, ...) __THROW
;
438 #if defined __USE_ISOC99 && !defined __USE_GNU \
439 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
440 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
442 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
443 GNU extension which conflicts with valid %a followed by letter
445 extern int __REDIRECT (fscanf
, (FILE *__restrict __stream
,
446 const char *__restrict __format
, ...),
447 __isoc99_fscanf
) __wur
;
448 extern int __REDIRECT (scanf
, (const char *__restrict __format
, ...),
449 __isoc99_scanf
) __wur
;
450 extern int __REDIRECT_NTH (sscanf
, (const char *__restrict __s
,
451 const char *__restrict __format
, ...),
454 extern int __isoc99_fscanf (FILE *__restrict __stream
,
455 const char *__restrict __format
, ...) __wur
;
456 extern int __isoc99_scanf (const char *__restrict __format
, ...) __wur
;
457 extern int __isoc99_sscanf (const char *__restrict __s
,
458 const char *__restrict __format
, ...) __THROW
;
459 # define fscanf __isoc99_fscanf
460 # define scanf __isoc99_scanf
461 # define sscanf __isoc99_sscanf
468 __BEGIN_NAMESPACE_C99
469 /* Read formatted input from S into argument list ARG.
471 This function is a possible cancellation point and therefore not
472 marked with __THROW. */
473 extern int vfscanf (FILE *__restrict __s
, const char *__restrict __format
,
475 __attribute__ ((__format__ (__scanf__
, 2, 0))) __wur
;
477 /* Read formatted input from stdin into argument list ARG.
479 This function is a possible cancellation point and therefore not
480 marked with __THROW. */
481 extern int vscanf (const char *__restrict __format
, _G_va_list __arg
)
482 __attribute__ ((__format__ (__scanf__
, 1, 0))) __wur
;
484 /* Read formatted input from S into argument list ARG. */
485 extern int vsscanf (const char *__restrict __s
,
486 const char *__restrict __format
, _G_va_list __arg
)
487 __THROW
__attribute__ ((__format__ (__scanf__
, 2, 0)));
489 # if !defined __USE_GNU \
490 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
491 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
493 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
494 GNU extension which conflicts with valid %a followed by letter
496 extern int __REDIRECT (vfscanf
,
497 (FILE *__restrict __s
,
498 const char *__restrict __format
, _G_va_list __arg
),
500 __attribute__ ((__format__ (__scanf__
, 2, 0))) __wur
;
501 extern int __REDIRECT (vscanf
, (const char *__restrict __format
,
502 _G_va_list __arg
), __isoc99_vscanf
)
503 __attribute__ ((__format__ (__scanf__
, 1, 0))) __wur
;
504 extern int __REDIRECT_NTH (vsscanf
,
505 (const char *__restrict __s
,
506 const char *__restrict __format
,
507 _G_va_list __arg
), __isoc99_vsscanf
)
508 __attribute__ ((__format__ (__scanf__
, 2, 0)));
510 extern int __isoc99_vfscanf (FILE *__restrict __s
,
511 const char *__restrict __format
,
512 _G_va_list __arg
) __wur
;
513 extern int __isoc99_vscanf (const char *__restrict __format
,
514 _G_va_list __arg
) __wur
;
515 extern int __isoc99_vsscanf (const char *__restrict __s
,
516 const char *__restrict __format
,
517 _G_va_list __arg
) __THROW
;
518 # define vfscanf __isoc99_vfscanf
519 # define vscanf __isoc99_vscanf
520 # define vsscanf __isoc99_vsscanf
525 #endif /* Use ISO C9x. */
528 __BEGIN_NAMESPACE_STD
529 /* Read a character from STREAM.
531 These functions are possible cancellation points and therefore not
532 marked with __THROW. */
533 extern int fgetc (FILE *__stream
);
534 extern int getc (FILE *__stream
);
536 /* Read a character from stdin.
538 This function is a possible cancellation point and therefore not
539 marked with __THROW. */
540 extern int getchar (void);
543 /* The C standard explicitly says this is a macro, so we always do the
544 optimization for it. */
545 #define getc(_fp) _IO_getc (_fp)
547 #ifdef __USE_POSIX199506
548 /* These are defined in POSIX.1:1996.
550 These functions are possible cancellation points and therefore not
551 marked with __THROW. */
552 extern int getc_unlocked (FILE *__stream
);
553 extern int getchar_unlocked (void);
554 #endif /* Use POSIX. */
557 /* Faster version when locking is not necessary.
559 This function is not part of POSIX and therefore no official
560 cancellation point. But due to similarity with an POSIX interface
561 or due to the implementation it is a cancellation point and
562 therefore not marked with __THROW. */
563 extern int fgetc_unlocked (FILE *__stream
);
564 #endif /* Use MISC. */
567 __BEGIN_NAMESPACE_STD
568 /* Write a character to STREAM.
570 These functions are possible cancellation points and therefore not
573 These functions is a possible cancellation point and therefore not
574 marked with __THROW. */
575 extern int fputc (int __c
, FILE *__stream
);
576 extern int putc (int __c
, FILE *__stream
);
578 /* Write a character to stdout.
580 This function is a possible cancellation point and therefore not
581 marked with __THROW. */
582 extern int putchar (int __c
);
585 /* The C standard explicitly says this can be a macro,
586 so we always do the optimization for it. */
587 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
590 /* Faster version when locking is not necessary.
592 This function is not part of POSIX and therefore no official
593 cancellation point. But due to similarity with an POSIX interface
594 or due to the implementation it is a cancellation point and
595 therefore not marked with __THROW. */
596 extern int fputc_unlocked (int __c
, FILE *__stream
);
597 #endif /* Use MISC. */
599 #ifdef __USE_POSIX199506
600 /* These are defined in POSIX.1:1996.
602 These functions are possible cancellation points and therefore not
603 marked with __THROW. */
604 extern int putc_unlocked (int __c
, FILE *__stream
);
605 extern int putchar_unlocked (int __c
);
606 #endif /* Use POSIX. */
609 #if defined __USE_MISC \
610 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
611 /* Get a word (int) from STREAM. */
612 extern int getw (FILE *__stream
);
614 /* Write a word (int) to STREAM. */
615 extern int putw (int __w
, FILE *__stream
);
619 __BEGIN_NAMESPACE_STD
620 /* Get a newline-terminated string of finite length from STREAM.
622 This function is a possible cancellation point and therefore not
623 marked with __THROW. */
624 extern char *fgets (char *__restrict __s
, int __n
, FILE *__restrict __stream
)
627 #if !defined __USE_ISOC11 \
628 || (defined __cplusplus && __cplusplus <= 201103L)
629 /* Get a newline-terminated string from stdin, removing the newline.
630 DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
632 The function has been officially removed in ISO C11. This opportunity
633 is used to also remove it from the GNU feature list. It is now only
634 available when explicitly using an old ISO C, Unix, or POSIX standard.
635 GCC defines _GNU_SOURCE when building C++ code and the function is still
636 in C++11, so it is also available for C++.
638 This function is a possible cancellation point and therefore not
639 marked with __THROW. */
640 extern char *gets (char *__s
) __wur __attribute_deprecated__
;
645 /* This function does the same as `fgets' but does not lock the stream.
647 This function is not part of POSIX and therefore no official
648 cancellation point. But due to similarity with an POSIX interface
649 or due to the implementation it is a cancellation point and
650 therefore not marked with __THROW. */
651 extern char *fgets_unlocked (char *__restrict __s
, int __n
,
652 FILE *__restrict __stream
) __wur
;
656 #ifdef __USE_XOPEN2K8
657 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
658 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
659 NULL), pointing to *N characters of space. It is realloc'd as
660 necessary. Returns the number of characters read (not including the
661 null terminator), or -1 on error or EOF.
663 These functions are not part of POSIX and therefore no official
664 cancellation point. But due to similarity with an POSIX interface
665 or due to the implementation they are cancellation points and
666 therefore not marked with __THROW. */
667 extern _IO_ssize_t
__getdelim (char **__restrict __lineptr
,
668 size_t *__restrict __n
, int __delimiter
,
669 FILE *__restrict __stream
) __wur
;
670 extern _IO_ssize_t
getdelim (char **__restrict __lineptr
,
671 size_t *__restrict __n
, int __delimiter
,
672 FILE *__restrict __stream
) __wur
;
674 /* Like `getdelim', but reads up to a newline.
676 This function is not part of POSIX and therefore no official
677 cancellation point. But due to similarity with an POSIX interface
678 or due to the implementation it is a cancellation point and
679 therefore not marked with __THROW. */
680 extern _IO_ssize_t
getline (char **__restrict __lineptr
,
681 size_t *__restrict __n
,
682 FILE *__restrict __stream
) __wur
;
686 __BEGIN_NAMESPACE_STD
687 /* Write a string to STREAM.
689 This function is a possible cancellation point and therefore not
690 marked with __THROW. */
691 extern int fputs (const char *__restrict __s
, FILE *__restrict __stream
);
693 /* Write a string, followed by a newline, to stdout.
695 This function is a possible cancellation point and therefore not
696 marked with __THROW. */
697 extern int puts (const char *__s
);
700 /* Push a character back onto the input buffer of STREAM.
702 This function is a possible cancellation point and therefore not
703 marked with __THROW. */
704 extern int ungetc (int __c
, FILE *__stream
);
707 /* Read chunks of generic data from STREAM.
709 This function is a possible cancellation point and therefore not
710 marked with __THROW. */
711 extern size_t fread (void *__restrict __ptr
, size_t __size
,
712 size_t __n
, FILE *__restrict __stream
) __wur
;
713 /* Write chunks of generic data to STREAM.
715 This function is a possible cancellation point and therefore not
716 marked with __THROW. */
717 extern size_t fwrite (const void *__restrict __ptr
, size_t __size
,
718 size_t __n
, FILE *__restrict __s
);
722 /* This function does the same as `fputs' but does not lock the stream.
724 This function is not part of POSIX and therefore no official
725 cancellation point. But due to similarity with an POSIX interface
726 or due to the implementation it is a cancellation point and
727 therefore not marked with __THROW. */
728 extern int fputs_unlocked (const char *__restrict __s
,
729 FILE *__restrict __stream
);
733 /* Faster versions when locking is not necessary.
735 These functions are not part of POSIX and therefore no official
736 cancellation point. But due to similarity with an POSIX interface
737 or due to the implementation they are cancellation points and
738 therefore not marked with __THROW. */
739 extern size_t fread_unlocked (void *__restrict __ptr
, size_t __size
,
740 size_t __n
, FILE *__restrict __stream
) __wur
;
741 extern size_t fwrite_unlocked (const void *__restrict __ptr
, size_t __size
,
742 size_t __n
, FILE *__restrict __stream
);
746 __BEGIN_NAMESPACE_STD
747 /* Seek to a certain position on STREAM.
749 This function is a possible cancellation point and therefore not
750 marked with __THROW. */
751 extern int fseek (FILE *__stream
, long int __off
, int __whence
);
752 /* Return the current position of STREAM.
754 This function is a possible cancellation point and therefore not
755 marked with __THROW. */
756 extern long int ftell (FILE *__stream
) __wur
;
757 /* Rewind to the beginning of STREAM.
759 This function is a possible cancellation point and therefore not
760 marked with __THROW. */
761 extern void rewind (FILE *__stream
);
764 /* The Single Unix Specification, Version 2, specifies an alternative,
765 more adequate interface for the two functions above which deal with
766 file offset. `long int' is not the right type. These definitions
767 are originally defined in the Large File Support API. */
769 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
770 # ifndef __USE_FILE_OFFSET64
771 /* Seek to a certain position on STREAM.
773 This function is a possible cancellation point and therefore not
774 marked with __THROW. */
775 extern int fseeko (FILE *__stream
, __off_t __off
, int __whence
);
776 /* Return the current position of STREAM.
778 This function is a possible cancellation point and therefore not
779 marked with __THROW. */
780 extern __off_t
ftello (FILE *__stream
) __wur
;
783 extern int __REDIRECT (fseeko
,
784 (FILE *__stream
, __off64_t __off
, int __whence
),
786 extern __off64_t
__REDIRECT (ftello
, (FILE *__stream
), ftello64
);
788 # define fseeko fseeko64
789 # define ftello ftello64
794 __BEGIN_NAMESPACE_STD
795 #ifndef __USE_FILE_OFFSET64
796 /* Get STREAM's position.
798 This function is a possible cancellation point and therefore not
799 marked with __THROW. */
800 extern int fgetpos (FILE *__restrict __stream
, fpos_t *__restrict __pos
);
801 /* Set STREAM's position.
803 This function is a possible cancellation point and therefore not
804 marked with __THROW. */
805 extern int fsetpos (FILE *__stream
, const fpos_t *__pos
);
808 extern int __REDIRECT (fgetpos
, (FILE *__restrict __stream
,
809 fpos_t *__restrict __pos
), fgetpos64
);
810 extern int __REDIRECT (fsetpos
,
811 (FILE *__stream
, const fpos_t *__pos
), fsetpos64
);
813 # define fgetpos fgetpos64
814 # define fsetpos fsetpos64
819 #ifdef __USE_LARGEFILE64
820 extern int fseeko64 (FILE *__stream
, __off64_t __off
, int __whence
);
821 extern __off64_t
ftello64 (FILE *__stream
) __wur
;
822 extern int fgetpos64 (FILE *__restrict __stream
, fpos64_t
*__restrict __pos
);
823 extern int fsetpos64 (FILE *__stream
, const fpos64_t
*__pos
);
826 __BEGIN_NAMESPACE_STD
827 /* Clear the error and EOF indicators for STREAM. */
828 extern void clearerr (FILE *__stream
) __THROW
;
829 /* Return the EOF indicator for STREAM. */
830 extern int feof (FILE *__stream
) __THROW __wur
;
831 /* Return the error indicator for STREAM. */
832 extern int ferror (FILE *__stream
) __THROW __wur
;
836 /* Faster versions when locking is not required. */
837 extern void clearerr_unlocked (FILE *__stream
) __THROW
;
838 extern int feof_unlocked (FILE *__stream
) __THROW __wur
;
839 extern int ferror_unlocked (FILE *__stream
) __THROW __wur
;
843 __BEGIN_NAMESPACE_STD
844 /* Print a message describing the meaning of the value of errno.
846 This function is a possible cancellation point and therefore not
847 marked with __THROW. */
848 extern void perror (const char *__s
);
851 /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
852 are available on this system. Even if available, these variables
853 should not be used directly. The `strerror' function provides
854 all the necessary functionality. */
855 #include <bits/sys_errlist.h>
859 /* Return the system file descriptor for STREAM. */
860 extern int fileno (FILE *__stream
) __THROW __wur
;
861 #endif /* Use POSIX. */
864 /* Faster version when locking is not required. */
865 extern int fileno_unlocked (FILE *__stream
) __THROW __wur
;
870 /* Create a new stream connected to a pipe running the given command.
872 This function is a possible cancellation point and therefore not
873 marked with __THROW. */
874 extern FILE *popen (const char *__command
, const char *__modes
) __wur
;
876 /* Close a stream opened by popen and return the status of its child.
878 This function is a possible cancellation point and therefore not
879 marked with __THROW. */
880 extern int pclose (FILE *__stream
);
885 /* Return the name of the controlling terminal. */
886 extern char *ctermid (char *__s
) __THROW
;
887 #endif /* Use POSIX. */
890 #if (defined __USE_XOPEN && !defined __USE_XOPEN2K) || defined __USE_GNU
891 /* Return the name of the current user. */
892 extern char *cuserid (char *__s
);
893 #endif /* Use X/Open, but not issue 6. */
897 struct obstack
; /* See <obstack.h>. */
899 /* Write formatted output to an obstack. */
900 extern int obstack_printf (struct obstack
*__restrict __obstack
,
901 const char *__restrict __format
, ...)
902 __THROWNL
__attribute__ ((__format__ (__printf__
, 2, 3)));
903 extern int obstack_vprintf (struct obstack
*__restrict __obstack
,
904 const char *__restrict __format
,
906 __THROWNL
__attribute__ ((__format__ (__printf__
, 2, 0)));
907 #endif /* Use GNU. */
910 #ifdef __USE_POSIX199506
911 /* These are defined in POSIX.1:1996. */
913 /* Acquire ownership of STREAM. */
914 extern void flockfile (FILE *__stream
) __THROW
;
916 /* Try to acquire ownership of STREAM but do not block if it is not
918 extern int ftrylockfile (FILE *__stream
) __THROW __wur
;
920 /* Relinquish the ownership granted for STREAM. */
921 extern void funlockfile (FILE *__stream
) __THROW
;
924 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
925 /* The X/Open standard requires some functions and variables to be
926 declared here which do not belong into this header. But we have to
927 follow. In GNU mode we don't do this nonsense. */
928 # define __need_getopt
930 #endif /* X/Open, but not issue 6 and not for GNU. */
932 /* If we are compiling with optimizing read this file. It contains
933 several optimizing inline functions and macros. */
934 #ifdef __USE_EXTERN_INLINES
935 # include <bits/stdio.h>
937 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
938 # include <bits/stdio2.h>
941 # include <bits/stdio-ldbl.h>
946 #endif /* <stdio.h> included. */
948 #endif /* !_STDIO_H */