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