Clean up conditionals for declaration of gets.
[glibc.git] / libio / stdio.h
blobc4f734cb3ccb2bca09ff0ceb6da6e0bf2b947d2b
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
25 #if !defined __need_FILE && !defined __need___FILE
26 # define _STDIO_H 1
27 # define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
28 # include <bits/libc-header-start.h>
30 __BEGIN_DECLS
32 # define __need_size_t
33 # define __need_NULL
34 # include <stddef.h>
36 # include <bits/types.h>
37 # define __need_FILE
38 # define __need___FILE
39 #endif /* Don't need FILE. */
42 #if !defined __FILE_defined && defined __need_FILE
44 /* Define outside of namespace so the C++ is happy. */
45 struct _IO_FILE;
47 __BEGIN_NAMESPACE_STD
48 /* The opaque type of streams. This is the definition used elsewhere. */
49 typedef struct _IO_FILE FILE;
50 __END_NAMESPACE_STD
51 #if defined __USE_LARGEFILE64 || defined __USE_POSIX \
52 || defined __USE_ISOC99 || defined __USE_XOPEN \
53 || defined __USE_POSIX2
54 __USING_NAMESPACE_STD(FILE)
55 #endif
57 # define __FILE_defined 1
58 #endif /* FILE not defined. */
59 #undef __need_FILE
62 #if !defined ____FILE_defined && defined __need___FILE
64 /* The opaque type of streams. This is the definition used elsewhere. */
65 typedef struct _IO_FILE __FILE;
67 # define ____FILE_defined 1
68 #endif /* __FILE not defined. */
69 #undef __need___FILE
72 #ifdef _STDIO_H
73 #define _STDIO_USES_IOSTREAM
75 #include <libio.h>
77 #if defined __USE_XOPEN || defined __USE_XOPEN2K8
78 # ifdef __GNUC__
79 # ifndef _VA_LIST_DEFINED
80 typedef _G_va_list va_list;
81 # define _VA_LIST_DEFINED
82 # endif
83 # else
84 # include <stdarg.h>
85 # endif
86 #endif
88 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
89 # ifndef __off_t_defined
90 # ifndef __USE_FILE_OFFSET64
91 typedef __off_t off_t;
92 # else
93 typedef __off64_t off_t;
94 # endif
95 # define __off_t_defined
96 # endif
97 # if defined __USE_LARGEFILE64 && !defined __off64_t_defined
98 typedef __off64_t off64_t;
99 # define __off64_t_defined
100 # endif
101 #endif
103 #ifdef __USE_XOPEN2K8
104 # ifndef __ssize_t_defined
105 typedef __ssize_t ssize_t;
106 # define __ssize_t_defined
107 # endif
108 #endif
110 /* The type of the second argument to `fgetpos' and `fsetpos'. */
111 __BEGIN_NAMESPACE_STD
112 #ifndef __USE_FILE_OFFSET64
113 typedef _G_fpos_t fpos_t;
114 #else
115 typedef _G_fpos64_t fpos_t;
116 #endif
117 __END_NAMESPACE_STD
118 #ifdef __USE_LARGEFILE64
119 typedef _G_fpos64_t fpos64_t;
120 #endif
122 /* The possibilities for the third argument to `setvbuf'. */
123 #define _IOFBF 0 /* Fully buffered. */
124 #define _IOLBF 1 /* Line buffered. */
125 #define _IONBF 2 /* No buffering. */
128 /* Default buffer size. */
129 #ifndef BUFSIZ
130 # define BUFSIZ _IO_BUFSIZ
131 #endif
134 /* End of file character.
135 Some things throughout the library rely on this being -1. */
136 #ifndef EOF
137 # define EOF (-1)
138 #endif
141 /* The possibilities for the third argument to `fseek'.
142 These values should not be changed. */
143 #define SEEK_SET 0 /* Seek from beginning of file. */
144 #define SEEK_CUR 1 /* Seek from current position. */
145 #define SEEK_END 2 /* Seek from end of file. */
146 #ifdef __USE_GNU
147 # define SEEK_DATA 3 /* Seek to next data. */
148 # define SEEK_HOLE 4 /* Seek to next hole. */
149 #endif
152 #if defined __USE_MISC || defined __USE_XOPEN
153 /* Default path prefix for `tempnam' and `tmpnam'. */
154 # define P_tmpdir "/tmp"
155 #endif
158 /* Get the values:
159 L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
160 TMP_MAX The minimum number of unique filenames generated by tmpnam
161 (and tempnam when it uses tmpnam's name space),
162 or tempnam (the two are separate).
163 L_ctermid How long an array to pass to `ctermid'.
164 L_cuserid How long an array to pass to `cuserid'.
165 FOPEN_MAX Minimum number of files that can be open at once.
166 FILENAME_MAX Maximum length of a filename. */
167 #include <bits/stdio_lim.h>
170 /* Standard streams. */
171 extern struct _IO_FILE *stdin; /* Standard input stream. */
172 extern struct _IO_FILE *stdout; /* Standard output stream. */
173 extern struct _IO_FILE *stderr; /* Standard error output stream. */
174 /* C89/C99 say they're macros. Make them happy. */
175 #define stdin stdin
176 #define stdout stdout
177 #define stderr stderr
179 __BEGIN_NAMESPACE_STD
180 /* Remove file FILENAME. */
181 extern int remove (const char *__filename) __THROW;
182 /* Rename file OLD to NEW. */
183 extern int rename (const char *__old, const char *__new) __THROW;
184 __END_NAMESPACE_STD
186 #ifdef __USE_ATFILE
187 /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
188 extern int renameat (int __oldfd, const char *__old, int __newfd,
189 const char *__new) __THROW;
190 #endif
192 __BEGIN_NAMESPACE_STD
193 /* Create a temporary file and open it read/write.
195 This function is a possible cancellation point and therefore not
196 marked with __THROW. */
197 #ifndef __USE_FILE_OFFSET64
198 extern FILE *tmpfile (void) __wur;
199 #else
200 # ifdef __REDIRECT
201 extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;
202 # else
203 # define tmpfile tmpfile64
204 # endif
205 #endif
207 #ifdef __USE_LARGEFILE64
208 extern FILE *tmpfile64 (void) __wur;
209 #endif
211 /* Generate a temporary filename. */
212 extern char *tmpnam (char *__s) __THROW __wur;
213 __END_NAMESPACE_STD
215 #ifdef __USE_MISC
216 /* This is the reentrant variant of `tmpnam'. The only difference is
217 that it does not allow S to be NULL. */
218 extern char *tmpnam_r (char *__s) __THROW __wur;
219 #endif
222 #if defined __USE_MISC || defined __USE_XOPEN
223 /* Generate a unique temporary filename using up to five characters of PFX
224 if it is not NULL. The directory to put this file in is searched for
225 as follows: First the environment variable "TMPDIR" is checked.
226 If it contains the name of a writable directory, that directory is used.
227 If not and if DIR is not NULL, that value is checked. If that fails,
228 P_tmpdir is tried and finally "/tmp". The storage for the filename
229 is allocated by `malloc'. */
230 extern char *tempnam (const char *__dir, const char *__pfx)
231 __THROW __attribute_malloc__ __wur;
232 #endif
235 __BEGIN_NAMESPACE_STD
236 /* Close STREAM.
238 This function is a possible cancellation point and therefore not
239 marked with __THROW. */
240 extern int fclose (FILE *__stream);
241 /* Flush STREAM, or all streams if STREAM is NULL.
243 This function is a possible cancellation point and therefore not
244 marked with __THROW. */
245 extern int fflush (FILE *__stream);
246 __END_NAMESPACE_STD
248 #ifdef __USE_MISC
249 /* Faster versions when locking is not required.
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. */
255 extern int fflush_unlocked (FILE *__stream);
256 #endif
258 #ifdef __USE_GNU
259 /* Close all streams.
261 This function is not part of POSIX and therefore no official
262 cancellation point. But due to similarity with an POSIX interface
263 or due to the implementation it is a cancellation point and
264 therefore not marked with __THROW. */
265 extern int fcloseall (void);
266 #endif
269 __BEGIN_NAMESPACE_STD
270 #ifndef __USE_FILE_OFFSET64
271 /* Open a file and create a new stream for it.
273 This function is a possible cancellation point and therefore not
274 marked with __THROW. */
275 extern FILE *fopen (const char *__restrict __filename,
276 const char *__restrict __modes) __wur;
277 /* Open a file, replacing an existing stream with it.
279 This function is a possible cancellation point and therefore not
280 marked with __THROW. */
281 extern FILE *freopen (const char *__restrict __filename,
282 const char *__restrict __modes,
283 FILE *__restrict __stream) __wur;
284 #else
285 # ifdef __REDIRECT
286 extern FILE *__REDIRECT (fopen, (const char *__restrict __filename,
287 const char *__restrict __modes), fopen64)
288 __wur;
289 extern FILE *__REDIRECT (freopen, (const char *__restrict __filename,
290 const char *__restrict __modes,
291 FILE *__restrict __stream), freopen64)
292 __wur;
293 # else
294 # define fopen fopen64
295 # define freopen freopen64
296 # endif
297 #endif
298 __END_NAMESPACE_STD
299 #ifdef __USE_LARGEFILE64
300 extern FILE *fopen64 (const char *__restrict __filename,
301 const char *__restrict __modes) __wur;
302 extern FILE *freopen64 (const char *__restrict __filename,
303 const char *__restrict __modes,
304 FILE *__restrict __stream) __wur;
305 #endif
307 #ifdef __USE_POSIX
308 /* Create a new stream that refers to an existing system file descriptor. */
309 extern FILE *fdopen (int __fd, const char *__modes) __THROW __wur;
310 #endif
312 #ifdef __USE_GNU
313 /* Create a new stream that refers to the given magic cookie,
314 and uses the given functions for input and output. */
315 extern FILE *fopencookie (void *__restrict __magic_cookie,
316 const char *__restrict __modes,
317 _IO_cookie_io_functions_t __io_funcs) __THROW __wur;
318 #endif
320 #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
321 /* Create a new stream that refers to a memory buffer. */
322 extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
323 __THROW __wur;
325 /* Open a stream that writes into a malloc'd buffer that is expanded as
326 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
327 and the number of characters written on fflush or fclose. */
328 extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;
329 #endif
332 __BEGIN_NAMESPACE_STD
333 /* If BUF is NULL, make STREAM unbuffered.
334 Else make it use buffer BUF, of size BUFSIZ. */
335 extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
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. */
339 extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
340 int __modes, size_t __n) __THROW;
341 __END_NAMESPACE_STD
343 #ifdef __USE_MISC
344 /* If BUF is NULL, make STREAM unbuffered.
345 Else make it use SIZE bytes of BUF for buffering. */
346 extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
347 size_t __size) __THROW;
349 /* Make STREAM line-buffered. */
350 extern void setlinebuf (FILE *__stream) __THROW;
351 #endif
354 __BEGIN_NAMESPACE_STD
355 /* Write formatted output to STREAM.
357 This function is a possible cancellation point and therefore not
358 marked with __THROW. */
359 extern int fprintf (FILE *__restrict __stream,
360 const char *__restrict __format, ...);
361 /* Write formatted output to stdout.
363 This function is a possible cancellation point and therefore not
364 marked with __THROW. */
365 extern int printf (const char *__restrict __format, ...);
366 /* Write formatted output to S. */
367 extern int sprintf (char *__restrict __s,
368 const char *__restrict __format, ...) __THROWNL;
370 /* Write formatted output to S from argument list ARG.
372 This function is a possible cancellation point and therefore not
373 marked with __THROW. */
374 extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
375 _G_va_list __arg);
376 /* Write formatted output to stdout from argument list ARG.
378 This function is a possible cancellation point and therefore not
379 marked with __THROW. */
380 extern int vprintf (const char *__restrict __format, _G_va_list __arg);
381 /* Write formatted output to S from argument list ARG. */
382 extern int vsprintf (char *__restrict __s, const char *__restrict __format,
383 _G_va_list __arg) __THROWNL;
384 __END_NAMESPACE_STD
386 #if defined __USE_ISOC99 || defined __USE_UNIX98
387 __BEGIN_NAMESPACE_C99
388 /* Maximum chars of output to write in MAXLEN. */
389 extern int snprintf (char *__restrict __s, size_t __maxlen,
390 const char *__restrict __format, ...)
391 __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));
393 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
394 const char *__restrict __format, _G_va_list __arg)
395 __THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));
396 __END_NAMESPACE_C99
397 #endif
399 #if __GLIBC_USE (LIB_EXT2)
400 /* Write formatted output to a string dynamically allocated with `malloc'.
401 Store the address of the string in *PTR. */
402 extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,
403 _G_va_list __arg)
404 __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
405 extern int __asprintf (char **__restrict __ptr,
406 const char *__restrict __fmt, ...)
407 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
408 extern int asprintf (char **__restrict __ptr,
409 const char *__restrict __fmt, ...)
410 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
411 #endif
413 #ifdef __USE_XOPEN2K8
414 /* Write formatted output to a file descriptor. */
415 extern int vdprintf (int __fd, const char *__restrict __fmt,
416 _G_va_list __arg)
417 __attribute__ ((__format__ (__printf__, 2, 0)));
418 extern int dprintf (int __fd, const char *__restrict __fmt, ...)
419 __attribute__ ((__format__ (__printf__, 2, 3)));
420 #endif
423 __BEGIN_NAMESPACE_STD
424 /* Read formatted input from STREAM.
426 This function is a possible cancellation point and therefore not
427 marked with __THROW. */
428 extern int fscanf (FILE *__restrict __stream,
429 const char *__restrict __format, ...) __wur;
430 /* Read formatted input from stdin.
432 This function is a possible cancellation point and therefore not
433 marked with __THROW. */
434 extern int scanf (const char *__restrict __format, ...) __wur;
435 /* Read formatted input from S. */
436 extern int sscanf (const char *__restrict __s,
437 const char *__restrict __format, ...) __THROW;
439 #if defined __USE_ISOC99 && !defined __USE_GNU \
440 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
441 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
442 # ifdef __REDIRECT
443 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
444 GNU extension which conflicts with valid %a followed by letter
445 s, S or [. */
446 extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
447 const char *__restrict __format, ...),
448 __isoc99_fscanf) __wur;
449 extern int __REDIRECT (scanf, (const char *__restrict __format, ...),
450 __isoc99_scanf) __wur;
451 extern int __REDIRECT_NTH (sscanf, (const char *__restrict __s,
452 const char *__restrict __format, ...),
453 __isoc99_sscanf);
454 # else
455 extern int __isoc99_fscanf (FILE *__restrict __stream,
456 const char *__restrict __format, ...) __wur;
457 extern int __isoc99_scanf (const char *__restrict __format, ...) __wur;
458 extern int __isoc99_sscanf (const char *__restrict __s,
459 const char *__restrict __format, ...) __THROW;
460 # define fscanf __isoc99_fscanf
461 # define scanf __isoc99_scanf
462 # define sscanf __isoc99_sscanf
463 # endif
464 #endif
466 __END_NAMESPACE_STD
468 #ifdef __USE_ISOC99
469 __BEGIN_NAMESPACE_C99
470 /* Read formatted input from S into argument list ARG.
472 This function is a possible cancellation point and therefore not
473 marked with __THROW. */
474 extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
475 _G_va_list __arg)
476 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
478 /* Read formatted input from stdin into argument list ARG.
480 This function is a possible cancellation point and therefore not
481 marked with __THROW. */
482 extern int vscanf (const char *__restrict __format, _G_va_list __arg)
483 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
485 /* Read formatted input from S into argument list ARG. */
486 extern int vsscanf (const char *__restrict __s,
487 const char *__restrict __format, _G_va_list __arg)
488 __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
490 # if !defined __USE_GNU \
491 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
492 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
493 # ifdef __REDIRECT
494 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
495 GNU extension which conflicts with valid %a followed by letter
496 s, S or [. */
497 extern int __REDIRECT (vfscanf,
498 (FILE *__restrict __s,
499 const char *__restrict __format, _G_va_list __arg),
500 __isoc99_vfscanf)
501 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
502 extern int __REDIRECT (vscanf, (const char *__restrict __format,
503 _G_va_list __arg), __isoc99_vscanf)
504 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
505 extern int __REDIRECT_NTH (vsscanf,
506 (const char *__restrict __s,
507 const char *__restrict __format,
508 _G_va_list __arg), __isoc99_vsscanf)
509 __attribute__ ((__format__ (__scanf__, 2, 0)));
510 # else
511 extern int __isoc99_vfscanf (FILE *__restrict __s,
512 const char *__restrict __format,
513 _G_va_list __arg) __wur;
514 extern int __isoc99_vscanf (const char *__restrict __format,
515 _G_va_list __arg) __wur;
516 extern int __isoc99_vsscanf (const char *__restrict __s,
517 const char *__restrict __format,
518 _G_va_list __arg) __THROW;
519 # define vfscanf __isoc99_vfscanf
520 # define vscanf __isoc99_vscanf
521 # define vsscanf __isoc99_vsscanf
522 # endif
523 # endif
525 __END_NAMESPACE_C99
526 #endif /* Use ISO C9x. */
529 __BEGIN_NAMESPACE_STD
530 /* Read a character from STREAM.
532 These functions are possible cancellation points and therefore not
533 marked with __THROW. */
534 extern int fgetc (FILE *__stream);
535 extern int getc (FILE *__stream);
537 /* Read a character from stdin.
539 This function is a possible cancellation point and therefore not
540 marked with __THROW. */
541 extern int getchar (void);
542 __END_NAMESPACE_STD
544 /* The C standard explicitly says this is a macro, so we always do the
545 optimization for it. */
546 #define getc(_fp) _IO_getc (_fp)
548 #ifdef __USE_POSIX199506
549 /* These are defined in POSIX.1:1996.
551 These functions are possible cancellation points and therefore not
552 marked with __THROW. */
553 extern int getc_unlocked (FILE *__stream);
554 extern int getchar_unlocked (void);
555 #endif /* Use POSIX. */
557 #ifdef __USE_MISC
558 /* Faster version when locking is not necessary.
560 This function is not part of POSIX and therefore no official
561 cancellation point. But due to similarity with an POSIX interface
562 or due to the implementation it is a cancellation point and
563 therefore not marked with __THROW. */
564 extern int fgetc_unlocked (FILE *__stream);
565 #endif /* Use MISC. */
568 __BEGIN_NAMESPACE_STD
569 /* Write a character to STREAM.
571 These functions are possible cancellation points and therefore not
572 marked with __THROW.
574 These functions is a possible cancellation point and therefore not
575 marked with __THROW. */
576 extern int fputc (int __c, FILE *__stream);
577 extern int putc (int __c, FILE *__stream);
579 /* Write a character to stdout.
581 This function is a possible cancellation point and therefore not
582 marked with __THROW. */
583 extern int putchar (int __c);
584 __END_NAMESPACE_STD
586 /* The C standard explicitly says this can be a macro,
587 so we always do the optimization for it. */
588 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
590 #ifdef __USE_MISC
591 /* Faster version when locking is not necessary.
593 This function is not part of POSIX and therefore no official
594 cancellation point. But due to similarity with an POSIX interface
595 or due to the implementation it is a cancellation point and
596 therefore not marked with __THROW. */
597 extern int fputc_unlocked (int __c, FILE *__stream);
598 #endif /* Use MISC. */
600 #ifdef __USE_POSIX199506
601 /* These are defined in POSIX.1:1996.
603 These functions are possible cancellation points and therefore not
604 marked with __THROW. */
605 extern int putc_unlocked (int __c, FILE *__stream);
606 extern int putchar_unlocked (int __c);
607 #endif /* Use POSIX. */
610 #if defined __USE_MISC \
611 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
612 /* Get a word (int) from STREAM. */
613 extern int getw (FILE *__stream);
615 /* Write a word (int) to STREAM. */
616 extern int putw (int __w, FILE *__stream);
617 #endif
620 __BEGIN_NAMESPACE_STD
621 /* Get a newline-terminated string of finite length from STREAM.
623 This function is a possible cancellation point and therefore not
624 marked with __THROW. */
625 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
626 __wur;
628 #if __GLIBC_USE (DEPRECATED_GETS)
629 /* Get a newline-terminated string from stdin, removing the newline.
631 This function is impossible to use safely. It has been officially
632 removed from ISO C11 and ISO C++14, and we have also removed it
633 from the _GNU_SOURCE feature list. It remains available when
634 explicitly using an old ISO C, Unix, or POSIX standard.
636 This function is a possible cancellation point and therefore not
637 marked with __THROW. */
638 extern char *gets (char *__s) __wur __attribute_deprecated__;
639 #endif
640 __END_NAMESPACE_STD
642 #ifdef __USE_GNU
643 /* This function does the same as `fgets' but does not lock the stream.
645 This function is not part of POSIX and therefore no official
646 cancellation point. But due to similarity with an POSIX interface
647 or due to the implementation it is a cancellation point and
648 therefore not marked with __THROW. */
649 extern char *fgets_unlocked (char *__restrict __s, int __n,
650 FILE *__restrict __stream) __wur;
651 #endif
654 #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
655 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
656 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
657 NULL), pointing to *N characters of space. It is realloc'd as
658 necessary. Returns the number of characters read (not including the
659 null terminator), or -1 on error or EOF.
661 These functions are not part of POSIX and therefore no official
662 cancellation point. But due to similarity with an POSIX interface
663 or due to the implementation they are cancellation points and
664 therefore not marked with __THROW. */
665 extern _IO_ssize_t __getdelim (char **__restrict __lineptr,
666 size_t *__restrict __n, int __delimiter,
667 FILE *__restrict __stream) __wur;
668 extern _IO_ssize_t getdelim (char **__restrict __lineptr,
669 size_t *__restrict __n, int __delimiter,
670 FILE *__restrict __stream) __wur;
672 /* Like `getdelim', but reads up to a newline.
674 This function is not part of POSIX and therefore no official
675 cancellation point. But due to similarity with an POSIX interface
676 or due to the implementation it is a cancellation point and
677 therefore not marked with __THROW. */
678 extern _IO_ssize_t getline (char **__restrict __lineptr,
679 size_t *__restrict __n,
680 FILE *__restrict __stream) __wur;
681 #endif
684 __BEGIN_NAMESPACE_STD
685 /* Write a string to STREAM.
687 This function is a possible cancellation point and therefore not
688 marked with __THROW. */
689 extern int fputs (const char *__restrict __s, FILE *__restrict __stream);
691 /* Write a string, followed by a newline, to stdout.
693 This function is a possible cancellation point and therefore not
694 marked with __THROW. */
695 extern int puts (const char *__s);
698 /* Push a character back onto the input buffer of STREAM.
700 This function is a possible cancellation point and therefore not
701 marked with __THROW. */
702 extern int ungetc (int __c, FILE *__stream);
705 /* Read chunks of generic data from STREAM.
707 This function is a possible cancellation point and therefore not
708 marked with __THROW. */
709 extern size_t fread (void *__restrict __ptr, size_t __size,
710 size_t __n, FILE *__restrict __stream) __wur;
711 /* Write chunks of generic data to STREAM.
713 This function is a possible cancellation point and therefore not
714 marked with __THROW. */
715 extern size_t fwrite (const void *__restrict __ptr, size_t __size,
716 size_t __n, FILE *__restrict __s);
717 __END_NAMESPACE_STD
719 #ifdef __USE_GNU
720 /* This function does the same as `fputs' but does not lock the stream.
722 This function is not part of POSIX and therefore no official
723 cancellation point. But due to similarity with an POSIX interface
724 or due to the implementation it is a cancellation point and
725 therefore not marked with __THROW. */
726 extern int fputs_unlocked (const char *__restrict __s,
727 FILE *__restrict __stream);
728 #endif
730 #ifdef __USE_MISC
731 /* Faster versions when locking is not necessary.
733 These functions are not part of POSIX and therefore no official
734 cancellation point. But due to similarity with an POSIX interface
735 or due to the implementation they are cancellation points and
736 therefore not marked with __THROW. */
737 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
738 size_t __n, FILE *__restrict __stream) __wur;
739 extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
740 size_t __n, FILE *__restrict __stream);
741 #endif
744 __BEGIN_NAMESPACE_STD
745 /* Seek to a certain position on STREAM.
747 This function is a possible cancellation point and therefore not
748 marked with __THROW. */
749 extern int fseek (FILE *__stream, long int __off, int __whence);
750 /* Return the current position of STREAM.
752 This function is a possible cancellation point and therefore not
753 marked with __THROW. */
754 extern long int ftell (FILE *__stream) __wur;
755 /* Rewind to the beginning of STREAM.
757 This function is a possible cancellation point and therefore not
758 marked with __THROW. */
759 extern void rewind (FILE *__stream);
760 __END_NAMESPACE_STD
762 /* The Single Unix Specification, Version 2, specifies an alternative,
763 more adequate interface for the two functions above which deal with
764 file offset. `long int' is not the right type. These definitions
765 are originally defined in the Large File Support API. */
767 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
768 # ifndef __USE_FILE_OFFSET64
769 /* Seek to a certain position on STREAM.
771 This function is a possible cancellation point and therefore not
772 marked with __THROW. */
773 extern int fseeko (FILE *__stream, __off_t __off, int __whence);
774 /* Return the current position of STREAM.
776 This function is a possible cancellation point and therefore not
777 marked with __THROW. */
778 extern __off_t ftello (FILE *__stream) __wur;
779 # else
780 # ifdef __REDIRECT
781 extern int __REDIRECT (fseeko,
782 (FILE *__stream, __off64_t __off, int __whence),
783 fseeko64);
784 extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
785 # else
786 # define fseeko fseeko64
787 # define ftello ftello64
788 # endif
789 # endif
790 #endif
792 __BEGIN_NAMESPACE_STD
793 #ifndef __USE_FILE_OFFSET64
794 /* Get STREAM's position.
796 This function is a possible cancellation point and therefore not
797 marked with __THROW. */
798 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
799 /* Set STREAM's position.
801 This function is a possible cancellation point and therefore not
802 marked with __THROW. */
803 extern int fsetpos (FILE *__stream, const fpos_t *__pos);
804 #else
805 # ifdef __REDIRECT
806 extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
807 fpos_t *__restrict __pos), fgetpos64);
808 extern int __REDIRECT (fsetpos,
809 (FILE *__stream, const fpos_t *__pos), fsetpos64);
810 # else
811 # define fgetpos fgetpos64
812 # define fsetpos fsetpos64
813 # endif
814 #endif
815 __END_NAMESPACE_STD
817 #ifdef __USE_LARGEFILE64
818 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
819 extern __off64_t ftello64 (FILE *__stream) __wur;
820 extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
821 extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos);
822 #endif
824 __BEGIN_NAMESPACE_STD
825 /* Clear the error and EOF indicators for STREAM. */
826 extern void clearerr (FILE *__stream) __THROW;
827 /* Return the EOF indicator for STREAM. */
828 extern int feof (FILE *__stream) __THROW __wur;
829 /* Return the error indicator for STREAM. */
830 extern int ferror (FILE *__stream) __THROW __wur;
831 __END_NAMESPACE_STD
833 #ifdef __USE_MISC
834 /* Faster versions when locking is not required. */
835 extern void clearerr_unlocked (FILE *__stream) __THROW;
836 extern int feof_unlocked (FILE *__stream) __THROW __wur;
837 extern int ferror_unlocked (FILE *__stream) __THROW __wur;
838 #endif
841 __BEGIN_NAMESPACE_STD
842 /* Print a message describing the meaning of the value of errno.
844 This function is a possible cancellation point and therefore not
845 marked with __THROW. */
846 extern void perror (const char *__s);
847 __END_NAMESPACE_STD
849 /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
850 are available on this system. Even if available, these variables
851 should not be used directly. The `strerror' function provides
852 all the necessary functionality. */
853 #include <bits/sys_errlist.h>
856 #ifdef __USE_POSIX
857 /* Return the system file descriptor for STREAM. */
858 extern int fileno (FILE *__stream) __THROW __wur;
859 #endif /* Use POSIX. */
861 #ifdef __USE_MISC
862 /* Faster version when locking is not required. */
863 extern int fileno_unlocked (FILE *__stream) __THROW __wur;
864 #endif
867 #ifdef __USE_POSIX2
868 /* Create a new stream connected to a pipe running the given command.
870 This function is a possible cancellation point and therefore not
871 marked with __THROW. */
872 extern FILE *popen (const char *__command, const char *__modes) __wur;
874 /* Close a stream opened by popen and return the status of its child.
876 This function is a possible cancellation point and therefore not
877 marked with __THROW. */
878 extern int pclose (FILE *__stream);
879 #endif
882 #ifdef __USE_POSIX
883 /* Return the name of the controlling terminal. */
884 extern char *ctermid (char *__s) __THROW;
885 #endif /* Use POSIX. */
888 #if (defined __USE_XOPEN && !defined __USE_XOPEN2K) || defined __USE_GNU
889 /* Return the name of the current user. */
890 extern char *cuserid (char *__s);
891 #endif /* Use X/Open, but not issue 6. */
894 #ifdef __USE_GNU
895 struct obstack; /* See <obstack.h>. */
897 /* Write formatted output to an obstack. */
898 extern int obstack_printf (struct obstack *__restrict __obstack,
899 const char *__restrict __format, ...)
900 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3)));
901 extern int obstack_vprintf (struct obstack *__restrict __obstack,
902 const char *__restrict __format,
903 _G_va_list __args)
904 __THROWNL __attribute__ ((__format__ (__printf__, 2, 0)));
905 #endif /* Use GNU. */
908 #ifdef __USE_POSIX199506
909 /* These are defined in POSIX.1:1996. */
911 /* Acquire ownership of STREAM. */
912 extern void flockfile (FILE *__stream) __THROW;
914 /* Try to acquire ownership of STREAM but do not block if it is not
915 possible. */
916 extern int ftrylockfile (FILE *__stream) __THROW __wur;
918 /* Relinquish the ownership granted for STREAM. */
919 extern void funlockfile (FILE *__stream) __THROW;
920 #endif /* POSIX */
922 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
923 /* The X/Open standard requires some functions and variables to be
924 declared here which do not belong into this header. But we have to
925 follow. In GNU mode we don't do this nonsense. */
926 # define __need_getopt
927 # include <getopt.h>
928 #endif /* X/Open, but not issue 6 and not for GNU. */
930 /* If we are compiling with optimizing read this file. It contains
931 several optimizing inline functions and macros. */
932 #ifdef __USE_EXTERN_INLINES
933 # include <bits/stdio.h>
934 #endif
935 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
936 # include <bits/stdio2.h>
937 #endif
938 #ifdef __LDBL_COMPAT
939 # include <bits/stdio-ldbl.h>
940 #endif
942 __END_DECLS
944 #endif /* <stdio.h> included. */
946 #endif /* !_STDIO_H */