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.
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
25#if !defined __need_FILE && !defined __need___FILE
26# define _STDIO_H 1
27# include <features.h>
28
29__BEGIN_DECLS
30
31# define __need_size_t
32# define __need_NULL
33# include <stddef.h>
34
35# include <bits/types.h>
36# define __need_FILE
37# define __need___FILE
38#endif /* Don't need FILE. */
39
40
41#if !defined __FILE_defined && defined __need_FILE
42
43/* Define outside of namespace so the C++ is happy. */
44struct _IO_FILE;
45
46__BEGIN_NAMESPACE_STD
47/* The opaque type of streams. This is the definition used elsewhere. */
48typedef struct _IO_FILE FILE;
49__END_NAMESPACE_STD
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)
54#endif
55
56# define __FILE_defined 1
57#endif /* FILE not defined. */
58#undef __need_FILE
59
60
61#if !defined ____FILE_defined && defined __need___FILE
62
63/* The opaque type of streams. This is the definition used elsewhere. */
64typedef struct _IO_FILE __FILE;
65
66# define ____FILE_defined 1
67#endif /* __FILE not defined. */
68#undef __need___FILE
69
70
71#ifdef _STDIO_H
72#define _STDIO_USES_IOSTREAM
73
74#include <libio.h>
75
76#if defined __USE_XOPEN || defined __USE_XOPEN2K8
77# ifdef __GNUC__
78# ifndef _VA_LIST_DEFINED
79typedef _G_va_list va_list;
80# define _VA_LIST_DEFINED
81# endif
82# else
83# include <stdarg.h>
84# endif
85#endif
86
87#ifdef __USE_XOPEN2K8
88# ifndef __off_t_defined
89# ifndef __USE_FILE_OFFSET64
90typedef __off_t off_t;
91# else
92typedef __off64_t off_t;
93# endif
94# define __off_t_defined
95# endif
96# if defined __USE_LARGEFILE64 && !defined __off64_t_defined
97typedef __off64_t off64_t;
98# define __off64_t_defined
99# endif
100
101# ifndef __ssize_t_defined
102typedef __ssize_t ssize_t;
103# define __ssize_t_defined
104# endif
105#endif
106
107/* The type of the second argument to `fgetpos' and `fsetpos'. */
108__BEGIN_NAMESPACE_STD
109#ifndef __USE_FILE_OFFSET64
110typedef _G_fpos_t fpos_t;
111#else
112typedef _G_fpos64_t fpos_t;
113#endif
114__END_NAMESPACE_STD
115#ifdef __USE_LARGEFILE64
116typedef _G_fpos64_t fpos64_t;
117#endif
118
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. */
123
124
125/* Default buffer size. */
126#ifndef BUFSIZ
127# define BUFSIZ _IO_BUFSIZ
128#endif
129
130
131/* End of file character.
132 Some things throughout the library rely on this being -1. */
133#ifndef EOF
134# define EOF (-1)
135#endif
136
137
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. */
143#ifdef __USE_GNU
144# define SEEK_DATA 3 /* Seek to next data. */
145# define SEEK_HOLE 4 /* Seek to next hole. */
146#endif
147
148
149#if defined __USE_SVID || defined __USE_XOPEN
150/* Default path prefix for `tempnam' and `tmpnam'. */
151# define P_tmpdir "/tmp"
152#endif
153
154
155/* Get the values:
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>
165
166
167/* Standard streams. */
168extern struct _IO_FILE *stdin; /* Standard input stream. */
169extern struct _IO_FILE *stdout; /* Standard output stream. */
170extern struct _IO_FILE *stderr; /* Standard error output stream. */
171/* C89/C99 say they're macros. Make them happy. */
172#define stdin stdin
173#define stdout stdout
174#define stderr stderr
175
176__BEGIN_NAMESPACE_STD
177/* Remove file FILENAME. */
178extern int remove (const char *__filename) __THROW;
179/* Rename file OLD to NEW. */
180extern int rename (const char *__old, const char *__new) __THROW;
181__END_NAMESPACE_STD
182
183#ifdef __USE_ATFILE
184/* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
185extern int renameat (int __oldfd, const char *__old, int __newfd,
186 const char *__new) __THROW;
187#endif
188
189__BEGIN_NAMESPACE_STD
190/* Create a temporary file and open it read/write.
191
192 This function is a possible cancellation point and therefore not
193 marked with __THROW. */
194#ifndef __USE_FILE_OFFSET64
195extern FILE *tmpfile (void) __wur;
196#else
197# ifdef __REDIRECT
198extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;
199# else
200# define tmpfile tmpfile64
201# endif
202#endif
203
204#ifdef __USE_LARGEFILE64
205extern FILE *tmpfile64 (void) __wur;
206#endif
207
208/* Generate a temporary filename. */
209extern char *tmpnam (char *__s) __THROW __wur;
210__END_NAMESPACE_STD
211
212#ifdef __USE_MISC
213/* This is the reentrant variant of `tmpnam'. The only difference is
214 that it does not allow S to be NULL. */
215extern char *tmpnam_r (char *__s) __THROW __wur;
216#endif
217
218
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'. */
227extern char *tempnam (const char *__dir, const char *__pfx)
228 __THROW __attribute_malloc__ __wur;
229#endif
230
231
232__BEGIN_NAMESPACE_STD
233/* Close STREAM.
234
235 This function is a possible cancellation point and therefore not
236 marked with __THROW. */
237extern int fclose (FILE *__stream);
238/* Flush STREAM, or all streams if STREAM is NULL.
239
240 This function is a possible cancellation point and therefore not
241 marked with __THROW. */
242extern int fflush (FILE *__stream);
243__END_NAMESPACE_STD
244
245#ifdef __USE_MISC
246/* Faster versions when locking is not required.
247
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. */
252extern int fflush_unlocked (FILE *__stream);
253#endif
254
255#ifdef __USE_GNU
256/* Close all streams.
257
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. */
262extern int fcloseall (void);
263#endif
264
265
266__BEGIN_NAMESPACE_STD
267#ifndef __USE_FILE_OFFSET64
268/* Open a file and create a new stream for it.
269
270 This function is a possible cancellation point and therefore not
271 marked with __THROW. */
272extern FILE *fopen (const char *__restrict __filename,
273 const char *__restrict __modes) __wur;
274/* Open a file, replacing an existing stream with it.
275
276 This function is a possible cancellation point and therefore not
277 marked with __THROW. */
278extern FILE *freopen (const char *__restrict __filename,
279 const char *__restrict __modes,
280 FILE *__restrict __stream) __wur;
281#else
282# ifdef __REDIRECT
283extern FILE *__REDIRECT (fopen, (const char *__restrict __filename,
284 const char *__restrict __modes), fopen64)
285 __wur;
286extern FILE *__REDIRECT (freopen, (const char *__restrict __filename,
287 const char *__restrict __modes,
288 FILE *__restrict __stream), freopen64)
289 __wur;
290# else
291# define fopen fopen64
292# define freopen freopen64
293# endif
294#endif
295__END_NAMESPACE_STD
296#ifdef __USE_LARGEFILE64
297extern FILE *fopen64 (const char *__restrict __filename,
298 const char *__restrict __modes) __wur;
299extern FILE *freopen64 (const char *__restrict __filename,
300 const char *__restrict __modes,
301 FILE *__restrict __stream) __wur;
302#endif
303
304#ifdef __USE_POSIX
305/* Create a new stream that refers to an existing system file descriptor. */
306extern FILE *fdopen (int __fd, const char *__modes) __THROW __wur;
307#endif
308
309#ifdef __USE_GNU
310/* Create a new stream that refers to the given magic cookie,
311 and uses the given functions for input and output. */
312extern FILE *fopencookie (void *__restrict __magic_cookie,
313 const char *__restrict __modes,
314 _IO_cookie_io_functions_t __io_funcs) __THROW __wur;
315#endif
316
317#ifdef __USE_XOPEN2K8
318/* Create a new stream that refers to a memory buffer. */
319extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
320 __THROW __wur;
321
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. */
325extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;
326#endif
327
328
329__BEGIN_NAMESPACE_STD
330/* If BUF is NULL, make STREAM unbuffered.
331 Else make it use buffer BUF, of size BUFSIZ. */
332extern 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. */
336extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
337 int __modes, size_t __n) __THROW;
338__END_NAMESPACE_STD
339
340#ifdef __USE_BSD
341/* If BUF is NULL, make STREAM unbuffered.
342 Else make it use SIZE bytes of BUF for buffering. */
343extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
344 size_t __size) __THROW;
345
346/* Make STREAM line-buffered. */
347extern void setlinebuf (FILE *__stream) __THROW;
348#endif
349
350
351__BEGIN_NAMESPACE_STD
352/* Write formatted output to STREAM.
353
354 This function is a possible cancellation point and therefore not
355 marked with __THROW. */
356extern int fprintf (FILE *__restrict __stream,
357 const char *__restrict __format, ...);
358/* Write formatted output to stdout.
359
360 This function is a possible cancellation point and therefore not
361 marked with __THROW. */
362extern int printf (const char *__restrict __format, ...);
363/* Write formatted output to S. */
364extern int sprintf (char *__restrict __s,
365 const char *__restrict __format, ...) __THROWNL;
366
367/* Write formatted output to S from argument list ARG.
368
369 This function is a possible cancellation point and therefore not
370 marked with __THROW. */
371extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
372 _G_va_list __arg);
373/* Write formatted output to stdout from argument list ARG.
374
375 This function is a possible cancellation point and therefore not
376 marked with __THROW. */
377extern int vprintf (const char *__restrict __format, _G_va_list __arg);
378/* Write formatted output to S from argument list ARG. */
379extern int vsprintf (char *__restrict __s, const char *__restrict __format,
380 _G_va_list __arg) __THROWNL;
381__END_NAMESPACE_STD
382
383#if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
384__BEGIN_NAMESPACE_C99
385/* Maximum chars of output to write in MAXLEN. */
386extern int snprintf (char *__restrict __s, size_t __maxlen,
387 const char *__restrict __format, ...)
388 __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));
389
390extern int vsnprintf (char *__restrict __s, size_t __maxlen,
391 const char *__restrict __format, _G_va_list __arg)
392 __THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));
393__END_NAMESPACE_C99
394#endif
395
396#ifdef __USE_GNU
397/* Write formatted output to a string dynamically allocated with `malloc'.
398 Store the address of the string in *PTR. */
399extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,
400 _G_va_list __arg)
401 __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
402extern int __asprintf (char **__restrict __ptr,
403 const char *__restrict __fmt, ...)
404 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
405extern int asprintf (char **__restrict __ptr,
406 const char *__restrict __fmt, ...)
407 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
408#endif
409
410#ifdef __USE_XOPEN2K8
411/* Write formatted output to a file descriptor. */
412extern int vdprintf (int __fd, const char *__restrict __fmt,
413 _G_va_list __arg)
414 __attribute__ ((__format__ (__printf__, 2, 0)));
415extern int dprintf (int __fd, const char *__restrict __fmt, ...)
416 __attribute__ ((__format__ (__printf__, 2, 3)));
417#endif
418
419
420__BEGIN_NAMESPACE_STD
421/* Read formatted input from STREAM.
422
423 This function is a possible cancellation point and therefore not
424 marked with __THROW. */
425extern int fscanf (FILE *__restrict __stream,
426 const char *__restrict __format, ...) __wur;
427/* Read formatted input from stdin.
428
429 This function is a possible cancellation point and therefore not
430 marked with __THROW. */
431extern int scanf (const char *__restrict __format, ...) __wur;
432/* Read formatted input from S. */
433extern int sscanf (const char *__restrict __s,
434 const char *__restrict __format, ...) __THROW;
435
436#if defined __USE_ISOC99 && !defined __USE_GNU \
437 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
438 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
439# ifdef __REDIRECT
440/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
441 GNU extension which conflicts with valid %a followed by letter
442 s, S or [. */
443extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
444 const char *__restrict __format, ...),
445 __isoc99_fscanf) __wur;
446extern int __REDIRECT (scanf, (const char *__restrict __format, ...),
447 __isoc99_scanf) __wur;
448extern int __REDIRECT_NTH (sscanf, (const char *__restrict __s,
449 const char *__restrict __format, ...),
450 __isoc99_sscanf);
451# else
452extern int __isoc99_fscanf (FILE *__restrict __stream,
453 const char *__restrict __format, ...) __wur;
454extern int __isoc99_scanf (const char *__restrict __format, ...) __wur;
455extern 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
460# endif
461#endif
462
463__END_NAMESPACE_STD
464
465#ifdef __USE_ISOC99
466__BEGIN_NAMESPACE_C99
467/* Read formatted input from S into argument list ARG.
468
469 This function is a possible cancellation point and therefore not
470 marked with __THROW. */
471extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
472 _G_va_list __arg)
473 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
474
475/* Read formatted input from stdin into argument list ARG.
476
477 This function is a possible cancellation point and therefore not
478 marked with __THROW. */
479extern int vscanf (const char *__restrict __format, _G_va_list __arg)
480 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
481
482/* Read formatted input from S into argument list ARG. */
483extern int vsscanf (const char *__restrict __s,
484 const char *__restrict __format, _G_va_list __arg)
485 __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
486
487# if !defined __USE_GNU \
488 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
489 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
490# ifdef __REDIRECT
491/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
492 GNU extension which conflicts with valid %a followed by letter
493 s, S or [. */
494extern int __REDIRECT (vfscanf,
495 (FILE *__restrict __s,
496 const char *__restrict __format, _G_va_list __arg),
497 __isoc99_vfscanf)
498 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
499extern int __REDIRECT (vscanf, (const char *__restrict __format,
500 _G_va_list __arg), __isoc99_vscanf)
501 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
502extern 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)));
507# else
508extern int __isoc99_vfscanf (FILE *__restrict __s,
509 const char *__restrict __format,
510 _G_va_list __arg) __wur;
511extern int __isoc99_vscanf (const char *__restrict __format,
512 _G_va_list __arg) __wur;
513extern 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
519# endif
520# endif
521
522__END_NAMESPACE_C99
523#endif /* Use ISO C9x. */
524
525
526__BEGIN_NAMESPACE_STD
527/* Read a character from STREAM.
528
529 These functions are possible cancellation points and therefore not
530 marked with __THROW. */
531extern int fgetc (FILE *__stream);
532extern int getc (FILE *__stream);
533
534/* Read a character from stdin.
535
536 This function is a possible cancellation point and therefore not
537 marked with __THROW. */
538extern int getchar (void);
539__END_NAMESPACE_STD
540
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)
544
545#if defined __USE_POSIX || defined __USE_MISC
546/* These are defined in POSIX.1:1996.
547
548 These functions are possible cancellation points and therefore not
549 marked with __THROW. */
550extern int getc_unlocked (FILE *__stream);
551extern int getchar_unlocked (void);
552#endif /* Use POSIX or MISC. */
553
554#ifdef __USE_MISC
555/* Faster version when locking is not necessary.
556
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. */
561extern int fgetc_unlocked (FILE *__stream);
562#endif /* Use MISC. */
563
564
565__BEGIN_NAMESPACE_STD
566/* Write a character to STREAM.
567
568 These functions are possible cancellation points and therefore not
569 marked with __THROW.
570
571 These functions is a possible cancellation point and therefore not
572 marked with __THROW. */
573extern int fputc (int __c, FILE *__stream);
574extern int putc (int __c, FILE *__stream);
575
576/* Write a character to stdout.
577
578 This function is a possible cancellation point and therefore not
579 marked with __THROW. */
580extern int putchar (int __c);
581__END_NAMESPACE_STD
582
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)
586
587#ifdef __USE_MISC
588/* Faster version when locking is not necessary.
589
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. */
594extern int fputc_unlocked (int __c, FILE *__stream);
595#endif /* Use MISC. */
596
597#if defined __USE_POSIX || defined __USE_MISC
598/* These are defined in POSIX.1:1996.
599
600 These functions are possible cancellation points and therefore not
601 marked with __THROW. */
602extern int putc_unlocked (int __c, FILE *__stream);
603extern int putchar_unlocked (int __c);
604#endif /* Use POSIX or MISC. */
605
606
607#if defined __USE_SVID || defined __USE_MISC \
608 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
609/* Get a word (int) from STREAM. */
610extern int getw (FILE *__stream);
611
612/* Write a word (int) to STREAM. */
613extern int putw (int __w, FILE *__stream);
614#endif
615
616
617__BEGIN_NAMESPACE_STD
618/* Get a newline-terminated string of finite length from STREAM.
619
620 This function is a possible cancellation point and therefore not
621 marked with __THROW. */
622extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
623 __wur;
624
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.
629
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++.
635
636 This function is a possible cancellation point and therefore not
637 marked with __THROW. */
638extern char *gets (char *__s) __wur __attribute_deprecated__;
639#endif
640__END_NAMESPACE_STD
641
642#ifdef __USE_GNU
643/* This function does the same as `fgets' but does not lock the stream.
644
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. */
649extern char *fgets_unlocked (char *__restrict __s, int __n,
650 FILE *__restrict __stream) __wur;
651#endif
652
653
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.
660
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. */
665extern _IO_ssize_t __getdelim (char **__restrict __lineptr,
666 size_t *__restrict __n, int __delimiter,
667 FILE *__restrict __stream) __wur;
668extern _IO_ssize_t getdelim (char **__restrict __lineptr,
669 size_t *__restrict __n, int __delimiter,
670 FILE *__restrict __stream) __wur;
671
672/* Like `getdelim', but reads up to a newline.
673
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. */
678extern _IO_ssize_t getline (char **__restrict __lineptr,
679 size_t *__restrict __n,
680 FILE *__restrict __stream) __wur;
681#endif
682
683
684__BEGIN_NAMESPACE_STD
685/* Write a string to STREAM.
686
687 This function is a possible cancellation point and therefore not
688 marked with __THROW. */
689extern int fputs (const char *__restrict __s, FILE *__restrict __stream);
690
691/* Write a string, followed by a newline, to stdout.
692
693 This function is a possible cancellation point and therefore not
694 marked with __THROW. */
695extern int puts (const char *__s);
696
697
698/* Push a character back onto the input buffer of STREAM.
699
700 This function is a possible cancellation point and therefore not
701 marked with __THROW. */
702extern int ungetc (int __c, FILE *__stream);
703
704
705/* Read chunks of generic data from STREAM.
706
707 This function is a possible cancellation point and therefore not
708 marked with __THROW. */
709extern 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.
712
713 This function is a possible cancellation point and therefore not
714 marked with __THROW. */
715extern size_t fwrite (const void *__restrict __ptr, size_t __size,
716 size_t __n, FILE *__restrict __s);
717__END_NAMESPACE_STD
718
719#ifdef __USE_GNU
720/* This function does the same as `fputs' but does not lock the stream.
721
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. */
726extern int fputs_unlocked (const char *__restrict __s,
727 FILE *__restrict __stream);
728#endif
729
730#ifdef __USE_MISC
731/* Faster versions when locking is not necessary.
732
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. */
737extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
738 size_t __n, FILE *__restrict __stream) __wur;
739extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
740 size_t __n, FILE *__restrict __stream);
741#endif
742
743
744__BEGIN_NAMESPACE_STD
745/* Seek to a certain position on STREAM.
746
747 This function is a possible cancellation point and therefore not
748 marked with __THROW. */
749extern int fseek (FILE *__stream, long int __off, int __whence);
750/* Return the current position of STREAM.
751
752 This function is a possible cancellation point and therefore not
753 marked with __THROW. */
754extern long int ftell (FILE *__stream) __wur;
755/* Rewind to the beginning of STREAM.
756
757 This function is a possible cancellation point and therefore not
758 marked with __THROW. */
759extern void rewind (FILE *__stream);
760__END_NAMESPACE_STD
761
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. */
766
767#if defined __USE_LARGEFILE || defined __USE_XOPEN2K
768# ifndef __USE_FILE_OFFSET64
769/* Seek to a certain position on STREAM.
770
771 This function is a possible cancellation point and therefore not
772 marked with __THROW. */
773extern int fseeko (FILE *__stream, __off_t __off, int __whence);
774/* Return the current position of STREAM.
775
776 This function is a possible cancellation point and therefore not
777 marked with __THROW. */
778extern __off_t ftello (FILE *__stream) __wur;
779# else
780# ifdef __REDIRECT
781extern int __REDIRECT (fseeko,
782 (FILE *__stream, __off64_t __off, int __whence),
783 fseeko64);
784extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
785# else
786# define fseeko fseeko64
787# define ftello ftello64
788# endif
789# endif
790#endif
791
792__BEGIN_NAMESPACE_STD
793#ifndef __USE_FILE_OFFSET64
794/* Get STREAM's position.
795
796 This function is a possible cancellation point and therefore not
797 marked with __THROW. */
798extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
799/* Set STREAM's position.
800
801 This function is a possible cancellation point and therefore not
802 marked with __THROW. */
803extern int fsetpos (FILE *__stream, const fpos_t *__pos);
804#else
805# ifdef __REDIRECT
806extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
807 fpos_t *__restrict __pos), fgetpos64);
808extern int __REDIRECT (fsetpos,
809 (FILE *__stream, const fpos_t *__pos), fsetpos64);
810# else
811# define fgetpos fgetpos64
812# define fsetpos fsetpos64
813# endif
814#endif
815__END_NAMESPACE_STD
816
817#ifdef __USE_LARGEFILE64
818extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
819extern __off64_t ftello64 (FILE *__stream) __wur;
820extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
821extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos);
822#endif
823
824__BEGIN_NAMESPACE_STD
825/* Clear the error and EOF indicators for STREAM. */
826extern void clearerr (FILE *__stream) __THROW;
827/* Return the EOF indicator for STREAM. */
828extern int feof (FILE *__stream) __THROW __wur;
829/* Return the error indicator for STREAM. */
830extern int ferror (FILE *__stream) __THROW __wur;
831__END_NAMESPACE_STD
832
833#ifdef __USE_MISC
834/* Faster versions when locking is not required. */
835extern void clearerr_unlocked (FILE *__stream) __THROW;
836extern int feof_unlocked (FILE *__stream) __THROW __wur;
837extern int ferror_unlocked (FILE *__stream) __THROW __wur;
838#endif
839
840
841__BEGIN_NAMESPACE_STD
842/* Print a message describing the meaning of the value of errno.
843
844 This function is a possible cancellation point and therefore not
845 marked with __THROW. */
846extern void perror (const char *__s);
847__END_NAMESPACE_STD
848
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>
854
855
856#ifdef __USE_POSIX
857/* Return the system file descriptor for STREAM. */
858extern int fileno (FILE *__stream) __THROW __wur;
859#endif /* Use POSIX. */
860
861#ifdef __USE_MISC
862/* Faster version when locking is not required. */
863extern int fileno_unlocked (FILE *__stream) __THROW __wur;
864#endif
865
866
867#if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
868 defined __USE_MISC)
869/* Create a new stream connected to a pipe running the given command.
870
871 This function is a possible cancellation point and therefore not
872 marked with __THROW. */
873extern FILE *popen (const char *__command, const char *__modes) __wur;
874
875/* Close a stream opened by popen and return the status of its child.
876
877 This function is a possible cancellation point and therefore not
878 marked with __THROW. */
879extern int pclose (FILE *__stream);
880#endif
881
882
883#ifdef __USE_POSIX
884/* Return the name of the controlling terminal. */
885extern char *ctermid (char *__s) __THROW;
886#endif /* Use POSIX. */
887
888
889#ifdef __USE_XOPEN
890/* Return the name of the current user. */
891extern char *cuserid (char *__s);
892#endif /* Use X/Open, but not issue 6. */
893
894
895#ifdef __USE_GNU
896struct obstack; /* See <obstack.h>. */
897
898/* Write formatted output to an obstack. */
899extern int obstack_printf (struct obstack *__restrict __obstack,
900 const char *__restrict __format, ...)
901 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3)));
902extern int obstack_vprintf (struct obstack *__restrict __obstack,
903 const char *__restrict __format,
904 _G_va_list __args)
905 __THROWNL __attribute__ ((__format__ (__printf__, 2, 0)));
906#endif /* Use GNU. */
907
908
909#if defined __USE_POSIX || defined __USE_MISC
910/* These are defined in POSIX.1:1996. */
911
912/* Acquire ownership of STREAM. */
913extern void flockfile (FILE *__stream) __THROW;
914
915/* Try to acquire ownership of STREAM but do not block if it is not
916 possible. */
917extern int ftrylockfile (FILE *__stream) __THROW __wur;
918
919/* Relinquish the ownership granted for STREAM. */
920extern void funlockfile (FILE *__stream) __THROW;
921#endif /* POSIX || misc */
922
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
928# include <getopt.h>
929#endif /* X/Open, but not issue 6 and not for GNU. */
930
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>
935#endif
936#if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
937# include <bits/stdio2.h>
938#endif
939#ifdef __LDBL_COMPAT
940# include <bits/stdio-ldbl.h>
941#endif
942
943__END_DECLS
944
945#endif /* <stdio.h> included. */
946
947#endif /* !_STDIO_H */
948