1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991-2014 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
20 * ISO C99 Standard: 7.19 Input/output <stdio.h>
25 #if !defined __need_FILE && !defined __need___FILE
27 # include <features.h>
31 # define __need_size_t
35 # include <bits/types.h>
37 # define __need___FILE
38 #endif /* Don't need FILE. */
41 #if !defined __FILE_defined && defined __need_FILE
43 /* Define outside of namespace so the C++ is happy. */
47 /* The opaque type of streams. This is the definition used elsewhere. */
48 typedef struct _IO_FILE
FILE;
50 #if defined __USE_LARGEFILE64 || defined __USE_SVID || defined __USE_POSIX \
51 || defined __USE_BSD || defined __USE_ISOC99 || defined __USE_XOPEN \
52 || defined __USE_POSIX2
53 __USING_NAMESPACE_STD(FILE)
56 # define __FILE_defined 1
57 #endif /* FILE not defined. */
61 #if !defined ____FILE_defined && defined __need___FILE
63 /* The opaque type of streams. This is the definition used elsewhere. */
64 typedef struct _IO_FILE __FILE
;
66 # define ____FILE_defined 1
67 #endif /* __FILE not defined. */
72 #define _STDIO_USES_IOSTREAM
76 #if defined __USE_XOPEN || defined __USE_XOPEN2K8
78 # ifndef _VA_LIST_DEFINED
79 typedef _G_va_list
va_list;
80 # define _VA_LIST_DEFINED
88 # ifndef __off_t_defined
89 # ifndef __USE_FILE_OFFSET64
90 typedef __off_t off_t
;
92 typedef __off64_t off_t
;
94 # define __off_t_defined
96 # if defined __USE_LARGEFILE64 && !defined __off64_t_defined
97 typedef __off64_t off64_t
;
98 # define __off64_t_defined
101 # ifndef __ssize_t_defined
102 typedef __ssize_t ssize_t
;
103 # define __ssize_t_defined
107 /* The type of the second argument to `fgetpos' and `fsetpos'. */
108 __BEGIN_NAMESPACE_STD
109 #ifndef __USE_FILE_OFFSET64
110 typedef _G_fpos_t
fpos_t;
112 typedef _G_fpos64_t
fpos_t;
115 #ifdef __USE_LARGEFILE64
116 typedef _G_fpos64_t fpos64_t
;
119 /* The possibilities for the third argument to `setvbuf'. */
120 #define _IOFBF 0 /* Fully buffered. */
121 #define _IOLBF 1 /* Line buffered. */
122 #define _IONBF 2 /* No buffering. */
125 /* Default buffer size. */
127 # define BUFSIZ _IO_BUFSIZ
131 /* End of file character.
132 Some things throughout the library rely on this being -1. */
138 /* The possibilities for the third argument to `fseek'.
139 These values should not be changed. */
140 #define SEEK_SET 0 /* Seek from beginning of file. */
141 #define SEEK_CUR 1 /* Seek from current position. */
142 #define SEEK_END 2 /* Seek from end of file. */
144 # define SEEK_DATA 3 /* Seek to next data. */
145 # define SEEK_HOLE 4 /* Seek to next hole. */
149 #if defined __USE_SVID || defined __USE_XOPEN
150 /* Default path prefix for `tempnam' and `tmpnam'. */
151 # define P_tmpdir "/tmp"
156 L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
157 TMP_MAX The minimum number of unique filenames generated by tmpnam
158 (and tempnam when it uses tmpnam's name space),
159 or tempnam (the two are separate).
160 L_ctermid How long an array to pass to `ctermid'.
161 L_cuserid How long an array to pass to `cuserid'.
162 FOPEN_MAX Minimum number of files that can be open at once.
163 FILENAME_MAX Maximum length of a filename. */
164 #include <bits/stdio_lim.h>
167 /* Standard streams. */
168 extern struct _IO_FILE
*stdin
; /* Standard input stream. */
169 extern struct _IO_FILE
*stdout
; /* Standard output stream. */
170 extern struct _IO_FILE
*stderr
; /* Standard error output stream. */
171 /* C89/C99 say they're macros. Make them happy. */
173 #define stdout stdout
174 #define stderr stderr
176 __BEGIN_NAMESPACE_STD
177 /* Remove file FILENAME. */
178 extern int remove (const char *__filename
) __THROW
;
179 /* Rename file OLD to NEW. */
180 extern int rename (const char *__old
, const char *__new
) __THROW
;
184 /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
185 extern int renameat (int __oldfd
, const char *__old
, int __newfd
,
186 const char *__new
) __THROW
;
189 __BEGIN_NAMESPACE_STD
190 /* Create a temporary file and open it read/write.
192 This function is a possible cancellation point and therefore not
193 marked with __THROW. */
194 #ifndef __USE_FILE_OFFSET64
195 extern FILE *tmpfile (void) __wur
;
198 extern FILE *__REDIRECT (tmpfile
, (void), tmpfile64
) __wur
;
200 # define tmpfile tmpfile64
204 #ifdef __USE_LARGEFILE64
205 extern FILE *tmpfile64 (void) __wur
;
208 /* Generate a temporary filename. */
209 extern char *tmpnam (char *__s
) __THROW __wur
;
213 /* This is the reentrant variant of `tmpnam'. The only difference is
214 that it does not allow S to be NULL. */
215 extern char *tmpnam_r (char *__s
) __THROW __wur
;
219 #if defined __USE_SVID || defined __USE_XOPEN
220 /* Generate a unique temporary filename using up to five characters of PFX
221 if it is not NULL. The directory to put this file in is searched for
222 as follows: First the environment variable "TMPDIR" is checked.
223 If it contains the name of a writable directory, that directory is used.
224 If not and if DIR is not NULL, that value is checked. If that fails,
225 P_tmpdir is tried and finally "/tmp". The storage for the filename
226 is allocated by `malloc'. */
227 extern char *tempnam (const char *__dir
, const char *__pfx
)
228 __THROW __attribute_malloc__ __wur
;
232 __BEGIN_NAMESPACE_STD
235 This function is a possible cancellation point and therefore not
236 marked with __THROW. */
237 extern int fclose (FILE *__stream
);
238 /* Flush STREAM, or all streams if STREAM is NULL.
240 This function is a possible cancellation point and therefore not
241 marked with __THROW. */
242 extern int fflush (FILE *__stream
);
246 /* Faster versions when locking is not required.
248 This function is not part of POSIX and therefore no official
249 cancellation point. But due to similarity with an POSIX interface
250 or due to the implementation it is a cancellation point and
251 therefore not marked with __THROW. */
252 extern int fflush_unlocked (FILE *__stream
);
256 /* Close all streams.
258 This function is not part of POSIX and therefore no official
259 cancellation point. But due to similarity with an POSIX interface
260 or due to the implementation it is a cancellation point and
261 therefore not marked with __THROW. */
262 extern int fcloseall (void);
266 __BEGIN_NAMESPACE_STD
267 #ifndef __USE_FILE_OFFSET64
268 /* Open a file and create a new stream for it.
270 This function is a possible cancellation point and therefore not
271 marked with __THROW. */
272 extern FILE *fopen (const char *__restrict __filename
,
273 const char *__restrict __modes
) __wur
;
274 /* Open a file, replacing an existing stream with it.
276 This function is a possible cancellation point and therefore not
277 marked with __THROW. */
278 extern FILE *freopen (const char *__restrict __filename
,
279 const char *__restrict __modes
,
280 FILE *__restrict __stream
) __wur
;
283 extern FILE *__REDIRECT (fopen
, (const char *__restrict __filename
,
284 const char *__restrict __modes
), fopen64
)
286 extern FILE *__REDIRECT (freopen
, (const char *__restrict __filename
,
287 const char *__restrict __modes
,
288 FILE *__restrict __stream
), freopen64
)
291 # define fopen fopen64
292 # define freopen freopen64
296 #ifdef __USE_LARGEFILE64
297 extern FILE *fopen64 (const char *__restrict __filename
,
298 const char *__restrict __modes
) __wur
;
299 extern FILE *freopen64 (const char *__restrict __filename
,
300 const char *__restrict __modes
,
301 FILE *__restrict __stream
) __wur
;
305 /* Create a new stream that refers to an existing system file descriptor. */
306 extern FILE *fdopen (int __fd
, const char *__modes
) __THROW __wur
;
310 /* Create a new stream that refers to the given magic cookie,
311 and uses the given functions for input and output. */
312 extern FILE *fopencookie (void *__restrict __magic_cookie
,
313 const char *__restrict __modes
,
314 _IO_cookie_io_functions_t __io_funcs
) __THROW __wur
;
317 #ifdef __USE_XOPEN2K8
318 /* Create a new stream that refers to a memory buffer. */
319 extern FILE *fmemopen (void *__s
, size_t __len
, const char *__modes
)
322 /* Open a stream that writes into a malloc'd buffer that is expanded as
323 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
324 and the number of characters written on fflush or fclose. */
325 extern FILE *open_memstream (char **__bufloc
, size_t *__sizeloc
) __THROW __wur
;
329 __BEGIN_NAMESPACE_STD
330 /* If BUF is NULL, make STREAM unbuffered.
331 Else make it use buffer BUF, of size BUFSIZ. */
332 extern void setbuf (FILE *__restrict __stream
, char *__restrict __buf
) __THROW
;
333 /* Make STREAM use buffering mode MODE.
334 If BUF is not NULL, use N bytes of it for buffering;
335 else allocate an internal buffer N bytes long. */
336 extern int setvbuf (FILE *__restrict __stream
, char *__restrict __buf
,
337 int __modes
, size_t __n
) __THROW
;
341 /* If BUF is NULL, make STREAM unbuffered.
342 Else make it use SIZE bytes of BUF for buffering. */
343 extern void setbuffer (FILE *__restrict __stream
, char *__restrict __buf
,
344 size_t __size
) __THROW
;
346 /* Make STREAM line-buffered. */
347 extern void setlinebuf (FILE *__stream
) __THROW
;
351 __BEGIN_NAMESPACE_STD
352 /* Write formatted output to STREAM.
354 This function is a possible cancellation point and therefore not
355 marked with __THROW. */
356 extern int fprintf (FILE *__restrict __stream
,
357 const char *__restrict __format
, ...);
358 /* Write formatted output to stdout.
360 This function is a possible cancellation point and therefore not
361 marked with __THROW. */
362 extern int printf (const char *__restrict __format
, ...);
363 /* Write formatted output to S. */
364 extern int sprintf (char *__restrict __s
,
365 const char *__restrict __format
, ...) __THROWNL
;
367 /* Write formatted output to S from argument list ARG.
369 This function is a possible cancellation point and therefore not
370 marked with __THROW. */
371 extern int vfprintf (FILE *__restrict __s
, const char *__restrict __format
,
373 /* Write formatted output to stdout from argument list ARG.
375 This function is a possible cancellation point and therefore not
376 marked with __THROW. */
377 extern int vprintf (const char *__restrict __format
, _G_va_list __arg
);
378 /* Write formatted output to S from argument list ARG. */
379 extern int vsprintf (char *__restrict __s
, const char *__restrict __format
,
380 _G_va_list __arg
) __THROWNL
;
383 #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
384 __BEGIN_NAMESPACE_C99
385 /* Maximum chars of output to write in MAXLEN. */
386 extern int snprintf (char *__restrict __s
, size_t __maxlen
,
387 const char *__restrict __format
, ...)
388 __THROWNL
__attribute__ ((__format__ (__printf__
, 3, 4)));
390 extern int vsnprintf (char *__restrict __s
, size_t __maxlen
,
391 const char *__restrict __format
, _G_va_list __arg
)
392 __THROWNL
__attribute__ ((__format__ (__printf__
, 3, 0)));
397 /* Write formatted output to a string dynamically allocated with `malloc'.
398 Store the address of the string in *PTR. */
399 extern int vasprintf (char **__restrict __ptr
, const char *__restrict __f
,
401 __THROWNL
__attribute__ ((__format__ (__printf__
, 2, 0))) __wur
;
402 extern int __asprintf (char **__restrict __ptr
,
403 const char *__restrict __fmt
, ...)
404 __THROWNL
__attribute__ ((__format__ (__printf__
, 2, 3))) __wur
;
405 extern int asprintf (char **__restrict __ptr
,
406 const char *__restrict __fmt
, ...)
407 __THROWNL
__attribute__ ((__format__ (__printf__
, 2, 3))) __wur
;
410 #ifdef __USE_XOPEN2K8
411 /* Write formatted output to a file descriptor. */
412 extern int vdprintf (int __fd
, const char *__restrict __fmt
,
414 __attribute__ ((__format__ (__printf__
, 2, 0)));
415 extern int dprintf (int __fd
, const char *__restrict __fmt
, ...)
416 __attribute__ ((__format__ (__printf__
, 2, 3)));
420 __BEGIN_NAMESPACE_STD
421 /* Read formatted input from STREAM.
423 This function is a possible cancellation point and therefore not
424 marked with __THROW. */
425 extern int fscanf (FILE *__restrict __stream
,
426 const char *__restrict __format
, ...) __wur
;
427 /* Read formatted input from stdin.
429 This function is a possible cancellation point and therefore not
430 marked with __THROW. */
431 extern int scanf (const char *__restrict __format
, ...) __wur
;
432 /* Read formatted input from S. */
433 extern int sscanf (const char *__restrict __s
,
434 const char *__restrict __format
, ...) __THROW
;
436 #if defined __USE_ISOC99 && !defined __USE_GNU \
437 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
438 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
440 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
441 GNU extension which conflicts with valid %a followed by letter
443 extern int __REDIRECT (fscanf
, (FILE *__restrict __stream
,
444 const char *__restrict __format
, ...),
445 __isoc99_fscanf
) __wur
;
446 extern int __REDIRECT (scanf
, (const char *__restrict __format
, ...),
447 __isoc99_scanf
) __wur
;
448 extern int __REDIRECT_NTH (sscanf
, (const char *__restrict __s
,
449 const char *__restrict __format
, ...),
452 extern int __isoc99_fscanf (FILE *__restrict __stream
,
453 const char *__restrict __format
, ...) __wur
;
454 extern int __isoc99_scanf (const char *__restrict __format
, ...) __wur
;
455 extern int __isoc99_sscanf (const char *__restrict __s
,
456 const char *__restrict __format
, ...) __THROW
;
457 # define fscanf __isoc99_fscanf
458 # define scanf __isoc99_scanf
459 # define sscanf __isoc99_sscanf
466 __BEGIN_NAMESPACE_C99
467 /* Read formatted input from S into argument list ARG.
469 This function is a possible cancellation point and therefore not
470 marked with __THROW. */
471 extern int vfscanf (FILE *__restrict __s
, const char *__restrict __format
,
473 __attribute__ ((__format__ (__scanf__
, 2, 0))) __wur
;
475 /* Read formatted input from stdin into argument list ARG.
477 This function is a possible cancellation point and therefore not
478 marked with __THROW. */
479 extern int vscanf (const char *__restrict __format
, _G_va_list __arg
)
480 __attribute__ ((__format__ (__scanf__
, 1, 0))) __wur
;
482 /* Read formatted input from S into argument list ARG. */
483 extern int vsscanf (const char *__restrict __s
,
484 const char *__restrict __format
, _G_va_list __arg
)
485 __THROW
__attribute__ ((__format__ (__scanf__
, 2, 0)));
487 # if !defined __USE_GNU \
488 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
489 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
491 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
492 GNU extension which conflicts with valid %a followed by letter
494 extern int __REDIRECT (vfscanf
,
495 (FILE *__restrict __s
,
496 const char *__restrict __format
, _G_va_list __arg
),
498 __attribute__ ((__format__ (__scanf__
, 2, 0))) __wur
;
499 extern int __REDIRECT (vscanf
, (const char *__restrict __format
,
500 _G_va_list __arg
), __isoc99_vscanf
)
501 __attribute__ ((__format__ (__scanf__
, 1, 0))) __wur
;
502 extern int __REDIRECT_NTH (vsscanf
,
503 (const char *__restrict __s
,
504 const char *__restrict __format
,
505 _G_va_list __arg
), __isoc99_vsscanf
)
506 __attribute__ ((__format__ (__scanf__
, 2, 0)));
508 extern int __isoc99_vfscanf (FILE *__restrict __s
,
509 const char *__restrict __format
,
510 _G_va_list __arg
) __wur
;
511 extern int __isoc99_vscanf (const char *__restrict __format
,
512 _G_va_list __arg
) __wur
;
513 extern int __isoc99_vsscanf (const char *__restrict __s
,
514 const char *__restrict __format
,
515 _G_va_list __arg
) __THROW
;
516 # define vfscanf __isoc99_vfscanf
517 # define vscanf __isoc99_vscanf
518 # define vsscanf __isoc99_vsscanf
523 #endif /* Use ISO C9x. */
526 __BEGIN_NAMESPACE_STD
527 /* Read a character from STREAM.
529 These functions are possible cancellation points and therefore not
530 marked with __THROW. */
531 extern int fgetc (FILE *__stream
);
532 extern int getc (FILE *__stream
);
534 /* Read a character from stdin.
536 This function is a possible cancellation point and therefore not
537 marked with __THROW. */
538 extern int getchar (void);
541 /* The C standard explicitly says this is a macro, so we always do the
542 optimization for it. */
543 #define getc(_fp) _IO_getc (_fp)
545 #if defined __USE_POSIX || defined __USE_MISC
546 /* These are defined in POSIX.1:1996.
548 These functions are possible cancellation points and therefore not
549 marked with __THROW. */
550 extern int getc_unlocked (FILE *__stream
);
551 extern int getchar_unlocked (void);
552 #endif /* Use POSIX or MISC. */
555 /* Faster version when locking is not necessary.
557 This function is not part of POSIX and therefore no official
558 cancellation point. But due to similarity with an POSIX interface
559 or due to the implementation it is a cancellation point and
560 therefore not marked with __THROW. */
561 extern int fgetc_unlocked (FILE *__stream
);
562 #endif /* Use MISC. */
565 __BEGIN_NAMESPACE_STD
566 /* Write a character to STREAM.
568 These functions are possible cancellation points and therefore not
571 These functions is a possible cancellation point and therefore not
572 marked with __THROW. */
573 extern int fputc (int __c
, FILE *__stream
);
574 extern int putc (int __c
, FILE *__stream
);
576 /* Write a character to stdout.
578 This function is a possible cancellation point and therefore not
579 marked with __THROW. */
580 extern int putchar (int __c
);
583 /* The C standard explicitly says this can be a macro,
584 so we always do the optimization for it. */
585 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
588 /* Faster version when locking is not necessary.
590 This function is not part of POSIX and therefore no official
591 cancellation point. But due to similarity with an POSIX interface
592 or due to the implementation it is a cancellation point and
593 therefore not marked with __THROW. */
594 extern int fputc_unlocked (int __c
, FILE *__stream
);
595 #endif /* Use MISC. */
597 #if defined __USE_POSIX || defined __USE_MISC
598 /* These are defined in POSIX.1:1996.
600 These functions are possible cancellation points and therefore not
601 marked with __THROW. */
602 extern int putc_unlocked (int __c
, FILE *__stream
);
603 extern int putchar_unlocked (int __c
);
604 #endif /* Use POSIX or MISC. */
607 #if defined __USE_SVID || defined __USE_MISC \
608 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
609 /* Get a word (int) from STREAM. */
610 extern int getw (FILE *__stream
);
612 /* Write a word (int) to STREAM. */
613 extern int putw (int __w
, FILE *__stream
);
617 __BEGIN_NAMESPACE_STD
618 /* Get a newline-terminated string of finite length from STREAM.
620 This function is a possible cancellation point and therefore not
621 marked with __THROW. */
622 extern char *fgets (char *__restrict __s
, int __n
, FILE *__restrict __stream
)
625 #if !defined __USE_ISOC11 \
626 || (defined __cplusplus && __cplusplus <= 201103L)
627 /* Get a newline-terminated string from stdin, removing the newline.
628 DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
630 The function has been officially removed in ISO C11. This opportunity
631 is used to also remove it from the GNU feature list. It is now only
632 available when explicitly using an old ISO C, Unix, or POSIX standard.
633 GCC defines _GNU_SOURCE when building C++ code and the function is still
634 in C++11, so it is also available for C++.
636 This function is a possible cancellation point and therefore not
637 marked with __THROW. */
638 extern char *gets (char *__s
) __wur __attribute_deprecated__
;
643 /* This function does the same as `fgets' but does not lock the stream.
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 char *fgets_unlocked (char *__restrict __s
, int __n
,
650 FILE *__restrict __stream
) __wur
;
654 #ifdef __USE_XOPEN2K8
655 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
656 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
657 NULL), pointing to *N characters of space. It is realloc'd as
658 necessary. Returns the number of characters read (not including the
659 null terminator), or -1 on error or EOF.
661 These functions are not part of POSIX and therefore no official
662 cancellation point. But due to similarity with an POSIX interface
663 or due to the implementation they are cancellation points and
664 therefore not marked with __THROW. */
665 extern _IO_ssize_t
__getdelim (char **__restrict __lineptr
,
666 size_t *__restrict __n
, int __delimiter
,
667 FILE *__restrict __stream
) __wur
;
668 extern _IO_ssize_t
getdelim (char **__restrict __lineptr
,
669 size_t *__restrict __n
, int __delimiter
,
670 FILE *__restrict __stream
) __wur
;
672 /* Like `getdelim', but reads up to a newline.
674 This function is not part of POSIX and therefore no official
675 cancellation point. But due to similarity with an POSIX interface
676 or due to the implementation it is a cancellation point and
677 therefore not marked with __THROW. */
678 extern _IO_ssize_t
getline (char **__restrict __lineptr
,
679 size_t *__restrict __n
,
680 FILE *__restrict __stream
) __wur
;
684 __BEGIN_NAMESPACE_STD
685 /* Write a string to STREAM.
687 This function is a possible cancellation point and therefore not
688 marked with __THROW. */
689 extern int fputs (const char *__restrict __s
, FILE *__restrict __stream
);
691 /* Write a string, followed by a newline, to stdout.
693 This function is a possible cancellation point and therefore not
694 marked with __THROW. */
695 extern int puts (const char *__s
);
698 /* Push a character back onto the input buffer of STREAM.
700 This function is a possible cancellation point and therefore not
701 marked with __THROW. */
702 extern int ungetc (int __c
, FILE *__stream
);
705 /* Read chunks of generic data from STREAM.
707 This function is a possible cancellation point and therefore not
708 marked with __THROW. */
709 extern size_t fread (void *__restrict __ptr
, size_t __size
,
710 size_t __n
, FILE *__restrict __stream
) __wur
;
711 /* Write chunks of generic data to STREAM.
713 This function is a possible cancellation point and therefore not
714 marked with __THROW. */
715 extern size_t fwrite (const void *__restrict __ptr
, size_t __size
,
716 size_t __n
, FILE *__restrict __s
);
720 /* This function does the same as `fputs' but does not lock the stream.
722 This function is not part of POSIX and therefore no official
723 cancellation point. But due to similarity with an POSIX interface
724 or due to the implementation it is a cancellation point and
725 therefore not marked with __THROW. */
726 extern int fputs_unlocked (const char *__restrict __s
,
727 FILE *__restrict __stream
);
731 /* Faster versions when locking is not necessary.
733 These functions are not part of POSIX and therefore no official
734 cancellation point. But due to similarity with an POSIX interface
735 or due to the implementation they are cancellation points and
736 therefore not marked with __THROW. */
737 extern size_t fread_unlocked (void *__restrict __ptr
, size_t __size
,
738 size_t __n
, FILE *__restrict __stream
) __wur
;
739 extern size_t fwrite_unlocked (const void *__restrict __ptr
, size_t __size
,
740 size_t __n
, FILE *__restrict __stream
);
744 __BEGIN_NAMESPACE_STD
745 /* Seek to a certain position on STREAM.
747 This function is a possible cancellation point and therefore not
748 marked with __THROW. */
749 extern int fseek (FILE *__stream
, long int __off
, int __whence
);
750 /* Return the current position of STREAM.
752 This function is a possible cancellation point and therefore not
753 marked with __THROW. */
754 extern long int ftell (FILE *__stream
) __wur
;
755 /* Rewind to the beginning of STREAM.
757 This function is a possible cancellation point and therefore not
758 marked with __THROW. */
759 extern void rewind (FILE *__stream
);
762 /* The Single Unix Specification, Version 2, specifies an alternative,
763 more adequate interface for the two functions above which deal with
764 file offset. `long int' is not the right type. These definitions
765 are originally defined in the Large File Support API. */
767 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
768 # ifndef __USE_FILE_OFFSET64
769 /* Seek to a certain position on STREAM.
771 This function is a possible cancellation point and therefore not
772 marked with __THROW. */
773 extern int fseeko (FILE *__stream
, __off_t __off
, int __whence
);
774 /* Return the current position of STREAM.
776 This function is a possible cancellation point and therefore not
777 marked with __THROW. */
778 extern __off_t
ftello (FILE *__stream
) __wur
;
781 extern int __REDIRECT (fseeko
,
782 (FILE *__stream
, __off64_t __off
, int __whence
),
784 extern __off64_t
__REDIRECT (ftello
, (FILE *__stream
), ftello64
);
786 # define fseeko fseeko64
787 # define ftello ftello64
792 __BEGIN_NAMESPACE_STD
793 #ifndef __USE_FILE_OFFSET64
794 /* Get STREAM's position.
796 This function is a possible cancellation point and therefore not
797 marked with __THROW. */
798 extern int fgetpos (FILE *__restrict __stream
, fpos_t *__restrict __pos
);
799 /* Set STREAM's position.
801 This function is a possible cancellation point and therefore not
802 marked with __THROW. */
803 extern int fsetpos (FILE *__stream
, const fpos_t *__pos
);
806 extern int __REDIRECT (fgetpos
, (FILE *__restrict __stream
,
807 fpos_t *__restrict __pos
), fgetpos64
);
808 extern int __REDIRECT (fsetpos
,
809 (FILE *__stream
, const fpos_t *__pos
), fsetpos64
);
811 # define fgetpos fgetpos64
812 # define fsetpos fsetpos64
817 #ifdef __USE_LARGEFILE64
818 extern int fseeko64 (FILE *__stream
, __off64_t __off
, int __whence
);
819 extern __off64_t
ftello64 (FILE *__stream
) __wur
;
820 extern int fgetpos64 (FILE *__restrict __stream
, fpos64_t
*__restrict __pos
);
821 extern int fsetpos64 (FILE *__stream
, const fpos64_t
*__pos
);
824 __BEGIN_NAMESPACE_STD
825 /* Clear the error and EOF indicators for STREAM. */
826 extern void clearerr (FILE *__stream
) __THROW
;
827 /* Return the EOF indicator for STREAM. */
828 extern int feof (FILE *__stream
) __THROW __wur
;
829 /* Return the error indicator for STREAM. */
830 extern int ferror (FILE *__stream
) __THROW __wur
;
834 /* Faster versions when locking is not required. */
835 extern void clearerr_unlocked (FILE *__stream
) __THROW
;
836 extern int feof_unlocked (FILE *__stream
) __THROW __wur
;
837 extern int ferror_unlocked (FILE *__stream
) __THROW __wur
;
841 __BEGIN_NAMESPACE_STD
842 /* Print a message describing the meaning of the value of errno.
844 This function is a possible cancellation point and therefore not
845 marked with __THROW. */
846 extern void perror (const char *__s
);
849 /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
850 are available on this system. Even if available, these variables
851 should not be used directly. The `strerror' function provides
852 all the necessary functionality. */
853 #include <bits/sys_errlist.h>
857 /* Return the system file descriptor for STREAM. */
858 extern int fileno (FILE *__stream
) __THROW __wur
;
859 #endif /* Use POSIX. */
862 /* Faster version when locking is not required. */
863 extern int fileno_unlocked (FILE *__stream
) __THROW __wur
;
867 #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
869 /* Create a new stream connected to a pipe running the given command.
871 This function is a possible cancellation point and therefore not
872 marked with __THROW. */
873 extern FILE *popen (const char *__command
, const char *__modes
) __wur
;
875 /* Close a stream opened by popen and return the status of its child.
877 This function is a possible cancellation point and therefore not
878 marked with __THROW. */
879 extern int pclose (FILE *__stream
);
884 /* Return the name of the controlling terminal. */
885 extern char *ctermid (char *__s
) __THROW
;
886 #endif /* Use POSIX. */
890 /* Return the name of the current user. */
891 extern char *cuserid (char *__s
);
892 #endif /* Use X/Open, but not issue 6. */
896 struct obstack
; /* See <obstack.h>. */
898 /* Write formatted output to an obstack. */
899 extern int obstack_printf (struct obstack
*__restrict __obstack
,
900 const char *__restrict __format
, ...)
901 __THROWNL
__attribute__ ((__format__ (__printf__
, 2, 3)));
902 extern int obstack_vprintf (struct obstack
*__restrict __obstack
,
903 const char *__restrict __format
,
905 __THROWNL
__attribute__ ((__format__ (__printf__
, 2, 0)));
906 #endif /* Use GNU. */
909 #if defined __USE_POSIX || defined __USE_MISC
910 /* These are defined in POSIX.1:1996. */
912 /* Acquire ownership of STREAM. */
913 extern void flockfile (FILE *__stream
) __THROW
;
915 /* Try to acquire ownership of STREAM but do not block if it is not
917 extern int ftrylockfile (FILE *__stream
) __THROW __wur
;
919 /* Relinquish the ownership granted for STREAM. */
920 extern void funlockfile (FILE *__stream
) __THROW
;
921 #endif /* POSIX || misc */
923 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
924 /* The X/Open standard requires some functions and variables to be
925 declared here which do not belong into this header. But we have to
926 follow. In GNU mode we don't do this nonsense. */
927 # define __need_getopt
929 #endif /* X/Open, but not issue 6 and not for GNU. */
931 /* If we are compiling with optimizing read this file. It contains
932 several optimizing inline functions and macros. */
933 #ifdef __USE_EXTERN_INLINES
934 # include <bits/stdio.h>
936 #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
937 # include <bits/stdio2.h>
940 # include <bits/stdio-ldbl.h>
945 #endif /* <stdio.h> included. */
947 #endif /* !_STDIO_H */