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