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