]> sourceware.org Git - glibc.git/blame - libio/stdio.h
Link tst-clock_gettime with $(librt)
[glibc.git] / libio / stdio.h
CommitLineData
2f6d1f1b 1/* Define ISO C stdio on top of C++ iostreams.
dff8da6b 2 Copyright (C) 1991-2024 Free Software Foundation, Inc.
64b1a441 3 Copyright The GNU Toolchain Authors.
41bdb6e2 4 This file is part of the GNU C Library.
96aa2d94 5
2f6d1f1b 6 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
96aa2d94 10
2f6d1f1b
UD
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 14 Lesser General Public License for more details.
96aa2d94 15
41bdb6e2 16 You should have received a copy of the GNU Lesser General Public
59ba27a6 17 License along with the GNU C Library; if not, see
5a82c748 18 <https://www.gnu.org/licenses/>. */
96aa2d94
RM
19
20/*
d1646309 21 * ISO C99 Standard: 7.19 Input/output <stdio.h>
96aa2d94
RM
22 */
23
24#ifndef _STDIO_H
199fc19d 25#define _STDIO_H 1
2f6d1f1b 26
199fc19d
ZW
27#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
28#include <bits/libc-header-start.h>
2f6d1f1b
UD
29
30__BEGIN_DECLS
31
199fc19d
ZW
32#define __need_size_t
33#define __need_NULL
34#include <stddef.h>
2f6d1f1b 35
a4fea3f2
ZW
36#define __need___va_list
37#include <stdarg.h>
38
199fc19d 39#include <bits/types.h>
a4fea3f2
ZW
40#include <bits/types/__fpos_t.h>
41#include <bits/types/__fpos64_t.h>
199fc19d
ZW
42#include <bits/types/__FILE.h>
43#include <bits/types/FILE.h>
a4fea3f2 44#include <bits/types/struct_FILE.h>
2f6d1f1b 45
0d5cb2ae 46#ifdef __USE_MISC
a4fea3f2
ZW
47# include <bits/types/cookie_io_functions_t.h>
48#endif
96aa2d94 49
cd2f000c 50#if defined __USE_XOPEN || defined __USE_XOPEN2K8
3bf3d361
UD
51# ifdef __GNUC__
52# ifndef _VA_LIST_DEFINED
a4fea3f2 53typedef __gnuc_va_list va_list;
3bf3d361
UD
54# define _VA_LIST_DEFINED
55# endif
56# else
57# include <stdarg.h>
58# endif
59#endif
60
10b8108a 61#if defined __USE_UNIX98 || defined __USE_XOPEN2K
cd2f000c
UD
62# ifndef __off_t_defined
63# ifndef __USE_FILE_OFFSET64
64typedef __off_t off_t;
65# else
66typedef __off64_t off_t;
67# endif
68# define __off_t_defined
69# endif
70# if defined __USE_LARGEFILE64 && !defined __off64_t_defined
71typedef __off64_t off64_t;
72# define __off64_t_defined
73# endif
bf074726 74#endif
cd2f000c 75
bf074726 76#ifdef __USE_XOPEN2K8
cd2f000c
UD
77# ifndef __ssize_t_defined
78typedef __ssize_t ssize_t;
79# define __ssize_t_defined
80# endif
81#endif
82
2f6d1f1b 83/* The type of the second argument to `fgetpos' and `fsetpos'. */
dfd2257a 84#ifndef __USE_FILE_OFFSET64
a4fea3f2 85typedef __fpos_t fpos_t;
dfd2257a 86#else
a4fea3f2 87typedef __fpos64_t fpos_t;
dfd2257a
UD
88#endif
89#ifdef __USE_LARGEFILE64
a4fea3f2 90typedef __fpos64_t fpos64_t;
dfd2257a 91#endif
2f6d1f1b 92
2f6d1f1b 93/* The possibilities for the third argument to `setvbuf'. */
798be72d 94#define _IOFBF 0 /* Fully buffered. */
2f6d1f1b
UD
95#define _IOLBF 1 /* Line buffered. */
96#define _IONBF 2 /* No buffering. */
97
98
99/* Default buffer size. */
a4fea3f2 100#define BUFSIZ 8192
96aa2d94 101
2f6d1f1b 102
a4fea3f2
ZW
103/* The value returned by fgetc and similar functions to indicate the
104 end of the file. */
105#define EOF (-1)
96aa2d94 106
96aa2d94 107
2f6d1f1b
UD
108/* The possibilities for the third argument to `fseek'.
109 These values should not be changed. */
110#define SEEK_SET 0 /* Seek from beginning of file. */
111#define SEEK_CUR 1 /* Seek from current position. */
112#define SEEK_END 2 /* Seek from end of file. */
798be72d
UD
113#ifdef __USE_GNU
114# define SEEK_DATA 3 /* Seek to next data. */
115# define SEEK_HOLE 4 /* Seek to next hole. */
116#endif
2f6d1f1b 117
96aa2d94 118
498afc54 119#if defined __USE_MISC || defined __USE_XOPEN
f65fd747 120/* Default path prefix for `tempnam' and `tmpnam'. */
dfd2257a 121# define P_tmpdir "/tmp"
f65fd747 122#endif
96aa2d94 123
f65ca70d
AZN
124#define L_tmpnam 20
125#define TMP_MAX 238328
96aa2d94 126
2f6d1f1b 127/* Get the values:
2f6d1f1b 128 FILENAME_MAX Maximum length of a filename. */
5107cf1d 129#include <bits/stdio_lim.h>
2f6d1f1b 130
f65ca70d
AZN
131#ifdef __USE_POSIX
132# define L_ctermid 9
133# if !defined __USE_XOPEN2K || defined __USE_GNU
134# define L_cuserid 9
135# endif
136#endif
137
138#undef FOPEN_MAX
139#define FOPEN_MAX 16
140
2f6d1f1b 141
42cc619d 142#if __GLIBC_USE (ISOC23)
01d34e93
JM
143/* Maximum length of printf output for a NaN. */
144# define _PRINTF_NAN_LEN_MAX 4
145#endif
146
147
2f6d1f1b 148/* Standard streams. */
a4fea3f2
ZW
149extern FILE *stdin; /* Standard input stream. */
150extern FILE *stdout; /* Standard output stream. */
151extern FILE *stderr; /* Standard error output stream. */
63ae7b63 152/* C89/C99 say they're macros. Make them happy. */
7df789e0
UD
153#define stdin stdin
154#define stdout stdout
155#define stderr stderr
96aa2d94 156
2f6d1f1b 157/* Remove file FILENAME. */
a784e502 158extern int remove (const char *__filename) __THROW;
2f6d1f1b 159/* Rename file OLD to NEW. */
a784e502 160extern int rename (const char *__old, const char *__new) __THROW;
2f6d1f1b 161
0b8f25bb 162#ifdef __USE_ATFILE
26cec518 163/* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
a784e502
UD
164extern int renameat (int __oldfd, const char *__old, int __newfd,
165 const char *__new) __THROW;
26cec518 166#endif
2f6d1f1b 167
d6da5cb6
FW
168#ifdef __USE_GNU
169/* Flags for renameat2. */
170# define RENAME_NOREPLACE (1 << 0)
171# define RENAME_EXCHANGE (1 << 1)
172# define RENAME_WHITEOUT (1 << 2)
173
174/* Rename file OLD relative to OLDFD to NEW relative to NEWFD, with
175 additional flags. */
176extern int renameat2 (int __oldfd, const char *__old, int __newfd,
177 const char *__new, unsigned int __flags) __THROW;
178#endif
179
c1760eaf
MS
180/* Close STREAM.
181
182 This function is a possible cancellation point and therefore not
183 marked with __THROW. */
71d9e0fe 184extern int fclose (FILE *__stream) __nonnull ((1));
c1760eaf
MS
185
186#undef __attr_dealloc_fclose
187#define __attr_dealloc_fclose __attr_dealloc (fclose, 1)
188
2c008571
UD
189/* Create a temporary file and open it read/write.
190
4c1423ed 191 This function is a possible cancellation point and therefore not
2c008571 192 marked with __THROW. */
dfd2257a 193#ifndef __USE_FILE_OFFSET64
c1760eaf
MS
194extern FILE *tmpfile (void)
195 __attribute_malloc__ __attr_dealloc_fclose __wur;
dfd2257a 196#else
01cad722 197# ifdef __REDIRECT
c1760eaf
MS
198extern FILE *__REDIRECT (tmpfile, (void), tmpfile64)
199 __attribute_malloc__ __attr_dealloc_fclose __wur;
01cad722
UD
200# else
201# define tmpfile tmpfile64
202# endif
dfd2257a 203#endif
7a5affeb 204
2c008571 205#ifdef __USE_LARGEFILE64
c1760eaf
MS
206extern FILE *tmpfile64 (void)
207 __attribute_malloc__ __attr_dealloc_fclose __wur;
2c008571
UD
208#endif
209
7a5affeb 210/* Generate a temporary filename. */
26492c0a 211extern char *tmpnam (char[L_tmpnam]) __THROW __wur;
7a5affeb 212
2f6d1f1b
UD
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. */
26492c0a 216extern char *tmpnam_r (char __s[L_tmpnam]) __THROW __wur;
d68171ed 217#endif
2f6d1f1b
UD
218
219
498afc54 220#if defined __USE_MISC || defined __USE_XOPEN
2f6d1f1b
UD
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'. */
a784e502 228extern char *tempnam (const char *__dir, const char *__pfx)
c1760eaf 229 __THROW __attribute_malloc__ __wur __attr_dealloc_free;
2cc7dc4d 230#endif
96aa2d94 231
2c008571
UD
232/* Flush STREAM, or all streams if STREAM is NULL.
233
234 This function is a possible cancellation point and therefore not
235 marked with __THROW. */
236extern int fflush (FILE *__stream);
2f6d1f1b
UD
237
238#ifdef __USE_MISC
2c008571
UD
239/* Faster versions when locking is not required.
240
241 This function is not part of POSIX and therefore no official
242 cancellation point. But due to similarity with an POSIX interface
243 or due to the implementation it is a cancellation point and
244 therefore not marked with __THROW. */
245extern int fflush_unlocked (FILE *__stream);
96aa2d94
RM
246#endif
247
2c6fe0bd 248#ifdef __USE_GNU
2c008571
UD
249/* Close all streams.
250
251 This function is not part of POSIX and therefore no official
252 cancellation point. But due to similarity with an POSIX interface
253 or due to the implementation it is a cancellation point and
254 therefore not marked with __THROW. */
255extern int fcloseall (void);
2c6fe0bd
UD
256#endif
257
76060ec0 258
dfd2257a 259#ifndef __USE_FILE_OFFSET64
2c008571
UD
260/* Open a file and create a new stream for it.
261
262 This function is a possible cancellation point and therefore not
263 marked with __THROW. */
a784e502 264extern FILE *fopen (const char *__restrict __filename,
c1760eaf
MS
265 const char *__restrict __modes)
266 __attribute_malloc__ __attr_dealloc_fclose __wur;
2c008571
UD
267/* Open a file, replacing an existing stream with it.
268
269 This function is a possible cancellation point and therefore not
270 marked with __THROW. */
a784e502
UD
271extern FILE *freopen (const char *__restrict __filename,
272 const char *__restrict __modes,
71d9e0fe 273 FILE *__restrict __stream) __wur __nonnull ((3));
dfd2257a 274#else
01cad722 275# ifdef __REDIRECT
a784e502
UD
276extern FILE *__REDIRECT (fopen, (const char *__restrict __filename,
277 const char *__restrict __modes), fopen64)
c1760eaf 278 __attribute_malloc__ __attr_dealloc_fclose __wur;
a784e502
UD
279extern FILE *__REDIRECT (freopen, (const char *__restrict __filename,
280 const char *__restrict __modes,
11bf311e 281 FILE *__restrict __stream), freopen64)
64b1a441 282 __wur __nonnull ((3));
01cad722
UD
283# else
284# define fopen fopen64
285# define freopen freopen64
286# endif
dfd2257a
UD
287#endif
288#ifdef __USE_LARGEFILE64
a784e502 289extern FILE *fopen64 (const char *__restrict __filename,
c1760eaf
MS
290 const char *__restrict __modes)
291 __attribute_malloc__ __attr_dealloc_fclose __wur;
a784e502
UD
292extern FILE *freopen64 (const char *__restrict __filename,
293 const char *__restrict __modes,
71d9e0fe 294 FILE *__restrict __stream) __wur __nonnull ((3));
dfd2257a 295#endif
76060ec0 296
2f6d1f1b
UD
297#ifdef __USE_POSIX
298/* Create a new stream that refers to an existing system file descriptor. */
c1760eaf
MS
299extern FILE *fdopen (int __fd, const char *__modes) __THROW
300 __attribute_malloc__ __attr_dealloc_fclose __wur;
96aa2d94
RM
301#endif
302
0d5cb2ae 303#ifdef __USE_MISC
2f6d1f1b
UD
304/* Create a new stream that refers to the given magic cookie,
305 and uses the given functions for input and output. */
c1422e5b 306extern FILE *fopencookie (void *__restrict __magic_cookie,
a784e502 307 const char *__restrict __modes,
c1760eaf
MS
308 cookie_io_functions_t __io_funcs) __THROW
309 __attribute_malloc__ __attr_dealloc_fclose __wur;
f503060b 310#endif
7a12c6bb 311
48789000 312#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
46e4bd3b 313/* Create a new stream that refers to a memory buffer. */
a784e502 314extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
c1760eaf 315 __THROW __attribute_malloc__ __attr_dealloc_fclose __wur;
46e4bd3b 316
96aa2d94
RM
317/* Open a stream that writes into a malloc'd buffer that is expanded as
318 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
319 and the number of characters written on fflush or fclose. */
c1760eaf
MS
320extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW
321 __attribute_malloc__ __attr_dealloc_fclose __wur;
322
323#ifdef _WCHAR_H
324/* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces
325 a wide character string. Declared here only to add attribute malloc
326 and only if <wchar.h> has been previously #included. */
327extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW
328 __attribute_malloc__ __attr_dealloc_fclose;
329# endif
96aa2d94
RM
330#endif
331
2f6d1f1b
UD
332/* If BUF is NULL, make STREAM unbuffered.
333 Else make it use buffer BUF, of size BUFSIZ. */
64b1a441
XR
334extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW
335 __nonnull ((1));
2f6d1f1b
UD
336/* Make STREAM use buffering mode MODE.
337 If BUF is not NULL, use N bytes of it for buffering;
338 else allocate an internal buffer N bytes long. */
c1422e5b 339extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
64b1a441 340 int __modes, size_t __n) __THROW __nonnull ((1));
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 345extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
64b1a441 346 size_t __size) __THROW __nonnull ((1));
2f6d1f1b
UD
347
348/* Make STREAM line-buffered. */
64b1a441 349extern void setlinebuf (FILE *__stream) __THROW __nonnull ((1));
96aa2d94
RM
350#endif
351
2f6d1f1b 352
2c008571
UD
353/* Write formatted output to STREAM.
354
355 This function is a possible cancellation point and therefore not
356 marked with __THROW. */
c1422e5b 357extern int fprintf (FILE *__restrict __stream,
64b1a441 358 const char *__restrict __format, ...) __nonnull ((1));
2c008571
UD
359/* Write formatted output to stdout.
360
361 This function is a possible cancellation point and therefore not
362 marked with __THROW. */
a784e502 363extern int printf (const char *__restrict __format, ...);
2f6d1f1b 364/* Write formatted output to S. */
c1422e5b 365extern int sprintf (char *__restrict __s,
a784e502 366 const char *__restrict __format, ...) __THROWNL;
2f6d1f1b 367
2c008571
UD
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. */
a784e502 372extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
64b1a441 373 __gnuc_va_list __arg) __nonnull ((1));
2c008571
UD
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. */
a4fea3f2 378extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);
2f6d1f1b 379/* Write formatted output to S from argument list ARG. */
a784e502 380extern int vsprintf (char *__restrict __s, const char *__restrict __format,
a4fea3f2 381 __gnuc_va_list __arg) __THROWNL;
2f6d1f1b 382
acd7f096 383#if defined __USE_ISOC99 || defined __USE_UNIX98
2f6d1f1b 384/* Maximum chars of output to write in MAXLEN. */
c1422e5b 385extern int snprintf (char *__restrict __s, size_t __maxlen,
a784e502 386 const char *__restrict __format, ...)
9beb2334 387 __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));
f41c8091 388
c1422e5b 389extern int vsnprintf (char *__restrict __s, size_t __maxlen,
a4fea3f2 390 const char *__restrict __format, __gnuc_va_list __arg)
9beb2334 391 __THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));
907a1bac 392#endif
2f6d1f1b 393
0d5cb2ae 394#if defined (__USE_MISC) || __GLIBC_USE (LIB_EXT2)
2f6d1f1b
UD
395/* Write formatted output to a string dynamically allocated with `malloc'.
396 Store the address of the string in *PTR. */
a784e502 397extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,
a4fea3f2 398 __gnuc_va_list __arg)
9beb2334 399 __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
c1422e5b 400extern int __asprintf (char **__restrict __ptr,
a784e502 401 const char *__restrict __fmt, ...)
9beb2334 402 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
c1422e5b 403extern int asprintf (char **__restrict __ptr,
a784e502 404 const char *__restrict __fmt, ...)
9beb2334 405 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
f503060b 406#endif
2f6d1f1b 407
f503060b 408#ifdef __USE_XOPEN2K8
36c8acb4 409/* Write formatted output to a file descriptor. */
a784e502 410extern int vdprintf (int __fd, const char *__restrict __fmt,
a4fea3f2 411 __gnuc_va_list __arg)
2c008571 412 __attribute__ ((__format__ (__printf__, 2, 0)));
a784e502 413extern int dprintf (int __fd, const char *__restrict __fmt, ...)
2c008571 414 __attribute__ ((__format__ (__printf__, 2, 3)));
19361cb7 415#endif
7c713e28 416
2f6d1f1b 417
2c008571
UD
418/* Read formatted input from STREAM.
419
420 This function is a possible cancellation point and therefore not
421 marked with __THROW. */
c1422e5b 422extern int fscanf (FILE *__restrict __stream,
64b1a441 423 const char *__restrict __format, ...) __wur __nonnull ((1));
2c008571
UD
424/* Read formatted input from stdin.
425
426 This function is a possible cancellation point and therefore not
427 marked with __THROW. */
a784e502 428extern int scanf (const char *__restrict __format, ...) __wur;
2f6d1f1b 429/* Read formatted input from S. */
a784e502
UD
430extern int sscanf (const char *__restrict __s,
431 const char *__restrict __format, ...) __THROW;
874aa523 432
03992356 433/* For historical reasons, the C99-compliant versions of the scanf
e4a39992 434 functions are at alternative names. When __LDBL_COMPAT or
e2239af3 435 __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI are in effect, this is handled in
e4a39992
GG
436 bits/stdio-ldbl.h. */
437#include <bits/floatn.h>
438#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \
e2239af3 439 && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
42cc619d 440# if __GLIBC_USE (C23_STRTOL)
dee2bea0
JM
441# ifdef __REDIRECT
442extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
443 const char *__restrict __format, ...),
64b1a441 444 __isoc23_fscanf) __wur __nonnull ((1));
dee2bea0
JM
445extern int __REDIRECT (scanf, (const char *__restrict __format, ...),
446 __isoc23_scanf) __wur;
447extern int __REDIRECT_NTH (sscanf, (const char *__restrict __s,
448 const char *__restrict __format, ...),
449 __isoc23_sscanf);
450# else
451extern int __isoc23_fscanf (FILE *__restrict __stream,
64b1a441
XR
452 const char *__restrict __format, ...) __wur
453 __nonnull ((1));
dee2bea0
JM
454extern int __isoc23_scanf (const char *__restrict __format, ...) __wur;
455extern int __isoc23_sscanf (const char *__restrict __s,
456 const char *__restrict __format, ...) __THROW;
457# define fscanf __isoc23_fscanf
458# define scanf __isoc23_scanf
459# define sscanf __isoc23_sscanf
460# endif
461# else
462# ifdef __REDIRECT
874aa523 463extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
a784e502 464 const char *__restrict __format, ...),
64b1a441 465 __isoc99_fscanf) __wur __nonnull ((1));
a784e502 466extern int __REDIRECT (scanf, (const char *__restrict __format, ...),
874aa523 467 __isoc99_scanf) __wur;
a784e502
UD
468extern int __REDIRECT_NTH (sscanf, (const char *__restrict __s,
469 const char *__restrict __format, ...),
f32f2869 470 __isoc99_sscanf);
dee2bea0 471# else
874aa523 472extern int __isoc99_fscanf (FILE *__restrict __stream,
64b1a441
XR
473 const char *__restrict __format, ...) __wur
474 __nonnull ((1));
a784e502
UD
475extern int __isoc99_scanf (const char *__restrict __format, ...) __wur;
476extern int __isoc99_sscanf (const char *__restrict __s,
477 const char *__restrict __format, ...) __THROW;
dee2bea0
JM
478# define fscanf __isoc99_fscanf
479# define scanf __isoc99_scanf
480# define sscanf __isoc99_sscanf
481# endif
874aa523
UD
482# endif
483#endif
484
ec751a23 485#ifdef __USE_ISOC99
2c008571
UD
486/* Read formatted input from S into argument list ARG.
487
488 This function is a possible cancellation point and therefore not
489 marked with __THROW. */
a784e502 490extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
a4fea3f2 491 __gnuc_va_list __arg)
64b1a441 492 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur __nonnull ((1));
2c008571
UD
493
494/* Read formatted input from stdin into argument list ARG.
2f6d1f1b 495
2c008571
UD
496 This function is a possible cancellation point and therefore not
497 marked with __THROW. */
a4fea3f2 498extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)
0476597b 499 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
2f6d1f1b
UD
500
501/* Read formatted input from S into argument list ARG. */
a784e502 502extern int vsscanf (const char *__restrict __s,
a4fea3f2 503 const char *__restrict __format, __gnuc_va_list __arg)
7d506e8e 504 __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
874aa523 505
03992356
ZW
506/* Same redirection as above for the v*scanf family. */
507# if !__GLIBC_USE (DEPRECATED_SCANF)
42cc619d 508# if __GLIBC_USE (C23_STRTOL)
dee2bea0
JM
509# if defined __REDIRECT && !defined __LDBL_COMPAT \
510 && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
511extern int __REDIRECT (vfscanf,
512 (FILE *__restrict __s,
513 const char *__restrict __format, __gnuc_va_list __arg),
514 __isoc23_vfscanf)
64b1a441 515 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur __nonnull ((1));
dee2bea0
JM
516extern int __REDIRECT (vscanf, (const char *__restrict __format,
517 __gnuc_va_list __arg), __isoc23_vscanf)
518 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
519extern int __REDIRECT_NTH (vsscanf,
520 (const char *__restrict __s,
521 const char *__restrict __format,
522 __gnuc_va_list __arg), __isoc23_vsscanf)
523 __attribute__ ((__format__ (__scanf__, 2, 0)));
524# elif !defined __REDIRECT
525extern int __isoc23_vfscanf (FILE *__restrict __s,
526 const char *__restrict __format,
64b1a441 527 __gnuc_va_list __arg) __wur __nonnull ((1));
dee2bea0
JM
528extern int __isoc23_vscanf (const char *__restrict __format,
529 __gnuc_va_list __arg) __wur;
530extern int __isoc23_vsscanf (const char *__restrict __s,
531 const char *__restrict __format,
532 __gnuc_va_list __arg) __THROW;
533# define vfscanf __isoc23_vfscanf
534# define vscanf __isoc23_vscanf
535# define vsscanf __isoc23_vsscanf
536# endif
537# else
538# if defined __REDIRECT && !defined __LDBL_COMPAT \
e2239af3 539 && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
874aa523
UD
540extern int __REDIRECT (vfscanf,
541 (FILE *__restrict __s,
a4fea3f2 542 const char *__restrict __format, __gnuc_va_list __arg),
874aa523 543 __isoc99_vfscanf)
64b1a441 544 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur __nonnull ((1));
a784e502 545extern int __REDIRECT (vscanf, (const char *__restrict __format,
a4fea3f2 546 __gnuc_va_list __arg), __isoc99_vscanf)
874aa523 547 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
f32f2869 548extern int __REDIRECT_NTH (vsscanf,
a784e502
UD
549 (const char *__restrict __s,
550 const char *__restrict __format,
a4fea3f2 551 __gnuc_va_list __arg), __isoc99_vsscanf)
f32f2869 552 __attribute__ ((__format__ (__scanf__, 2, 0)));
dee2bea0 553# elif !defined __REDIRECT
874aa523 554extern int __isoc99_vfscanf (FILE *__restrict __s,
a784e502 555 const char *__restrict __format,
64b1a441 556 __gnuc_va_list __arg) __wur __nonnull ((1));
a784e502 557extern int __isoc99_vscanf (const char *__restrict __format,
a4fea3f2 558 __gnuc_va_list __arg) __wur;
a784e502
UD
559extern int __isoc99_vsscanf (const char *__restrict __s,
560 const char *__restrict __format,
a4fea3f2 561 __gnuc_va_list __arg) __THROW;
dee2bea0
JM
562# define vfscanf __isoc99_vfscanf
563# define vscanf __isoc99_vscanf
564# define vsscanf __isoc99_vsscanf
565# endif
874aa523
UD
566# endif
567# endif
2b33e5b0 568#endif /* Use ISO C9x. */
2f6d1f1b
UD
569
570
2c008571 571/* Read a character from STREAM.
2f6d1f1b 572
2c008571
UD
573 These functions are possible cancellation points and therefore not
574 marked with __THROW. */
64b1a441
XR
575extern int fgetc (FILE *__stream) __nonnull ((1));
576extern int getc (FILE *__stream) __nonnull ((1));
2c008571
UD
577
578/* Read a character from stdin.
579
580 This function is a possible cancellation point and therefore not
581 marked with __THROW. */
582extern int getchar (void);
2f6d1f1b 583
a7657f30 584#ifdef __USE_POSIX199506
2c008571
UD
585/* These are defined in POSIX.1:1996.
586
587 These functions are possible cancellation points and therefore not
588 marked with __THROW. */
64b1a441 589extern int getc_unlocked (FILE *__stream) __nonnull ((1));
2c008571 590extern int getchar_unlocked (void);
acd7f096 591#endif /* Use POSIX. */
2f6d1f1b 592
209caedf 593#ifdef __USE_MISC
2c008571
UD
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. */
64b1a441 600extern int fgetc_unlocked (FILE *__stream) __nonnull ((1));
209caedf
UD
601#endif /* Use MISC. */
602
2f6d1f1b 603
2c008571
UD
604/* Write a character to STREAM.
605
606 These functions are possible cancellation points and therefore not
bc2e3689
UD
607 marked with __THROW.
608
609 These functions is a possible cancellation point and therefore not
2c008571 610 marked with __THROW. */
64b1a441
XR
611extern int fputc (int __c, FILE *__stream) __nonnull ((2));
612extern int putc (int __c, FILE *__stream) __nonnull ((2));
2f6d1f1b 613
2c008571
UD
614/* Write a character to stdout.
615
616 This function is a possible cancellation point and therefore not
617 marked with __THROW. */
618extern int putchar (int __c);
2f6d1f1b 619
2f6d1f1b 620#ifdef __USE_MISC
2c008571
UD
621/* Faster version when locking is not necessary.
622
623 This function is not part of POSIX and therefore no official
624 cancellation point. But due to similarity with an POSIX interface
625 or due to the implementation it is a cancellation point and
626 therefore not marked with __THROW. */
64b1a441 627extern int fputc_unlocked (int __c, FILE *__stream) __nonnull ((2));
2f6d1f1b
UD
628#endif /* Use MISC. */
629
a7657f30 630#ifdef __USE_POSIX199506
2c008571
UD
631/* These are defined in POSIX.1:1996.
632
633 These functions are possible cancellation points and therefore not
634 marked with __THROW. */
64b1a441 635extern int putc_unlocked (int __c, FILE *__stream) __nonnull ((2));
2c008571 636extern int putchar_unlocked (int __c);
acd7f096 637#endif /* Use POSIX. */
2f6d1f1b
UD
638
639
ed9a38e2 640#if defined __USE_MISC \
2c008571 641 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
2f6d1f1b 642/* Get a word (int) from STREAM. */
64b1a441 643extern int getw (FILE *__stream) __nonnull ((1));
2f6d1f1b
UD
644
645/* Write a word (int) to STREAM. */
64b1a441 646extern int putw (int __w, FILE *__stream) __nonnull ((2));
96aa2d94
RM
647#endif
648
7c713e28 649
2c008571
UD
650/* Get a newline-terminated string of finite length from STREAM.
651
652 This function is a possible cancellation point and therefore not
653 marked with __THROW. */
0476597b 654extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
64b1a441 655 __wur __fortified_attr_access (__write_only__, 1, 2) __nonnull ((3));
2f6d1f1b 656
7caa5054 657#if __GLIBC_USE (DEPRECATED_GETS)
7a5affeb 658/* Get a newline-terminated string from stdin, removing the newline.
2c008571 659
7caa5054
ZW
660 This function is impossible to use safely. It has been officially
661 removed from ISO C11 and ISO C++14, and we have also removed it
662 from the _GNU_SOURCE feature list. It remains available when
663 explicitly using an old ISO C, Unix, or POSIX standard.
03a71829 664
2c008571
UD
665 This function is a possible cancellation point and therefore not
666 marked with __THROW. */
16578fa7 667extern char *gets (char *__s) __wur __attribute_deprecated__;
03a71829 668#endif
7a5affeb 669
77ccaba1 670#ifdef __USE_GNU
2c008571
UD
671/* This function does the same as `fgets' but does not lock the stream.
672
673 This function is not part of POSIX and therefore no official
674 cancellation point. But due to similarity with an POSIX interface
675 or due to the implementation it is a cancellation point and
676 therefore not marked with __THROW. */
c1422e5b 677extern char *fgets_unlocked (char *__restrict __s, int __n,
06febd8c 678 FILE *__restrict __stream) __wur
64b1a441 679 __fortified_attr_access (__write_only__, 1, 2) __nonnull ((3));
77ccaba1
UD
680#endif
681
2f6d1f1b 682
48789000 683#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
2f6d1f1b
UD
684/* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
685 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
686 NULL), pointing to *N characters of space. It is realloc'd as
687 necessary. Returns the number of characters read (not including the
e7ac92e6 688 null terminator), or -1 on error or EOF. */
a4fea3f2
ZW
689extern __ssize_t __getdelim (char **__restrict __lineptr,
690 size_t *__restrict __n, int __delimiter,
64b1a441 691 FILE *__restrict __stream) __wur __nonnull ((4));
a4fea3f2
ZW
692extern __ssize_t getdelim (char **__restrict __lineptr,
693 size_t *__restrict __n, int __delimiter,
64b1a441 694 FILE *__restrict __stream) __wur __nonnull ((4));
2f6d1f1b 695
e7ac92e6 696/* Like `getdelim', but reads up to a newline. */
a4fea3f2
ZW
697extern __ssize_t getline (char **__restrict __lineptr,
698 size_t *__restrict __n,
64b1a441 699 FILE *__restrict __stream) __wur __nonnull ((3));
2f6d1f1b
UD
700#endif
701
702
2c008571
UD
703/* Write a string to STREAM.
704
4c1423ed 705 This function is a possible cancellation point and therefore not
2c008571 706 marked with __THROW. */
64b1a441
XR
707extern int fputs (const char *__restrict __s, FILE *__restrict __stream)
708 __nonnull ((2));
2c008571
UD
709
710/* Write a string, followed by a newline, to stdout.
50304ef0 711
4c1423ed 712 This function is a possible cancellation point and therefore not
2c008571 713 marked with __THROW. */
a784e502 714extern int puts (const char *__s);
2f6d1f1b
UD
715
716
2c008571 717/* Push a character back onto the input buffer of STREAM.
2f6d1f1b 718
4c1423ed 719 This function is a possible cancellation point and therefore not
2c008571 720 marked with __THROW. */
64b1a441 721extern int ungetc (int __c, FILE *__stream) __nonnull ((2));
2f6d1f1b 722
2c008571
UD
723
724/* Read chunks of generic data from STREAM.
725
4c1423ed 726 This function is a possible cancellation point and therefore not
2c008571 727 marked with __THROW. */
c1422e5b 728extern size_t fread (void *__restrict __ptr, size_t __size,
64b1a441
XR
729 size_t __n, FILE *__restrict __stream) __wur
730 __nonnull((4));
2c008571
UD
731/* Write chunks of generic data to STREAM.
732
4c1423ed 733 This function is a possible cancellation point and therefore not
2c008571 734 marked with __THROW. */
a784e502 735extern size_t fwrite (const void *__restrict __ptr, size_t __size,
64b1a441 736 size_t __n, FILE *__restrict __s) __nonnull((4));
7a5affeb
UD
737
738#ifdef __USE_GNU
2c008571
UD
739/* This function does the same as `fputs' but does not lock the stream.
740
741 This function is not part of POSIX and therefore no official
742 cancellation point. But due to similarity with an POSIX interface
743 or due to the implementation it is a cancellation point and
744 therefore not marked with __THROW. */
a784e502 745extern int fputs_unlocked (const char *__restrict __s,
64b1a441 746 FILE *__restrict __stream) __nonnull ((2));
7a5affeb 747#endif
2f6d1f1b
UD
748
749#ifdef __USE_MISC
2c008571
UD
750/* Faster versions when locking is not necessary.
751
752 These functions are not part of POSIX and therefore no official
753 cancellation point. But due to similarity with an POSIX interface
754 or due to the implementation they are cancellation points and
755 therefore not marked with __THROW. */
c1422e5b 756extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
64b1a441
XR
757 size_t __n, FILE *__restrict __stream) __wur
758 __nonnull ((4));
a784e502 759extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
64b1a441
XR
760 size_t __n, FILE *__restrict __stream)
761 __nonnull ((4));
2f6d1f1b
UD
762#endif
763
764
2c008571
UD
765/* Seek to a certain position on STREAM.
766
767 This function is a possible cancellation point and therefore not
768 marked with __THROW. */
64b1a441
XR
769extern int fseek (FILE *__stream, long int __off, int __whence)
770 __nonnull ((1));
2c008571
UD
771/* Return the current position of STREAM.
772
773 This function is a possible cancellation point and therefore not
774 marked with __THROW. */
64b1a441 775extern long int ftell (FILE *__stream) __wur __nonnull ((1));
2c008571
UD
776/* Rewind to the beginning of STREAM.
777
778 This function is a possible cancellation point and therefore not
779 marked with __THROW. */
64b1a441 780extern void rewind (FILE *__stream) __nonnull ((1));
2f6d1f1b 781
a5a0310d
UD
782/* The Single Unix Specification, Version 2, specifies an alternative,
783 more adequate interface for the two functions above which deal with
dfd2257a
UD
784 file offset. `long int' is not the right type. These definitions
785 are originally defined in the Large File Support API. */
786
7a80496f 787#if defined __USE_LARGEFILE || defined __USE_XOPEN2K
7a5affeb 788# ifndef __USE_FILE_OFFSET64
2c008571
UD
789/* Seek to a certain position on STREAM.
790
791 This function is a possible cancellation point and therefore not
792 marked with __THROW. */
64b1a441
XR
793extern int fseeko (FILE *__stream, __off_t __off, int __whence)
794 __nonnull ((1));
2c008571
UD
795/* Return the current position of STREAM.
796
797 This function is a possible cancellation point and therefore not
798 marked with __THROW. */
64b1a441 799extern __off_t ftello (FILE *__stream) __wur __nonnull ((1));
7a5affeb
UD
800# else
801# ifdef __REDIRECT
802extern int __REDIRECT (fseeko,
2c008571 803 (FILE *__stream, __off64_t __off, int __whence),
64b1a441
XR
804 fseeko64) __nonnull ((1));
805extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64)
806 __nonnull ((1));
7a5affeb
UD
807# else
808# define fseeko fseeko64
809# define ftello ftello64
810# endif
6796bc80 811# endif
7a5affeb 812#endif
bfce746a 813
7a5affeb 814#ifndef __USE_FILE_OFFSET64
2c008571
UD
815/* Get STREAM's position.
816
817 This function is a possible cancellation point and therefore not
818 marked with __THROW. */
64b1a441
XR
819extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos)
820 __nonnull ((1));
2c008571
UD
821/* Set STREAM's position.
822
823 This function is a possible cancellation point and therefore not
824 marked with __THROW. */
64b1a441 825extern int fsetpos (FILE *__stream, const fpos_t *__pos) __nonnull ((1));
bfce746a 826#else
01cad722 827# ifdef __REDIRECT
c1422e5b 828extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
64b1a441
XR
829 fpos_t *__restrict __pos), fgetpos64)
830 __nonnull ((1));
c1422e5b 831extern int __REDIRECT (fsetpos,
64b1a441
XR
832 (FILE *__stream, const fpos_t *__pos), fsetpos64)
833 __nonnull ((1));
bfce746a 834# else
bfce746a
UD
835# define fgetpos fgetpos64
836# define fsetpos fsetpos64
dfd2257a 837# endif
bfce746a 838#endif
01cad722 839
bfce746a 840#ifdef __USE_LARGEFILE64
64b1a441
XR
841extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence)
842 __nonnull ((1));
843extern __off64_t ftello64 (FILE *__stream) __wur __nonnull ((1));
844extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos)
845 __nonnull ((1));
846extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos) __nonnull ((1));
dfd2257a 847#endif
2f6d1f1b 848
2f6d1f1b 849/* Clear the error and EOF indicators for STREAM. */
64b1a441 850extern void clearerr (FILE *__stream) __THROW __nonnull ((1));
2f6d1f1b 851/* Return the EOF indicator for STREAM. */
64b1a441 852extern int feof (FILE *__stream) __THROW __wur __nonnull ((1));
2f6d1f1b 853/* Return the error indicator for STREAM. */
64b1a441 854extern int ferror (FILE *__stream) __THROW __wur __nonnull ((1));
2f6d1f1b
UD
855
856#ifdef __USE_MISC
857/* Faster versions when locking is not required. */
64b1a441
XR
858extern void clearerr_unlocked (FILE *__stream) __THROW __nonnull ((1));
859extern int feof_unlocked (FILE *__stream) __THROW __wur __nonnull ((1));
860extern int ferror_unlocked (FILE *__stream) __THROW __wur __nonnull ((1));
2f6d1f1b
UD
861#endif
862
863
2c008571
UD
864/* Print a message describing the meaning of the value of errno.
865
866 This function is a possible cancellation point and therefore not
867 marked with __THROW. */
e6a25275 868extern void perror (const char *__s) __COLD;
2f6d1f1b 869
2f6d1f1b
UD
870
871#ifdef __USE_POSIX
872/* Return the system file descriptor for STREAM. */
64b1a441 873extern int fileno (FILE *__stream) __THROW __wur __nonnull ((1));
2f6d1f1b
UD
874#endif /* Use POSIX. */
875
876#ifdef __USE_MISC
877/* Faster version when locking is not required. */
64b1a441 878extern int fileno_unlocked (FILE *__stream) __THROW __wur __nonnull ((1));
2f6d1f1b
UD
879#endif
880
881
acd7f096 882#ifdef __USE_POSIX2
c1760eaf 883/* Close a stream opened by popen and return the status of its child.
bc2e3689
UD
884
885 This function is a possible cancellation point and therefore not
886 marked with __THROW. */
64b1a441 887extern int pclose (FILE *__stream) __nonnull ((1));
2c008571 888
c1760eaf 889/* Create a new stream connected to a pipe running the given command.
bc2e3689
UD
890
891 This function is a possible cancellation point and therefore not
892 marked with __THROW. */
c1760eaf
MS
893extern FILE *popen (const char *__command, const char *__modes)
894 __attribute_malloc__ __attr_dealloc (pclose, 1) __wur;
895
2f6d1f1b
UD
896#endif
897
898
899#ifdef __USE_POSIX
900/* Return the name of the controlling terminal. */
26492c0a
MS
901extern char *ctermid (char *__s) __THROW
902 __attr_access ((__write_only__, 1));
2f6d1f1b
UD
903#endif /* Use POSIX. */
904
905
12404bb0 906#if (defined __USE_XOPEN && !defined __USE_XOPEN2K) || defined __USE_GNU
2f6d1f1b 907/* Return the name of the current user. */
26492c0a
MS
908extern char *cuserid (char *__s)
909 __attr_access ((__write_only__, 1));
219aa9e9 910#endif /* Use X/Open, but not issue 6. */
2f6d1f1b
UD
911
912
913#ifdef __USE_GNU
914struct obstack; /* See <obstack.h>. */
915
916/* Write formatted output to an obstack. */
c1422e5b 917extern int obstack_printf (struct obstack *__restrict __obstack,
a784e502 918 const char *__restrict __format, ...)
9beb2334 919 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3)));
c1422e5b 920extern int obstack_vprintf (struct obstack *__restrict __obstack,
a784e502 921 const char *__restrict __format,
a4fea3f2 922 __gnuc_va_list __args)
9beb2334 923 __THROWNL __attribute__ ((__format__ (__printf__, 2, 0)));
2f6d1f1b
UD
924#endif /* Use GNU. */
925
926
a7657f30 927#ifdef __USE_POSIX199506
2f6d1f1b
UD
928/* These are defined in POSIX.1:1996. */
929
930/* Acquire ownership of STREAM. */
64b1a441 931extern void flockfile (FILE *__stream) __THROW __nonnull ((1));
2f6d1f1b
UD
932
933/* Try to acquire ownership of STREAM but do not block if it is not
934 possible. */
64b1a441 935extern int ftrylockfile (FILE *__stream) __THROW __wur __nonnull ((1));
2f6d1f1b
UD
936
937/* Relinquish the ownership granted for STREAM. */
64b1a441 938extern void funlockfile (FILE *__stream) __THROW __nonnull ((1));
acd7f096 939#endif /* POSIX */
2f6d1f1b 940
219aa9e9 941#if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
10a33cf8
ZW
942/* X/Open Issues 1-5 required getopt to be declared in this
943 header. It was removed in Issue 6. GNU follows Issue 6. */
944# include <bits/getopt_posix.h>
945#endif
9756dfe1 946
a4fea3f2
ZW
947/* Slow-path routines used by the optimized inline functions in
948 bits/stdio.h. */
949extern int __uflow (FILE *);
950extern int __overflow (FILE *, int);
951
d0fa09a7
TMQMF
952#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
953/* Declare all functions from bits/stdio2-decl.h first. */
954# include <bits/stdio2-decl.h>
955#endif
956
957/* The following headers provide asm redirections. These redirections must
958 appear before the first usage of these functions, e.g. in bits/stdio.h. */
959#if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
960# include <bits/stdio-ldbl.h>
961#endif
962
085320f5 963/* If we are compiling with optimizing read this file. It contains
9b2c7523 964 several optimizing inline functions and macros. */
085320f5
UD
965#ifdef __USE_EXTERN_INLINES
966# include <bits/stdio.h>
967#endif
884ddc50 968#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
d0fa09a7 969/* Now include the function definitions and redirects too. */
b5cc329c
UD
970# include <bits/stdio2.h>
971#endif
e4a39992 972
085320f5 973__END_DECLS
f41c8091 974
2f6d1f1b 975#endif /* <stdio.h> included. */
This page took 0.794439 seconds and 6 git commands to generate.