* sysdeps/ieee754/k_standard.c (__kernel_standard): Pole errors
[glibc.git] / libio / stdio.h
blobd7d241c92512bc925e806acaf7954b5032fe2ecd
1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991, 1994-2007, 2008, 2009 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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
21 * ISO C99 Standard: 7.19 Input/output <stdio.h>
24 #ifndef _STDIO_H
26 #if !defined __need_FILE && !defined __need___FILE
27 # define _STDIO_H 1
28 # include <features.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_SVID || defined __USE_POSIX \
52 || defined __USE_BSD || 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 #ifdef __USE_XOPEN
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 /* The type of the second argument to `fgetpos' and `fsetpos'. */
89 __BEGIN_NAMESPACE_STD
90 #ifndef __USE_FILE_OFFSET64
91 typedef _G_fpos_t fpos_t;
92 #else
93 typedef _G_fpos64_t fpos_t;
94 #endif
95 __END_NAMESPACE_STD
96 #ifdef __USE_LARGEFILE64
97 typedef _G_fpos64_t fpos64_t;
98 #endif
100 /* The possibilities for the third argument to `setvbuf'. */
101 #define _IOFBF 0 /* Fully buffered. */
102 #define _IOLBF 1 /* Line buffered. */
103 #define _IONBF 2 /* No buffering. */
106 /* Default buffer size. */
107 #ifndef BUFSIZ
108 # define BUFSIZ _IO_BUFSIZ
109 #endif
112 /* End of file character.
113 Some things throughout the library rely on this being -1. */
114 #ifndef EOF
115 # define EOF (-1)
116 #endif
119 /* The possibilities for the third argument to `fseek'.
120 These values should not be changed. */
121 #define SEEK_SET 0 /* Seek from beginning of file. */
122 #define SEEK_CUR 1 /* Seek from current position. */
123 #define SEEK_END 2 /* Seek from end of file. */
126 #if defined __USE_SVID || defined __USE_XOPEN
127 /* Default path prefix for `tempnam' and `tmpnam'. */
128 # define P_tmpdir "/tmp"
129 #endif
132 /* Get the values:
133 L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
134 TMP_MAX The minimum number of unique filenames generated by tmpnam
135 (and tempnam when it uses tmpnam's name space),
136 or tempnam (the two are separate).
137 L_ctermid How long an array to pass to `ctermid'.
138 L_cuserid How long an array to pass to `cuserid'.
139 FOPEN_MAX Minimum number of files that can be open at once.
140 FILENAME_MAX Maximum length of a filename. */
141 #include <bits/stdio_lim.h>
144 /* Standard streams. */
145 extern struct _IO_FILE *stdin; /* Standard input stream. */
146 extern struct _IO_FILE *stdout; /* Standard output stream. */
147 extern struct _IO_FILE *stderr; /* Standard error output stream. */
148 /* C89/C99 say they're macros. Make them happy. */
149 #define stdin stdin
150 #define stdout stdout
151 #define stderr stderr
153 __BEGIN_NAMESPACE_STD
154 /* Remove file FILENAME. */
155 extern int remove (__const char *__filename) __THROW;
156 /* Rename file OLD to NEW. */
157 extern int rename (__const char *__old, __const char *__new) __THROW;
158 __END_NAMESPACE_STD
160 #ifdef __USE_ATFILE
161 /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
162 extern int renameat (int __oldfd, __const char *__old, int __newfd,
163 __const char *__new) __THROW;
164 #endif
166 __BEGIN_NAMESPACE_STD
167 /* Create a temporary file and open it read/write.
169 This function is a possible cancellation points and therefore not
170 marked with __THROW. */
171 #ifndef __USE_FILE_OFFSET64
172 extern FILE *tmpfile (void) __wur;
173 #else
174 # ifdef __REDIRECT
175 extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;
176 # else
177 # define tmpfile tmpfile64
178 # endif
179 #endif
181 #ifdef __USE_LARGEFILE64
182 extern FILE *tmpfile64 (void) __wur;
183 #endif
185 /* Generate a temporary filename. */
186 extern char *tmpnam (char *__s) __THROW __wur;
187 __END_NAMESPACE_STD
189 #ifdef __USE_MISC
190 /* This is the reentrant variant of `tmpnam'. The only difference is
191 that it does not allow S to be NULL. */
192 extern char *tmpnam_r (char *__s) __THROW __wur;
193 #endif
196 #if defined __USE_SVID || defined __USE_XOPEN
197 /* Generate a unique temporary filename using up to five characters of PFX
198 if it is not NULL. The directory to put this file in is searched for
199 as follows: First the environment variable "TMPDIR" is checked.
200 If it contains the name of a writable directory, that directory is used.
201 If not and if DIR is not NULL, that value is checked. If that fails,
202 P_tmpdir is tried and finally "/tmp". The storage for the filename
203 is allocated by `malloc'. */
204 extern char *tempnam (__const char *__dir, __const char *__pfx)
205 __THROW __attribute_malloc__ __wur;
206 #endif
209 __BEGIN_NAMESPACE_STD
210 /* Close STREAM.
212 This function is a possible cancellation point and therefore not
213 marked with __THROW. */
214 extern int fclose (FILE *__stream);
215 /* Flush STREAM, or all streams if STREAM is NULL.
217 This function is a possible cancellation point and therefore not
218 marked with __THROW. */
219 extern int fflush (FILE *__stream);
220 __END_NAMESPACE_STD
222 #ifdef __USE_MISC
223 /* Faster versions when locking is not required.
225 This function is not part of POSIX and therefore no official
226 cancellation point. But due to similarity with an POSIX interface
227 or due to the implementation it is a cancellation point and
228 therefore not marked with __THROW. */
229 extern int fflush_unlocked (FILE *__stream);
230 #endif
232 #ifdef __USE_GNU
233 /* Close all streams.
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 fcloseall (void);
240 #endif
243 __BEGIN_NAMESPACE_STD
244 #ifndef __USE_FILE_OFFSET64
245 /* Open a file and create a new stream for it.
247 This function is a possible cancellation point and therefore not
248 marked with __THROW. */
249 extern FILE *fopen (__const char *__restrict __filename,
250 __const char *__restrict __modes) __wur;
251 /* Open a file, replacing an existing stream with it.
253 This function is a possible cancellation point and therefore not
254 marked with __THROW. */
255 extern FILE *freopen (__const char *__restrict __filename,
256 __const char *__restrict __modes,
257 FILE *__restrict __stream) __wur;
258 #else
259 # ifdef __REDIRECT
260 extern FILE *__REDIRECT (fopen, (__const char *__restrict __filename,
261 __const char *__restrict __modes), fopen64)
262 __wur;
263 extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
264 __const char *__restrict __modes,
265 FILE *__restrict __stream), freopen64)
266 __wur;
267 # else
268 # define fopen fopen64
269 # define freopen freopen64
270 # endif
271 #endif
272 __END_NAMESPACE_STD
273 #ifdef __USE_LARGEFILE64
274 extern FILE *fopen64 (__const char *__restrict __filename,
275 __const char *__restrict __modes) __wur;
276 extern FILE *freopen64 (__const char *__restrict __filename,
277 __const char *__restrict __modes,
278 FILE *__restrict __stream) __wur;
279 #endif
281 #ifdef __USE_POSIX
282 /* Create a new stream that refers to an existing system file descriptor. */
283 extern FILE *fdopen (int __fd, __const char *__modes) __THROW __wur;
284 #endif
286 #ifdef __USE_GNU
287 /* Create a new stream that refers to the given magic cookie,
288 and uses the given functions for input and output. */
289 extern FILE *fopencookie (void *__restrict __magic_cookie,
290 __const char *__restrict __modes,
291 _IO_cookie_io_functions_t __io_funcs) __THROW __wur;
292 #endif
294 #ifdef __USE_XOPEN2K8
295 /* Create a new stream that refers to a memory buffer. */
296 extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes)
297 __THROW __wur;
299 /* Open a stream that writes into a malloc'd buffer that is expanded as
300 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
301 and the number of characters written on fflush or fclose. */
302 extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;
303 #endif
306 __BEGIN_NAMESPACE_STD
307 /* If BUF is NULL, make STREAM unbuffered.
308 Else make it use buffer BUF, of size BUFSIZ. */
309 extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
310 /* Make STREAM use buffering mode MODE.
311 If BUF is not NULL, use N bytes of it for buffering;
312 else allocate an internal buffer N bytes long. */
313 extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
314 int __modes, size_t __n) __THROW;
315 __END_NAMESPACE_STD
317 #ifdef __USE_BSD
318 /* If BUF is NULL, make STREAM unbuffered.
319 Else make it use SIZE bytes of BUF for buffering. */
320 extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
321 size_t __size) __THROW;
323 /* Make STREAM line-buffered. */
324 extern void setlinebuf (FILE *__stream) __THROW;
325 #endif
328 __BEGIN_NAMESPACE_STD
329 /* Write formatted output to STREAM.
331 This function is a possible cancellation point and therefore not
332 marked with __THROW. */
333 extern int fprintf (FILE *__restrict __stream,
334 __const char *__restrict __format, ...);
335 /* Write formatted output to stdout.
337 This function is a possible cancellation point and therefore not
338 marked with __THROW. */
339 extern int printf (__const char *__restrict __format, ...);
340 /* Write formatted output to S. */
341 extern int sprintf (char *__restrict __s,
342 __const char *__restrict __format, ...) __THROW;
344 /* Write formatted output to S from argument list ARG.
346 This function is a possible cancellation point and therefore not
347 marked with __THROW. */
348 extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
349 _G_va_list __arg);
350 /* Write formatted output to stdout from argument list ARG.
352 This function is a possible cancellation point and therefore not
353 marked with __THROW. */
354 extern int vprintf (__const char *__restrict __format, _G_va_list __arg);
355 /* Write formatted output to S from argument list ARG. */
356 extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
357 _G_va_list __arg) __THROW;
358 __END_NAMESPACE_STD
360 #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
361 __BEGIN_NAMESPACE_C99
362 /* Maximum chars of output to write in MAXLEN. */
363 extern int snprintf (char *__restrict __s, size_t __maxlen,
364 __const char *__restrict __format, ...)
365 __THROW __attribute__ ((__format__ (__printf__, 3, 4)));
367 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
368 __const char *__restrict __format, _G_va_list __arg)
369 __THROW __attribute__ ((__format__ (__printf__, 3, 0)));
370 __END_NAMESPACE_C99
371 #endif
373 #ifdef __USE_GNU
374 /* Write formatted output to a string dynamically allocated with `malloc'.
375 Store the address of the string in *PTR. */
376 extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f,
377 _G_va_list __arg)
378 __THROW __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
379 extern int __asprintf (char **__restrict __ptr,
380 __const char *__restrict __fmt, ...)
381 __THROW __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
382 extern int asprintf (char **__restrict __ptr,
383 __const char *__restrict __fmt, ...)
384 __THROW __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
385 #endif
387 #ifdef __USE_XOPEN2K8
388 /* Write formatted output to a file descriptor.
390 These functions are not part of POSIX and therefore no official
391 cancellation point. But due to similarity with an POSIX interface
392 or due to the implementation they are cancellation points and
393 therefore not marked with __THROW. */
394 extern int vdprintf (int __fd, __const char *__restrict __fmt,
395 _G_va_list __arg)
396 __attribute__ ((__format__ (__printf__, 2, 0)));
397 extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
398 __attribute__ ((__format__ (__printf__, 2, 3)));
399 #endif
402 __BEGIN_NAMESPACE_STD
403 /* Read formatted input from STREAM.
405 This function is a possible cancellation point and therefore not
406 marked with __THROW. */
407 extern int fscanf (FILE *__restrict __stream,
408 __const char *__restrict __format, ...) __wur;
409 /* Read formatted input from stdin.
411 This function is a possible cancellation point and therefore not
412 marked with __THROW. */
413 extern int scanf (__const char *__restrict __format, ...) __wur;
414 /* Read formatted input from S. */
415 extern int sscanf (__const char *__restrict __s,
416 __const char *__restrict __format, ...) __THROW;
418 #if defined __USE_ISOC99 && !defined __USE_GNU \
419 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
420 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
421 # ifdef __REDIRECT
422 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
423 GNU extension which conflicts with valid %a followed by letter
424 s, S or [. */
425 extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
426 __const char *__restrict __format, ...),
427 __isoc99_fscanf) __wur;
428 extern int __REDIRECT (scanf, (__const char *__restrict __format, ...),
429 __isoc99_scanf) __wur;
430 extern int __REDIRECT (sscanf, (__const char *__restrict __s,
431 __const char *__restrict __format, ...),
432 __isoc99_sscanf) __THROW;
433 # else
434 extern int __isoc99_fscanf (FILE *__restrict __stream,
435 __const char *__restrict __format, ...) __wur;
436 extern int __isoc99_scanf (__const char *__restrict __format, ...) __wur;
437 extern int __isoc99_sscanf (__const char *__restrict __s,
438 __const char *__restrict __format, ...) __THROW;
439 # define fscanf __isoc99_fscanf
440 # define scanf __isoc99_scanf
441 # define sscanf __isoc99_sscanf
442 # endif
443 #endif
445 __END_NAMESPACE_STD
447 #ifdef __USE_ISOC99
448 __BEGIN_NAMESPACE_C99
449 /* Read formatted input from S into argument list ARG.
451 This function is a possible cancellation point and therefore not
452 marked with __THROW. */
453 extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
454 _G_va_list __arg)
455 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
457 /* Read formatted input from stdin into argument list ARG.
459 This function is a possible cancellation point and therefore not
460 marked with __THROW. */
461 extern int vscanf (__const char *__restrict __format, _G_va_list __arg)
462 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
464 /* Read formatted input from S into argument list ARG. */
465 extern int vsscanf (__const char *__restrict __s,
466 __const char *__restrict __format, _G_va_list __arg)
467 __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
469 # if !defined __USE_GNU \
470 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
471 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
472 # ifdef __REDIRECT
473 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
474 GNU extension which conflicts with valid %a followed by letter
475 s, S or [. */
476 extern int __REDIRECT (vfscanf,
477 (FILE *__restrict __s,
478 __const char *__restrict __format, _G_va_list __arg),
479 __isoc99_vfscanf)
480 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
481 extern int __REDIRECT (vscanf, (__const char *__restrict __format,
482 _G_va_list __arg), __isoc99_vscanf)
483 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
484 extern int __REDIRECT (vsscanf,
485 (__const char *__restrict __s,
486 __const char *__restrict __format, _G_va_list __arg),
487 __isoc99_vsscanf)
488 __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
489 # else
490 extern int __isoc99_vfscanf (FILE *__restrict __s,
491 __const char *__restrict __format,
492 _G_va_list __arg) __wur;
493 extern int __isoc99_vscanf (__const char *__restrict __format,
494 _G_va_list __arg) __wur;
495 extern int __isoc99_vsscanf (__const char *__restrict __s,
496 __const char *__restrict __format,
497 _G_va_list __arg) __THROW;
498 # define vfscanf __isoc99_vfscanf
499 # define vscanf __isoc99_vscanf
500 # define vsscanf __isoc99_vsscanf
501 # endif
502 # endif
504 __END_NAMESPACE_C99
505 #endif /* Use ISO C9x. */
508 __BEGIN_NAMESPACE_STD
509 /* Read a character from STREAM.
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);
516 /* Read a character from stdin.
518 This function is a possible cancellation point and therefore not
519 marked with __THROW. */
520 extern int getchar (void);
521 __END_NAMESPACE_STD
523 /* The C standard explicitly says this is a macro, so we always do the
524 optimization for it. */
525 #define getc(_fp) _IO_getc (_fp)
527 #if defined __USE_POSIX || defined __USE_MISC
528 /* These are defined in POSIX.1:1996.
530 These functions are possible cancellation points and therefore not
531 marked with __THROW. */
532 extern int getc_unlocked (FILE *__stream);
533 extern int getchar_unlocked (void);
534 #endif /* Use POSIX or MISC. */
536 #ifdef __USE_MISC
537 /* Faster version when locking is not necessary.
539 This function is not part of POSIX and therefore no official
540 cancellation point. But due to similarity with an POSIX interface
541 or due to the implementation it is a cancellation point and
542 therefore not marked with __THROW. */
543 extern int fgetc_unlocked (FILE *__stream);
544 #endif /* Use MISC. */
547 __BEGIN_NAMESPACE_STD
548 /* Write a character to STREAM.
550 These functions are possible cancellation points and therefore not
551 marked with __THROW.
553 These functions is a possible cancellation point and therefore not
554 marked with __THROW. */
555 extern int fputc (int __c, FILE *__stream);
556 extern int putc (int __c, FILE *__stream);
558 /* Write a character to stdout.
560 This function is a possible cancellation point and therefore not
561 marked with __THROW. */
562 extern int putchar (int __c);
563 __END_NAMESPACE_STD
565 /* The C standard explicitly says this can be a macro,
566 so we always do the optimization for it. */
567 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
569 #ifdef __USE_MISC
570 /* Faster version when locking is not necessary.
572 This function is not part of POSIX and therefore no official
573 cancellation point. But due to similarity with an POSIX interface
574 or due to the implementation it is a cancellation point and
575 therefore not marked with __THROW. */
576 extern int fputc_unlocked (int __c, FILE *__stream);
577 #endif /* Use MISC. */
579 #if defined __USE_POSIX || defined __USE_MISC
580 /* These are defined in POSIX.1:1996.
582 These functions are possible cancellation points and therefore not
583 marked with __THROW. */
584 extern int putc_unlocked (int __c, FILE *__stream);
585 extern int putchar_unlocked (int __c);
586 #endif /* Use POSIX or MISC. */
589 #if defined __USE_SVID || defined __USE_MISC \
590 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
591 /* Get a word (int) from STREAM. */
592 extern int getw (FILE *__stream);
594 /* Write a word (int) to STREAM. */
595 extern int putw (int __w, FILE *__stream);
596 #endif
599 __BEGIN_NAMESPACE_STD
600 /* Get a newline-terminated string of finite length from STREAM.
602 This function is a possible cancellation point and therefore not
603 marked with __THROW. */
604 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
605 __wur;
607 /* Get a newline-terminated string from stdin, removing the newline.
608 DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
610 This function is a possible cancellation point and therefore not
611 marked with __THROW. */
612 extern char *gets (char *__s) __wur;
613 __END_NAMESPACE_STD
615 #ifdef __USE_GNU
616 /* This function does the same as `fgets' but does not lock the stream.
618 This function is not part of POSIX and therefore no official
619 cancellation point. But due to similarity with an POSIX interface
620 or due to the implementation it is a cancellation point and
621 therefore not marked with __THROW. */
622 extern char *fgets_unlocked (char *__restrict __s, int __n,
623 FILE *__restrict __stream) __wur;
624 #endif
627 #ifdef __USE_XOPEN2K8
628 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
629 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
630 NULL), pointing to *N characters of space. It is realloc'd as
631 necessary. Returns the number of characters read (not including the
632 null terminator), or -1 on error or EOF.
634 These functions are not part of POSIX and therefore no official
635 cancellation point. But due to similarity with an POSIX interface
636 or due to the implementation they are cancellation points and
637 therefore not marked with __THROW. */
638 extern _IO_ssize_t __getdelim (char **__restrict __lineptr,
639 size_t *__restrict __n, int __delimiter,
640 FILE *__restrict __stream) __wur;
641 extern _IO_ssize_t getdelim (char **__restrict __lineptr,
642 size_t *__restrict __n, int __delimiter,
643 FILE *__restrict __stream) __wur;
645 /* Like `getdelim', but reads up to a newline.
647 This function is not part of POSIX and therefore no official
648 cancellation point. But due to similarity with an POSIX interface
649 or due to the implementation it is a cancellation point and
650 therefore not marked with __THROW. */
651 extern _IO_ssize_t getline (char **__restrict __lineptr,
652 size_t *__restrict __n,
653 FILE *__restrict __stream) __wur;
654 #endif
657 __BEGIN_NAMESPACE_STD
658 /* Write a string to STREAM.
660 This function is a possible cancellation points and therefore not
661 marked with __THROW. */
662 extern int fputs (__const char *__restrict __s, FILE *__restrict __stream);
664 /* Write a string, followed by a newline, to stdout.
666 This function is a possible cancellation points and therefore not
667 marked with __THROW. */
668 extern int puts (__const char *__s);
671 /* Push a character back onto the input buffer of STREAM.
673 This function is a possible cancellation points and therefore not
674 marked with __THROW. */
675 extern int ungetc (int __c, FILE *__stream);
678 /* Read chunks of generic data from STREAM.
680 This function is a possible cancellation points and therefore not
681 marked with __THROW. */
682 extern size_t fread (void *__restrict __ptr, size_t __size,
683 size_t __n, FILE *__restrict __stream) __wur;
684 /* Write chunks of generic data to STREAM.
686 This function is a possible cancellation points and therefore not
687 marked with __THROW. */
688 extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
689 size_t __n, FILE *__restrict __s) __wur;
690 __END_NAMESPACE_STD
692 #ifdef __USE_GNU
693 /* This function does the same as `fputs' but does not lock the stream.
695 This function is not part of POSIX and therefore no official
696 cancellation point. But due to similarity with an POSIX interface
697 or due to the implementation it is a cancellation point and
698 therefore not marked with __THROW. */
699 extern int fputs_unlocked (__const char *__restrict __s,
700 FILE *__restrict __stream);
701 #endif
703 #ifdef __USE_MISC
704 /* Faster versions when locking is not necessary.
706 These functions are not part of POSIX and therefore no official
707 cancellation point. But due to similarity with an POSIX interface
708 or due to the implementation they are cancellation points and
709 therefore not marked with __THROW. */
710 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
711 size_t __n, FILE *__restrict __stream) __wur;
712 extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
713 size_t __n, FILE *__restrict __stream) __wur;
714 #endif
717 __BEGIN_NAMESPACE_STD
718 /* Seek to a certain position on STREAM.
720 This function is a possible cancellation point and therefore not
721 marked with __THROW. */
722 extern int fseek (FILE *__stream, long int __off, int __whence);
723 /* Return the current position of STREAM.
725 This function is a possible cancellation point and therefore not
726 marked with __THROW. */
727 extern long int ftell (FILE *__stream) __wur;
728 /* Rewind to the beginning of STREAM.
730 This function is a possible cancellation point and therefore not
731 marked with __THROW. */
732 extern void rewind (FILE *__stream);
733 __END_NAMESPACE_STD
735 /* The Single Unix Specification, Version 2, specifies an alternative,
736 more adequate interface for the two functions above which deal with
737 file offset. `long int' is not the right type. These definitions
738 are originally defined in the Large File Support API. */
740 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
741 # ifndef __USE_FILE_OFFSET64
742 /* Seek to a certain position on STREAM.
744 This function is a possible cancellation point and therefore not
745 marked with __THROW. */
746 extern int fseeko (FILE *__stream, __off_t __off, int __whence);
747 /* Return the current position of STREAM.
749 This function is a possible cancellation point and therefore not
750 marked with __THROW. */
751 extern __off_t ftello (FILE *__stream) __wur;
752 # else
753 # ifdef __REDIRECT
754 extern int __REDIRECT (fseeko,
755 (FILE *__stream, __off64_t __off, int __whence),
756 fseeko64);
757 extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
758 # else
759 # define fseeko fseeko64
760 # define ftello ftello64
761 # endif
762 # endif
763 #endif
765 __BEGIN_NAMESPACE_STD
766 #ifndef __USE_FILE_OFFSET64
767 /* Get STREAM's position.
769 This function is a possible cancellation point and therefore not
770 marked with __THROW. */
771 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
772 /* Set STREAM's position.
774 This function is a possible cancellation point and therefore not
775 marked with __THROW. */
776 extern int fsetpos (FILE *__stream, __const fpos_t *__pos);
777 #else
778 # ifdef __REDIRECT
779 extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
780 fpos_t *__restrict __pos), fgetpos64);
781 extern int __REDIRECT (fsetpos,
782 (FILE *__stream, __const fpos_t *__pos), fsetpos64);
783 # else
784 # define fgetpos fgetpos64
785 # define fsetpos fsetpos64
786 # endif
787 #endif
788 __END_NAMESPACE_STD
790 #ifdef __USE_LARGEFILE64
791 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
792 extern __off64_t ftello64 (FILE *__stream) __wur;
793 extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
794 extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos);
795 #endif
797 __BEGIN_NAMESPACE_STD
798 /* Clear the error and EOF indicators for STREAM. */
799 extern void clearerr (FILE *__stream) __THROW;
800 /* Return the EOF indicator for STREAM. */
801 extern int feof (FILE *__stream) __THROW __wur;
802 /* Return the error indicator for STREAM. */
803 extern int ferror (FILE *__stream) __THROW __wur;
804 __END_NAMESPACE_STD
806 #ifdef __USE_MISC
807 /* Faster versions when locking is not required. */
808 extern void clearerr_unlocked (FILE *__stream) __THROW;
809 extern int feof_unlocked (FILE *__stream) __THROW __wur;
810 extern int ferror_unlocked (FILE *__stream) __THROW __wur;
811 #endif
814 __BEGIN_NAMESPACE_STD
815 /* Print a message describing the meaning of the value of errno.
817 This function is a possible cancellation point and therefore not
818 marked with __THROW. */
819 extern void perror (__const char *__s);
820 __END_NAMESPACE_STD
822 /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
823 are available on this system. Even if available, these variables
824 should not be used directly. The `strerror' function provides
825 all the necessary functionality. */
826 #include <bits/sys_errlist.h>
829 #ifdef __USE_POSIX
830 /* Return the system file descriptor for STREAM. */
831 extern int fileno (FILE *__stream) __THROW __wur;
832 #endif /* Use POSIX. */
834 #ifdef __USE_MISC
835 /* Faster version when locking is not required. */
836 extern int fileno_unlocked (FILE *__stream) __THROW __wur;
837 #endif
840 #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
841 defined __USE_MISC)
842 /* Create a new stream connected to a pipe running the given command.
844 This function is a possible cancellation point and therefore not
845 marked with __THROW. */
846 extern FILE *popen (__const char *__command, __const char *__modes) __wur;
848 /* Close a stream opened by popen and return the status of its child.
850 This function is a possible cancellation point and therefore not
851 marked with __THROW. */
852 extern int pclose (FILE *__stream);
853 #endif
856 #ifdef __USE_POSIX
857 /* Return the name of the controlling terminal. */
858 extern char *ctermid (char *__s) __THROW;
859 #endif /* Use POSIX. */
862 #ifdef __USE_XOPEN
863 /* Return the name of the current user. */
864 extern char *cuserid (char *__s);
865 #endif /* Use X/Open, but not issue 6. */
868 #ifdef __USE_GNU
869 struct obstack; /* See <obstack.h>. */
871 /* Write formatted output to an obstack. */
872 extern int obstack_printf (struct obstack *__restrict __obstack,
873 __const char *__restrict __format, ...)
874 __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
875 extern int obstack_vprintf (struct obstack *__restrict __obstack,
876 __const char *__restrict __format,
877 _G_va_list __args)
878 __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
879 #endif /* Use GNU. */
882 #if defined __USE_POSIX || defined __USE_MISC
883 /* These are defined in POSIX.1:1996. */
885 /* Acquire ownership of STREAM. */
886 extern void flockfile (FILE *__stream) __THROW;
888 /* Try to acquire ownership of STREAM but do not block if it is not
889 possible. */
890 extern int ftrylockfile (FILE *__stream) __THROW __wur;
892 /* Relinquish the ownership granted for STREAM. */
893 extern void funlockfile (FILE *__stream) __THROW;
894 #endif /* POSIX || misc */
896 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
897 /* The X/Open standard requires some functions and variables to be
898 declared here which do not belong into this header. But we have to
899 follow. In GNU mode we don't do this nonsense. */
900 # define __need_getopt
901 # include <getopt.h>
902 #endif /* X/Open, but not issue 6 and not for GNU. */
904 /* If we are compiling with optimizing read this file. It contains
905 several optimizing inline functions and macros. */
906 #ifdef __USE_EXTERN_INLINES
907 # include <bits/stdio.h>
908 #endif
909 #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
910 # include <bits/stdio2.h>
911 #endif
912 #ifdef __LDBL_COMPAT
913 # include <bits/stdio-ldbl.h>
914 #endif
916 __END_DECLS
918 #endif /* <stdio.h> included. */
920 #endif /* !_STDIO_H */