2.5-18.1
[glibc.git] / libio / stdio.h
blobc8fe52cf31cae60582c4e6308de658e58022e5b4
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 #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
159 #ifdef __USE_ATFILE
160 /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
161 extern int renameat (int __oldfd, __const char *__old, int __newfd,
162 __const char *__new) __THROW;
163 #endif
165 __BEGIN_NAMESPACE_STD
166 /* Create a temporary file and open it read/write.
168 This function is a possible cancellation points and therefore not
169 marked with __THROW. */
170 #ifndef __USE_FILE_OFFSET64
171 extern FILE *tmpfile (void);
172 #else
173 # ifdef __REDIRECT
174 extern FILE *__REDIRECT (tmpfile, (void), tmpfile64);
175 # else
176 # define tmpfile tmpfile64
177 # endif
178 #endif
180 #ifdef __USE_LARGEFILE64
181 extern FILE *tmpfile64 (void);
182 #endif
184 /* Generate a temporary filename. */
185 extern char *tmpnam (char *__s) __THROW;
186 __END_NAMESPACE_STD
188 #ifdef __USE_MISC
189 /* This is the reentrant variant of `tmpnam'. The only difference is
190 that it does not allow S to be NULL. */
191 extern char *tmpnam_r (char *__s) __THROW;
192 #endif
195 #if defined __USE_SVID || defined __USE_XOPEN
196 /* Generate a unique temporary filename using up to five characters of PFX
197 if it is not NULL. The directory to put this file in is searched for
198 as follows: First the environment variable "TMPDIR" is checked.
199 If it contains the name of a writable directory, that directory is used.
200 If not and if DIR is not NULL, that value is checked. If that fails,
201 P_tmpdir is tried and finally "/tmp". The storage for the filename
202 is allocated by `malloc'. */
203 extern char *tempnam (__const char *__dir, __const char *__pfx)
204 __THROW __attribute_malloc__;
205 #endif
208 __BEGIN_NAMESPACE_STD
209 /* Close STREAM.
211 This function is a possible cancellation point and therefore not
212 marked with __THROW. */
213 extern int fclose (FILE *__stream);
214 /* Flush STREAM, or all streams if STREAM is NULL.
216 This function is a possible cancellation point and therefore not
217 marked with __THROW. */
218 extern int fflush (FILE *__stream);
219 __END_NAMESPACE_STD
221 #ifdef __USE_MISC
222 /* Faster versions when locking is not required.
224 This function is not part of POSIX and therefore no official
225 cancellation point. But due to similarity with an POSIX interface
226 or due to the implementation it is a cancellation point and
227 therefore not marked with __THROW. */
228 extern int fflush_unlocked (FILE *__stream);
229 #endif
231 #ifdef __USE_GNU
232 /* Close all streams.
234 This function is not part of POSIX and therefore no official
235 cancellation point. But due to similarity with an POSIX interface
236 or due to the implementation it is a cancellation point and
237 therefore not marked with __THROW. */
238 extern int fcloseall (void);
239 #endif
242 __BEGIN_NAMESPACE_STD
243 #ifndef __USE_FILE_OFFSET64
244 /* Open a file and create a new stream for it.
246 This function is a possible cancellation point and therefore not
247 marked with __THROW. */
248 extern FILE *fopen (__const char *__restrict __filename,
249 __const char *__restrict __modes);
250 /* Open a file, replacing an existing stream with it.
252 This function is a possible cancellation point and therefore not
253 marked with __THROW. */
254 extern FILE *freopen (__const char *__restrict __filename,
255 __const char *__restrict __modes,
256 FILE *__restrict __stream);
257 #else
258 # ifdef __REDIRECT
259 extern FILE *__REDIRECT (fopen, (__const char *__restrict __filename,
260 __const char *__restrict __modes), fopen64);
261 extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
262 __const char *__restrict __modes,
263 FILE *__restrict __stream), freopen64);
264 # else
265 # define fopen fopen64
266 # define freopen freopen64
267 # endif
268 #endif
269 __END_NAMESPACE_STD
270 #ifdef __USE_LARGEFILE64
271 extern FILE *fopen64 (__const char *__restrict __filename,
272 __const char *__restrict __modes);
273 extern FILE *freopen64 (__const char *__restrict __filename,
274 __const char *__restrict __modes,
275 FILE *__restrict __stream);
276 #endif
278 #ifdef __USE_POSIX
279 /* Create a new stream that refers to an existing system file descriptor. */
280 extern FILE *fdopen (int __fd, __const char *__modes) __THROW;
281 #endif
283 #ifdef __USE_GNU
284 /* Create a new stream that refers to the given magic cookie,
285 and uses the given functions for input and output. */
286 extern FILE *fopencookie (void *__restrict __magic_cookie,
287 __const char *__restrict __modes,
288 _IO_cookie_io_functions_t __io_funcs) __THROW;
290 /* Create a new stream that refers to a memory buffer. */
291 extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes) __THROW;
293 /* Open a stream that writes into a malloc'd buffer that is expanded as
294 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
295 and the number of characters written on fflush or fclose. */
296 extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW;
297 #endif
300 __BEGIN_NAMESPACE_STD
301 /* If BUF is NULL, make STREAM unbuffered.
302 Else make it use buffer BUF, of size BUFSIZ. */
303 extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
304 /* Make STREAM use buffering mode MODE.
305 If BUF is not NULL, use N bytes of it for buffering;
306 else allocate an internal buffer N bytes long. */
307 extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
308 int __modes, size_t __n) __THROW;
309 __END_NAMESPACE_STD
311 #ifdef __USE_BSD
312 /* If BUF is NULL, make STREAM unbuffered.
313 Else make it use SIZE bytes of BUF for buffering. */
314 extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
315 size_t __size) __THROW;
317 /* Make STREAM line-buffered. */
318 extern void setlinebuf (FILE *__stream) __THROW;
319 #endif
322 __BEGIN_NAMESPACE_STD
323 /* Write formatted output to STREAM.
325 This function is a possible cancellation point and therefore not
326 marked with __THROW. */
327 extern int fprintf (FILE *__restrict __stream,
328 __const char *__restrict __format, ...);
329 /* Write formatted output to stdout.
331 This function is a possible cancellation point and therefore not
332 marked with __THROW. */
333 extern int printf (__const char *__restrict __format, ...);
334 /* Write formatted output to S. */
335 extern int sprintf (char *__restrict __s,
336 __const char *__restrict __format, ...) __THROW;
338 /* Write formatted output to S from argument list ARG.
340 This function is a possible cancellation point and therefore not
341 marked with __THROW. */
342 extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
343 _G_va_list __arg);
344 /* Write formatted output to stdout from argument list ARG.
346 This function is a possible cancellation point and therefore not
347 marked with __THROW. */
348 extern int vprintf (__const char *__restrict __format, _G_va_list __arg);
349 /* Write formatted output to S from argument list ARG. */
350 extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
351 _G_va_list __arg) __THROW;
352 __END_NAMESPACE_STD
354 #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
355 __BEGIN_NAMESPACE_C99
356 /* Maximum chars of output to write in MAXLEN. */
357 extern int snprintf (char *__restrict __s, size_t __maxlen,
358 __const char *__restrict __format, ...)
359 __THROW __attribute__ ((__format__ (__printf__, 3, 4)));
361 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
362 __const char *__restrict __format, _G_va_list __arg)
363 __THROW __attribute__ ((__format__ (__printf__, 3, 0)));
364 __END_NAMESPACE_C99
365 #endif
367 #ifdef __USE_GNU
368 /* Write formatted output to a string dynamically allocated with `malloc'.
369 Store the address of the string in *PTR. */
370 extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f,
371 _G_va_list __arg)
372 __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
373 extern int __asprintf (char **__restrict __ptr,
374 __const char *__restrict __fmt, ...)
375 __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
376 extern int asprintf (char **__restrict __ptr,
377 __const char *__restrict __fmt, ...)
378 __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
380 /* Write formatted output to a file descriptor.
382 These functions are not part of POSIX and therefore no official
383 cancellation point. But due to similarity with an POSIX interface
384 or due to the implementation they are cancellation points and
385 therefore not marked with __THROW. */
386 extern int vdprintf (int __fd, __const char *__restrict __fmt,
387 _G_va_list __arg)
388 __attribute__ ((__format__ (__printf__, 2, 0)));
389 extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
390 __attribute__ ((__format__ (__printf__, 2, 3)));
391 #endif
394 __BEGIN_NAMESPACE_STD
395 /* Read formatted input from STREAM.
397 This function is a possible cancellation point and therefore not
398 marked with __THROW. */
399 extern int fscanf (FILE *__restrict __stream,
400 __const char *__restrict __format, ...) __wur;
401 /* Read formatted input from stdin.
403 This function is a possible cancellation point and therefore not
404 marked with __THROW. */
405 extern int scanf (__const char *__restrict __format, ...) __wur;
406 /* Read formatted input from S. */
407 extern int sscanf (__const char *__restrict __s,
408 __const char *__restrict __format, ...) __THROW;
409 __END_NAMESPACE_STD
411 #ifdef __USE_ISOC99
412 __BEGIN_NAMESPACE_C99
413 /* Read formatted input from S into argument list ARG.
415 This function is a possible cancellation point and therefore not
416 marked with __THROW. */
417 extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
418 _G_va_list __arg)
419 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
421 /* Read formatted input from stdin into argument list ARG.
423 This function is a possible cancellation point and therefore not
424 marked with __THROW. */
425 extern int vscanf (__const char *__restrict __format, _G_va_list __arg)
426 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
428 /* Read formatted input from S into argument list ARG. */
429 extern int vsscanf (__const char *__restrict __s,
430 __const char *__restrict __format, _G_va_list __arg)
431 __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
432 __END_NAMESPACE_C99
433 #endif /* Use ISO C9x. */
436 __BEGIN_NAMESPACE_STD
437 /* Read a character from STREAM.
439 These functions are possible cancellation points and therefore not
440 marked with __THROW. */
441 extern int fgetc (FILE *__stream);
442 extern int getc (FILE *__stream);
444 /* Read a character from stdin.
446 This function is a possible cancellation point and therefore not
447 marked with __THROW. */
448 extern int getchar (void);
449 __END_NAMESPACE_STD
451 /* The C standard explicitly says this is a macro, so we always do the
452 optimization for it. */
453 #define getc(_fp) _IO_getc (_fp)
455 #if defined __USE_POSIX || defined __USE_MISC
456 /* These are defined in POSIX.1:1996.
458 These functions are possible cancellation points and therefore not
459 marked with __THROW. */
460 extern int getc_unlocked (FILE *__stream);
461 extern int getchar_unlocked (void);
462 #endif /* Use POSIX or MISC. */
464 #ifdef __USE_MISC
465 /* Faster version when locking is not necessary.
467 This function is not part of POSIX and therefore no official
468 cancellation point. But due to similarity with an POSIX interface
469 or due to the implementation it is a cancellation point and
470 therefore not marked with __THROW. */
471 extern int fgetc_unlocked (FILE *__stream);
472 #endif /* Use MISC. */
475 __BEGIN_NAMESPACE_STD
476 /* Write a character to STREAM.
478 These functions are possible cancellation points and therefore not
479 marked with __THROW.
481 These functions is a possible cancellation point and therefore not
482 marked with __THROW. */
483 extern int fputc (int __c, FILE *__stream);
484 extern int putc (int __c, FILE *__stream);
486 /* Write a character to stdout.
488 This function is a possible cancellation point and therefore not
489 marked with __THROW. */
490 extern int putchar (int __c);
491 __END_NAMESPACE_STD
493 /* The C standard explicitly says this can be a macro,
494 so we always do the optimization for it. */
495 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
497 #ifdef __USE_MISC
498 /* Faster version when locking is not necessary.
500 This function is not part of POSIX and therefore no official
501 cancellation point. But due to similarity with an POSIX interface
502 or due to the implementation it is a cancellation point and
503 therefore not marked with __THROW. */
504 extern int fputc_unlocked (int __c, FILE *__stream);
505 #endif /* Use MISC. */
507 #if defined __USE_POSIX || defined __USE_MISC
508 /* These are defined in POSIX.1:1996.
510 These functions are possible cancellation points and therefore not
511 marked with __THROW. */
512 extern int putc_unlocked (int __c, FILE *__stream);
513 extern int putchar_unlocked (int __c);
514 #endif /* Use POSIX or MISC. */
517 #if defined __USE_SVID || defined __USE_MISC \
518 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
519 /* Get a word (int) from STREAM. */
520 extern int getw (FILE *__stream);
522 /* Write a word (int) to STREAM. */
523 extern int putw (int __w, FILE *__stream);
524 #endif
527 __BEGIN_NAMESPACE_STD
528 /* Get a newline-terminated string of finite length from STREAM.
530 This function is a possible cancellation point and therefore not
531 marked with __THROW. */
532 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
533 __wur;
535 /* Get a newline-terminated string from stdin, removing the newline.
536 DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
538 This function is a possible cancellation point and therefore not
539 marked with __THROW. */
540 extern char *gets (char *__s) __wur;
541 __END_NAMESPACE_STD
543 #ifdef __USE_GNU
544 /* This function does the same as `fgets' but does not lock the stream.
546 This function is not part of POSIX and therefore no official
547 cancellation point. But due to similarity with an POSIX interface
548 or due to the implementation it is a cancellation point and
549 therefore not marked with __THROW. */
550 extern char *fgets_unlocked (char *__restrict __s, int __n,
551 FILE *__restrict __stream) __wur;
552 #endif
555 #ifdef __USE_GNU
556 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
557 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
558 NULL), pointing to *N characters of space. It is realloc'd as
559 necessary. Returns the number of characters read (not including the
560 null terminator), or -1 on error or EOF.
562 These functions are not part of POSIX and therefore no official
563 cancellation point. But due to similarity with an POSIX interface
564 or due to the implementation they are cancellation points and
565 therefore not marked with __THROW. */
566 extern _IO_ssize_t __getdelim (char **__restrict __lineptr,
567 size_t *__restrict __n, int __delimiter,
568 FILE *__restrict __stream) __wur;
569 extern _IO_ssize_t getdelim (char **__restrict __lineptr,
570 size_t *__restrict __n, int __delimiter,
571 FILE *__restrict __stream) __wur;
573 /* Like `getdelim', but reads up to a newline.
575 This function is not part of POSIX and therefore no official
576 cancellation point. But due to similarity with an POSIX interface
577 or due to the implementation it is a cancellation point and
578 therefore not marked with __THROW. */
579 extern _IO_ssize_t getline (char **__restrict __lineptr,
580 size_t *__restrict __n,
581 FILE *__restrict __stream) __wur;
582 #endif
585 __BEGIN_NAMESPACE_STD
586 /* Write a string to STREAM.
588 This function is a possible cancellation points and therefore not
589 marked with __THROW. */
590 extern int fputs (__const char *__restrict __s, FILE *__restrict __stream);
592 /* Write a string, followed by a newline, to stdout.
594 This function is a possible cancellation points and therefore not
595 marked with __THROW. */
596 extern int puts (__const char *__s);
599 /* Push a character back onto the input buffer of STREAM.
601 This function is a possible cancellation points and therefore not
602 marked with __THROW. */
603 extern int ungetc (int __c, FILE *__stream);
606 /* Read chunks of generic data from STREAM.
608 This function is a possible cancellation points and therefore not
609 marked with __THROW. */
610 extern size_t fread (void *__restrict __ptr, size_t __size,
611 size_t __n, FILE *__restrict __stream) __wur;
612 /* Write chunks of generic data to STREAM.
614 This function is a possible cancellation points and therefore not
615 marked with __THROW. */
616 extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
617 size_t __n, FILE *__restrict __s) __wur;
618 __END_NAMESPACE_STD
620 #ifdef __USE_GNU
621 /* This function does the same as `fputs' but does not lock the stream.
623 This function is not part of POSIX and therefore no official
624 cancellation point. But due to similarity with an POSIX interface
625 or due to the implementation it is a cancellation point and
626 therefore not marked with __THROW. */
627 extern int fputs_unlocked (__const char *__restrict __s,
628 FILE *__restrict __stream);
629 #endif
631 #ifdef __USE_MISC
632 /* Faster versions when locking is not necessary.
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 size_t fread_unlocked (void *__restrict __ptr, size_t __size,
639 size_t __n, FILE *__restrict __stream) __wur;
640 extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
641 size_t __n, FILE *__restrict __stream) __wur;
642 #endif
645 __BEGIN_NAMESPACE_STD
646 /* Seek to a certain position on STREAM.
648 This function is a possible cancellation point and therefore not
649 marked with __THROW. */
650 extern int fseek (FILE *__stream, long int __off, int __whence);
651 /* Return the current position of STREAM.
653 This function is a possible cancellation point and therefore not
654 marked with __THROW. */
655 extern long int ftell (FILE *__stream) __wur;
656 /* Rewind to the beginning of STREAM.
658 This function is a possible cancellation point and therefore not
659 marked with __THROW. */
660 extern void rewind (FILE *__stream);
661 __END_NAMESPACE_STD
663 /* The Single Unix Specification, Version 2, specifies an alternative,
664 more adequate interface for the two functions above which deal with
665 file offset. `long int' is not the right type. These definitions
666 are originally defined in the Large File Support API. */
668 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
669 # ifndef __USE_FILE_OFFSET64
670 /* Seek to a certain position on STREAM.
672 This function is a possible cancellation point and therefore not
673 marked with __THROW. */
674 extern int fseeko (FILE *__stream, __off_t __off, int __whence);
675 /* Return the current position of STREAM.
677 This function is a possible cancellation point and therefore not
678 marked with __THROW. */
679 extern __off_t ftello (FILE *__stream) __wur;
680 # else
681 # ifdef __REDIRECT
682 extern int __REDIRECT (fseeko,
683 (FILE *__stream, __off64_t __off, int __whence),
684 fseeko64);
685 extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
686 # else
687 # define fseeko fseeko64
688 # define ftello ftello64
689 # endif
690 # endif
691 #endif
693 __BEGIN_NAMESPACE_STD
694 #ifndef __USE_FILE_OFFSET64
695 /* Get STREAM's position.
697 This function is a possible cancellation point and therefore not
698 marked with __THROW. */
699 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
700 /* Set STREAM's position.
702 This function is a possible cancellation point and therefore not
703 marked with __THROW. */
704 extern int fsetpos (FILE *__stream, __const fpos_t *__pos);
705 #else
706 # ifdef __REDIRECT
707 extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
708 fpos_t *__restrict __pos), fgetpos64);
709 extern int __REDIRECT (fsetpos,
710 (FILE *__stream, __const fpos_t *__pos), fsetpos64);
711 # else
712 # define fgetpos fgetpos64
713 # define fsetpos fsetpos64
714 # endif
715 #endif
716 __END_NAMESPACE_STD
718 #ifdef __USE_LARGEFILE64
719 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
720 extern __off64_t ftello64 (FILE *__stream) __wur;
721 extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
722 extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos);
723 #endif
725 __BEGIN_NAMESPACE_STD
726 /* Clear the error and EOF indicators for STREAM. */
727 extern void clearerr (FILE *__stream) __THROW;
728 /* Return the EOF indicator for STREAM. */
729 extern int feof (FILE *__stream) __THROW __wur;
730 /* Return the error indicator for STREAM. */
731 extern int ferror (FILE *__stream) __THROW __wur;
732 __END_NAMESPACE_STD
734 #ifdef __USE_MISC
735 /* Faster versions when locking is not required. */
736 extern void clearerr_unlocked (FILE *__stream) __THROW;
737 extern int feof_unlocked (FILE *__stream) __THROW __wur;
738 extern int ferror_unlocked (FILE *__stream) __THROW __wur;
739 #endif
742 __BEGIN_NAMESPACE_STD
743 /* Print a message describing the meaning of the value of errno.
745 This function is a possible cancellation point and therefore not
746 marked with __THROW. */
747 extern void perror (__const char *__s);
748 __END_NAMESPACE_STD
750 /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
751 are available on this system. Even if available, these variables
752 should not be used directly. The `strerror' function provides
753 all the necessary functionality. */
754 #include <bits/sys_errlist.h>
757 #ifdef __USE_POSIX
758 /* Return the system file descriptor for STREAM. */
759 extern int fileno (FILE *__stream) __THROW __wur;
760 #endif /* Use POSIX. */
762 #ifdef __USE_MISC
763 /* Faster version when locking is not required. */
764 extern int fileno_unlocked (FILE *__stream) __THROW __wur;
765 #endif
768 #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
769 defined __USE_MISC)
770 /* Create a new stream connected to a pipe running the given command.
772 This function is a possible cancellation point and therefore not
773 marked with __THROW. */
774 extern FILE *popen (__const char *__command, __const char *__modes) __wur;
776 /* Close a stream opened by popen and return the status of its child.
778 This function is a possible cancellation point and therefore not
779 marked with __THROW. */
780 extern int pclose (FILE *__stream);
781 #endif
784 #ifdef __USE_POSIX
785 /* Return the name of the controlling terminal. */
786 extern char *ctermid (char *__s) __THROW;
787 #endif /* Use POSIX. */
790 #ifdef __USE_XOPEN
791 /* Return the name of the current user. */
792 extern char *cuserid (char *__s);
793 #endif /* Use X/Open, but not issue 6. */
796 #ifdef __USE_GNU
797 struct obstack; /* See <obstack.h>. */
799 /* Write formatted output to an obstack. */
800 extern int obstack_printf (struct obstack *__restrict __obstack,
801 __const char *__restrict __format, ...)
802 __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
803 extern int obstack_vprintf (struct obstack *__restrict __obstack,
804 __const char *__restrict __format,
805 _G_va_list __args)
806 __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
807 #endif /* Use GNU. */
810 #if defined __USE_POSIX || defined __USE_MISC
811 /* These are defined in POSIX.1:1996. */
813 /* Acquire ownership of STREAM. */
814 extern void flockfile (FILE *__stream) __THROW;
816 /* Try to acquire ownership of STREAM but do not block if it is not
817 possible. */
818 extern int ftrylockfile (FILE *__stream) __THROW __wur;
820 /* Relinquish the ownership granted for STREAM. */
821 extern void funlockfile (FILE *__stream) __THROW;
822 #endif /* POSIX || misc */
824 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
825 /* The X/Open standard requires some functions and variables to be
826 declared here which do not belong into this header. But we have to
827 follow. In GNU mode we don't do this nonsense. */
828 # define __need_getopt
829 # include <getopt.h>
830 #endif /* X/Open, but not issue 6 and not for GNU. */
832 /* If we are compiling with optimizing read this file. It contains
833 several optimizing inline functions and macros. */
834 #ifdef __USE_EXTERN_INLINES
835 # include <bits/stdio.h>
836 #endif
837 #if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus
838 # include <bits/stdio2.h>
839 #endif
840 #ifdef __LDBL_COMPAT
841 # include <bits/stdio-ldbl.h>
842 #endif
844 __END_DECLS
846 #endif /* <stdio.h> included. */
848 #endif /* !_STDIO_H */