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