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