1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991, 1994-2007, 2008, 2009 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
79 # ifndef _VA_LIST_DEFINED
80 typedef _G_va_list
va_list;
81 # define _VA_LIST_DEFINED
88 /* The type of the second argument to `fgetpos' and `fsetpos'. */
90 #ifndef __USE_FILE_OFFSET64
91 typedef _G_fpos_t
fpos_t;
93 typedef _G_fpos64_t
fpos_t;
96 #ifdef __USE_LARGEFILE64
97 typedef _G_fpos64_t fpos64_t
;
100 /* The possibilities for the third argument to `setvbuf'. */
101 #define _IOFBF 0 /* Fully buffered. */
102 #define _IOLBF 1 /* Line buffered. */
103 #define _IONBF 2 /* No buffering. */
106 /* Default buffer size. */
108 # define BUFSIZ _IO_BUFSIZ
112 /* End of file character.
113 Some things throughout the library rely on this being -1. */
119 /* The possibilities for the third argument to `fseek'.
120 These values should not be changed. */
121 #define SEEK_SET 0 /* Seek from beginning of file. */
122 #define SEEK_CUR 1 /* Seek from current position. */
123 #define SEEK_END 2 /* Seek from end of file. */
126 #if defined __USE_SVID || defined __USE_XOPEN
127 /* Default path prefix for `tempnam' and `tmpnam'. */
128 # define P_tmpdir "/tmp"
133 L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
134 TMP_MAX The minimum number of unique filenames generated by tmpnam
135 (and tempnam when it uses tmpnam's name space),
136 or tempnam (the two are separate).
137 L_ctermid How long an array to pass to `ctermid'.
138 L_cuserid How long an array to pass to `cuserid'.
139 FOPEN_MAX Minimum number of files that can be open at once.
140 FILENAME_MAX Maximum length of a filename. */
141 #include <bits/stdio_lim.h>
144 /* Standard streams. */
145 extern struct _IO_FILE
*stdin
; /* Standard input stream. */
146 extern struct _IO_FILE
*stdout
; /* Standard output stream. */
147 extern struct _IO_FILE
*stderr
; /* Standard error output stream. */
149 /* C89/C99 say they're macros. Make them happy. */
151 #define stdout stdout
152 #define stderr stderr
155 __BEGIN_NAMESPACE_STD
156 /* Remove file FILENAME. */
157 extern int remove (__const
char *__filename
) __THROW
;
158 /* Rename file OLD to NEW. */
159 extern int rename (__const
char *__old
, __const
char *__new
) __THROW
;
163 /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
164 extern int renameat (int __oldfd
, __const
char *__old
, int __newfd
,
165 __const
char *__new
) __THROW
;
168 __BEGIN_NAMESPACE_STD
169 /* Create a temporary file and open it read/write.
171 This function is a possible cancellation points and therefore not
172 marked with __THROW. */
173 #ifndef __USE_FILE_OFFSET64
174 extern FILE *tmpfile (void) __wur
;
177 extern FILE *__REDIRECT (tmpfile
, (void), tmpfile64
) __wur
;
179 # define tmpfile tmpfile64
183 #ifdef __USE_LARGEFILE64
184 extern FILE *tmpfile64 (void) __wur
;
187 /* Generate a temporary filename. */
188 extern char *tmpnam (char *__s
) __THROW __wur
;
192 /* This is the reentrant variant of `tmpnam'. The only difference is
193 that it does not allow S to be NULL. */
194 extern char *tmpnam_r (char *__s
) __THROW __wur
;
198 #if defined __USE_SVID || defined __USE_XOPEN
199 /* Generate a unique temporary filename using up to five characters of PFX
200 if it is not NULL. The directory to put this file in is searched for
201 as follows: First the environment variable "TMPDIR" is checked.
202 If it contains the name of a writable directory, that directory is used.
203 If not and if DIR is not NULL, that value is checked. If that fails,
204 P_tmpdir is tried and finally "/tmp". The storage for the filename
205 is allocated by `malloc'. */
206 extern char *tempnam (__const
char *__dir
, __const
char *__pfx
)
207 __THROW __attribute_malloc__ __wur
;
211 __BEGIN_NAMESPACE_STD
214 This function is a possible cancellation point and therefore not
215 marked with __THROW. */
216 extern int fclose (FILE *__stream
);
217 /* Flush STREAM, or all streams if STREAM is NULL.
219 This function is a possible cancellation point and therefore not
220 marked with __THROW. */
221 extern int fflush (FILE *__stream
);
225 /* Faster versions when locking is not required.
227 This function is not part of POSIX and therefore no official
228 cancellation point. But due to similarity with an POSIX interface
229 or due to the implementation it is a cancellation point and
230 therefore not marked with __THROW. */
231 extern int fflush_unlocked (FILE *__stream
);
235 /* Close all streams.
237 This function is not part of POSIX and therefore no official
238 cancellation point. But due to similarity with an POSIX interface
239 or due to the implementation it is a cancellation point and
240 therefore not marked with __THROW. */
241 extern int fcloseall (void);
245 __BEGIN_NAMESPACE_STD
246 #ifndef __USE_FILE_OFFSET64
247 /* Open a file and create a new stream for it.
249 This function is a possible cancellation point and therefore not
250 marked with __THROW. */
251 extern FILE *fopen (__const
char *__restrict __filename
,
252 __const
char *__restrict __modes
) __wur
;
253 /* Open a file, replacing an existing stream with it.
255 This function is a possible cancellation point and therefore not
256 marked with __THROW. */
257 extern FILE *freopen (__const
char *__restrict __filename
,
258 __const
char *__restrict __modes
,
259 FILE *__restrict __stream
) __wur
;
262 extern FILE *__REDIRECT (fopen
, (__const
char *__restrict __filename
,
263 __const
char *__restrict __modes
), fopen64
)
265 extern FILE *__REDIRECT (freopen
, (__const
char *__restrict __filename
,
266 __const
char *__restrict __modes
,
267 FILE *__restrict __stream
), freopen64
)
270 # define fopen fopen64
271 # define freopen freopen64
275 #ifdef __USE_LARGEFILE64
276 extern FILE *fopen64 (__const
char *__restrict __filename
,
277 __const
char *__restrict __modes
) __wur
;
278 extern FILE *freopen64 (__const
char *__restrict __filename
,
279 __const
char *__restrict __modes
,
280 FILE *__restrict __stream
) __wur
;
284 /* Create a new stream that refers to an existing system file descriptor. */
285 extern FILE *fdopen (int __fd
, __const
char *__modes
) __THROW __wur
;
289 /* Create a new stream that refers to the given magic cookie,
290 and uses the given functions for input and output. */
291 extern FILE *fopencookie (void *__restrict __magic_cookie
,
292 __const
char *__restrict __modes
,
293 _IO_cookie_io_functions_t __io_funcs
) __THROW __wur
;
296 #ifdef __USE_XOPEN2K8
297 /* Create a new stream that refers to a memory buffer. */
298 extern FILE *fmemopen (void *__s
, size_t __len
, __const
char *__modes
)
301 /* Open a stream that writes into a malloc'd buffer that is expanded as
302 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
303 and the number of characters written on fflush or fclose. */
304 extern FILE *open_memstream (char **__bufloc
, size_t *__sizeloc
) __THROW __wur
;
308 __BEGIN_NAMESPACE_STD
309 /* If BUF is NULL, make STREAM unbuffered.
310 Else make it use buffer BUF, of size BUFSIZ. */
311 extern void setbuf (FILE *__restrict __stream
, char *__restrict __buf
) __THROW
;
312 /* Make STREAM use buffering mode MODE.
313 If BUF is not NULL, use N bytes of it for buffering;
314 else allocate an internal buffer N bytes long. */
315 extern int setvbuf (FILE *__restrict __stream
, char *__restrict __buf
,
316 int __modes
, size_t __n
) __THROW
;
320 /* If BUF is NULL, make STREAM unbuffered.
321 Else make it use SIZE bytes of BUF for buffering. */
322 extern void setbuffer (FILE *__restrict __stream
, char *__restrict __buf
,
323 size_t __size
) __THROW
;
325 /* Make STREAM line-buffered. */
326 extern void setlinebuf (FILE *__stream
) __THROW
;
330 __BEGIN_NAMESPACE_STD
331 /* Write formatted output to STREAM.
333 This function is a possible cancellation point and therefore not
334 marked with __THROW. */
335 extern int fprintf (FILE *__restrict __stream
,
336 __const
char *__restrict __format
, ...);
337 /* Write formatted output to stdout.
339 This function is a possible cancellation point and therefore not
340 marked with __THROW. */
341 extern int printf (__const
char *__restrict __format
, ...);
342 /* Write formatted output to S. */
343 extern int sprintf (char *__restrict __s
,
344 __const
char *__restrict __format
, ...) __THROW
;
346 /* Write formatted output to S from argument list ARG.
348 This function is a possible cancellation point and therefore not
349 marked with __THROW. */
350 extern int vfprintf (FILE *__restrict __s
, __const
char *__restrict __format
,
352 /* Write formatted output to stdout from argument list ARG.
354 This function is a possible cancellation point and therefore not
355 marked with __THROW. */
356 extern int vprintf (__const
char *__restrict __format
, _G_va_list __arg
);
357 /* Write formatted output to S from argument list ARG. */
358 extern int vsprintf (char *__restrict __s
, __const
char *__restrict __format
,
359 _G_va_list __arg
) __THROW
;
362 #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
363 __BEGIN_NAMESPACE_C99
364 /* Maximum chars of output to write in MAXLEN. */
365 extern int snprintf (char *__restrict __s
, size_t __maxlen
,
366 __const
char *__restrict __format
, ...)
367 __THROW
__attribute__ ((__format__ (__printf__
, 3, 4)));
369 extern int vsnprintf (char *__restrict __s
, size_t __maxlen
,
370 __const
char *__restrict __format
, _G_va_list __arg
)
371 __THROW
__attribute__ ((__format__ (__printf__
, 3, 0)));
376 /* Write formatted output to a string dynamically allocated with `malloc'.
377 Store the address of the string in *PTR. */
378 extern int vasprintf (char **__restrict __ptr
, __const
char *__restrict __f
,
380 __THROW
__attribute__ ((__format__ (__printf__
, 2, 0))) __wur
;
381 extern int __asprintf (char **__restrict __ptr
,
382 __const
char *__restrict __fmt
, ...)
383 __THROW
__attribute__ ((__format__ (__printf__
, 2, 3))) __wur
;
384 extern int asprintf (char **__restrict __ptr
,
385 __const
char *__restrict __fmt
, ...)
386 __THROW
__attribute__ ((__format__ (__printf__
, 2, 3))) __wur
;
389 #ifdef __USE_XOPEN2K8
390 /* Write formatted output to a file descriptor.
392 These functions are not part of POSIX and therefore no official
393 cancellation point. But due to similarity with an POSIX interface
394 or due to the implementation they are cancellation points and
395 therefore not marked with __THROW. */
396 extern int vdprintf (int __fd
, __const
char *__restrict __fmt
,
398 __attribute__ ((__format__ (__printf__
, 2, 0)));
399 extern int dprintf (int __fd
, __const
char *__restrict __fmt
, ...)
400 __attribute__ ((__format__ (__printf__
, 2, 3)));
404 __BEGIN_NAMESPACE_STD
405 /* Read formatted input from STREAM.
407 This function is a possible cancellation point and therefore not
408 marked with __THROW. */
409 extern int fscanf (FILE *__restrict __stream
,
410 __const
char *__restrict __format
, ...) __wur
;
411 /* Read formatted input from stdin.
413 This function is a possible cancellation point and therefore not
414 marked with __THROW. */
415 extern int scanf (__const
char *__restrict __format
, ...) __wur
;
416 /* Read formatted input from S. */
417 extern int sscanf (__const
char *__restrict __s
,
418 __const
char *__restrict __format
, ...) __THROW
;
420 #if defined __USE_ISOC99 && !defined __USE_GNU \
421 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
422 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
424 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
425 GNU extension which conflicts with valid %a followed by letter
427 extern int __REDIRECT (fscanf
, (FILE *__restrict __stream
,
428 __const
char *__restrict __format
, ...),
429 __isoc99_fscanf
) __wur
;
430 extern int __REDIRECT (scanf
, (__const
char *__restrict __format
, ...),
431 __isoc99_scanf
) __wur
;
432 extern int __REDIRECT (sscanf
, (__const
char *__restrict __s
,
433 __const
char *__restrict __format
, ...),
434 __isoc99_sscanf
) __THROW
;
436 extern int __isoc99_fscanf (FILE *__restrict __stream
,
437 __const
char *__restrict __format
, ...) __wur
;
438 extern int __isoc99_scanf (__const
char *__restrict __format
, ...) __wur
;
439 extern int __isoc99_sscanf (__const
char *__restrict __s
,
440 __const
char *__restrict __format
, ...) __THROW
;
441 # define fscanf __isoc99_fscanf
442 # define scanf __isoc99_scanf
443 # define sscanf __isoc99_sscanf
450 __BEGIN_NAMESPACE_C99
451 /* Read formatted input from S into argument list ARG.
453 This function is a possible cancellation point and therefore not
454 marked with __THROW. */
455 extern int vfscanf (FILE *__restrict __s
, __const
char *__restrict __format
,
457 __attribute__ ((__format__ (__scanf__
, 2, 0))) __wur
;
459 /* Read formatted input from stdin into argument list ARG.
461 This function is a possible cancellation point and therefore not
462 marked with __THROW. */
463 extern int vscanf (__const
char *__restrict __format
, _G_va_list __arg
)
464 __attribute__ ((__format__ (__scanf__
, 1, 0))) __wur
;
466 /* Read formatted input from S into argument list ARG. */
467 extern int vsscanf (__const
char *__restrict __s
,
468 __const
char *__restrict __format
, _G_va_list __arg
)
469 __THROW
__attribute__ ((__format__ (__scanf__
, 2, 0)));
471 # if !defined __USE_GNU \
472 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
473 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
475 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
476 GNU extension which conflicts with valid %a followed by letter
478 extern int __REDIRECT (vfscanf
,
479 (FILE *__restrict __s
,
480 __const
char *__restrict __format
, _G_va_list __arg
),
482 __attribute__ ((__format__ (__scanf__
, 2, 0))) __wur
;
483 extern int __REDIRECT (vscanf
, (__const
char *__restrict __format
,
484 _G_va_list __arg
), __isoc99_vscanf
)
485 __attribute__ ((__format__ (__scanf__
, 1, 0))) __wur
;
486 extern int __REDIRECT (vsscanf
,
487 (__const
char *__restrict __s
,
488 __const
char *__restrict __format
, _G_va_list __arg
),
490 __THROW
__attribute__ ((__format__ (__scanf__
, 2, 0)));
492 extern int __isoc99_vfscanf (FILE *__restrict __s
,
493 __const
char *__restrict __format
,
494 _G_va_list __arg
) __wur
;
495 extern int __isoc99_vscanf (__const
char *__restrict __format
,
496 _G_va_list __arg
) __wur
;
497 extern int __isoc99_vsscanf (__const
char *__restrict __s
,
498 __const
char *__restrict __format
,
499 _G_va_list __arg
) __THROW
;
500 # define vfscanf __isoc99_vfscanf
501 # define vscanf __isoc99_vscanf
502 # define vsscanf __isoc99_vsscanf
507 #endif /* Use ISO C9x. */
510 __BEGIN_NAMESPACE_STD
511 /* Read a character from STREAM.
513 These functions are possible cancellation points and therefore not
514 marked with __THROW. */
515 extern int fgetc (FILE *__stream
);
516 extern int getc (FILE *__stream
);
518 /* Read a character from stdin.
520 This function is a possible cancellation point and therefore not
521 marked with __THROW. */
522 extern int getchar (void);
525 /* The C standard explicitly says this is a macro, so we always do the
526 optimization for it. */
527 #define getc(_fp) _IO_getc (_fp)
529 #if defined __USE_POSIX || defined __USE_MISC
530 /* These are defined in POSIX.1:1996.
532 These functions are possible cancellation points and therefore not
533 marked with __THROW. */
534 extern int getc_unlocked (FILE *__stream
);
535 extern int getchar_unlocked (void);
536 #endif /* Use POSIX or MISC. */
539 /* Faster version when locking is not necessary.
541 This function is not part of POSIX and therefore no official
542 cancellation point. But due to similarity with an POSIX interface
543 or due to the implementation it is a cancellation point and
544 therefore not marked with __THROW. */
545 extern int fgetc_unlocked (FILE *__stream
);
546 #endif /* Use MISC. */
549 __BEGIN_NAMESPACE_STD
550 /* Write a character to STREAM.
552 These functions are possible cancellation points and therefore not
555 These functions is a possible cancellation point and therefore not
556 marked with __THROW. */
557 extern int fputc (int __c
, FILE *__stream
);
558 extern int putc (int __c
, FILE *__stream
);
560 /* Write a character to stdout.
562 This function is a possible cancellation point and therefore not
563 marked with __THROW. */
564 extern int putchar (int __c
);
567 /* The C standard explicitly says this can be a macro,
568 so we always do the optimization for it. */
569 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
572 /* Faster version when locking is not necessary.
574 This function is not part of POSIX and therefore no official
575 cancellation point. But due to similarity with an POSIX interface
576 or due to the implementation it is a cancellation point and
577 therefore not marked with __THROW. */
578 extern int fputc_unlocked (int __c
, FILE *__stream
);
579 #endif /* Use MISC. */
581 #if defined __USE_POSIX || defined __USE_MISC
582 /* These are defined in POSIX.1:1996.
584 These functions are possible cancellation points and therefore not
585 marked with __THROW. */
586 extern int putc_unlocked (int __c
, FILE *__stream
);
587 extern int putchar_unlocked (int __c
);
588 #endif /* Use POSIX or MISC. */
591 #if defined __USE_SVID || defined __USE_MISC \
592 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
593 /* Get a word (int) from STREAM. */
594 extern int getw (FILE *__stream
);
596 /* Write a word (int) to STREAM. */
597 extern int putw (int __w
, FILE *__stream
);
601 __BEGIN_NAMESPACE_STD
602 /* Get a newline-terminated string of finite length from STREAM.
604 This function is a possible cancellation point and therefore not
605 marked with __THROW. */
606 extern char *fgets (char *__restrict __s
, int __n
, FILE *__restrict __stream
)
609 /* Get a newline-terminated string from stdin, removing the newline.
610 DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
612 This function is a possible cancellation point and therefore not
613 marked with __THROW. */
614 extern char *gets (char *__s
) __wur
;
618 /* This function does the same as `fgets' but does not lock the stream.
620 This function is not part of POSIX and therefore no official
621 cancellation point. But due to similarity with an POSIX interface
622 or due to the implementation it is a cancellation point and
623 therefore not marked with __THROW. */
624 extern char *fgets_unlocked (char *__restrict __s
, int __n
,
625 FILE *__restrict __stream
) __wur
;
629 #ifdef __USE_XOPEN2K8
630 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
631 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
632 NULL), pointing to *N characters of space. It is realloc'd as
633 necessary. Returns the number of characters read (not including the
634 null terminator), or -1 on error or EOF.
636 These functions are not part of POSIX and therefore no official
637 cancellation point. But due to similarity with an POSIX interface
638 or due to the implementation they are cancellation points and
639 therefore not marked with __THROW. */
640 extern _IO_ssize_t
__getdelim (char **__restrict __lineptr
,
641 size_t *__restrict __n
, int __delimiter
,
642 FILE *__restrict __stream
) __wur
;
643 extern _IO_ssize_t
getdelim (char **__restrict __lineptr
,
644 size_t *__restrict __n
, int __delimiter
,
645 FILE *__restrict __stream
) __wur
;
647 /* Like `getdelim', but reads up to a newline.
649 This function is not part of POSIX and therefore no official
650 cancellation point. But due to similarity with an POSIX interface
651 or due to the implementation it is a cancellation point and
652 therefore not marked with __THROW. */
653 extern _IO_ssize_t
getline (char **__restrict __lineptr
,
654 size_t *__restrict __n
,
655 FILE *__restrict __stream
) __wur
;
659 __BEGIN_NAMESPACE_STD
660 /* Write a string to STREAM.
662 This function is a possible cancellation points and therefore not
663 marked with __THROW. */
664 extern int fputs (__const
char *__restrict __s
, FILE *__restrict __stream
);
666 /* Write a string, followed by a newline, to stdout.
668 This function is a possible cancellation points and therefore not
669 marked with __THROW. */
670 extern int puts (__const
char *__s
);
673 /* Push a character back onto the input buffer of STREAM.
675 This function is a possible cancellation points and therefore not
676 marked with __THROW. */
677 extern int ungetc (int __c
, FILE *__stream
);
680 /* Read chunks of generic data from STREAM.
682 This function is a possible cancellation points and therefore not
683 marked with __THROW. */
684 extern size_t fread (void *__restrict __ptr
, size_t __size
,
685 size_t __n
, FILE *__restrict __stream
) __wur
;
686 /* Write chunks of generic data to STREAM.
688 This function is a possible cancellation points and therefore not
689 marked with __THROW. */
690 extern size_t fwrite (__const
void *__restrict __ptr
, size_t __size
,
691 size_t __n
, FILE *__restrict __s
) __wur
;
695 /* This function does the same as `fputs' but does not lock the stream.
697 This function is not part of POSIX and therefore no official
698 cancellation point. But due to similarity with an POSIX interface
699 or due to the implementation it is a cancellation point and
700 therefore not marked with __THROW. */
701 extern int fputs_unlocked (__const
char *__restrict __s
,
702 FILE *__restrict __stream
);
706 /* Faster versions when locking is not necessary.
708 These functions are not part of POSIX and therefore no official
709 cancellation point. But due to similarity with an POSIX interface
710 or due to the implementation they are cancellation points and
711 therefore not marked with __THROW. */
712 extern size_t fread_unlocked (void *__restrict __ptr
, size_t __size
,
713 size_t __n
, FILE *__restrict __stream
) __wur
;
714 extern size_t fwrite_unlocked (__const
void *__restrict __ptr
, size_t __size
,
715 size_t __n
, FILE *__restrict __stream
) __wur
;
719 __BEGIN_NAMESPACE_STD
720 /* Seek to a certain position on STREAM.
722 This function is a possible cancellation point and therefore not
723 marked with __THROW. */
724 extern int fseek (FILE *__stream
, long int __off
, int __whence
);
725 /* Return the current position of STREAM.
727 This function is a possible cancellation point and therefore not
728 marked with __THROW. */
729 extern long int ftell (FILE *__stream
) __wur
;
730 /* Rewind to the beginning of STREAM.
732 This function is a possible cancellation point and therefore not
733 marked with __THROW. */
734 extern void rewind (FILE *__stream
);
737 /* The Single Unix Specification, Version 2, specifies an alternative,
738 more adequate interface for the two functions above which deal with
739 file offset. `long int' is not the right type. These definitions
740 are originally defined in the Large File Support API. */
742 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
743 # ifndef __USE_FILE_OFFSET64
744 /* Seek to a certain position on STREAM.
746 This function is a possible cancellation point and therefore not
747 marked with __THROW. */
748 extern int fseeko (FILE *__stream
, __off_t __off
, int __whence
);
749 /* Return the current position of STREAM.
751 This function is a possible cancellation point and therefore not
752 marked with __THROW. */
753 extern __off_t
ftello (FILE *__stream
) __wur
;
756 extern int __REDIRECT (fseeko
,
757 (FILE *__stream
, __off64_t __off
, int __whence
),
759 extern __off64_t
__REDIRECT (ftello
, (FILE *__stream
), ftello64
);
761 # define fseeko fseeko64
762 # define ftello ftello64
767 __BEGIN_NAMESPACE_STD
768 #ifndef __USE_FILE_OFFSET64
769 /* Get STREAM's position.
771 This function is a possible cancellation point and therefore not
772 marked with __THROW. */
773 extern int fgetpos (FILE *__restrict __stream
, fpos_t *__restrict __pos
);
774 /* Set STREAM's position.
776 This function is a possible cancellation point and therefore not
777 marked with __THROW. */
778 extern int fsetpos (FILE *__stream
, __const
fpos_t *__pos
);
781 extern int __REDIRECT (fgetpos
, (FILE *__restrict __stream
,
782 fpos_t *__restrict __pos
), fgetpos64
);
783 extern int __REDIRECT (fsetpos
,
784 (FILE *__stream
, __const
fpos_t *__pos
), fsetpos64
);
786 # define fgetpos fgetpos64
787 # define fsetpos fsetpos64
792 #ifdef __USE_LARGEFILE64
793 extern int fseeko64 (FILE *__stream
, __off64_t __off
, int __whence
);
794 extern __off64_t
ftello64 (FILE *__stream
) __wur
;
795 extern int fgetpos64 (FILE *__restrict __stream
, fpos64_t
*__restrict __pos
);
796 extern int fsetpos64 (FILE *__stream
, __const fpos64_t
*__pos
);
799 __BEGIN_NAMESPACE_STD
800 /* Clear the error and EOF indicators for STREAM. */
801 extern void clearerr (FILE *__stream
) __THROW
;
802 /* Return the EOF indicator for STREAM. */
803 extern int feof (FILE *__stream
) __THROW __wur
;
804 /* Return the error indicator for STREAM. */
805 extern int ferror (FILE *__stream
) __THROW __wur
;
809 /* Faster versions when locking is not required. */
810 extern void clearerr_unlocked (FILE *__stream
) __THROW
;
811 extern int feof_unlocked (FILE *__stream
) __THROW __wur
;
812 extern int ferror_unlocked (FILE *__stream
) __THROW __wur
;
816 __BEGIN_NAMESPACE_STD
817 /* Print a message describing the meaning of the value of errno.
819 This function is a possible cancellation point and therefore not
820 marked with __THROW. */
821 extern void perror (__const
char *__s
);
824 /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
825 are available on this system. Even if available, these variables
826 should not be used directly. The `strerror' function provides
827 all the necessary functionality. */
828 #include <bits/sys_errlist.h>
832 /* Return the system file descriptor for STREAM. */
833 extern int fileno (FILE *__stream
) __THROW __wur
;
834 #endif /* Use POSIX. */
837 /* Faster version when locking is not required. */
838 extern int fileno_unlocked (FILE *__stream
) __THROW __wur
;
842 #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
844 /* Create a new stream connected to a pipe running the given command.
846 This function is a possible cancellation point and therefore not
847 marked with __THROW. */
848 extern FILE *popen (__const
char *__command
, __const
char *__modes
) __wur
;
850 /* Close a stream opened by popen and return the status of its child.
852 This function is a possible cancellation point and therefore not
853 marked with __THROW. */
854 extern int pclose (FILE *__stream
);
859 /* Return the name of the controlling terminal. */
860 extern char *ctermid (char *__s
) __THROW
;
861 #endif /* Use POSIX. */
865 /* Return the name of the current user. */
866 extern char *cuserid (char *__s
);
867 #endif /* Use X/Open, but not issue 6. */
871 struct obstack
; /* See <obstack.h>. */
873 /* Write formatted output to an obstack. */
874 extern int obstack_printf (struct obstack
*__restrict __obstack
,
875 __const
char *__restrict __format
, ...)
876 __THROW
__attribute__ ((__format__ (__printf__
, 2, 3)));
877 extern int obstack_vprintf (struct obstack
*__restrict __obstack
,
878 __const
char *__restrict __format
,
880 __THROW
__attribute__ ((__format__ (__printf__
, 2, 0)));
881 #endif /* Use GNU. */
884 #if defined __USE_POSIX || defined __USE_MISC
885 /* These are defined in POSIX.1:1996. */
887 /* Acquire ownership of STREAM. */
888 extern void flockfile (FILE *__stream
) __THROW
;
890 /* Try to acquire ownership of STREAM but do not block if it is not
892 extern int ftrylockfile (FILE *__stream
) __THROW __wur
;
894 /* Relinquish the ownership granted for STREAM. */
895 extern void funlockfile (FILE *__stream
) __THROW
;
896 #endif /* POSIX || misc */
898 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
899 /* The X/Open standard requires some functions and variables to be
900 declared here which do not belong into this header. But we have to
901 follow. In GNU mode we don't do this nonsense. */
902 # define __need_getopt
904 #endif /* X/Open, but not issue 6 and not for GNU. */
906 /* If we are compiling with optimizing read this file. It contains
907 several optimizing inline functions and macros. */
908 #ifdef __USE_EXTERN_INLINES
909 # include <bits/stdio.h>
911 #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
912 # include <bits/stdio2.h>
915 # include <bits/stdio-ldbl.h>
920 #endif /* <stdio.h> included. */
922 #endif /* !_STDIO_H */