1/* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991-2018 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
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.
9
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.
14
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/>. */
18
19/*
20 * ISO C99 Standard: 7.19 Input/output <stdio.h>
21 */
22
23#ifndef _STDIO_H
24#define _STDIO_H 1
25
26#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
27#include <bits/libc-header-start.h>
28
29__BEGIN_DECLS
30
31#define __need_size_t
32#define __need_NULL
33#include <stddef.h>
34
35#define __need___va_list
36#include <stdarg.h>
37
38#include <bits/types.h>
39#include <bits/types/__fpos_t.h>
40#include <bits/types/__fpos64_t.h>
41#include <bits/types/__FILE.h>
42#include <bits/types/FILE.h>
43#include <bits/types/struct_FILE.h>
44
45#ifdef __USE_GNU
46# include <bits/types/cookie_io_functions_t.h>
47#endif
48
49#if defined __USE_XOPEN || defined __USE_XOPEN2K8
50# ifdef __GNUC__
51# ifndef _VA_LIST_DEFINED
52typedef __gnuc_va_list va_list;
53# define _VA_LIST_DEFINED
54# endif
55# else
56# include <stdarg.h>
57# endif
58#endif
59
60#if defined __USE_UNIX98 || defined __USE_XOPEN2K
61# ifndef __off_t_defined
62# ifndef __USE_FILE_OFFSET64
63typedef __off_t off_t;
64# else
65typedef __off64_t off_t;
66# endif
67# define __off_t_defined
68# endif
69# if defined __USE_LARGEFILE64 && !defined __off64_t_defined
70typedef __off64_t off64_t;
71# define __off64_t_defined
72# endif
73#endif
74
75#ifdef __USE_XOPEN2K8
76# ifndef __ssize_t_defined
77typedef __ssize_t ssize_t;
78# define __ssize_t_defined
79# endif
80#endif
81
82/* The type of the second argument to `fgetpos' and `fsetpos'. */
83#ifndef __USE_FILE_OFFSET64
84typedef __fpos_t fpos_t;
85#else
86typedef __fpos64_t fpos_t;
87#endif
88#ifdef __USE_LARGEFILE64
89typedef __fpos64_t fpos64_t;
90#endif
91
92/* The possibilities for the third argument to `setvbuf'. */
93#define _IOFBF 0 /* Fully buffered. */
94#define _IOLBF 1 /* Line buffered. */
95#define _IONBF 2 /* No buffering. */
96
97
98/* Default buffer size. */
99#define BUFSIZ 8192
100
101
102/* The value returned by fgetc and similar functions to indicate the
103 end of the file. */
104#define EOF (-1)
105
106
107/* The possibilities for the third argument to `fseek'.
108 These values should not be changed. */
109#define SEEK_SET 0 /* Seek from beginning of file. */
110#define SEEK_CUR 1 /* Seek from current position. */
111#define SEEK_END 2 /* Seek from end of file. */
112#ifdef __USE_GNU
113# define SEEK_DATA 3 /* Seek to next data. */
114# define SEEK_HOLE 4 /* Seek to next hole. */
115#endif
116
117
118#if defined __USE_MISC || defined __USE_XOPEN
119/* Default path prefix for `tempnam' and `tmpnam'. */
120# define P_tmpdir "/tmp"
121#endif
122
123
124/* Get the values:
125 L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
126 TMP_MAX The minimum number of unique filenames generated by tmpnam
127 (and tempnam when it uses tmpnam's name space),
128 or tempnam (the two are separate).
129 L_ctermid How long an array to pass to `ctermid'.
130 L_cuserid How long an array to pass to `cuserid'.
131 FOPEN_MAX Minimum number of files that can be open at once.
132 FILENAME_MAX Maximum length of a filename. */
133#include <bits/stdio_lim.h>
134
135
136/* Standard streams. */
137extern FILE *stdin; /* Standard input stream. */
138extern FILE *stdout; /* Standard output stream. */
139extern FILE *stderr; /* Standard error output stream. */
140/* C89/C99 say they're macros. Make them happy. */
141#define stdin stdin
142#define stdout stdout
143#define stderr stderr
144
145/* Remove file FILENAME. */
146extern int remove (const char *__filename) __THROW;
147/* Rename file OLD to NEW. */
148extern int rename (const char *__old, const char *__new) __THROW;
149
150#ifdef __USE_ATFILE
151/* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
152extern int renameat (int __oldfd, const char *__old, int __newfd,
153 const char *__new) __THROW;
154#endif
155
156/* Create a temporary file and open it read/write.
157
158 This function is a possible cancellation point and therefore not
159 marked with __THROW. */
160#ifndef __USE_FILE_OFFSET64
161extern FILE *tmpfile (void) __wur;
162#else
163# ifdef __REDIRECT
164extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;
165# else
166# define tmpfile tmpfile64
167# endif
168#endif
169
170#ifdef __USE_LARGEFILE64
171extern FILE *tmpfile64 (void) __wur;
172#endif
173
174/* Generate a temporary filename. */
175extern char *tmpnam (char *__s) __THROW __wur;
176
177#ifdef __USE_MISC
178/* This is the reentrant variant of `tmpnam'. The only difference is
179 that it does not allow S to be NULL. */
180extern char *tmpnam_r (char *__s) __THROW __wur;
181#endif
182
183
184#if defined __USE_MISC || defined __USE_XOPEN
185/* Generate a unique temporary filename using up to five characters of PFX
186 if it is not NULL. The directory to put this file in is searched for
187 as follows: First the environment variable "TMPDIR" is checked.
188 If it contains the name of a writable directory, that directory is used.
189 If not and if DIR is not NULL, that value is checked. If that fails,
190 P_tmpdir is tried and finally "/tmp". The storage for the filename
191 is allocated by `malloc'. */
192extern char *tempnam (const char *__dir, const char *__pfx)
193 __THROW __attribute_malloc__ __wur;
194#endif
195
196
197/* Close STREAM.
198
199 This function is a possible cancellation point and therefore not
200 marked with __THROW. */
201extern int fclose (FILE *__stream);
202/* Flush STREAM, or all streams if STREAM is NULL.
203
204 This function is a possible cancellation point and therefore not
205 marked with __THROW. */
206extern int fflush (FILE *__stream);
207
208#ifdef __USE_MISC
209/* Faster versions when locking is not required.
210
211 This function is not part of POSIX and therefore no official
212 cancellation point. But due to similarity with an POSIX interface
213 or due to the implementation it is a cancellation point and
214 therefore not marked with __THROW. */
215extern int fflush_unlocked (FILE *__stream);
216#endif
217
218#ifdef __USE_GNU
219/* Close all streams.
220
221 This function is not part of POSIX and therefore no official
222 cancellation point. But due to similarity with an POSIX interface
223 or due to the implementation it is a cancellation point and
224 therefore not marked with __THROW. */
225extern int fcloseall (void);
226#endif
227
228
229#ifndef __USE_FILE_OFFSET64
230/* Open a file and create a new stream for it.
231
232 This function is a possible cancellation point and therefore not
233 marked with __THROW. */
234extern FILE *fopen (const char *__restrict __filename,
235 const char *__restrict __modes) __wur;
236/* Open a file, replacing an existing stream with it.
237
238 This function is a possible cancellation point and therefore not
239 marked with __THROW. */
240extern FILE *freopen (const char *__restrict __filename,
241 const char *__restrict __modes,
242 FILE *__restrict __stream) __wur;
243#else
244# ifdef __REDIRECT
245extern FILE *__REDIRECT (fopen, (const char *__restrict __filename,
246 const char *__restrict __modes), fopen64)
247 __wur;
248extern FILE *__REDIRECT (freopen, (const char *__restrict __filename,
249 const char *__restrict __modes,
250 FILE *__restrict __stream), freopen64)
251 __wur;
252# else
253# define fopen fopen64
254# define freopen freopen64
255# endif
256#endif
257#ifdef __USE_LARGEFILE64
258extern FILE *fopen64 (const char *__restrict __filename,
259 const char *__restrict __modes) __wur;
260extern FILE *freopen64 (const char *__restrict __filename,
261 const char *__restrict __modes,
262 FILE *__restrict __stream) __wur;
263#endif
264
265#ifdef __USE_POSIX
266/* Create a new stream that refers to an existing system file descriptor. */
267extern FILE *fdopen (int __fd, const char *__modes) __THROW __wur;
268#endif
269
270#ifdef __USE_GNU
271/* Create a new stream that refers to the given magic cookie,
272 and uses the given functions for input and output. */
273extern FILE *fopencookie (void *__restrict __magic_cookie,
274 const char *__restrict __modes,
275 cookie_io_functions_t __io_funcs) __THROW __wur;
276#endif
277
278#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
279/* Create a new stream that refers to a memory buffer. */
280extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
281 __THROW __wur;
282
283/* Open a stream that writes into a malloc'd buffer that is expanded as
284 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
285 and the number of characters written on fflush or fclose. */
286extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;
287#endif
288
289
290/* If BUF is NULL, make STREAM unbuffered.
291 Else make it use buffer BUF, of size BUFSIZ. */
292extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
293/* Make STREAM use buffering mode MODE.
294 If BUF is not NULL, use N bytes of it for buffering;
295 else allocate an internal buffer N bytes long. */
296extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
297 int __modes, size_t __n) __THROW;
298
299#ifdef __USE_MISC
300/* If BUF is NULL, make STREAM unbuffered.
301 Else make it use SIZE bytes of BUF for buffering. */
302extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
303 size_t __size) __THROW;
304
305/* Make STREAM line-buffered. */
306extern void setlinebuf (FILE *__stream) __THROW;
307#endif
308
309
310/* Write formatted output to STREAM.
311
312 This function is a possible cancellation point and therefore not
313 marked with __THROW. */
314extern int fprintf (FILE *__restrict __stream,
315 const char *__restrict __format, ...);
316/* Write formatted output to stdout.
317
318 This function is a possible cancellation point and therefore not
319 marked with __THROW. */
320extern int printf (const char *__restrict __format, ...);
321/* Write formatted output to S. */
322extern int sprintf (char *__restrict __s,
323 const char *__restrict __format, ...) __THROWNL;
324
325/* Write formatted output to S from argument list ARG.
326
327 This function is a possible cancellation point and therefore not
328 marked with __THROW. */
329extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
330 __gnuc_va_list __arg);
331/* Write formatted output to stdout from argument list ARG.
332
333 This function is a possible cancellation point and therefore not
334 marked with __THROW. */
335extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);
336/* Write formatted output to S from argument list ARG. */
337extern int vsprintf (char *__restrict __s, const char *__restrict __format,
338 __gnuc_va_list __arg) __THROWNL;
339
340#if defined __USE_ISOC99 || defined __USE_UNIX98
341/* Maximum chars of output to write in MAXLEN. */
342extern int snprintf (char *__restrict __s, size_t __maxlen,
343 const char *__restrict __format, ...)
344 __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));
345
346extern int vsnprintf (char *__restrict __s, size_t __maxlen,
347 const char *__restrict __format, __gnuc_va_list __arg)
348 __THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));
349#endif
350
351#if __GLIBC_USE (LIB_EXT2)
352/* Write formatted output to a string dynamically allocated with `malloc'.
353 Store the address of the string in *PTR. */
354extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,
355 __gnuc_va_list __arg)
356 __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
357extern int __asprintf (char **__restrict __ptr,
358 const char *__restrict __fmt, ...)
359 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
360extern int asprintf (char **__restrict __ptr,
361 const char *__restrict __fmt, ...)
362 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
363#endif
364
365#ifdef __USE_XOPEN2K8
366/* Write formatted output to a file descriptor. */
367extern int vdprintf (int __fd, const char *__restrict __fmt,
368 __gnuc_va_list __arg)
369 __attribute__ ((__format__ (__printf__, 2, 0)));
370extern int dprintf (int __fd, const char *__restrict __fmt, ...)
371 __attribute__ ((__format__ (__printf__, 2, 3)));
372#endif
373
374
375/* Read formatted input from STREAM.
376
377 This function is a possible cancellation point and therefore not
378 marked with __THROW. */
379extern int fscanf (FILE *__restrict __stream,
380 const char *__restrict __format, ...) __wur;
381/* Read formatted input from stdin.
382
383 This function is a possible cancellation point and therefore not
384 marked with __THROW. */
385extern int scanf (const char *__restrict __format, ...) __wur;
386/* Read formatted input from S. */
387extern int sscanf (const char *__restrict __s,
388 const char *__restrict __format, ...) __THROW;
389
390#if defined __USE_ISOC99 && !defined __USE_GNU \
391 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
392 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
393# ifdef __REDIRECT
394/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
395 GNU extension which conflicts with valid %a followed by letter
396 s, S or [. */
397extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
398 const char *__restrict __format, ...),
399 __isoc99_fscanf) __wur;
400extern int __REDIRECT (scanf, (const char *__restrict __format, ...),
401 __isoc99_scanf) __wur;
402extern int __REDIRECT_NTH (sscanf, (const char *__restrict __s,
403 const char *__restrict __format, ...),
404 __isoc99_sscanf);
405# else
406extern int __isoc99_fscanf (FILE *__restrict __stream,
407 const char *__restrict __format, ...) __wur;
408extern int __isoc99_scanf (const char *__restrict __format, ...) __wur;
409extern int __isoc99_sscanf (const char *__restrict __s,
410 const char *__restrict __format, ...) __THROW;
411# define fscanf __isoc99_fscanf
412# define scanf __isoc99_scanf
413# define sscanf __isoc99_sscanf
414# endif
415#endif
416
417#ifdef __USE_ISOC99
418/* Read formatted input from S into argument list ARG.
419
420 This function is a possible cancellation point and therefore not
421 marked with __THROW. */
422extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
423 __gnuc_va_list __arg)
424 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
425
426/* Read formatted input from stdin into argument list ARG.
427
428 This function is a possible cancellation point and therefore not
429 marked with __THROW. */
430extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)
431 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
432
433/* Read formatted input from S into argument list ARG. */
434extern int vsscanf (const char *__restrict __s,
435 const char *__restrict __format, __gnuc_va_list __arg)
436 __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
437
438# if !defined __USE_GNU \
439 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
440 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
441# ifdef __REDIRECT
442/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
443 GNU extension which conflicts with valid %a followed by letter
444 s, S or [. */
445extern int __REDIRECT (vfscanf,
446 (FILE *__restrict __s,
447 const char *__restrict __format, __gnuc_va_list __arg),
448 __isoc99_vfscanf)
449 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
450extern int __REDIRECT (vscanf, (const char *__restrict __format,
451 __gnuc_va_list __arg), __isoc99_vscanf)
452 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
453extern int __REDIRECT_NTH (vsscanf,
454 (const char *__restrict __s,
455 const char *__restrict __format,
456 __gnuc_va_list __arg), __isoc99_vsscanf)
457 __attribute__ ((__format__ (__scanf__, 2, 0)));
458# else
459extern int __isoc99_vfscanf (FILE *__restrict __s,
460 const char *__restrict __format,
461 __gnuc_va_list __arg) __wur;
462extern int __isoc99_vscanf (const char *__restrict __format,
463 __gnuc_va_list __arg) __wur;
464extern int __isoc99_vsscanf (const char *__restrict __s,
465 const char *__restrict __format,
466 __gnuc_va_list __arg) __THROW;
467# define vfscanf __isoc99_vfscanf
468# define vscanf __isoc99_vscanf
469# define vsscanf __isoc99_vsscanf
470# endif
471# endif
472#endif /* Use ISO C9x. */
473
474
475/* Read a character from STREAM.
476
477 These functions are possible cancellation points and therefore not
478 marked with __THROW. */
479extern int fgetc (FILE *__stream);
480extern int getc (FILE *__stream);
481
482/* Read a character from stdin.
483
484 This function is a possible cancellation point and therefore not
485 marked with __THROW. */
486extern int getchar (void);
487
488#ifdef __USE_POSIX199506
489/* These are defined in POSIX.1:1996.
490
491 These functions are possible cancellation points and therefore not
492 marked with __THROW. */
493extern int getc_unlocked (FILE *__stream);
494extern int getchar_unlocked (void);
495#endif /* Use POSIX. */
496
497#ifdef __USE_MISC
498/* Faster version when locking is not necessary.
499
500 This function is not part of POSIX and therefore no official
501 cancellation point. But due to similarity with an POSIX interface
502 or due to the implementation it is a cancellation point and
503 therefore not marked with __THROW. */
504extern int fgetc_unlocked (FILE *__stream);
505#endif /* Use MISC. */
506
507
508/* Write a character to STREAM.
509
510 These functions are possible cancellation points and therefore not
511 marked with __THROW.
512
513 These functions is a possible cancellation point and therefore not
514 marked with __THROW. */
515extern int fputc (int __c, FILE *__stream);
516extern int putc (int __c, FILE *__stream);
517
518/* Write a character to stdout.
519
520 This function is a possible cancellation point and therefore not
521 marked with __THROW. */
522extern int putchar (int __c);
523
524#ifdef __USE_MISC
525/* Faster version when locking is not necessary.
526
527 This function is not part of POSIX and therefore no official
528 cancellation point. But due to similarity with an POSIX interface
529 or due to the implementation it is a cancellation point and
530 therefore not marked with __THROW. */
531extern int fputc_unlocked (int __c, FILE *__stream);
532#endif /* Use MISC. */
533
534#ifdef __USE_POSIX199506
535/* These are defined in POSIX.1:1996.
536
537 These functions are possible cancellation points and therefore not
538 marked with __THROW. */
539extern int putc_unlocked (int __c, FILE *__stream);
540extern int putchar_unlocked (int __c);
541#endif /* Use POSIX. */
542
543
544#if defined __USE_MISC \
545 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
546/* Get a word (int) from STREAM. */
547extern int getw (FILE *__stream);
548
549/* Write a word (int) to STREAM. */
550extern int putw (int __w, FILE *__stream);
551#endif
552
553
554/* Get a newline-terminated string of finite length from STREAM.
555
556 This function is a possible cancellation point and therefore not
557 marked with __THROW. */
558extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
559 __wur;
560
561#if __GLIBC_USE (DEPRECATED_GETS)
562/* Get a newline-terminated string from stdin, removing the newline.
563
564 This function is impossible to use safely. It has been officially
565 removed from ISO C11 and ISO C++14, and we have also removed it
566 from the _GNU_SOURCE feature list. It remains available when
567 explicitly using an old ISO C, Unix, or POSIX standard.
568
569 This function is a possible cancellation point and therefore not
570 marked with __THROW. */
571extern char *gets (char *__s) __wur __attribute_deprecated__;
572#endif
573
574#ifdef __USE_GNU
575/* This function does the same as `fgets' but does not lock the stream.
576
577 This function is not part of POSIX and therefore no official
578 cancellation point. But due to similarity with an POSIX interface
579 or due to the implementation it is a cancellation point and
580 therefore not marked with __THROW. */
581extern char *fgets_unlocked (char *__restrict __s, int __n,
582 FILE *__restrict __stream) __wur;
583#endif
584
585
586#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
587/* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
588 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
589 NULL), pointing to *N characters of space. It is realloc'd as
590 necessary. Returns the number of characters read (not including the
591 null terminator), or -1 on error or EOF.
592
593 These functions are not part of POSIX and therefore no official
594 cancellation point. But due to similarity with an POSIX interface
595 or due to the implementation they are cancellation points and
596 therefore not marked with __THROW. */
597extern __ssize_t __getdelim (char **__restrict __lineptr,
598 size_t *__restrict __n, int __delimiter,
599 FILE *__restrict __stream) __wur;
600extern __ssize_t getdelim (char **__restrict __lineptr,
601 size_t *__restrict __n, int __delimiter,
602 FILE *__restrict __stream) __wur;
603
604/* Like `getdelim', but reads up to a newline.
605
606 This function is not part of POSIX and therefore no official
607 cancellation point. But due to similarity with an POSIX interface
608 or due to the implementation it is a cancellation point and
609 therefore not marked with __THROW. */
610extern __ssize_t getline (char **__restrict __lineptr,
611 size_t *__restrict __n,
612 FILE *__restrict __stream) __wur;
613#endif
614
615
616/* Write a string to STREAM.
617
618 This function is a possible cancellation point and therefore not
619 marked with __THROW. */
620extern int fputs (const char *__restrict __s, FILE *__restrict __stream);
621
622/* Write a string, followed by a newline, to stdout.
623
624 This function is a possible cancellation point and therefore not
625 marked with __THROW. */
626extern int puts (const char *__s);
627
628
629/* Push a character back onto the input buffer of STREAM.
630
631 This function is a possible cancellation point and therefore not
632 marked with __THROW. */
633extern int ungetc (int __c, FILE *__stream);
634
635
636/* Read chunks of generic data from STREAM.
637
638 This function is a possible cancellation point and therefore not
639 marked with __THROW. */
640extern size_t fread (void *__restrict __ptr, size_t __size,
641 size_t __n, FILE *__restrict __stream) __wur;
642/* Write chunks of generic data to STREAM.
643
644 This function is a possible cancellation point and therefore not
645 marked with __THROW. */
646extern size_t fwrite (const void *__restrict __ptr, size_t __size,
647 size_t __n, FILE *__restrict __s);
648
649#ifdef __USE_GNU
650/* This function does the same as `fputs' but does not lock the stream.
651
652 This function is not part of POSIX and therefore no official
653 cancellation point. But due to similarity with an POSIX interface
654 or due to the implementation it is a cancellation point and
655 therefore not marked with __THROW. */
656extern int fputs_unlocked (const char *__restrict __s,
657 FILE *__restrict __stream);
658#endif
659
660#ifdef __USE_MISC
661/* Faster versions when locking is not necessary.
662
663 These functions are not part of POSIX and therefore no official
664 cancellation point. But due to similarity with an POSIX interface
665 or due to the implementation they are cancellation points and
666 therefore not marked with __THROW. */
667extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
668 size_t __n, FILE *__restrict __stream) __wur;
669extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
670 size_t __n, FILE *__restrict __stream);
671#endif
672
673
674/* Seek to a certain position on STREAM.
675
676 This function is a possible cancellation point and therefore not
677 marked with __THROW. */
678extern int fseek (FILE *__stream, long int __off, int __whence);
679/* Return the current position of STREAM.
680
681 This function is a possible cancellation point and therefore not
682 marked with __THROW. */
683extern long int ftell (FILE *__stream) __wur;
684/* Rewind to the beginning of STREAM.
685
686 This function is a possible cancellation point and therefore not
687 marked with __THROW. */
688extern void rewind (FILE *__stream);
689
690/* The Single Unix Specification, Version 2, specifies an alternative,
691 more adequate interface for the two functions above which deal with
692 file offset. `long int' is not the right type. These definitions
693 are originally defined in the Large File Support API. */
694
695#if defined __USE_LARGEFILE || defined __USE_XOPEN2K
696# ifndef __USE_FILE_OFFSET64
697/* Seek to a certain position on STREAM.
698
699 This function is a possible cancellation point and therefore not
700 marked with __THROW. */
701extern int fseeko (FILE *__stream, __off_t __off, int __whence);
702/* Return the current position of STREAM.
703
704 This function is a possible cancellation point and therefore not
705 marked with __THROW. */
706extern __off_t ftello (FILE *__stream) __wur;
707# else
708# ifdef __REDIRECT
709extern int __REDIRECT (fseeko,
710 (FILE *__stream, __off64_t __off, int __whence),
711 fseeko64);
712extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
713# else
714# define fseeko fseeko64
715# define ftello ftello64
716# endif
717# endif
718#endif
719
720#ifndef __USE_FILE_OFFSET64
721/* Get STREAM's position.
722
723 This function is a possible cancellation point and therefore not
724 marked with __THROW. */
725extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
726/* Set STREAM's position.
727
728 This function is a possible cancellation point and therefore not
729 marked with __THROW. */
730extern int fsetpos (FILE *__stream, const fpos_t *__pos);
731#else
732# ifdef __REDIRECT
733extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
734 fpos_t *__restrict __pos), fgetpos64);
735extern int __REDIRECT (fsetpos,
736 (FILE *__stream, const fpos_t *__pos), fsetpos64);
737# else
738# define fgetpos fgetpos64
739# define fsetpos fsetpos64
740# endif
741#endif
742
743#ifdef __USE_LARGEFILE64
744extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
745extern __off64_t ftello64 (FILE *__stream) __wur;
746extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
747extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos);
748#endif
749
750/* Clear the error and EOF indicators for STREAM. */
751extern void clearerr (FILE *__stream) __THROW;
752/* Return the EOF indicator for STREAM. */
753extern int feof (FILE *__stream) __THROW __wur;
754/* Return the error indicator for STREAM. */
755extern int ferror (FILE *__stream) __THROW __wur;
756
757#ifdef __USE_MISC
758/* Faster versions when locking is not required. */
759extern void clearerr_unlocked (FILE *__stream) __THROW;
760extern int feof_unlocked (FILE *__stream) __THROW __wur;
761extern int ferror_unlocked (FILE *__stream) __THROW __wur;
762#endif
763
764
765/* Print a message describing the meaning of the value of errno.
766
767 This function is a possible cancellation point and therefore not
768 marked with __THROW. */
769extern void perror (const char *__s);
770
771/* Provide the declarations for `sys_errlist' and `sys_nerr' if they
772 are available on this system. Even if available, these variables
773 should not be used directly. The `strerror' function provides
774 all the necessary functionality. */
775#include <bits/sys_errlist.h>
776
777
778#ifdef __USE_POSIX
779/* Return the system file descriptor for STREAM. */
780extern int fileno (FILE *__stream) __THROW __wur;
781#endif /* Use POSIX. */
782
783#ifdef __USE_MISC
784/* Faster version when locking is not required. */
785extern int fileno_unlocked (FILE *__stream) __THROW __wur;
786#endif
787
788
789#ifdef __USE_POSIX2
790/* Create a new stream connected to a pipe running the given command.
791
792 This function is a possible cancellation point and therefore not
793 marked with __THROW. */
794extern FILE *popen (const char *__command, const char *__modes) __wur;
795
796/* Close a stream opened by popen and return the status of its child.
797
798 This function is a possible cancellation point and therefore not
799 marked with __THROW. */
800extern int pclose (FILE *__stream);
801#endif
802
803
804#ifdef __USE_POSIX
805/* Return the name of the controlling terminal. */
806extern char *ctermid (char *__s) __THROW;
807#endif /* Use POSIX. */
808
809
810#if (defined __USE_XOPEN && !defined __USE_XOPEN2K) || defined __USE_GNU
811/* Return the name of the current user. */
812extern char *cuserid (char *__s);
813#endif /* Use X/Open, but not issue 6. */
814
815
816#ifdef __USE_GNU
817struct obstack; /* See <obstack.h>. */
818
819/* Write formatted output to an obstack. */
820extern int obstack_printf (struct obstack *__restrict __obstack,
821 const char *__restrict __format, ...)
822 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3)));
823extern int obstack_vprintf (struct obstack *__restrict __obstack,
824 const char *__restrict __format,
825 __gnuc_va_list __args)
826 __THROWNL __attribute__ ((__format__ (__printf__, 2, 0)));
827#endif /* Use GNU. */
828
829
830#ifdef __USE_POSIX199506
831/* These are defined in POSIX.1:1996. */
832
833/* Acquire ownership of STREAM. */
834extern void flockfile (FILE *__stream) __THROW;
835
836/* Try to acquire ownership of STREAM but do not block if it is not
837 possible. */
838extern int ftrylockfile (FILE *__stream) __THROW __wur;
839
840/* Relinquish the ownership granted for STREAM. */
841extern void funlockfile (FILE *__stream) __THROW;
842#endif /* POSIX */
843
844#if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
845/* X/Open Issues 1-5 required getopt to be declared in this
846 header. It was removed in Issue 6. GNU follows Issue 6. */
847# include <bits/getopt_posix.h>
848#endif
849
850/* Slow-path routines used by the optimized inline functions in
851 bits/stdio.h. */
852extern int __uflow (FILE *);
853extern int __overflow (FILE *, int);
854
855/* If we are compiling with optimizing read this file. It contains
856 several optimizing inline functions and macros. */
857#ifdef __USE_EXTERN_INLINES
858# include <bits/stdio.h>
859#endif
860#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
861# include <bits/stdio2.h>
862#endif
863#ifdef __LDBL_COMPAT
864# include <bits/stdio-ldbl.h>
865#endif
866
867__END_DECLS
868
869#endif /* <stdio.h> included. */
870