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, 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_SVID || defined __USE_POSIX \
51 || defined __USE_BSD || 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
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
101 # ifndef __ssize_t_defined
102 typedef __ssize_t ssize_t
;
103 # define __ssize_t_defined
107 /* The type of the second argument to `fgetpos' and `fsetpos'. */
108 __BEGIN_NAMESPACE_STD
109 #ifndef __USE_FILE_OFFSET64
110 typedef _G_fpos_t
fpos_t;
112 typedef _G_fpos64_t
fpos_t;
115 #ifdef __USE_LARGEFILE64
116 typedef _G_fpos64_t fpos64_t
;
119 /* The possibilities for the third argument to `setvbuf'. */
120 #define _IOFBF 0 /* Fully buffered. */
121 #define _IOLBF 1 /* Line buffered. */
122 #define _IONBF 2 /* No buffering. */
125 /* Default buffer size. */
127 # define BUFSIZ _IO_BUFSIZ
131 /* End of file character.
132 Some things throughout the library rely on this being -1. */
138 /* The possibilities for the third argument to `fseek'.
139 These values should not be changed. */
140 #define SEEK_SET 0 /* Seek from beginning of file. */
141 #define SEEK_CUR 1 /* Seek from current position. */
142 #define SEEK_END 2 /* Seek from end of file. */
144 # define SEEK_DATA 3 /* Seek to next data. */
145 # define SEEK_HOLE 4 /* Seek to next hole. */
149 #if defined __USE_SVID || defined __USE_XOPEN
150 /* Default path prefix for `tempnam' and `tmpnam'. */
151 # define P_tmpdir "/tmp"
156 L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
157 TMP_MAX The minimum number of unique filenames generated by tmpnam
158 (and tempnam when it uses tmpnam's name space),
159 or tempnam (the two are separate).
160 L_ctermid How long an array to pass to `ctermid'.
161 L_cuserid How long an array to pass to `cuserid'.
162 FOPEN_MAX Minimum number of files that can be open at once.
163 FILENAME_MAX Maximum length of a filename. */
164 #include <bits/stdio_lim.h>
167 /* Standard streams. */
168 extern struct _IO_FILE
*stdin
; /* Standard input stream. */
169 extern struct _IO_FILE
*stdout
; /* Standard output stream. */
170 extern struct _IO_FILE
*stderr
; /* Standard error output stream. */
171 /* C89/C99 say they're macros. Make them happy. */
173 #define stdout stdout
174 #define stderr stderr
176 __BEGIN_NAMESPACE_STD
177 /* Remove file FILENAME. */
178 extern int remove (const char *__filename
) __THROW
;
179 /* Rename file OLD to NEW. */
180 extern int rename (const char *__old
, const char *__new
) __THROW
;
184 /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
185 extern int renameat (int __oldfd
, const char *__old
, int __newfd
,
186 const char *__new
) __THROW
;
189 __BEGIN_NAMESPACE_STD
190 /* Create a temporary file and open it read/write.
192 This function is a possible cancellation point and therefore not
193 marked with __THROW. */
194 #ifndef __USE_FILE_OFFSET64
195 extern FILE *tmpfile (void) __wur
;
198 extern FILE *__REDIRECT (tmpfile
, (void), tmpfile64
) __wur
;
200 # define tmpfile tmpfile64
204 #ifdef __USE_LARGEFILE64
205 extern FILE *tmpfile64 (void) __wur
;
208 /* Generate a temporary filename. */
209 extern char *tmpnam (char *__s
) __THROW __wur
;
213 /* This is the reentrant variant of `tmpnam'. The only difference is
214 that it does not allow S to be NULL. */
215 extern char *tmpnam_r (char *__s
) __THROW __wur
;
219 #if defined __USE_SVID || defined __USE_XOPEN
220 /* Generate a unique temporary filename using up to five characters of PFX
221 if it is not NULL. The directory to put this file in is searched for
222 as follows: First the environment variable "TMPDIR" is checked.
223 If it contains the name of a writable directory, that directory is used.
224 If not and if DIR is not NULL, that value is checked. If that fails,
225 P_tmpdir is tried and finally "/tmp". The storage for the filename
226 is allocated by `malloc'. */
227 extern char *tempnam (const char *__dir
, const char *__pfx
)
228 __THROW __attribute_malloc__ __wur
;
232 __BEGIN_NAMESPACE_STD
235 This function is a possible cancellation point and therefore not
236 marked with __THROW. */
237 extern int fclose (FILE *__stream
);
238 /* Flush STREAM, or all streams if STREAM is NULL.
240 This function is a possible cancellation point and therefore not
241 marked with __THROW. */
242 extern int fflush (FILE *__stream
);
246 /* Faster versions when locking is not required.
248 This function is not part of POSIX and therefore no official
249 cancellation point. But due to similarity with an POSIX interface
250 or due to the implementation it is a cancellation point and
251 therefore not marked with __THROW. */
252 extern int fflush_unlocked (FILE *__stream
);
256 /* Close all streams.
258 This function is not part of POSIX and therefore no official
259 cancellation point. But due to similarity with an POSIX interface
260 or due to the implementation it is a cancellation point and
261 therefore not marked with __THROW. */
262 extern int fcloseall (void);
266 __BEGIN_NAMESPACE_STD
267 #ifndef __USE_FILE_OFFSET64
268 /* Open a file and create a new stream for it.
270 This function is a possible cancellation point and therefore not
271 marked with __THROW. */
272 extern FILE *fopen (const char *__restrict __filename
,
273 const char *__restrict __modes
) __wur
;
274 /* Open a file, replacing an existing stream with it.
276 This function is a possible cancellation point and therefore not
277 marked with __THROW. */
278 extern FILE *freopen (const char *__restrict __filename
,
279 const char *__restrict __modes
,
280 FILE *__restrict __stream
) __wur
;
283 extern FILE *__REDIRECT (fopen
, (const char *__restrict __filename
,
284 const char *__restrict __modes
), fopen64
)
286 extern FILE *__REDIRECT (freopen
, (const char *__restrict __filename
,
287 const char *__restrict __modes
,
288 FILE *__restrict __stream
), freopen64
)
291 # define fopen fopen64
292 # define freopen freopen64
296 #ifdef __USE_LARGEFILE64
297 extern FILE *fopen64 (const char *__restrict __filename
,
298 const char *__restrict __modes
) __wur
;
299 extern FILE *freopen64 (const char *__restrict __filename
,
300 const char *__restrict __modes
,
301 FILE *__restrict __stream
) __wur
;
305 /* Create a new stream that refers to an existing system file descriptor. */
306 extern FILE *fdopen (int __fd
, const char *__modes
) __THROW __wur
;
310 /* Create a new stream that refers to the given magic cookie,
311 and uses the given functions for input and output. */
312 extern FILE *fopencookie (void *__restrict __magic_cookie
,
313 const char *__restrict __modes
,
314 _IO_cookie_io_functions_t __io_funcs
) __THROW __wur
;
317 #ifdef __USE_XOPEN2K8
318 /* Create a new stream that refers to a memory buffer. */
319 extern FILE *fmemopen (void *__s
, size_t __len
, const char *__modes
)
322 /* Open a stream that writes into a malloc'd buffer that is expanded as
323 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
324 and the number of characters written on fflush or fclose. */
325 extern FILE *open_memstream (char **__bufloc
, size_t *__sizeloc
) __THROW __wur
;
329 __BEGIN_NAMESPACE_STD
330 /* If BUF is NULL, make STREAM unbuffered.
331 Else make it use buffer BUF, of size BUFSIZ. */
332 extern void setbuf (FILE *__restrict __stream
, char *__restrict __buf
) __THROW
;
333 /* Make STREAM use buffering mode MODE.
334 If BUF is not NULL, use N bytes of it for buffering;
335 else allocate an internal buffer N bytes long. */
336 extern int setvbuf (FILE *__restrict __stream
, char *__restrict __buf
,
337 int __modes
, size_t __n
) __THROW
;
341 /* If BUF is NULL, make STREAM unbuffered.
342 Else make it use SIZE bytes of BUF for buffering. */
343 extern void setbuffer (FILE *__restrict __stream
, char *__restrict __buf
,
344 size_t __size
) __THROW
;
346 /* Make STREAM line-buffered. */
347 extern void setlinebuf (FILE *__stream
) __THROW
;
351 __BEGIN_NAMESPACE_STD
352 /* Write formatted output to STREAM.
354 This function is a possible cancellation point and therefore not
355 marked with __THROW. */
356 extern int fprintf (FILE *__restrict __stream
,
357 const char *__restrict __format
, ...);
358 /* Write formatted output to stdout.
360 This function is a possible cancellation point and therefore not
361 marked with __THROW. */
362 extern int printf (const char *__restrict __format
, ...);
363 /* Write formatted output to S. */
364 extern int sprintf (char *__restrict __s
,
365 const char *__restrict __format
, ...) __THROWNL
;
367 /* Write formatted output to S from argument list ARG.
369 This function is a possible cancellation point and therefore not
370 marked with __THROW. */
371 extern int vfprintf (FILE *__restrict __s
, const char *__restrict __format
,
373 /* Write formatted output to stdout from argument list ARG.
375 This function is a possible cancellation point and therefore not
376 marked with __THROW. */
377 extern int vprintf (const char *__restrict __format
, _G_va_list __arg
);
378 /* Write formatted output to S from argument list ARG. */
379 extern int vsprintf (char *__restrict __s
, const char *__restrict __format
,
380 _G_va_list __arg
) __THROWNL
;
383 #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
384 __BEGIN_NAMESPACE_C99
385 /* Maximum chars of output to write in MAXLEN. */
386 extern int snprintf (char *__restrict __s
, size_t __maxlen
,
387 const char *__restrict __format
, ...)
388 __THROWNL
__attribute__ ((__format__ (__printf__
, 3, 4)));
390 extern int vsnprintf (char *__restrict __s
, size_t __maxlen
,
391 const char *__restrict __format
, _G_va_list __arg
)
392 __THROWNL
__attribute__ ((__format__ (__printf__
, 3, 0)));
397 /* Write formatted output to a string dynamically allocated with `malloc'.
398 Store the address of the string in *PTR. */
399 extern int vasprintf (char **__restrict __ptr
, const char *__restrict __f
,
401 __THROWNL
__attribute__ ((__format__ (__printf__
, 2, 0))) __wur
;
402 extern int __asprintf (char **__restrict __ptr
,
403 const char *__restrict __fmt
, ...)
404 __THROWNL
__attribute__ ((__format__ (__printf__
, 2, 3))) __wur
;
405 extern int asprintf (char **__restrict __ptr
,
406 const char *__restrict __fmt
, ...)
407 __THROWNL
__attribute__ ((__format__ (__printf__
, 2, 3))) __wur
;
410 #ifdef __USE_XOPEN2K8
411 /* Write formatted output to a file descriptor.
413 These functions are not part of POSIX and therefore no official
414 cancellation point. But due to similarity with an POSIX interface
415 or due to the implementation they are cancellation points and
416 therefore not marked with __THROW. */
417 extern int vdprintf (int __fd
, const char *__restrict __fmt
,
419 __attribute__ ((__format__ (__printf__
, 2, 0)));
420 extern int dprintf (int __fd
, const char *__restrict __fmt
, ...)
421 __attribute__ ((__format__ (__printf__
, 2, 3)));
425 __BEGIN_NAMESPACE_STD
426 /* Read formatted input from STREAM.
428 This function is a possible cancellation point and therefore not
429 marked with __THROW. */
430 extern int fscanf (FILE *__restrict __stream
,
431 const char *__restrict __format
, ...) __wur
;
432 /* Read formatted input from stdin.
434 This function is a possible cancellation point and therefore not
435 marked with __THROW. */
436 extern int scanf (const char *__restrict __format
, ...) __wur
;
437 /* Read formatted input from S. */
438 extern int sscanf (const char *__restrict __s
,
439 const char *__restrict __format
, ...) __THROW
;
441 #if defined __USE_ISOC99 && !defined __USE_GNU \
442 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
443 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
445 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
446 GNU extension which conflicts with valid %a followed by letter
448 extern int __REDIRECT (fscanf
, (FILE *__restrict __stream
,
449 const char *__restrict __format
, ...),
450 __isoc99_fscanf
) __wur
;
451 extern int __REDIRECT (scanf
, (const char *__restrict __format
, ...),
452 __isoc99_scanf
) __wur
;
453 extern int __REDIRECT_NTH (sscanf
, (const char *__restrict __s
,
454 const char *__restrict __format
, ...),
457 extern int __isoc99_fscanf (FILE *__restrict __stream
,
458 const char *__restrict __format
, ...) __wur
;
459 extern int __isoc99_scanf (const char *__restrict __format
, ...) __wur
;
460 extern int __isoc99_sscanf (const char *__restrict __s
,
461 const char *__restrict __format
, ...) __THROW
;
462 # define fscanf __isoc99_fscanf
463 # define scanf __isoc99_scanf
464 # define sscanf __isoc99_sscanf
471 __BEGIN_NAMESPACE_C99
472 /* Read formatted input from S into argument list ARG.
474 This function is a possible cancellation point and therefore not
475 marked with __THROW. */
476 extern int vfscanf (FILE *__restrict __s
, const char *__restrict __format
,
478 __attribute__ ((__format__ (__scanf__
, 2, 0))) __wur
;
480 /* Read formatted input from stdin into argument list ARG.
482 This function is a possible cancellation point and therefore not
483 marked with __THROW. */
484 extern int vscanf (const char *__restrict __format
, _G_va_list __arg
)
485 __attribute__ ((__format__ (__scanf__
, 1, 0))) __wur
;
487 /* Read formatted input from S into argument list ARG. */
488 extern int vsscanf (const char *__restrict __s
,
489 const char *__restrict __format
, _G_va_list __arg
)
490 __THROW
__attribute__ ((__format__ (__scanf__
, 2, 0)));
492 # if !defined __USE_GNU \
493 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
494 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
496 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
497 GNU extension which conflicts with valid %a followed by letter
499 extern int __REDIRECT (vfscanf
,
500 (FILE *__restrict __s
,
501 const char *__restrict __format
, _G_va_list __arg
),
503 __attribute__ ((__format__ (__scanf__
, 2, 0))) __wur
;
504 extern int __REDIRECT (vscanf
, (const char *__restrict __format
,
505 _G_va_list __arg
), __isoc99_vscanf
)
506 __attribute__ ((__format__ (__scanf__
, 1, 0))) __wur
;
507 extern int __REDIRECT_NTH (vsscanf
,
508 (const char *__restrict __s
,
509 const char *__restrict __format
,
510 _G_va_list __arg
), __isoc99_vsscanf
)
511 __attribute__ ((__format__ (__scanf__
, 2, 0)));
513 extern int __isoc99_vfscanf (FILE *__restrict __s
,
514 const char *__restrict __format
,
515 _G_va_list __arg
) __wur
;
516 extern int __isoc99_vscanf (const char *__restrict __format
,
517 _G_va_list __arg
) __wur
;
518 extern int __isoc99_vsscanf (const char *__restrict __s
,
519 const char *__restrict __format
,
520 _G_va_list __arg
) __THROW
;
521 # define vfscanf __isoc99_vfscanf
522 # define vscanf __isoc99_vscanf
523 # define vsscanf __isoc99_vsscanf
528 #endif /* Use ISO C9x. */
531 __BEGIN_NAMESPACE_STD
532 /* Read a character from STREAM.
534 These functions are possible cancellation points and therefore not
535 marked with __THROW. */
536 extern int fgetc (FILE *__stream
);
537 extern int getc (FILE *__stream
);
539 /* Read a character from stdin.
541 This function is a possible cancellation point and therefore not
542 marked with __THROW. */
543 extern int getchar (void);
546 /* The C standard explicitly says this is a macro, so we always do the
547 optimization for it. */
548 #define getc(_fp) _IO_getc (_fp)
550 #if defined __USE_POSIX || defined __USE_MISC
551 /* These are defined in POSIX.1:1996.
553 These functions are possible cancellation points and therefore not
554 marked with __THROW. */
555 extern int getc_unlocked (FILE *__stream
);
556 extern int getchar_unlocked (void);
557 #endif /* Use POSIX or MISC. */
560 /* Faster version when locking is not necessary.
562 This function is not part of POSIX and therefore no official
563 cancellation point. But due to similarity with an POSIX interface
564 or due to the implementation it is a cancellation point and
565 therefore not marked with __THROW. */
566 extern int fgetc_unlocked (FILE *__stream
);
567 #endif /* Use MISC. */
570 __BEGIN_NAMESPACE_STD
571 /* Write a character to STREAM.
573 These functions are possible cancellation points and therefore not
576 These functions is a possible cancellation point and therefore not
577 marked with __THROW. */
578 extern int fputc (int __c
, FILE *__stream
);
579 extern int putc (int __c
, FILE *__stream
);
581 /* Write a character to stdout.
583 This function is a possible cancellation point and therefore not
584 marked with __THROW. */
585 extern int putchar (int __c
);
588 /* The C standard explicitly says this can be a macro,
589 so we always do the optimization for it. */
590 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
593 /* Faster version when locking is not necessary.
595 This function is not part of POSIX and therefore no official
596 cancellation point. But due to similarity with an POSIX interface
597 or due to the implementation it is a cancellation point and
598 therefore not marked with __THROW. */
599 extern int fputc_unlocked (int __c
, FILE *__stream
);
600 #endif /* Use MISC. */
602 #if defined __USE_POSIX || defined __USE_MISC
603 /* These are defined in POSIX.1:1996.
605 These functions are possible cancellation points and therefore not
606 marked with __THROW. */
607 extern int putc_unlocked (int __c
, FILE *__stream
);
608 extern int putchar_unlocked (int __c
);
609 #endif /* Use POSIX or MISC. */
612 #if defined __USE_SVID || defined __USE_MISC \
613 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
614 /* Get a word (int) from STREAM. */
615 extern int getw (FILE *__stream
);
617 /* Write a word (int) to STREAM. */
618 extern int putw (int __w
, FILE *__stream
);
622 __BEGIN_NAMESPACE_STD
623 /* Get a newline-terminated string of finite length from STREAM.
625 This function is a possible cancellation point and therefore not
626 marked with __THROW. */
627 extern char *fgets (char *__restrict __s
, int __n
, FILE *__restrict __stream
)
630 #if !defined __USE_ISOC11 \
631 || (defined __cplusplus && __cplusplus <= 201103L && !defined __USE_GNU)
632 /* Get a newline-terminated string from stdin, removing the newline.
633 DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
635 The function has been officially removed in ISO C11. This opportunity
636 is used to also remove it from the GNU feature list. It is now only
637 available when explicitly using an old ISO C, Unix, or POSIX standard.
638 GCC defines _GNU_SOURCE when building C++ code and the function is still
639 in C++11, so it is also available for C++.
641 This function is a possible cancellation point and therefore not
642 marked with __THROW. */
643 extern char *gets (char *__s
) __wur __attribute_deprecated__
;
648 /* This function does the same as `fgets' but does not lock the stream.
650 This function is not part of POSIX and therefore no official
651 cancellation point. But due to similarity with an POSIX interface
652 or due to the implementation it is a cancellation point and
653 therefore not marked with __THROW. */
654 extern char *fgets_unlocked (char *__restrict __s
, int __n
,
655 FILE *__restrict __stream
) __wur
;
659 #ifdef __USE_XOPEN2K8
660 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
661 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
662 NULL), pointing to *N characters of space. It is realloc'd as
663 necessary. Returns the number of characters read (not including the
664 null terminator), or -1 on error or EOF.
666 These functions are not part of POSIX and therefore no official
667 cancellation point. But due to similarity with an POSIX interface
668 or due to the implementation they are cancellation points and
669 therefore not marked with __THROW. */
670 extern _IO_ssize_t
__getdelim (char **__restrict __lineptr
,
671 size_t *__restrict __n
, int __delimiter
,
672 FILE *__restrict __stream
) __wur
;
673 extern _IO_ssize_t
getdelim (char **__restrict __lineptr
,
674 size_t *__restrict __n
, int __delimiter
,
675 FILE *__restrict __stream
) __wur
;
677 /* Like `getdelim', but reads up to a newline.
679 This function is not part of POSIX and therefore no official
680 cancellation point. But due to similarity with an POSIX interface
681 or due to the implementation it is a cancellation point and
682 therefore not marked with __THROW. */
683 extern _IO_ssize_t
getline (char **__restrict __lineptr
,
684 size_t *__restrict __n
,
685 FILE *__restrict __stream
) __wur
;
689 __BEGIN_NAMESPACE_STD
690 /* Write a string to STREAM.
692 This function is a possible cancellation point and therefore not
693 marked with __THROW. */
694 extern int fputs (const char *__restrict __s
, FILE *__restrict __stream
);
696 /* Write a string, followed by a newline, to stdout.
698 This function is a possible cancellation point and therefore not
699 marked with __THROW. */
700 extern int puts (const char *__s
);
703 /* Push a character back onto the input buffer of STREAM.
705 This function is a possible cancellation point and therefore not
706 marked with __THROW. */
707 extern int ungetc (int __c
, FILE *__stream
);
710 /* Read chunks of generic data from STREAM.
712 This function is a possible cancellation point and therefore not
713 marked with __THROW. */
714 extern size_t fread (void *__restrict __ptr
, size_t __size
,
715 size_t __n
, FILE *__restrict __stream
) __wur
;
716 /* Write chunks of generic data to STREAM.
718 This function is a possible cancellation point and therefore not
719 marked with __THROW. */
720 extern size_t fwrite (const void *__restrict __ptr
, size_t __size
,
721 size_t __n
, FILE *__restrict __s
) __wur
;
725 /* This function does the same as `fputs' but does not lock the stream.
727 This function is not part of POSIX and therefore no official
728 cancellation point. But due to similarity with an POSIX interface
729 or due to the implementation it is a cancellation point and
730 therefore not marked with __THROW. */
731 extern int fputs_unlocked (const char *__restrict __s
,
732 FILE *__restrict __stream
);
736 /* Faster versions when locking is not necessary.
738 These functions are not part of POSIX and therefore no official
739 cancellation point. But due to similarity with an POSIX interface
740 or due to the implementation they are cancellation points and
741 therefore not marked with __THROW. */
742 extern size_t fread_unlocked (void *__restrict __ptr
, size_t __size
,
743 size_t __n
, FILE *__restrict __stream
) __wur
;
744 extern size_t fwrite_unlocked (const void *__restrict __ptr
, size_t __size
,
745 size_t __n
, FILE *__restrict __stream
) __wur
;
749 __BEGIN_NAMESPACE_STD
750 /* Seek to a certain position on STREAM.
752 This function is a possible cancellation point and therefore not
753 marked with __THROW. */
754 extern int fseek (FILE *__stream
, long int __off
, int __whence
);
755 /* Return the current position of STREAM.
757 This function is a possible cancellation point and therefore not
758 marked with __THROW. */
759 extern long int ftell (FILE *__stream
) __wur
;
760 /* Rewind to the beginning of STREAM.
762 This function is a possible cancellation point and therefore not
763 marked with __THROW. */
764 extern void rewind (FILE *__stream
);
767 /* The Single Unix Specification, Version 2, specifies an alternative,
768 more adequate interface for the two functions above which deal with
769 file offset. `long int' is not the right type. These definitions
770 are originally defined in the Large File Support API. */
772 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
773 # ifndef __USE_FILE_OFFSET64
774 /* Seek to a certain position on STREAM.
776 This function is a possible cancellation point and therefore not
777 marked with __THROW. */
778 extern int fseeko (FILE *__stream
, __off_t __off
, int __whence
);
779 /* Return the current position of STREAM.
781 This function is a possible cancellation point and therefore not
782 marked with __THROW. */
783 extern __off_t
ftello (FILE *__stream
) __wur
;
786 extern int __REDIRECT (fseeko
,
787 (FILE *__stream
, __off64_t __off
, int __whence
),
789 extern __off64_t
__REDIRECT (ftello
, (FILE *__stream
), ftello64
);
791 # define fseeko fseeko64
792 # define ftello ftello64
797 __BEGIN_NAMESPACE_STD
798 #ifndef __USE_FILE_OFFSET64
799 /* Get STREAM's position.
801 This function is a possible cancellation point and therefore not
802 marked with __THROW. */
803 extern int fgetpos (FILE *__restrict __stream
, fpos_t *__restrict __pos
);
804 /* Set STREAM's position.
806 This function is a possible cancellation point and therefore not
807 marked with __THROW. */
808 extern int fsetpos (FILE *__stream
, const fpos_t *__pos
);
811 extern int __REDIRECT (fgetpos
, (FILE *__restrict __stream
,
812 fpos_t *__restrict __pos
), fgetpos64
);
813 extern int __REDIRECT (fsetpos
,
814 (FILE *__stream
, const fpos_t *__pos
), fsetpos64
);
816 # define fgetpos fgetpos64
817 # define fsetpos fsetpos64
822 #ifdef __USE_LARGEFILE64
823 extern int fseeko64 (FILE *__stream
, __off64_t __off
, int __whence
);
824 extern __off64_t
ftello64 (FILE *__stream
) __wur
;
825 extern int fgetpos64 (FILE *__restrict __stream
, fpos64_t
*__restrict __pos
);
826 extern int fsetpos64 (FILE *__stream
, const fpos64_t
*__pos
);
829 __BEGIN_NAMESPACE_STD
830 /* Clear the error and EOF indicators for STREAM. */
831 extern void clearerr (FILE *__stream
) __THROW
;
832 /* Return the EOF indicator for STREAM. */
833 extern int feof (FILE *__stream
) __THROW __wur
;
834 /* Return the error indicator for STREAM. */
835 extern int ferror (FILE *__stream
) __THROW __wur
;
839 /* Faster versions when locking is not required. */
840 extern void clearerr_unlocked (FILE *__stream
) __THROW
;
841 extern int feof_unlocked (FILE *__stream
) __THROW __wur
;
842 extern int ferror_unlocked (FILE *__stream
) __THROW __wur
;
846 __BEGIN_NAMESPACE_STD
847 /* Print a message describing the meaning of the value of errno.
849 This function is a possible cancellation point and therefore not
850 marked with __THROW. */
851 extern void perror (const char *__s
);
854 /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
855 are available on this system. Even if available, these variables
856 should not be used directly. The `strerror' function provides
857 all the necessary functionality. */
858 #include <bits/sys_errlist.h>
862 /* Return the system file descriptor for STREAM. */
863 extern int fileno (FILE *__stream
) __THROW __wur
;
864 #endif /* Use POSIX. */
867 /* Faster version when locking is not required. */
868 extern int fileno_unlocked (FILE *__stream
) __THROW __wur
;
872 #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
874 /* Create a new stream connected to a pipe running the given command.
876 This function is a possible cancellation point and therefore not
877 marked with __THROW. */
878 extern FILE *popen (const char *__command
, const char *__modes
) __wur
;
880 /* Close a stream opened by popen and return the status of its child.
882 This function is a possible cancellation point and therefore not
883 marked with __THROW. */
884 extern int pclose (FILE *__stream
);
889 /* Return the name of the controlling terminal. */
890 extern char *ctermid (char *__s
) __THROW
;
891 #endif /* Use POSIX. */
895 /* Return the name of the current user. */
896 extern char *cuserid (char *__s
);
897 #endif /* Use X/Open, but not issue 6. */
901 struct obstack
; /* See <obstack.h>. */
903 /* Write formatted output to an obstack. */
904 extern int obstack_printf (struct obstack
*__restrict __obstack
,
905 const char *__restrict __format
, ...)
906 __THROWNL
__attribute__ ((__format__ (__printf__
, 2, 3)));
907 extern int obstack_vprintf (struct obstack
*__restrict __obstack
,
908 const char *__restrict __format
,
910 __THROWNL
__attribute__ ((__format__ (__printf__
, 2, 0)));
911 #endif /* Use GNU. */
914 #if defined __USE_POSIX || defined __USE_MISC
915 /* These are defined in POSIX.1:1996. */
917 /* Acquire ownership of STREAM. */
918 extern void flockfile (FILE *__stream
) __THROW
;
920 /* Try to acquire ownership of STREAM but do not block if it is not
922 extern int ftrylockfile (FILE *__stream
) __THROW __wur
;
924 /* Relinquish the ownership granted for STREAM. */
925 extern void funlockfile (FILE *__stream
) __THROW
;
926 #endif /* POSIX || misc */
928 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
929 /* The X/Open standard requires some functions and variables to be
930 declared here which do not belong into this header. But we have to
931 follow. In GNU mode we don't do this nonsense. */
932 # define __need_getopt
934 #endif /* X/Open, but not issue 6 and not for GNU. */
936 /* If we are compiling with optimizing read this file. It contains
937 several optimizing inline functions and macros. */
938 #ifdef __USE_EXTERN_INLINES
939 # include <bits/stdio.h>
941 #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
942 # include <bits/stdio2.h>
945 # include <bits/stdio-ldbl.h>
950 #endif /* <stdio.h> included. */
952 #endif /* !_STDIO_H */