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