1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991,1994-2004,2005,2006,2007 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
;
295 /* Create a new stream that refers to a memory buffer. */
296 extern FILE *fmemopen (void *__s
, size_t __len
, __const
char *__modes
)
299 /* Open a stream that writes into a malloc'd buffer that is expanded as
300 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
301 and the number of characters written on fflush or fclose. */
302 extern FILE *open_memstream (char **__bufloc
, size_t *__sizeloc
) __THROW __wur
;
306 __BEGIN_NAMESPACE_STD
307 /* If BUF is NULL, make STREAM unbuffered.
308 Else make it use buffer BUF, of size BUFSIZ. */
309 extern void setbuf (FILE *__restrict __stream
, char *__restrict __buf
) __THROW
;
310 /* Make STREAM use buffering mode MODE.
311 If BUF is not NULL, use N bytes of it for buffering;
312 else allocate an internal buffer N bytes long. */
313 extern int setvbuf (FILE *__restrict __stream
, char *__restrict __buf
,
314 int __modes
, size_t __n
) __THROW
;
318 /* If BUF is NULL, make STREAM unbuffered.
319 Else make it use SIZE bytes of BUF for buffering. */
320 extern void setbuffer (FILE *__restrict __stream
, char *__restrict __buf
,
321 size_t __size
) __THROW
;
323 /* Make STREAM line-buffered. */
324 extern void setlinebuf (FILE *__stream
) __THROW
;
328 __BEGIN_NAMESPACE_STD
329 /* Write formatted output to STREAM.
331 This function is a possible cancellation point and therefore not
332 marked with __THROW. */
333 extern int fprintf (FILE *__restrict __stream
,
334 __const
char *__restrict __format
, ...);
335 /* Write formatted output to stdout.
337 This function is a possible cancellation point and therefore not
338 marked with __THROW. */
339 extern int printf (__const
char *__restrict __format
, ...);
340 /* Write formatted output to S. */
341 extern int sprintf (char *__restrict __s
,
342 __const
char *__restrict __format
, ...) __THROW
;
344 /* Write formatted output to S from argument list ARG.
346 This function is a possible cancellation point and therefore not
347 marked with __THROW. */
348 extern int vfprintf (FILE *__restrict __s
, __const
char *__restrict __format
,
350 /* Write formatted output to stdout from argument list ARG.
352 This function is a possible cancellation point and therefore not
353 marked with __THROW. */
354 extern int vprintf (__const
char *__restrict __format
, _G_va_list __arg
);
355 /* Write formatted output to S from argument list ARG. */
356 extern int vsprintf (char *__restrict __s
, __const
char *__restrict __format
,
357 _G_va_list __arg
) __THROW
;
360 #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
361 __BEGIN_NAMESPACE_C99
362 /* Maximum chars of output to write in MAXLEN. */
363 extern int snprintf (char *__restrict __s
, size_t __maxlen
,
364 __const
char *__restrict __format
, ...)
365 __THROW
__attribute__ ((__format__ (__printf__
, 3, 4)));
367 extern int vsnprintf (char *__restrict __s
, size_t __maxlen
,
368 __const
char *__restrict __format
, _G_va_list __arg
)
369 __THROW
__attribute__ ((__format__ (__printf__
, 3, 0)));
374 /* Write formatted output to a string dynamically allocated with `malloc'.
375 Store the address of the string in *PTR. */
376 extern int vasprintf (char **__restrict __ptr
, __const
char *__restrict __f
,
378 __THROW
__attribute__ ((__format__ (__printf__
, 2, 0))) __wur
;
379 extern int __asprintf (char **__restrict __ptr
,
380 __const
char *__restrict __fmt
, ...)
381 __THROW
__attribute__ ((__format__ (__printf__
, 2, 3))) __wur
;
382 extern int asprintf (char **__restrict __ptr
,
383 __const
char *__restrict __fmt
, ...)
384 __THROW
__attribute__ ((__format__ (__printf__
, 2, 3))) __wur
;
386 /* Write formatted output to a file descriptor.
388 These functions are not part of POSIX and therefore no official
389 cancellation point. But due to similarity with an POSIX interface
390 or due to the implementation they are cancellation points and
391 therefore not marked with __THROW. */
392 extern int vdprintf (int __fd
, __const
char *__restrict __fmt
,
394 __attribute__ ((__format__ (__printf__
, 2, 0)));
395 extern int dprintf (int __fd
, __const
char *__restrict __fmt
, ...)
396 __attribute__ ((__format__ (__printf__
, 2, 3)));
400 __BEGIN_NAMESPACE_STD
401 /* Read formatted input from STREAM.
403 This function is a possible cancellation point and therefore not
404 marked with __THROW. */
405 extern int fscanf (FILE *__restrict __stream
,
406 __const
char *__restrict __format
, ...) __wur
;
407 /* Read formatted input from stdin.
409 This function is a possible cancellation point and therefore not
410 marked with __THROW. */
411 extern int scanf (__const
char *__restrict __format
, ...) __wur
;
412 /* Read formatted input from S. */
413 extern int sscanf (__const
char *__restrict __s
,
414 __const
char *__restrict __format
, ...) __THROW
;
416 #if defined __USE_ISOC99 && !defined __USE_GNU \
417 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
418 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
420 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
421 GNU extension which conflicts with valid %a followed by letter
423 extern int __REDIRECT (fscanf
, (FILE *__restrict __stream
,
424 __const
char *__restrict __format
, ...),
425 __isoc99_fscanf
) __wur
;
426 extern int __REDIRECT (scanf
, (__const
char *__restrict __format
, ...),
427 __isoc99_scanf
) __wur
;
428 extern int __REDIRECT (sscanf
, (__const
char *__restrict __s
,
429 __const
char *__restrict __format
, ...),
430 __isoc99_sscanf
) __THROW
;
432 extern int __isoc99_fscanf (FILE *__restrict __stream
,
433 __const
char *__restrict __format
, ...) __wur
;
434 extern int __isoc99_scanf (__const
char *__restrict __format
, ...) __wur
;
435 extern int __isoc99_sscanf (__const
char *__restrict __s
,
436 __const
char *__restrict __format
, ...) __THROW
;
437 # define fscanf __isoc99_fscanf
438 # define scanf __isoc99_scanf
439 # define sscanf __isoc99_sscanf
446 __BEGIN_NAMESPACE_C99
447 /* Read formatted input from S into argument list ARG.
449 This function is a possible cancellation point and therefore not
450 marked with __THROW. */
451 extern int vfscanf (FILE *__restrict __s
, __const
char *__restrict __format
,
453 __attribute__ ((__format__ (__scanf__
, 2, 0))) __wur
;
455 /* Read formatted input from stdin into argument list ARG.
457 This function is a possible cancellation point and therefore not
458 marked with __THROW. */
459 extern int vscanf (__const
char *__restrict __format
, _G_va_list __arg
)
460 __attribute__ ((__format__ (__scanf__
, 1, 0))) __wur
;
462 /* Read formatted input from S into argument list ARG. */
463 extern int vsscanf (__const
char *__restrict __s
,
464 __const
char *__restrict __format
, _G_va_list __arg
)
465 __THROW
__attribute__ ((__format__ (__scanf__
, 2, 0)));
467 # if !defined __USE_GNU \
468 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
469 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
471 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
472 GNU extension which conflicts with valid %a followed by letter
474 extern int __REDIRECT (vfscanf
,
475 (FILE *__restrict __s
,
476 __const
char *__restrict __format
, _G_va_list __arg
),
478 __attribute__ ((__format__ (__scanf__
, 2, 0))) __wur
;
479 extern int __REDIRECT (vscanf
, (__const
char *__restrict __format
,
480 _G_va_list __arg
), __isoc99_vfscanf
)
481 __attribute__ ((__format__ (__scanf__
, 1, 0))) __wur
;
482 extern int __REDIRECT (vsscanf
,
483 (__const
char *__restrict __s
,
484 __const
char *__restrict __format
, _G_va_list __arg
),
486 __THROW
__attribute__ ((__format__ (__scanf__
, 2, 0)));
488 extern int __isoc99_vfscanf (FILE *__restrict __s
,
489 __const
char *__restrict __format
,
490 _G_va_list __arg
) __wur
;
491 extern int __isoc99_vscanf (__const
char *__restrict __format
,
492 _G_va_list __arg
) __wur
;
493 extern int __isoc99_vsscanf (__const
char *__restrict __s
,
494 __const
char *__restrict __format
,
495 _G_va_list __arg
) __THROW
;
496 # define vfscanf __isoc99_vfscanf
497 # define vscanf __isoc99_vsscanf
498 # define vsscanf __isoc99_vsscanf
503 #endif /* Use ISO C9x. */
506 __BEGIN_NAMESPACE_STD
507 /* Read a character from STREAM.
509 These functions are possible cancellation points and therefore not
510 marked with __THROW. */
511 extern int fgetc (FILE *__stream
);
512 extern int getc (FILE *__stream
);
514 /* Read a character from stdin.
516 This function is a possible cancellation point and therefore not
517 marked with __THROW. */
518 extern int getchar (void);
521 /* The C standard explicitly says this is a macro, so we always do the
522 optimization for it. */
523 #define getc(_fp) _IO_getc (_fp)
525 #if defined __USE_POSIX || defined __USE_MISC
526 /* These are defined in POSIX.1:1996.
528 These functions are possible cancellation points and therefore not
529 marked with __THROW. */
530 extern int getc_unlocked (FILE *__stream
);
531 extern int getchar_unlocked (void);
532 #endif /* Use POSIX or MISC. */
535 /* Faster version when locking is not necessary.
537 This function is not part of POSIX and therefore no official
538 cancellation point. But due to similarity with an POSIX interface
539 or due to the implementation it is a cancellation point and
540 therefore not marked with __THROW. */
541 extern int fgetc_unlocked (FILE *__stream
);
542 #endif /* Use MISC. */
545 __BEGIN_NAMESPACE_STD
546 /* Write a character to STREAM.
548 These functions are possible cancellation points and therefore not
551 These functions is a possible cancellation point and therefore not
552 marked with __THROW. */
553 extern int fputc (int __c
, FILE *__stream
);
554 extern int putc (int __c
, FILE *__stream
);
556 /* Write a character to stdout.
558 This function is a possible cancellation point and therefore not
559 marked with __THROW. */
560 extern int putchar (int __c
);
563 /* The C standard explicitly says this can be a macro,
564 so we always do the optimization for it. */
565 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
568 /* Faster version when locking is not necessary.
570 This function is not part of POSIX and therefore no official
571 cancellation point. But due to similarity with an POSIX interface
572 or due to the implementation it is a cancellation point and
573 therefore not marked with __THROW. */
574 extern int fputc_unlocked (int __c
, FILE *__stream
);
575 #endif /* Use MISC. */
577 #if defined __USE_POSIX || defined __USE_MISC
578 /* These are defined in POSIX.1:1996.
580 These functions are possible cancellation points and therefore not
581 marked with __THROW. */
582 extern int putc_unlocked (int __c
, FILE *__stream
);
583 extern int putchar_unlocked (int __c
);
584 #endif /* Use POSIX or MISC. */
587 #if defined __USE_SVID || defined __USE_MISC \
588 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
589 /* Get a word (int) from STREAM. */
590 extern int getw (FILE *__stream
);
592 /* Write a word (int) to STREAM. */
593 extern int putw (int __w
, FILE *__stream
);
597 __BEGIN_NAMESPACE_STD
598 /* Get a newline-terminated string of finite length from STREAM.
600 This function is a possible cancellation point and therefore not
601 marked with __THROW. */
602 extern char *fgets (char *__restrict __s
, int __n
, FILE *__restrict __stream
)
605 /* Get a newline-terminated string from stdin, removing the newline.
606 DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
608 This function is a possible cancellation point and therefore not
609 marked with __THROW. */
610 extern char *gets (char *__s
) __wur
;
614 /* This function does the same as `fgets' but does not lock the stream.
616 This function is not part of POSIX and therefore no official
617 cancellation point. But due to similarity with an POSIX interface
618 or due to the implementation it is a cancellation point and
619 therefore not marked with __THROW. */
620 extern char *fgets_unlocked (char *__restrict __s
, int __n
,
621 FILE *__restrict __stream
) __wur
;
626 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
627 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
628 NULL), pointing to *N characters of space. It is realloc'd as
629 necessary. Returns the number of characters read (not including the
630 null terminator), or -1 on error or EOF.
632 These functions are not part of POSIX and therefore no official
633 cancellation point. But due to similarity with an POSIX interface
634 or due to the implementation they are cancellation points and
635 therefore not marked with __THROW. */
636 extern _IO_ssize_t
__getdelim (char **__restrict __lineptr
,
637 size_t *__restrict __n
, int __delimiter
,
638 FILE *__restrict __stream
) __wur
;
639 extern _IO_ssize_t
getdelim (char **__restrict __lineptr
,
640 size_t *__restrict __n
, int __delimiter
,
641 FILE *__restrict __stream
) __wur
;
643 /* Like `getdelim', but reads up to a newline.
645 This function is not part of POSIX and therefore no official
646 cancellation point. But due to similarity with an POSIX interface
647 or due to the implementation it is a cancellation point and
648 therefore not marked with __THROW. */
649 extern _IO_ssize_t
getline (char **__restrict __lineptr
,
650 size_t *__restrict __n
,
651 FILE *__restrict __stream
) __wur
;
655 __BEGIN_NAMESPACE_STD
656 /* Write a string to STREAM.
658 This function is a possible cancellation points and therefore not
659 marked with __THROW. */
660 extern int fputs (__const
char *__restrict __s
, FILE *__restrict __stream
);
662 /* Write a string, followed by a newline, to stdout.
664 This function is a possible cancellation points and therefore not
665 marked with __THROW. */
666 extern int puts (__const
char *__s
);
669 /* Push a character back onto the input buffer of STREAM.
671 This function is a possible cancellation points and therefore not
672 marked with __THROW. */
673 extern int ungetc (int __c
, FILE *__stream
);
676 /* Read chunks of generic data from STREAM.
678 This function is a possible cancellation points and therefore not
679 marked with __THROW. */
680 extern size_t fread (void *__restrict __ptr
, size_t __size
,
681 size_t __n
, FILE *__restrict __stream
) __wur
;
682 /* Write chunks of generic data to STREAM.
684 This function is a possible cancellation points and therefore not
685 marked with __THROW. */
686 extern size_t fwrite (__const
void *__restrict __ptr
, size_t __size
,
687 size_t __n
, FILE *__restrict __s
) __wur
;
691 /* This function does the same as `fputs' but does not lock the stream.
693 This function is not part of POSIX and therefore no official
694 cancellation point. But due to similarity with an POSIX interface
695 or due to the implementation it is a cancellation point and
696 therefore not marked with __THROW. */
697 extern int fputs_unlocked (__const
char *__restrict __s
,
698 FILE *__restrict __stream
);
702 /* Faster versions when locking is not necessary.
704 These functions are not part of POSIX and therefore no official
705 cancellation point. But due to similarity with an POSIX interface
706 or due to the implementation they are cancellation points and
707 therefore not marked with __THROW. */
708 extern size_t fread_unlocked (void *__restrict __ptr
, size_t __size
,
709 size_t __n
, FILE *__restrict __stream
) __wur
;
710 extern size_t fwrite_unlocked (__const
void *__restrict __ptr
, size_t __size
,
711 size_t __n
, FILE *__restrict __stream
) __wur
;
715 __BEGIN_NAMESPACE_STD
716 /* Seek to a certain position on STREAM.
718 This function is a possible cancellation point and therefore not
719 marked with __THROW. */
720 extern int fseek (FILE *__stream
, long int __off
, int __whence
);
721 /* Return the current position of STREAM.
723 This function is a possible cancellation point and therefore not
724 marked with __THROW. */
725 extern long int ftell (FILE *__stream
) __wur
;
726 /* Rewind to the beginning of STREAM.
728 This function is a possible cancellation point and therefore not
729 marked with __THROW. */
730 extern void rewind (FILE *__stream
);
733 /* The Single Unix Specification, Version 2, specifies an alternative,
734 more adequate interface for the two functions above which deal with
735 file offset. `long int' is not the right type. These definitions
736 are originally defined in the Large File Support API. */
738 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
739 # ifndef __USE_FILE_OFFSET64
740 /* Seek to a certain position on STREAM.
742 This function is a possible cancellation point and therefore not
743 marked with __THROW. */
744 extern int fseeko (FILE *__stream
, __off_t __off
, int __whence
);
745 /* Return the current position of STREAM.
747 This function is a possible cancellation point and therefore not
748 marked with __THROW. */
749 extern __off_t
ftello (FILE *__stream
) __wur
;
752 extern int __REDIRECT (fseeko
,
753 (FILE *__stream
, __off64_t __off
, int __whence
),
755 extern __off64_t
__REDIRECT (ftello
, (FILE *__stream
), ftello64
);
757 # define fseeko fseeko64
758 # define ftello ftello64
763 __BEGIN_NAMESPACE_STD
764 #ifndef __USE_FILE_OFFSET64
765 /* Get STREAM's position.
767 This function is a possible cancellation point and therefore not
768 marked with __THROW. */
769 extern int fgetpos (FILE *__restrict __stream
, fpos_t *__restrict __pos
);
770 /* Set STREAM's position.
772 This function is a possible cancellation point and therefore not
773 marked with __THROW. */
774 extern int fsetpos (FILE *__stream
, __const
fpos_t *__pos
);
777 extern int __REDIRECT (fgetpos
, (FILE *__restrict __stream
,
778 fpos_t *__restrict __pos
), fgetpos64
);
779 extern int __REDIRECT (fsetpos
,
780 (FILE *__stream
, __const
fpos_t *__pos
), fsetpos64
);
782 # define fgetpos fgetpos64
783 # define fsetpos fsetpos64
788 #ifdef __USE_LARGEFILE64
789 extern int fseeko64 (FILE *__stream
, __off64_t __off
, int __whence
);
790 extern __off64_t
ftello64 (FILE *__stream
) __wur
;
791 extern int fgetpos64 (FILE *__restrict __stream
, fpos64_t
*__restrict __pos
);
792 extern int fsetpos64 (FILE *__stream
, __const fpos64_t
*__pos
);
795 __BEGIN_NAMESPACE_STD
796 /* Clear the error and EOF indicators for STREAM. */
797 extern void clearerr (FILE *__stream
) __THROW
;
798 /* Return the EOF indicator for STREAM. */
799 extern int feof (FILE *__stream
) __THROW __wur
;
800 /* Return the error indicator for STREAM. */
801 extern int ferror (FILE *__stream
) __THROW __wur
;
805 /* Faster versions when locking is not required. */
806 extern void clearerr_unlocked (FILE *__stream
) __THROW
;
807 extern int feof_unlocked (FILE *__stream
) __THROW __wur
;
808 extern int ferror_unlocked (FILE *__stream
) __THROW __wur
;
812 __BEGIN_NAMESPACE_STD
813 /* Print a message describing the meaning of the value of errno.
815 This function is a possible cancellation point and therefore not
816 marked with __THROW. */
817 extern void perror (__const
char *__s
);
820 /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
821 are available on this system. Even if available, these variables
822 should not be used directly. The `strerror' function provides
823 all the necessary functionality. */
824 #include <bits/sys_errlist.h>
828 /* Return the system file descriptor for STREAM. */
829 extern int fileno (FILE *__stream
) __THROW __wur
;
830 #endif /* Use POSIX. */
833 /* Faster version when locking is not required. */
834 extern int fileno_unlocked (FILE *__stream
) __THROW __wur
;
838 #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
840 /* Create a new stream connected to a pipe running the given command.
842 This function is a possible cancellation point and therefore not
843 marked with __THROW. */
844 extern FILE *popen (__const
char *__command
, __const
char *__modes
) __wur
;
846 /* Close a stream opened by popen and return the status of its child.
848 This function is a possible cancellation point and therefore not
849 marked with __THROW. */
850 extern int pclose (FILE *__stream
);
855 /* Return the name of the controlling terminal. */
856 extern char *ctermid (char *__s
) __THROW
;
857 #endif /* Use POSIX. */
861 /* Return the name of the current user. */
862 extern char *cuserid (char *__s
);
863 #endif /* Use X/Open, but not issue 6. */
867 struct obstack
; /* See <obstack.h>. */
869 /* Write formatted output to an obstack. */
870 extern int obstack_printf (struct obstack
*__restrict __obstack
,
871 __const
char *__restrict __format
, ...)
872 __THROW
__attribute__ ((__format__ (__printf__
, 2, 3)));
873 extern int obstack_vprintf (struct obstack
*__restrict __obstack
,
874 __const
char *__restrict __format
,
876 __THROW
__attribute__ ((__format__ (__printf__
, 2, 0)));
877 #endif /* Use GNU. */
880 #if defined __USE_POSIX || defined __USE_MISC
881 /* These are defined in POSIX.1:1996. */
883 /* Acquire ownership of STREAM. */
884 extern void flockfile (FILE *__stream
) __THROW
;
886 /* Try to acquire ownership of STREAM but do not block if it is not
888 extern int ftrylockfile (FILE *__stream
) __THROW __wur
;
890 /* Relinquish the ownership granted for STREAM. */
891 extern void funlockfile (FILE *__stream
) __THROW
;
892 #endif /* POSIX || misc */
894 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
895 /* The X/Open standard requires some functions and variables to be
896 declared here which do not belong into this header. But we have to
897 follow. In GNU mode we don't do this nonsense. */
898 # define __need_getopt
900 #endif /* X/Open, but not issue 6 and not for GNU. */
902 /* If we are compiling with optimizing read this file. It contains
903 several optimizing inline functions and macros. */
904 #ifdef __USE_EXTERN_INLINES
905 # include <bits/stdio.h>
907 #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
908 # include <bits/stdio2.h>
911 # include <bits/stdio-ldbl.h>
916 #endif /* <stdio.h> included. */
918 #endif /* !_STDIO_H */