2.3.5-8
[glibc.git] / libio / stdio.h
blobac42b3e2ac7af97401777fe8dd6b46321434c612
1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991,1994-2004, 2005 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 __BEGIN_NAMESPACE_STD
45 /* The opaque type of streams. This is the definition used elsewhere. */
46 typedef struct _IO_FILE FILE;
47 __END_NAMESPACE_STD
48 #if defined __USE_LARGEFILE64 || defined __USE_SVID || defined __USE_POSIX \
49 || defined __USE_BSD || defined __USE_ISOC99 || defined __USE_XOPEN \
50 || defined __USE_POSIX2
51 __USING_NAMESPACE_STD(FILE)
52 #endif
54 # define __FILE_defined 1
55 #endif /* FILE not defined. */
56 #undef __need_FILE
59 #if !defined ____FILE_defined && defined __need___FILE
61 /* The opaque type of streams. This is the definition used elsewhere. */
62 typedef struct _IO_FILE __FILE;
64 # define ____FILE_defined 1
65 #endif /* __FILE not defined. */
66 #undef __need___FILE
69 #ifdef _STDIO_H
70 #define _STDIO_USES_IOSTREAM
72 #include <libio.h>
74 #ifdef __USE_XOPEN
75 # ifdef __GNUC__
76 # ifndef _VA_LIST_DEFINED
77 typedef _G_va_list va_list;
78 # define _VA_LIST_DEFINED
79 # endif
80 # else
81 # include <stdarg.h>
82 # endif
83 #endif
85 /* The type of the second argument to `fgetpos' and `fsetpos'. */
86 __BEGIN_NAMESPACE_STD
87 #ifndef __USE_FILE_OFFSET64
88 typedef _G_fpos_t fpos_t;
89 #else
90 typedef _G_fpos64_t fpos_t;
91 #endif
92 __END_NAMESPACE_STD
93 #ifdef __USE_LARGEFILE64
94 typedef _G_fpos64_t fpos64_t;
95 #endif
97 /* The possibilities for the third argument to `setvbuf'. */
98 #define _IOFBF 0 /* Fully buffered. */
99 #define _IOLBF 1 /* Line buffered. */
100 #define _IONBF 2 /* No buffering. */
103 /* Default buffer size. */
104 #ifndef BUFSIZ
105 # define BUFSIZ _IO_BUFSIZ
106 #endif
109 /* End of file character.
110 Some things throughout the library rely on this being -1. */
111 #ifndef EOF
112 # define EOF (-1)
113 #endif
116 /* The possibilities for the third argument to `fseek'.
117 These values should not be changed. */
118 #define SEEK_SET 0 /* Seek from beginning of file. */
119 #define SEEK_CUR 1 /* Seek from current position. */
120 #define SEEK_END 2 /* Seek from end of file. */
123 #if defined __USE_SVID || defined __USE_XOPEN
124 /* Default path prefix for `tempnam' and `tmpnam'. */
125 # define P_tmpdir "/tmp"
126 #endif
129 /* Get the values:
130 L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
131 TMP_MAX The minimum number of unique filenames generated by tmpnam
132 (and tempnam when it uses tmpnam's name space),
133 or tempnam (the two are separate).
134 L_ctermid How long an array to pass to `ctermid'.
135 L_cuserid How long an array to pass to `cuserid'.
136 FOPEN_MAX Minimum number of files that can be open at once.
137 FILENAME_MAX Maximum length of a filename. */
138 #include <bits/stdio_lim.h>
141 /* Standard streams. */
142 extern struct _IO_FILE *stdin; /* Standard input stream. */
143 extern struct _IO_FILE *stdout; /* Standard output stream. */
144 extern struct _IO_FILE *stderr; /* Standard error output stream. */
145 #ifdef __STDC__
146 /* C89/C99 say they're macros. Make them happy. */
147 #define stdin stdin
148 #define stdout stdout
149 #define stderr stderr
150 #endif
152 __BEGIN_NAMESPACE_STD
153 /* Remove file FILENAME. */
154 extern int remove (__const char *__filename) __THROW;
155 /* Rename file OLD to NEW. */
156 extern int rename (__const char *__old, __const char *__new) __THROW;
157 __END_NAMESPACE_STD
160 __BEGIN_NAMESPACE_STD
161 /* Create a temporary file and open it read/write.
163 This function is a possible cancellation points and therefore not
164 marked with __THROW. */
165 #ifndef __USE_FILE_OFFSET64
166 extern FILE *tmpfile (void);
167 #else
168 # ifdef __REDIRECT
169 extern FILE *__REDIRECT (tmpfile, (void), tmpfile64);
170 # else
171 # define tmpfile tmpfile64
172 # endif
173 #endif
175 #ifdef __USE_LARGEFILE64
176 extern FILE *tmpfile64 (void);
177 #endif
179 /* Generate a temporary filename. */
180 extern char *tmpnam (char *__s) __THROW;
181 __END_NAMESPACE_STD
183 #ifdef __USE_MISC
184 /* This is the reentrant variant of `tmpnam'. The only difference is
185 that it does not allow S to be NULL. */
186 extern char *tmpnam_r (char *__s) __THROW;
187 #endif
190 #if defined __USE_SVID || defined __USE_XOPEN
191 /* Generate a unique temporary filename using up to five characters of PFX
192 if it is not NULL. The directory to put this file in is searched for
193 as follows: First the environment variable "TMPDIR" is checked.
194 If it contains the name of a writable directory, that directory is used.
195 If not and if DIR is not NULL, that value is checked. If that fails,
196 P_tmpdir is tried and finally "/tmp". The storage for the filename
197 is allocated by `malloc'. */
198 extern char *tempnam (__const char *__dir, __const char *__pfx)
199 __THROW __attribute_malloc__;
200 #endif
203 __BEGIN_NAMESPACE_STD
204 /* Close STREAM.
206 This function is a possible cancellation point and therefore not
207 marked with __THROW. */
208 extern int fclose (FILE *__stream);
209 /* Flush STREAM, or all streams if STREAM is NULL.
211 This function is a possible cancellation point and therefore not
212 marked with __THROW. */
213 extern int fflush (FILE *__stream);
214 __END_NAMESPACE_STD
216 #ifdef __USE_MISC
217 /* Faster versions when locking is not required.
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 fflush_unlocked (FILE *__stream);
224 #endif
226 #ifdef __USE_GNU
227 /* Close all streams.
229 This function is not part of POSIX and therefore no official
230 cancellation point. But due to similarity with an POSIX interface
231 or due to the implementation it is a cancellation point and
232 therefore not marked with __THROW. */
233 extern int fcloseall (void);
234 #endif
237 __BEGIN_NAMESPACE_STD
238 #ifndef __USE_FILE_OFFSET64
239 /* Open a file and create a new stream for it.
241 This function is a possible cancellation point and therefore not
242 marked with __THROW. */
243 extern FILE *fopen (__const char *__restrict __filename,
244 __const char *__restrict __modes);
245 /* Open a file, replacing an existing stream with it.
247 This function is a possible cancellation point and therefore not
248 marked with __THROW. */
249 extern FILE *freopen (__const char *__restrict __filename,
250 __const char *__restrict __modes,
251 FILE *__restrict __stream);
252 #else
253 # ifdef __REDIRECT
254 extern FILE *__REDIRECT (fopen, (__const char *__restrict __filename,
255 __const char *__restrict __modes), fopen64);
256 extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
257 __const char *__restrict __modes,
258 FILE *__restrict __stream), freopen64);
259 # else
260 # define fopen fopen64
261 # define freopen freopen64
262 # endif
263 #endif
264 __END_NAMESPACE_STD
265 #ifdef __USE_LARGEFILE64
266 extern FILE *fopen64 (__const char *__restrict __filename,
267 __const char *__restrict __modes);
268 extern FILE *freopen64 (__const char *__restrict __filename,
269 __const char *__restrict __modes,
270 FILE *__restrict __stream);
271 #endif
273 #ifdef __USE_POSIX
274 /* Create a new stream that refers to an existing system file descriptor. */
275 extern FILE *fdopen (int __fd, __const char *__modes) __THROW;
276 #endif
278 #ifdef __USE_GNU
279 /* Create a new stream that refers to the given magic cookie,
280 and uses the given functions for input and output. */
281 extern FILE *fopencookie (void *__restrict __magic_cookie,
282 __const char *__restrict __modes,
283 _IO_cookie_io_functions_t __io_funcs) __THROW;
285 /* Create a new stream that refers to a memory buffer. */
286 extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes) __THROW;
288 /* Open a stream that writes into a malloc'd buffer that is expanded as
289 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
290 and the number of characters written on fflush or fclose. */
291 extern FILE *open_memstream (char **__restrict __bufloc,
292 size_t *__restrict __sizeloc) __THROW;
293 #endif
296 __BEGIN_NAMESPACE_STD
297 /* If BUF is NULL, make STREAM unbuffered.
298 Else make it use buffer BUF, of size BUFSIZ. */
299 extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
300 /* Make STREAM use buffering mode MODE.
301 If BUF is not NULL, use N bytes of it for buffering;
302 else allocate an internal buffer N bytes long. */
303 extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
304 int __modes, size_t __n) __THROW;
305 __END_NAMESPACE_STD
307 #ifdef __USE_BSD
308 /* If BUF is NULL, make STREAM unbuffered.
309 Else make it use SIZE bytes of BUF for buffering. */
310 extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
311 size_t __size) __THROW;
313 /* Make STREAM line-buffered. */
314 extern void setlinebuf (FILE *__stream) __THROW;
315 #endif
318 __BEGIN_NAMESPACE_STD
319 /* Write formatted output to STREAM.
321 This function is a possible cancellation point and therefore not
322 marked with __THROW. */
323 extern int fprintf (FILE *__restrict __stream,
324 __const char *__restrict __format, ...);
325 /* Write formatted output to stdout.
327 This function is a possible cancellation point and therefore not
328 marked with __THROW. */
329 extern int printf (__const char *__restrict __format, ...);
330 /* Write formatted output to S. */
331 extern int sprintf (char *__restrict __s,
332 __const char *__restrict __format, ...) __THROW;
334 /* Write formatted output to S from argument list ARG.
336 This function is a possible cancellation point and therefore not
337 marked with __THROW. */
338 extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
339 _G_va_list __arg);
340 /* Write formatted output to stdout from argument list ARG.
342 This function is a possible cancellation point and therefore not
343 marked with __THROW. */
344 extern int vprintf (__const char *__restrict __format, _G_va_list __arg);
345 /* Write formatted output to S from argument list ARG. */
346 extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
347 _G_va_list __arg) __THROW;
348 __END_NAMESPACE_STD
350 #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
351 __BEGIN_NAMESPACE_C99
352 /* Maximum chars of output to write in MAXLEN. */
353 extern int snprintf (char *__restrict __s, size_t __maxlen,
354 __const char *__restrict __format, ...)
355 __THROW __attribute__ ((__format__ (__printf__, 3, 4)));
357 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
358 __const char *__restrict __format, _G_va_list __arg)
359 __THROW __attribute__ ((__format__ (__printf__, 3, 0)));
360 __END_NAMESPACE_C99
361 #endif
363 #ifdef __USE_GNU
364 /* Write formatted output to a string dynamically allocated with `malloc'.
365 Store the address of the string in *PTR. */
366 extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f,
367 _G_va_list __arg)
368 __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
369 extern int __asprintf (char **__restrict __ptr,
370 __const char *__restrict __fmt, ...)
371 __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
372 extern int asprintf (char **__restrict __ptr,
373 __const char *__restrict __fmt, ...)
374 __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
376 /* Write formatted output to a file descriptor.
378 These functions are not part of POSIX and therefore no official
379 cancellation point. But due to similarity with an POSIX interface
380 or due to the implementation they are cancellation points and
381 therefore not marked with __THROW. */
382 extern int vdprintf (int __fd, __const char *__restrict __fmt,
383 _G_va_list __arg)
384 __attribute__ ((__format__ (__printf__, 2, 0)));
385 extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
386 __attribute__ ((__format__ (__printf__, 2, 3)));
387 #endif
390 __BEGIN_NAMESPACE_STD
391 /* Read formatted input from STREAM.
393 This function is a possible cancellation point and therefore not
394 marked with __THROW. */
395 extern int fscanf (FILE *__restrict __stream,
396 __const char *__restrict __format, ...) __wur;
397 /* Read formatted input from stdin.
399 This function is a possible cancellation point and therefore not
400 marked with __THROW. */
401 extern int scanf (__const char *__restrict __format, ...) __wur;
402 /* Read formatted input from S. */
403 extern int sscanf (__const char *__restrict __s,
404 __const char *__restrict __format, ...) __THROW __wur;
405 __END_NAMESPACE_STD
407 #ifdef __USE_ISOC99
408 __BEGIN_NAMESPACE_C99
409 /* Read formatted input from S into argument list ARG.
411 This function is a possible cancellation point and therefore not
412 marked with __THROW. */
413 extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
414 _G_va_list __arg)
415 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
417 /* Read formatted input from stdin into argument list ARG.
419 This function is a possible cancellation point and therefore not
420 marked with __THROW. */
421 extern int vscanf (__const char *__restrict __format, _G_va_list __arg)
422 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
424 /* Read formatted input from S into argument list ARG. */
425 extern int vsscanf (__const char *__restrict __s,
426 __const char *__restrict __format, _G_va_list __arg)
427 __THROW __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
428 __END_NAMESPACE_C99
429 #endif /* Use ISO C9x. */
432 __BEGIN_NAMESPACE_STD
433 /* Read a character from STREAM.
435 These functions are possible cancellation points and therefore not
436 marked with __THROW. */
437 extern int fgetc (FILE *__stream);
438 extern int getc (FILE *__stream);
440 /* Read a character from stdin.
442 This function is a possible cancellation point and therefore not
443 marked with __THROW. */
444 extern int getchar (void);
445 __END_NAMESPACE_STD
447 /* The C standard explicitly says this is a macro, so we always do the
448 optimization for it. */
449 #define getc(_fp) _IO_getc (_fp)
451 #if defined __USE_POSIX || defined __USE_MISC
452 /* These are defined in POSIX.1:1996.
454 These functions are possible cancellation points and therefore not
455 marked with __THROW. */
456 extern int getc_unlocked (FILE *__stream);
457 extern int getchar_unlocked (void);
458 #endif /* Use POSIX or MISC. */
460 #ifdef __USE_MISC
461 /* Faster version when locking is not necessary.
463 This function is not part of POSIX and therefore no official
464 cancellation point. But due to similarity with an POSIX interface
465 or due to the implementation it is a cancellation point and
466 therefore not marked with __THROW. */
467 extern int fgetc_unlocked (FILE *__stream);
468 #endif /* Use MISC. */
471 __BEGIN_NAMESPACE_STD
472 /* Write a character to STREAM.
474 These functions are possible cancellation points and therefore not
475 marked with __THROW.
477 These functions is a possible cancellation point and therefore not
478 marked with __THROW. */
479 extern int fputc (int __c, FILE *__stream);
480 extern int putc (int __c, FILE *__stream);
482 /* Write a character to stdout.
484 This function is a possible cancellation point and therefore not
485 marked with __THROW. */
486 extern int putchar (int __c);
487 __END_NAMESPACE_STD
489 /* The C standard explicitly says this can be a macro,
490 so we always do the optimization for it. */
491 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
493 #ifdef __USE_MISC
494 /* Faster version when locking is not necessary.
496 This function is not part of POSIX and therefore no official
497 cancellation point. But due to similarity with an POSIX interface
498 or due to the implementation it is a cancellation point and
499 therefore not marked with __THROW. */
500 extern int fputc_unlocked (int __c, FILE *__stream);
501 #endif /* Use MISC. */
503 #if defined __USE_POSIX || defined __USE_MISC
504 /* These are defined in POSIX.1:1996.
506 These functions are possible cancellation points and therefore not
507 marked with __THROW. */
508 extern int putc_unlocked (int __c, FILE *__stream);
509 extern int putchar_unlocked (int __c);
510 #endif /* Use POSIX or MISC. */
513 #if defined __USE_SVID || defined __USE_MISC \
514 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
515 /* Get a word (int) from STREAM. */
516 extern int getw (FILE *__stream);
518 /* Write a word (int) to STREAM. */
519 extern int putw (int __w, FILE *__stream);
520 #endif
523 __BEGIN_NAMESPACE_STD
524 /* Get a newline-terminated string of finite length from STREAM.
526 This function is a possible cancellation point and therefore not
527 marked with __THROW. */
528 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
529 __wur;
531 /* Get a newline-terminated string from stdin, removing the newline.
532 DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
534 This function is a possible cancellation point and therefore not
535 marked with __THROW. */
536 extern char *gets (char *__s) __wur;
537 __END_NAMESPACE_STD
539 #ifdef __USE_GNU
540 /* This function does the same as `fgets' but does not lock the stream.
542 This function is not part of POSIX and therefore no official
543 cancellation point. But due to similarity with an POSIX interface
544 or due to the implementation it is a cancellation point and
545 therefore not marked with __THROW. */
546 extern char *fgets_unlocked (char *__restrict __s, int __n,
547 FILE *__restrict __stream) __wur;
548 #endif
551 #ifdef __USE_GNU
552 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
553 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
554 NULL), pointing to *N characters of space. It is realloc'd as
555 necessary. Returns the number of characters read (not including the
556 null terminator), or -1 on error or EOF.
558 These functions are not part of POSIX and therefore no official
559 cancellation point. But due to similarity with an POSIX interface
560 or due to the implementation they are cancellation points and
561 therefore not marked with __THROW. */
562 extern _IO_ssize_t __getdelim (char **__restrict __lineptr,
563 size_t *__restrict __n, int __delimiter,
564 FILE *__restrict __stream) __wur;
565 extern _IO_ssize_t getdelim (char **__restrict __lineptr,
566 size_t *__restrict __n, int __delimiter,
567 FILE *__restrict __stream) __wur;
569 /* Like `getdelim', but reads up to a newline.
571 This function is not part of POSIX and therefore no official
572 cancellation point. But due to similarity with an POSIX interface
573 or due to the implementation it is a cancellation point and
574 therefore not marked with __THROW. */
575 extern _IO_ssize_t getline (char **__restrict __lineptr,
576 size_t *__restrict __n,
577 FILE *__restrict __stream) __wur;
578 #endif
581 __BEGIN_NAMESPACE_STD
582 /* Write a string to STREAM.
584 This function is a possible cancellation points and therefore not
585 marked with __THROW. */
586 extern int fputs (__const char *__restrict __s, FILE *__restrict __stream);
588 /* Write a string, followed by a newline, to stdout.
590 This function is a possible cancellation points and therefore not
591 marked with __THROW. */
592 extern int puts (__const char *__s);
595 /* Push a character back onto the input buffer of STREAM.
597 This function is a possible cancellation points and therefore not
598 marked with __THROW. */
599 extern int ungetc (int __c, FILE *__stream) __wur;
602 /* Read chunks of generic data from STREAM.
604 This function is a possible cancellation points and therefore not
605 marked with __THROW. */
606 extern size_t fread (void *__restrict __ptr, size_t __size,
607 size_t __n, FILE *__restrict __stream) __wur;
608 /* Write chunks of generic data to STREAM.
610 This function is a possible cancellation points and therefore not
611 marked with __THROW. */
612 extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
613 size_t __n, FILE *__restrict __s) __wur;
614 __END_NAMESPACE_STD
616 #ifdef __USE_GNU
617 /* This function does the same as `fputs' but does not lock the stream.
619 This function is not part of POSIX and therefore no official
620 cancellation point. But due to similarity with an POSIX interface
621 or due to the implementation it is a cancellation point and
622 therefore not marked with __THROW. */
623 extern int fputs_unlocked (__const char *__restrict __s,
624 FILE *__restrict __stream);
625 #endif
627 #ifdef __USE_MISC
628 /* Faster versions when locking is not necessary.
630 These functions are not part of POSIX and therefore no official
631 cancellation point. But due to similarity with an POSIX interface
632 or due to the implementation they are cancellation points and
633 therefore not marked with __THROW. */
634 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
635 size_t __n, FILE *__restrict __stream) __wur;
636 extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
637 size_t __n, FILE *__restrict __stream) __wur;
638 #endif
641 __BEGIN_NAMESPACE_STD
642 /* Seek to a certain position on STREAM.
644 This function is a possible cancellation point and therefore not
645 marked with __THROW. */
646 extern int fseek (FILE *__stream, long int __off, int __whence);
647 /* Return the current position of STREAM.
649 This function is a possible cancellation point and therefore not
650 marked with __THROW. */
651 extern long int ftell (FILE *__stream) __wur;
652 /* Rewind to the beginning of STREAM.
654 This function is a possible cancellation point and therefore not
655 marked with __THROW. */
656 extern void rewind (FILE *__stream);
657 __END_NAMESPACE_STD
659 /* The Single Unix Specification, Version 2, specifies an alternative,
660 more adequate interface for the two functions above which deal with
661 file offset. `long int' is not the right type. These definitions
662 are originally defined in the Large File Support API. */
664 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
665 # ifndef __USE_FILE_OFFSET64
666 /* Seek to a certain position on STREAM.
668 This function is a possible cancellation point and therefore not
669 marked with __THROW. */
670 extern int fseeko (FILE *__stream, __off_t __off, int __whence);
671 /* Return the current position of STREAM.
673 This function is a possible cancellation point and therefore not
674 marked with __THROW. */
675 extern __off_t ftello (FILE *__stream) __wur;
676 # else
677 # ifdef __REDIRECT
678 extern int __REDIRECT (fseeko,
679 (FILE *__stream, __off64_t __off, int __whence),
680 fseeko64);
681 extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
682 # else
683 # define fseeko fseeko64
684 # define ftello ftello64
685 # endif
686 # endif
687 #endif
689 __BEGIN_NAMESPACE_STD
690 #ifndef __USE_FILE_OFFSET64
691 /* Get STREAM's position.
693 This function is a possible cancellation point and therefore not
694 marked with __THROW. */
695 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
696 /* Set STREAM's position.
698 This function is a possible cancellation point and therefore not
699 marked with __THROW. */
700 extern int fsetpos (FILE *__stream, __const fpos_t *__pos);
701 #else
702 # ifdef __REDIRECT
703 extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
704 fpos_t *__restrict __pos), fgetpos64);
705 extern int __REDIRECT (fsetpos,
706 (FILE *__stream, __const fpos_t *__pos), fsetpos64);
707 # else
708 # define fgetpos fgetpos64
709 # define fsetpos fsetpos64
710 # endif
711 #endif
712 __END_NAMESPACE_STD
714 #ifdef __USE_LARGEFILE64
715 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
716 extern __off64_t ftello64 (FILE *__stream) __wur;
717 extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
718 extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos);
719 #endif
721 __BEGIN_NAMESPACE_STD
722 /* Clear the error and EOF indicators for STREAM. */
723 extern void clearerr (FILE *__stream) __THROW;
724 /* Return the EOF indicator for STREAM. */
725 extern int feof (FILE *__stream) __THROW;
726 /* Return the error indicator for STREAM. */
727 extern int ferror (FILE *__stream) __THROW;
728 __END_NAMESPACE_STD
730 #ifdef __USE_MISC
731 /* Faster versions when locking is not required. */
732 extern void clearerr_unlocked (FILE *__stream) __THROW;
733 extern int feof_unlocked (FILE *__stream) __THROW;
734 extern int ferror_unlocked (FILE *__stream) __THROW;
735 #endif
738 __BEGIN_NAMESPACE_STD
739 /* Print a message describing the meaning of the value of errno.
741 This function is a possible cancellation point and therefore not
742 marked with __THROW. */
743 extern void perror (__const char *__s);
744 __END_NAMESPACE_STD
746 /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
747 are available on this system. Even if available, these variables
748 should not be used directly. The `strerror' function provides
749 all the necessary functionality. */
750 #include <bits/sys_errlist.h>
753 #ifdef __USE_POSIX
754 /* Return the system file descriptor for STREAM. */
755 extern int fileno (FILE *__stream) __THROW;
756 #endif /* Use POSIX. */
758 #ifdef __USE_MISC
759 /* Faster version when locking is not required. */
760 extern int fileno_unlocked (FILE *__stream) __THROW;
761 #endif
764 #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
765 defined __USE_MISC)
766 /* Create a new stream connected to a pipe running the given command.
768 This function is a possible cancellation point and therefore not
769 marked with __THROW. */
770 extern FILE *popen (__const char *__command, __const char *__modes);
772 /* Close a stream opened by popen and return the status of its child.
774 This function is a possible cancellation point and therefore not
775 marked with __THROW. */
776 extern int pclose (FILE *__stream);
777 #endif
780 #ifdef __USE_POSIX
781 /* Return the name of the controlling terminal. */
782 extern char *ctermid (char *__s) __THROW;
783 #endif /* Use POSIX. */
786 #ifdef __USE_XOPEN
787 /* Return the name of the current user. */
788 extern char *cuserid (char *__s);
789 #endif /* Use X/Open, but not issue 6. */
792 #ifdef __USE_GNU
793 struct obstack; /* See <obstack.h>. */
795 /* Write formatted output to an obstack. */
796 extern int obstack_printf (struct obstack *__restrict __obstack,
797 __const char *__restrict __format, ...)
798 __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
799 extern int obstack_vprintf (struct obstack *__restrict __obstack,
800 __const char *__restrict __format,
801 _G_va_list __args)
802 __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
803 #endif /* Use GNU. */
806 #if defined __USE_POSIX || defined __USE_MISC
807 /* These are defined in POSIX.1:1996. */
809 /* Acquire ownership of STREAM. */
810 extern void flockfile (FILE *__stream) __THROW;
812 /* Try to acquire ownership of STREAM but do not block if it is not
813 possible. */
814 extern int ftrylockfile (FILE *__stream) __THROW __wur;
816 /* Relinquish the ownership granted for STREAM. */
817 extern void funlockfile (FILE *__stream) __THROW;
818 #endif /* POSIX || misc */
820 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
821 /* The X/Open standard requires some functions and variables to be
822 declared here which do not belong into this header. But we have to
823 follow. In GNU mode we don't do this nonsense. */
824 # define __need_getopt
825 # include <getopt.h>
826 #endif /* X/Open, but not issue 6 and not for GNU. */
828 /* If we are compiling with optimizing read this file. It contains
829 several optimizing inline functions and macros. */
830 #ifdef __USE_EXTERN_INLINES
831 # include <bits/stdio.h>
832 #endif
833 #if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus
834 # include <bits/stdio2.h>
835 #endif
837 __END_DECLS
839 #endif /* <stdio.h> included. */
841 #endif /* !_STDIO_H */