.
[glibc.git] / libio / stdio.h
blob5e74305638397490afe71636c7308daa882e7899
1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991,1994-2004,2005,2006 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 /* C89/C99 say they're macros. Make them happy. */
146 #define stdin stdin
147 #define stdout stdout
148 #define stderr stderr
150 __BEGIN_NAMESPACE_STD
151 /* Remove file FILENAME. */
152 extern int remove (__const char *__filename) __THROW;
153 /* Rename file OLD to NEW. */
154 extern int rename (__const char *__old, __const char *__new) __THROW;
155 __END_NAMESPACE_STD
157 #ifdef __USE_ATFILE
158 /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
159 extern int renameat (int __oldfd, __const char *__old, int __newfd,
160 __const char *__new) __THROW;
161 #endif
163 __BEGIN_NAMESPACE_STD
164 /* Create a temporary file and open it read/write.
166 This function is a possible cancellation points and therefore not
167 marked with __THROW. */
168 #ifndef __USE_FILE_OFFSET64
169 extern FILE *tmpfile (void);
170 #else
171 # ifdef __REDIRECT
172 extern FILE *__REDIRECT (tmpfile, (void), tmpfile64);
173 # else
174 # define tmpfile tmpfile64
175 # endif
176 #endif
178 #ifdef __USE_LARGEFILE64
179 extern FILE *tmpfile64 (void);
180 #endif
182 /* Generate a temporary filename. */
183 extern char *tmpnam (char *__s) __THROW;
184 __END_NAMESPACE_STD
186 #ifdef __USE_MISC
187 /* This is the reentrant variant of `tmpnam'. The only difference is
188 that it does not allow S to be NULL. */
189 extern char *tmpnam_r (char *__s) __THROW;
190 #endif
193 #if defined __USE_SVID || defined __USE_XOPEN
194 /* Generate a unique temporary filename using up to five characters of PFX
195 if it is not NULL. The directory to put this file in is searched for
196 as follows: First the environment variable "TMPDIR" is checked.
197 If it contains the name of a writable directory, that directory is used.
198 If not and if DIR is not NULL, that value is checked. If that fails,
199 P_tmpdir is tried and finally "/tmp". The storage for the filename
200 is allocated by `malloc'. */
201 extern char *tempnam (__const char *__dir, __const char *__pfx)
202 __THROW __attribute_malloc__;
203 #endif
206 __BEGIN_NAMESPACE_STD
207 /* Close STREAM.
209 This function is a possible cancellation point and therefore not
210 marked with __THROW. */
211 extern int fclose (FILE *__stream);
212 /* Flush STREAM, or all streams if STREAM is NULL.
214 This function is a possible cancellation point and therefore not
215 marked with __THROW. */
216 extern int fflush (FILE *__stream);
217 __END_NAMESPACE_STD
219 #ifdef __USE_MISC
220 /* Faster versions when locking is not required.
222 This function is not part of POSIX and therefore no official
223 cancellation point. But due to similarity with an POSIX interface
224 or due to the implementation it is a cancellation point and
225 therefore not marked with __THROW. */
226 extern int fflush_unlocked (FILE *__stream);
227 #endif
229 #ifdef __USE_GNU
230 /* Close all streams.
232 This function is not part of POSIX and therefore no official
233 cancellation point. But due to similarity with an POSIX interface
234 or due to the implementation it is a cancellation point and
235 therefore not marked with __THROW. */
236 extern int fcloseall (void);
237 #endif
240 __BEGIN_NAMESPACE_STD
241 #ifndef __USE_FILE_OFFSET64
242 /* Open a file and create a new stream for it.
244 This function is a possible cancellation point and therefore not
245 marked with __THROW. */
246 extern FILE *fopen (__const char *__restrict __filename,
247 __const char *__restrict __modes);
248 /* Open a file, replacing an existing stream with it.
250 This function is a possible cancellation point and therefore not
251 marked with __THROW. */
252 extern FILE *freopen (__const char *__restrict __filename,
253 __const char *__restrict __modes,
254 FILE *__restrict __stream);
255 #else
256 # ifdef __REDIRECT
257 extern FILE *__REDIRECT (fopen, (__const char *__restrict __filename,
258 __const char *__restrict __modes), fopen64);
259 extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
260 __const char *__restrict __modes,
261 FILE *__restrict __stream), freopen64);
262 # else
263 # define fopen fopen64
264 # define freopen freopen64
265 # endif
266 #endif
267 __END_NAMESPACE_STD
268 #ifdef __USE_LARGEFILE64
269 extern FILE *fopen64 (__const char *__restrict __filename,
270 __const char *__restrict __modes);
271 extern FILE *freopen64 (__const char *__restrict __filename,
272 __const char *__restrict __modes,
273 FILE *__restrict __stream);
274 #endif
276 #ifdef __USE_POSIX
277 /* Create a new stream that refers to an existing system file descriptor. */
278 extern FILE *fdopen (int __fd, __const char *__modes) __THROW;
279 #endif
281 #ifdef __USE_GNU
282 /* Create a new stream that refers to the given magic cookie,
283 and uses the given functions for input and output. */
284 extern FILE *fopencookie (void *__restrict __magic_cookie,
285 __const char *__restrict __modes,
286 _IO_cookie_io_functions_t __io_funcs) __THROW;
288 /* Create a new stream that refers to a memory buffer. */
289 extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes) __THROW;
291 /* Open a stream that writes into a malloc'd buffer that is expanded as
292 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
293 and the number of characters written on fflush or fclose. */
294 extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW;
295 #endif
298 __BEGIN_NAMESPACE_STD
299 /* If BUF is NULL, make STREAM unbuffered.
300 Else make it use buffer BUF, of size BUFSIZ. */
301 extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
302 /* Make STREAM use buffering mode MODE.
303 If BUF is not NULL, use N bytes of it for buffering;
304 else allocate an internal buffer N bytes long. */
305 extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
306 int __modes, size_t __n) __THROW;
307 __END_NAMESPACE_STD
309 #ifdef __USE_BSD
310 /* If BUF is NULL, make STREAM unbuffered.
311 Else make it use SIZE bytes of BUF for buffering. */
312 extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
313 size_t __size) __THROW;
315 /* Make STREAM line-buffered. */
316 extern void setlinebuf (FILE *__stream) __THROW;
317 #endif
320 __BEGIN_NAMESPACE_STD
321 /* Write formatted output to STREAM.
323 This function is a possible cancellation point and therefore not
324 marked with __THROW. */
325 extern int fprintf (FILE *__restrict __stream,
326 __const char *__restrict __format, ...);
327 /* Write formatted output to stdout.
329 This function is a possible cancellation point and therefore not
330 marked with __THROW. */
331 extern int printf (__const char *__restrict __format, ...);
332 /* Write formatted output to S. */
333 extern int sprintf (char *__restrict __s,
334 __const char *__restrict __format, ...) __THROW;
336 /* Write formatted output to S from argument list ARG.
338 This function is a possible cancellation point and therefore not
339 marked with __THROW. */
340 extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
341 _G_va_list __arg);
342 /* Write formatted output to stdout from argument list ARG.
344 This function is a possible cancellation point and therefore not
345 marked with __THROW. */
346 extern int vprintf (__const char *__restrict __format, _G_va_list __arg);
347 /* Write formatted output to S from argument list ARG. */
348 extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
349 _G_va_list __arg) __THROW;
350 __END_NAMESPACE_STD
352 #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
353 __BEGIN_NAMESPACE_C99
354 /* Maximum chars of output to write in MAXLEN. */
355 extern int snprintf (char *__restrict __s, size_t __maxlen,
356 __const char *__restrict __format, ...)
357 __THROW __attribute__ ((__format__ (__printf__, 3, 4)));
359 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
360 __const char *__restrict __format, _G_va_list __arg)
361 __THROW __attribute__ ((__format__ (__printf__, 3, 0)));
362 __END_NAMESPACE_C99
363 #endif
365 #ifdef __USE_GNU
366 /* Write formatted output to a string dynamically allocated with `malloc'.
367 Store the address of the string in *PTR. */
368 extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f,
369 _G_va_list __arg)
370 __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
371 extern int __asprintf (char **__restrict __ptr,
372 __const char *__restrict __fmt, ...)
373 __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
374 extern int asprintf (char **__restrict __ptr,
375 __const char *__restrict __fmt, ...)
376 __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
378 /* Write formatted output to a file descriptor.
380 These functions are not part of POSIX and therefore no official
381 cancellation point. But due to similarity with an POSIX interface
382 or due to the implementation they are cancellation points and
383 therefore not marked with __THROW. */
384 extern int vdprintf (int __fd, __const char *__restrict __fmt,
385 _G_va_list __arg)
386 __attribute__ ((__format__ (__printf__, 2, 0)));
387 extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
388 __attribute__ ((__format__ (__printf__, 2, 3)));
389 #endif
392 __BEGIN_NAMESPACE_STD
393 /* Read formatted input from STREAM.
395 This function is a possible cancellation point and therefore not
396 marked with __THROW. */
397 extern int fscanf (FILE *__restrict __stream,
398 __const char *__restrict __format, ...) __wur;
399 /* Read formatted input from stdin.
401 This function is a possible cancellation point and therefore not
402 marked with __THROW. */
403 extern int scanf (__const char *__restrict __format, ...) __wur;
404 /* Read formatted input from S. */
405 extern int sscanf (__const char *__restrict __s,
406 __const char *__restrict __format, ...) __THROW;
407 __END_NAMESPACE_STD
409 #ifdef __USE_ISOC99
410 __BEGIN_NAMESPACE_C99
411 /* Read formatted input from S into argument list ARG.
413 This function is a possible cancellation point and therefore not
414 marked with __THROW. */
415 extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
416 _G_va_list __arg)
417 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
419 /* Read formatted input from stdin into argument list ARG.
421 This function is a possible cancellation point and therefore not
422 marked with __THROW. */
423 extern int vscanf (__const char *__restrict __format, _G_va_list __arg)
424 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
426 /* Read formatted input from S into argument list ARG. */
427 extern int vsscanf (__const char *__restrict __s,
428 __const char *__restrict __format, _G_va_list __arg)
429 __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
430 __END_NAMESPACE_C99
431 #endif /* Use ISO C9x. */
434 __BEGIN_NAMESPACE_STD
435 /* Read a character from STREAM.
437 These functions are possible cancellation points and therefore not
438 marked with __THROW. */
439 extern int fgetc (FILE *__stream);
440 extern int getc (FILE *__stream);
442 /* Read a character from stdin.
444 This function is a possible cancellation point and therefore not
445 marked with __THROW. */
446 extern int getchar (void);
447 __END_NAMESPACE_STD
449 /* The C standard explicitly says this is a macro, so we always do the
450 optimization for it. */
451 #define getc(_fp) _IO_getc (_fp)
453 #if defined __USE_POSIX || defined __USE_MISC
454 /* These are defined in POSIX.1:1996.
456 These functions are possible cancellation points and therefore not
457 marked with __THROW. */
458 extern int getc_unlocked (FILE *__stream);
459 extern int getchar_unlocked (void);
460 #endif /* Use POSIX or MISC. */
462 #ifdef __USE_MISC
463 /* Faster version when locking is not necessary.
465 This function is not part of POSIX and therefore no official
466 cancellation point. But due to similarity with an POSIX interface
467 or due to the implementation it is a cancellation point and
468 therefore not marked with __THROW. */
469 extern int fgetc_unlocked (FILE *__stream);
470 #endif /* Use MISC. */
473 __BEGIN_NAMESPACE_STD
474 /* Write a character to STREAM.
476 These functions are possible cancellation points and therefore not
477 marked with __THROW.
479 These functions is a possible cancellation point and therefore not
480 marked with __THROW. */
481 extern int fputc (int __c, FILE *__stream);
482 extern int putc (int __c, FILE *__stream);
484 /* Write a character to stdout.
486 This function is a possible cancellation point and therefore not
487 marked with __THROW. */
488 extern int putchar (int __c);
489 __END_NAMESPACE_STD
491 /* The C standard explicitly says this can be a macro,
492 so we always do the optimization for it. */
493 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
495 #ifdef __USE_MISC
496 /* Faster version when locking is not necessary.
498 This function is not part of POSIX and therefore no official
499 cancellation point. But due to similarity with an POSIX interface
500 or due to the implementation it is a cancellation point and
501 therefore not marked with __THROW. */
502 extern int fputc_unlocked (int __c, FILE *__stream);
503 #endif /* Use MISC. */
505 #if defined __USE_POSIX || defined __USE_MISC
506 /* These are defined in POSIX.1:1996.
508 These functions are possible cancellation points and therefore not
509 marked with __THROW. */
510 extern int putc_unlocked (int __c, FILE *__stream);
511 extern int putchar_unlocked (int __c);
512 #endif /* Use POSIX or MISC. */
515 #if defined __USE_SVID || defined __USE_MISC \
516 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
517 /* Get a word (int) from STREAM. */
518 extern int getw (FILE *__stream);
520 /* Write a word (int) to STREAM. */
521 extern int putw (int __w, FILE *__stream);
522 #endif
525 __BEGIN_NAMESPACE_STD
526 /* Get a newline-terminated string of finite length from STREAM.
528 This function is a possible cancellation point and therefore not
529 marked with __THROW. */
530 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
531 __wur;
533 /* Get a newline-terminated string from stdin, removing the newline.
534 DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
536 This function is a possible cancellation point and therefore not
537 marked with __THROW. */
538 extern char *gets (char *__s) __wur;
539 __END_NAMESPACE_STD
541 #ifdef __USE_GNU
542 /* This function does the same as `fgets' but does not lock the stream.
544 This function is not part of POSIX and therefore no official
545 cancellation point. But due to similarity with an POSIX interface
546 or due to the implementation it is a cancellation point and
547 therefore not marked with __THROW. */
548 extern char *fgets_unlocked (char *__restrict __s, int __n,
549 FILE *__restrict __stream) __wur;
550 #endif
553 #ifdef __USE_GNU
554 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
555 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
556 NULL), pointing to *N characters of space. It is realloc'd as
557 necessary. Returns the number of characters read (not including the
558 null terminator), or -1 on error or EOF.
560 These functions are 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 they are cancellation points and
563 therefore not marked with __THROW. */
564 extern _IO_ssize_t __getdelim (char **__restrict __lineptr,
565 size_t *__restrict __n, int __delimiter,
566 FILE *__restrict __stream) __wur;
567 extern _IO_ssize_t getdelim (char **__restrict __lineptr,
568 size_t *__restrict __n, int __delimiter,
569 FILE *__restrict __stream) __wur;
571 /* Like `getdelim', but reads up to a newline.
573 This function is not part of POSIX and therefore no official
574 cancellation point. But due to similarity with an POSIX interface
575 or due to the implementation it is a cancellation point and
576 therefore not marked with __THROW. */
577 extern _IO_ssize_t getline (char **__restrict __lineptr,
578 size_t *__restrict __n,
579 FILE *__restrict __stream) __wur;
580 #endif
583 __BEGIN_NAMESPACE_STD
584 /* Write a string to STREAM.
586 This function is a possible cancellation points and therefore not
587 marked with __THROW. */
588 extern int fputs (__const char *__restrict __s, FILE *__restrict __stream);
590 /* Write a string, followed by a newline, to stdout.
592 This function is a possible cancellation points and therefore not
593 marked with __THROW. */
594 extern int puts (__const char *__s);
597 /* Push a character back onto the input buffer of STREAM.
599 This function is a possible cancellation points and therefore not
600 marked with __THROW. */
601 extern int ungetc (int __c, FILE *__stream);
604 /* Read chunks of generic data from STREAM.
606 This function is a possible cancellation points and therefore not
607 marked with __THROW. */
608 extern size_t fread (void *__restrict __ptr, size_t __size,
609 size_t __n, FILE *__restrict __stream) __wur;
610 /* Write chunks of generic data to STREAM.
612 This function is a possible cancellation points and therefore not
613 marked with __THROW. */
614 extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
615 size_t __n, FILE *__restrict __s) __wur;
616 __END_NAMESPACE_STD
618 #ifdef __USE_GNU
619 /* This function does the same as `fputs' but does not lock the stream.
621 This function is not part of POSIX and therefore no official
622 cancellation point. But due to similarity with an POSIX interface
623 or due to the implementation it is a cancellation point and
624 therefore not marked with __THROW. */
625 extern int fputs_unlocked (__const char *__restrict __s,
626 FILE *__restrict __stream);
627 #endif
629 #ifdef __USE_MISC
630 /* Faster versions when locking is not necessary.
632 These functions are not part of POSIX and therefore no official
633 cancellation point. But due to similarity with an POSIX interface
634 or due to the implementation they are cancellation points and
635 therefore not marked with __THROW. */
636 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
637 size_t __n, FILE *__restrict __stream) __wur;
638 extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
639 size_t __n, FILE *__restrict __stream) __wur;
640 #endif
643 __BEGIN_NAMESPACE_STD
644 /* Seek to a certain position on STREAM.
646 This function is a possible cancellation point and therefore not
647 marked with __THROW. */
648 extern int fseek (FILE *__stream, long int __off, int __whence);
649 /* Return the current position of STREAM.
651 This function is a possible cancellation point and therefore not
652 marked with __THROW. */
653 extern long int ftell (FILE *__stream) __wur;
654 /* Rewind to the beginning of STREAM.
656 This function is a possible cancellation point and therefore not
657 marked with __THROW. */
658 extern void rewind (FILE *__stream);
659 __END_NAMESPACE_STD
661 /* The Single Unix Specification, Version 2, specifies an alternative,
662 more adequate interface for the two functions above which deal with
663 file offset. `long int' is not the right type. These definitions
664 are originally defined in the Large File Support API. */
666 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
667 # ifndef __USE_FILE_OFFSET64
668 /* Seek to a certain position on STREAM.
670 This function is a possible cancellation point and therefore not
671 marked with __THROW. */
672 extern int fseeko (FILE *__stream, __off_t __off, int __whence);
673 /* Return the current position of STREAM.
675 This function is a possible cancellation point and therefore not
676 marked with __THROW. */
677 extern __off_t ftello (FILE *__stream) __wur;
678 # else
679 # ifdef __REDIRECT
680 extern int __REDIRECT (fseeko,
681 (FILE *__stream, __off64_t __off, int __whence),
682 fseeko64);
683 extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
684 # else
685 # define fseeko fseeko64
686 # define ftello ftello64
687 # endif
688 # endif
689 #endif
691 __BEGIN_NAMESPACE_STD
692 #ifndef __USE_FILE_OFFSET64
693 /* Get STREAM's position.
695 This function is a possible cancellation point and therefore not
696 marked with __THROW. */
697 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
698 /* Set STREAM's position.
700 This function is a possible cancellation point and therefore not
701 marked with __THROW. */
702 extern int fsetpos (FILE *__stream, __const fpos_t *__pos);
703 #else
704 # ifdef __REDIRECT
705 extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
706 fpos_t *__restrict __pos), fgetpos64);
707 extern int __REDIRECT (fsetpos,
708 (FILE *__stream, __const fpos_t *__pos), fsetpos64);
709 # else
710 # define fgetpos fgetpos64
711 # define fsetpos fsetpos64
712 # endif
713 #endif
714 __END_NAMESPACE_STD
716 #ifdef __USE_LARGEFILE64
717 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
718 extern __off64_t ftello64 (FILE *__stream) __wur;
719 extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
720 extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos);
721 #endif
723 __BEGIN_NAMESPACE_STD
724 /* Clear the error and EOF indicators for STREAM. */
725 extern void clearerr (FILE *__stream) __THROW;
726 /* Return the EOF indicator for STREAM. */
727 extern int feof (FILE *__stream) __THROW __wur;
728 /* Return the error indicator for STREAM. */
729 extern int ferror (FILE *__stream) __THROW __wur;
730 __END_NAMESPACE_STD
732 #ifdef __USE_MISC
733 /* Faster versions when locking is not required. */
734 extern void clearerr_unlocked (FILE *__stream) __THROW;
735 extern int feof_unlocked (FILE *__stream) __THROW __wur;
736 extern int ferror_unlocked (FILE *__stream) __THROW __wur;
737 #endif
740 __BEGIN_NAMESPACE_STD
741 /* Print a message describing the meaning of the value of errno.
743 This function is a possible cancellation point and therefore not
744 marked with __THROW. */
745 extern void perror (__const char *__s);
746 __END_NAMESPACE_STD
748 /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
749 are available on this system. Even if available, these variables
750 should not be used directly. The `strerror' function provides
751 all the necessary functionality. */
752 #include <bits/sys_errlist.h>
755 #ifdef __USE_POSIX
756 /* Return the system file descriptor for STREAM. */
757 extern int fileno (FILE *__stream) __THROW __wur;
758 #endif /* Use POSIX. */
760 #ifdef __USE_MISC
761 /* Faster version when locking is not required. */
762 extern int fileno_unlocked (FILE *__stream) __THROW __wur;
763 #endif
766 #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
767 defined __USE_MISC)
768 /* Create a new stream connected to a pipe running the given command.
770 This function is a possible cancellation point and therefore not
771 marked with __THROW. */
772 extern FILE *popen (__const char *__command, __const char *__modes) __wur;
774 /* Close a stream opened by popen and return the status of its child.
776 This function is a possible cancellation point and therefore not
777 marked with __THROW. */
778 extern int pclose (FILE *__stream);
779 #endif
782 #ifdef __USE_POSIX
783 /* Return the name of the controlling terminal. */
784 extern char *ctermid (char *__s) __THROW;
785 #endif /* Use POSIX. */
788 #ifdef __USE_XOPEN
789 /* Return the name of the current user. */
790 extern char *cuserid (char *__s);
791 #endif /* Use X/Open, but not issue 6. */
794 #ifdef __USE_GNU
795 struct obstack; /* See <obstack.h>. */
797 /* Write formatted output to an obstack. */
798 extern int obstack_printf (struct obstack *__restrict __obstack,
799 __const char *__restrict __format, ...)
800 __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
801 extern int obstack_vprintf (struct obstack *__restrict __obstack,
802 __const char *__restrict __format,
803 _G_va_list __args)
804 __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
805 #endif /* Use GNU. */
808 #if defined __USE_POSIX || defined __USE_MISC
809 /* These are defined in POSIX.1:1996. */
811 /* Acquire ownership of STREAM. */
812 extern void flockfile (FILE *__stream) __THROW;
814 /* Try to acquire ownership of STREAM but do not block if it is not
815 possible. */
816 extern int ftrylockfile (FILE *__stream) __THROW __wur;
818 /* Relinquish the ownership granted for STREAM. */
819 extern void funlockfile (FILE *__stream) __THROW;
820 #endif /* POSIX || misc */
822 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
823 /* The X/Open standard requires some functions and variables to be
824 declared here which do not belong into this header. But we have to
825 follow. In GNU mode we don't do this nonsense. */
826 # define __need_getopt
827 # include <getopt.h>
828 #endif /* X/Open, but not issue 6 and not for GNU. */
830 /* If we are compiling with optimizing read this file. It contains
831 several optimizing inline functions and macros. */
832 #ifdef __USE_EXTERN_INLINES
833 # include <bits/stdio.h>
834 #endif
835 #if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus
836 # include <bits/stdio2.h>
837 #endif
838 #ifdef __LDBL_COMPAT
839 # include <bits/stdio-ldbl.h>
840 #endif
842 __END_DECLS
844 #endif /* <stdio.h> included. */
846 #endif /* !_STDIO_H */