1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991, 1994-2007, 2008 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. */
148 /* C89/C99 say they're macros. Make them happy. */
150 #define stdout stdout
151 #define stderr stderr
153 __BEGIN_NAMESPACE_STD
154 /* Remove file FILENAME. */
155 extern int remove (__const
char *__filename
) __THROW
;
156 /* Rename file OLD to NEW. */
157 extern int rename (__const
char *__old
, __const
char *__new
) __THROW
;
161 /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
162 extern int renameat (int __oldfd
, __const
char *__old
, int __newfd
,
163 __const
char *__new
) __THROW
;
166 __BEGIN_NAMESPACE_STD
167 /* Create a temporary file and open it read/write.
169 This function is a possible cancellation points and therefore not
170 marked with __THROW. */
171 #ifndef __USE_FILE_OFFSET64
172 extern FILE *tmpfile (void) __wur
;
175 extern FILE *__REDIRECT (tmpfile
, (void), tmpfile64
) __wur
;
177 # define tmpfile tmpfile64
181 #ifdef __USE_LARGEFILE64
182 extern FILE *tmpfile64 (void) __wur
;
185 /* Generate a temporary filename. */
186 extern char *tmpnam (char *__s
) __THROW __wur
;
190 /* This is the reentrant variant of `tmpnam'. The only difference is
191 that it does not allow S to be NULL. */
192 extern char *tmpnam_r (char *__s
) __THROW __wur
;
196 #if defined __USE_SVID || defined __USE_XOPEN
197 /* Generate a unique temporary filename using up to five characters of PFX
198 if it is not NULL. The directory to put this file in is searched for
199 as follows: First the environment variable "TMPDIR" is checked.
200 If it contains the name of a writable directory, that directory is used.
201 If not and if DIR is not NULL, that value is checked. If that fails,
202 P_tmpdir is tried and finally "/tmp". The storage for the filename
203 is allocated by `malloc'. */
204 extern char *tempnam (__const
char *__dir
, __const
char *__pfx
)
205 __THROW __attribute_malloc__ __wur
;
209 __BEGIN_NAMESPACE_STD
212 This function is a possible cancellation point and therefore not
213 marked with __THROW. */
214 extern int fclose (FILE *__stream
);
215 /* Flush STREAM, or all streams if STREAM is NULL.
217 This function is a possible cancellation point and therefore not
218 marked with __THROW. */
219 extern int fflush (FILE *__stream
);
223 /* Faster versions when locking is not required.
225 This function is not part of POSIX and therefore no official
226 cancellation point. But due to similarity with an POSIX interface
227 or due to the implementation it is a cancellation point and
228 therefore not marked with __THROW. */
229 extern int fflush_unlocked (FILE *__stream
);
233 /* Close all streams.
235 This function is not part of POSIX and therefore no official
236 cancellation point. But due to similarity with an POSIX interface
237 or due to the implementation it is a cancellation point and
238 therefore not marked with __THROW. */
239 extern int fcloseall (void);
243 __BEGIN_NAMESPACE_STD
244 #ifndef __USE_FILE_OFFSET64
245 /* Open a file and create a new stream for it.
247 This function is a possible cancellation point and therefore not
248 marked with __THROW. */
249 extern FILE *fopen (__const
char *__restrict __filename
,
250 __const
char *__restrict __modes
) __wur
;
251 /* Open a file, replacing an existing stream with it.
253 This function is a possible cancellation point and therefore not
254 marked with __THROW. */
255 extern FILE *freopen (__const
char *__restrict __filename
,
256 __const
char *__restrict __modes
,
257 FILE *__restrict __stream
) __wur
;
260 extern FILE *__REDIRECT (fopen
, (__const
char *__restrict __filename
,
261 __const
char *__restrict __modes
), fopen64
)
263 extern FILE *__REDIRECT (freopen
, (__const
char *__restrict __filename
,
264 __const
char *__restrict __modes
,
265 FILE *__restrict __stream
), freopen64
)
268 # define fopen fopen64
269 # define freopen freopen64
273 #ifdef __USE_LARGEFILE64
274 extern FILE *fopen64 (__const
char *__restrict __filename
,
275 __const
char *__restrict __modes
) __wur
;
276 extern FILE *freopen64 (__const
char *__restrict __filename
,
277 __const
char *__restrict __modes
,
278 FILE *__restrict __stream
) __wur
;
282 /* Create a new stream that refers to an existing system file descriptor. */
283 extern FILE *fdopen (int __fd
, __const
char *__modes
) __THROW __wur
;
287 /* Create a new stream that refers to the given magic cookie,
288 and uses the given functions for input and output. */
289 extern FILE *fopencookie (void *__restrict __magic_cookie
,
290 __const
char *__restrict __modes
,
291 _IO_cookie_io_functions_t __io_funcs
) __THROW __wur
;
293 /* Create a new stream that refers to a memory buffer. */
294 extern FILE *fmemopen (void *__s
, size_t __len
, __const
char *__modes
)
297 /* Open a stream that writes into a malloc'd buffer that is expanded as
298 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
299 and the number of characters written on fflush or fclose. */
300 extern FILE *open_memstream (char **__bufloc
, size_t *__sizeloc
) __THROW __wur
;
304 __BEGIN_NAMESPACE_STD
305 /* If BUF is NULL, make STREAM unbuffered.
306 Else make it use buffer BUF, of size BUFSIZ. */
307 extern void setbuf (FILE *__restrict __stream
, char *__restrict __buf
) __THROW
;
308 /* Make STREAM use buffering mode MODE.
309 If BUF is not NULL, use N bytes of it for buffering;
310 else allocate an internal buffer N bytes long. */
311 extern int setvbuf (FILE *__restrict __stream
, char *__restrict __buf
,
312 int __modes
, size_t __n
) __THROW
;
316 /* If BUF is NULL, make STREAM unbuffered.
317 Else make it use SIZE bytes of BUF for buffering. */
318 extern void setbuffer (FILE *__restrict __stream
, char *__restrict __buf
,
319 size_t __size
) __THROW
;
321 /* Make STREAM line-buffered. */
322 extern void setlinebuf (FILE *__stream
) __THROW
;
326 __BEGIN_NAMESPACE_STD
327 /* Write formatted output to STREAM.
329 This function is a possible cancellation point and therefore not
330 marked with __THROW. */
331 extern int fprintf (FILE *__restrict __stream
,
332 __const
char *__restrict __format
, ...);
333 /* Write formatted output to stdout.
335 This function is a possible cancellation point and therefore not
336 marked with __THROW. */
337 extern int printf (__const
char *__restrict __format
, ...);
338 /* Write formatted output to S. */
339 extern int sprintf (char *__restrict __s
,
340 __const
char *__restrict __format
, ...) __THROW
;
342 /* Write formatted output to S from argument list ARG.
344 This function is a possible cancellation point and therefore not
345 marked with __THROW. */
346 extern int vfprintf (FILE *__restrict __s
, __const
char *__restrict __format
,
348 /* Write formatted output to stdout from argument list ARG.
350 This function is a possible cancellation point and therefore not
351 marked with __THROW. */
352 extern int vprintf (__const
char *__restrict __format
, _G_va_list __arg
);
353 /* Write formatted output to S from argument list ARG. */
354 extern int vsprintf (char *__restrict __s
, __const
char *__restrict __format
,
355 _G_va_list __arg
) __THROW
;
358 #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
359 __BEGIN_NAMESPACE_C99
360 /* Maximum chars of output to write in MAXLEN. */
361 extern int snprintf (char *__restrict __s
, size_t __maxlen
,
362 __const
char *__restrict __format
, ...)
363 __THROW
__attribute__ ((__format__ (__printf__
, 3, 4)));
365 extern int vsnprintf (char *__restrict __s
, size_t __maxlen
,
366 __const
char *__restrict __format
, _G_va_list __arg
)
367 __THROW
__attribute__ ((__format__ (__printf__
, 3, 0)));
372 /* Write formatted output to a string dynamically allocated with `malloc'.
373 Store the address of the string in *PTR. */
374 extern int vasprintf (char **__restrict __ptr
, __const
char *__restrict __f
,
376 __THROW
__attribute__ ((__format__ (__printf__
, 2, 0))) __wur
;
377 extern int __asprintf (char **__restrict __ptr
,
378 __const
char *__restrict __fmt
, ...)
379 __THROW
__attribute__ ((__format__ (__printf__
, 2, 3))) __wur
;
380 extern int asprintf (char **__restrict __ptr
,
381 __const
char *__restrict __fmt
, ...)
382 __THROW
__attribute__ ((__format__ (__printf__
, 2, 3))) __wur
;
384 /* Write formatted output to a file descriptor.
386 These functions are not part of POSIX and therefore no official
387 cancellation point. But due to similarity with an POSIX interface
388 or due to the implementation they are cancellation points and
389 therefore not marked with __THROW. */
390 extern int vdprintf (int __fd
, __const
char *__restrict __fmt
,
392 __attribute__ ((__format__ (__printf__
, 2, 0)));
393 extern int dprintf (int __fd
, __const
char *__restrict __fmt
, ...)
394 __attribute__ ((__format__ (__printf__
, 2, 3)));
398 __BEGIN_NAMESPACE_STD
399 /* Read formatted input from STREAM.
401 This function is a possible cancellation point and therefore not
402 marked with __THROW. */
403 extern int fscanf (FILE *__restrict __stream
,
404 __const
char *__restrict __format
, ...) __wur
;
405 /* Read formatted input from stdin.
407 This function is a possible cancellation point and therefore not
408 marked with __THROW. */
409 extern int scanf (__const
char *__restrict __format
, ...) __wur
;
410 /* Read formatted input from S. */
411 extern int sscanf (__const
char *__restrict __s
,
412 __const
char *__restrict __format
, ...) __THROW
;
414 #if defined __USE_ISOC99 && !defined __USE_GNU \
415 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
416 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
418 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
419 GNU extension which conflicts with valid %a followed by letter
421 extern int __REDIRECT (fscanf
, (FILE *__restrict __stream
,
422 __const
char *__restrict __format
, ...),
423 __isoc99_fscanf
) __wur
;
424 extern int __REDIRECT (scanf
, (__const
char *__restrict __format
, ...),
425 __isoc99_scanf
) __wur
;
426 extern int __REDIRECT (sscanf
, (__const
char *__restrict __s
,
427 __const
char *__restrict __format
, ...),
428 __isoc99_sscanf
) __THROW
;
430 extern int __isoc99_fscanf (FILE *__restrict __stream
,
431 __const
char *__restrict __format
, ...) __wur
;
432 extern int __isoc99_scanf (__const
char *__restrict __format
, ...) __wur
;
433 extern int __isoc99_sscanf (__const
char *__restrict __s
,
434 __const
char *__restrict __format
, ...) __THROW
;
435 # define fscanf __isoc99_fscanf
436 # define scanf __isoc99_scanf
437 # define sscanf __isoc99_sscanf
444 __BEGIN_NAMESPACE_C99
445 /* Read formatted input from S into argument list ARG.
447 This function is a possible cancellation point and therefore not
448 marked with __THROW. */
449 extern int vfscanf (FILE *__restrict __s
, __const
char *__restrict __format
,
451 __attribute__ ((__format__ (__scanf__
, 2, 0))) __wur
;
453 /* Read formatted input from stdin into argument list ARG.
455 This function is a possible cancellation point and therefore not
456 marked with __THROW. */
457 extern int vscanf (__const
char *__restrict __format
, _G_va_list __arg
)
458 __attribute__ ((__format__ (__scanf__
, 1, 0))) __wur
;
460 /* Read formatted input from S into argument list ARG. */
461 extern int vsscanf (__const
char *__restrict __s
,
462 __const
char *__restrict __format
, _G_va_list __arg
)
463 __THROW
__attribute__ ((__format__ (__scanf__
, 2, 0)));
465 # if !defined __USE_GNU \
466 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
467 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
469 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
470 GNU extension which conflicts with valid %a followed by letter
472 extern int __REDIRECT (vfscanf
,
473 (FILE *__restrict __s
,
474 __const
char *__restrict __format
, _G_va_list __arg
),
476 __attribute__ ((__format__ (__scanf__
, 2, 0))) __wur
;
477 extern int __REDIRECT (vscanf
, (__const
char *__restrict __format
,
478 _G_va_list __arg
), __isoc99_vfscanf
)
479 __attribute__ ((__format__ (__scanf__
, 1, 0))) __wur
;
480 extern int __REDIRECT (vsscanf
,
481 (__const
char *__restrict __s
,
482 __const
char *__restrict __format
, _G_va_list __arg
),
484 __THROW
__attribute__ ((__format__ (__scanf__
, 2, 0)));
486 extern int __isoc99_vfscanf (FILE *__restrict __s
,
487 __const
char *__restrict __format
,
488 _G_va_list __arg
) __wur
;
489 extern int __isoc99_vscanf (__const
char *__restrict __format
,
490 _G_va_list __arg
) __wur
;
491 extern int __isoc99_vsscanf (__const
char *__restrict __s
,
492 __const
char *__restrict __format
,
493 _G_va_list __arg
) __THROW
;
494 # define vfscanf __isoc99_vfscanf
495 # define vscanf __isoc99_vscanf
496 # define vsscanf __isoc99_vsscanf
501 #endif /* Use ISO C9x. */
504 __BEGIN_NAMESPACE_STD
505 /* Read a character from STREAM.
507 These functions are possible cancellation points and therefore not
508 marked with __THROW. */
509 extern int fgetc (FILE *__stream
);
510 extern int getc (FILE *__stream
);
512 /* Read a character from stdin.
514 This function is a possible cancellation point and therefore not
515 marked with __THROW. */
516 extern int getchar (void);
519 /* The C standard explicitly says this is a macro, so we always do the
520 optimization for it. */
521 #define getc(_fp) _IO_getc (_fp)
523 #if defined __USE_POSIX || defined __USE_MISC
524 /* These are defined in POSIX.1:1996.
526 These functions are possible cancellation points and therefore not
527 marked with __THROW. */
528 extern int getc_unlocked (FILE *__stream
);
529 extern int getchar_unlocked (void);
530 #endif /* Use POSIX or MISC. */
533 /* Faster version when locking is not necessary.
535 This function is not part of POSIX and therefore no official
536 cancellation point. But due to similarity with an POSIX interface
537 or due to the implementation it is a cancellation point and
538 therefore not marked with __THROW. */
539 extern int fgetc_unlocked (FILE *__stream
);
540 #endif /* Use MISC. */
543 __BEGIN_NAMESPACE_STD
544 /* Write a character to STREAM.
546 These functions are possible cancellation points and therefore not
549 These functions is a possible cancellation point and therefore not
550 marked with __THROW. */
551 extern int fputc (int __c
, FILE *__stream
);
552 extern int putc (int __c
, FILE *__stream
);
554 /* Write a character to stdout.
556 This function is a possible cancellation point and therefore not
557 marked with __THROW. */
558 extern int putchar (int __c
);
561 /* The C standard explicitly says this can be a macro,
562 so we always do the optimization for it. */
563 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
566 /* Faster version when locking is not necessary.
568 This function is not part of POSIX and therefore no official
569 cancellation point. But due to similarity with an POSIX interface
570 or due to the implementation it is a cancellation point and
571 therefore not marked with __THROW. */
572 extern int fputc_unlocked (int __c
, FILE *__stream
);
573 #endif /* Use MISC. */
575 #if defined __USE_POSIX || defined __USE_MISC
576 /* These are defined in POSIX.1:1996.
578 These functions are possible cancellation points and therefore not
579 marked with __THROW. */
580 extern int putc_unlocked (int __c
, FILE *__stream
);
581 extern int putchar_unlocked (int __c
);
582 #endif /* Use POSIX or MISC. */
585 #if defined __USE_SVID || defined __USE_MISC \
586 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
587 /* Get a word (int) from STREAM. */
588 extern int getw (FILE *__stream
);
590 /* Write a word (int) to STREAM. */
591 extern int putw (int __w
, FILE *__stream
);
595 __BEGIN_NAMESPACE_STD
596 /* Get a newline-terminated string of finite length from STREAM.
598 This function is a possible cancellation point and therefore not
599 marked with __THROW. */
600 extern char *fgets (char *__restrict __s
, int __n
, FILE *__restrict __stream
)
603 /* Get a newline-terminated string from stdin, removing the newline.
604 DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
606 This function is a possible cancellation point and therefore not
607 marked with __THROW. */
608 extern char *gets (char *__s
) __wur
;
612 /* This function does the same as `fgets' but does not lock the stream.
614 This function is not part of POSIX and therefore no official
615 cancellation point. But due to similarity with an POSIX interface
616 or due to the implementation it is a cancellation point and
617 therefore not marked with __THROW. */
618 extern char *fgets_unlocked (char *__restrict __s
, int __n
,
619 FILE *__restrict __stream
) __wur
;
624 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
625 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
626 NULL), pointing to *N characters of space. It is realloc'd as
627 necessary. Returns the number of characters read (not including the
628 null terminator), or -1 on error or EOF.
630 These functions are not part of POSIX and therefore no official
631 cancellation point. But due to similarity with an POSIX interface
632 or due to the implementation they are cancellation points and
633 therefore not marked with __THROW. */
634 extern _IO_ssize_t
__getdelim (char **__restrict __lineptr
,
635 size_t *__restrict __n
, int __delimiter
,
636 FILE *__restrict __stream
) __wur
;
637 extern _IO_ssize_t
getdelim (char **__restrict __lineptr
,
638 size_t *__restrict __n
, int __delimiter
,
639 FILE *__restrict __stream
) __wur
;
641 /* Like `getdelim', but reads up to a newline.
643 This function is not part of POSIX and therefore no official
644 cancellation point. But due to similarity with an POSIX interface
645 or due to the implementation it is a cancellation point and
646 therefore not marked with __THROW. */
647 extern _IO_ssize_t
getline (char **__restrict __lineptr
,
648 size_t *__restrict __n
,
649 FILE *__restrict __stream
) __wur
;
653 __BEGIN_NAMESPACE_STD
654 /* Write a string to STREAM.
656 This function is a possible cancellation points and therefore not
657 marked with __THROW. */
658 extern int fputs (__const
char *__restrict __s
, FILE *__restrict __stream
);
660 /* Write a string, followed by a newline, to stdout.
662 This function is a possible cancellation points and therefore not
663 marked with __THROW. */
664 extern int puts (__const
char *__s
);
667 /* Push a character back onto the input buffer of STREAM.
669 This function is a possible cancellation points and therefore not
670 marked with __THROW. */
671 extern int ungetc (int __c
, FILE *__stream
);
674 /* Read chunks of generic data from STREAM.
676 This function is a possible cancellation points and therefore not
677 marked with __THROW. */
678 extern size_t fread (void *__restrict __ptr
, size_t __size
,
679 size_t __n
, FILE *__restrict __stream
) __wur
;
680 /* Write chunks of generic data to STREAM.
682 This function is a possible cancellation points and therefore not
683 marked with __THROW. */
684 extern size_t fwrite (__const
void *__restrict __ptr
, size_t __size
,
685 size_t __n
, FILE *__restrict __s
) __wur
;
689 /* This function does the same as `fputs' but does not lock the stream.
691 This function is not part of POSIX and therefore no official
692 cancellation point. But due to similarity with an POSIX interface
693 or due to the implementation it is a cancellation point and
694 therefore not marked with __THROW. */
695 extern int fputs_unlocked (__const
char *__restrict __s
,
696 FILE *__restrict __stream
);
700 /* Faster versions when locking is not necessary.
702 These functions are not part of POSIX and therefore no official
703 cancellation point. But due to similarity with an POSIX interface
704 or due to the implementation they are cancellation points and
705 therefore not marked with __THROW. */
706 extern size_t fread_unlocked (void *__restrict __ptr
, size_t __size
,
707 size_t __n
, FILE *__restrict __stream
) __wur
;
708 extern size_t fwrite_unlocked (__const
void *__restrict __ptr
, size_t __size
,
709 size_t __n
, FILE *__restrict __stream
) __wur
;
713 __BEGIN_NAMESPACE_STD
714 /* Seek to a certain position on STREAM.
716 This function is a possible cancellation point and therefore not
717 marked with __THROW. */
718 extern int fseek (FILE *__stream
, long int __off
, int __whence
);
719 /* Return the current position of STREAM.
721 This function is a possible cancellation point and therefore not
722 marked with __THROW. */
723 extern long int ftell (FILE *__stream
) __wur
;
724 /* Rewind to the beginning of STREAM.
726 This function is a possible cancellation point and therefore not
727 marked with __THROW. */
728 extern void rewind (FILE *__stream
);
731 /* The Single Unix Specification, Version 2, specifies an alternative,
732 more adequate interface for the two functions above which deal with
733 file offset. `long int' is not the right type. These definitions
734 are originally defined in the Large File Support API. */
736 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
737 # ifndef __USE_FILE_OFFSET64
738 /* Seek to a certain position on STREAM.
740 This function is a possible cancellation point and therefore not
741 marked with __THROW. */
742 extern int fseeko (FILE *__stream
, __off_t __off
, int __whence
);
743 /* Return the current position of STREAM.
745 This function is a possible cancellation point and therefore not
746 marked with __THROW. */
747 extern __off_t
ftello (FILE *__stream
) __wur
;
750 extern int __REDIRECT (fseeko
,
751 (FILE *__stream
, __off64_t __off
, int __whence
),
753 extern __off64_t
__REDIRECT (ftello
, (FILE *__stream
), ftello64
);
755 # define fseeko fseeko64
756 # define ftello ftello64
761 __BEGIN_NAMESPACE_STD
762 #ifndef __USE_FILE_OFFSET64
763 /* Get STREAM's position.
765 This function is a possible cancellation point and therefore not
766 marked with __THROW. */
767 extern int fgetpos (FILE *__restrict __stream
, fpos_t *__restrict __pos
);
768 /* Set STREAM's position.
770 This function is a possible cancellation point and therefore not
771 marked with __THROW. */
772 extern int fsetpos (FILE *__stream
, __const
fpos_t *__pos
);
775 extern int __REDIRECT (fgetpos
, (FILE *__restrict __stream
,
776 fpos_t *__restrict __pos
), fgetpos64
);
777 extern int __REDIRECT (fsetpos
,
778 (FILE *__stream
, __const
fpos_t *__pos
), fsetpos64
);
780 # define fgetpos fgetpos64
781 # define fsetpos fsetpos64
786 #ifdef __USE_LARGEFILE64
787 extern int fseeko64 (FILE *__stream
, __off64_t __off
, int __whence
);
788 extern __off64_t
ftello64 (FILE *__stream
) __wur
;
789 extern int fgetpos64 (FILE *__restrict __stream
, fpos64_t
*__restrict __pos
);
790 extern int fsetpos64 (FILE *__stream
, __const fpos64_t
*__pos
);
793 __BEGIN_NAMESPACE_STD
794 /* Clear the error and EOF indicators for STREAM. */
795 extern void clearerr (FILE *__stream
) __THROW
;
796 /* Return the EOF indicator for STREAM. */
797 extern int feof (FILE *__stream
) __THROW __wur
;
798 /* Return the error indicator for STREAM. */
799 extern int ferror (FILE *__stream
) __THROW __wur
;
803 /* Faster versions when locking is not required. */
804 extern void clearerr_unlocked (FILE *__stream
) __THROW
;
805 extern int feof_unlocked (FILE *__stream
) __THROW __wur
;
806 extern int ferror_unlocked (FILE *__stream
) __THROW __wur
;
810 __BEGIN_NAMESPACE_STD
811 /* Print a message describing the meaning of the value of errno.
813 This function is a possible cancellation point and therefore not
814 marked with __THROW. */
815 extern void perror (__const
char *__s
);
818 /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
819 are available on this system. Even if available, these variables
820 should not be used directly. The `strerror' function provides
821 all the necessary functionality. */
822 #include <bits/sys_errlist.h>
826 /* Return the system file descriptor for STREAM. */
827 extern int fileno (FILE *__stream
) __THROW __wur
;
828 #endif /* Use POSIX. */
831 /* Faster version when locking is not required. */
832 extern int fileno_unlocked (FILE *__stream
) __THROW __wur
;
836 #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
838 /* Create a new stream connected to a pipe running the given command.
840 This function is a possible cancellation point and therefore not
841 marked with __THROW. */
842 extern FILE *popen (__const
char *__command
, __const
char *__modes
) __wur
;
844 /* Close a stream opened by popen and return the status of its child.
846 This function is a possible cancellation point and therefore not
847 marked with __THROW. */
848 extern int pclose (FILE *__stream
);
853 /* Return the name of the controlling terminal. */
854 extern char *ctermid (char *__s
) __THROW
;
855 #endif /* Use POSIX. */
859 /* Return the name of the current user. */
860 extern char *cuserid (char *__s
);
861 #endif /* Use X/Open, but not issue 6. */
865 struct obstack
; /* See <obstack.h>. */
867 /* Write formatted output to an obstack. */
868 extern int obstack_printf (struct obstack
*__restrict __obstack
,
869 __const
char *__restrict __format
, ...)
870 __THROW
__attribute__ ((__format__ (__printf__
, 2, 3)));
871 extern int obstack_vprintf (struct obstack
*__restrict __obstack
,
872 __const
char *__restrict __format
,
874 __THROW
__attribute__ ((__format__ (__printf__
, 2, 0)));
875 #endif /* Use GNU. */
878 #if defined __USE_POSIX || defined __USE_MISC
879 /* These are defined in POSIX.1:1996. */
881 /* Acquire ownership of STREAM. */
882 extern void flockfile (FILE *__stream
) __THROW
;
884 /* Try to acquire ownership of STREAM but do not block if it is not
886 extern int ftrylockfile (FILE *__stream
) __THROW __wur
;
888 /* Relinquish the ownership granted for STREAM. */
889 extern void funlockfile (FILE *__stream
) __THROW
;
890 #endif /* POSIX || misc */
892 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
893 /* The X/Open standard requires some functions and variables to be
894 declared here which do not belong into this header. But we have to
895 follow. In GNU mode we don't do this nonsense. */
896 # define __need_getopt
898 #endif /* X/Open, but not issue 6 and not for GNU. */
900 /* If we are compiling with optimizing read this file. It contains
901 several optimizing inline functions and macros. */
902 #ifdef __USE_EXTERN_INLINES
903 # include <bits/stdio.h>
905 #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
906 # include <bits/stdio2.h>
909 # include <bits/stdio-ldbl.h>
914 #endif /* <stdio.h> included. */
916 #endif /* !_STDIO_H */