Updated to fedora-glibc-20070510T2308
[glibc.git] / libio / stdio.h
blob46274623c0000ec153c6a069bc87176694df40ee
1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991,1994-2004,2005,2006,2007 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 #ifdef __STDC__
149 /* C89/C99 say they're macros. Make them happy. */
150 #define stdin stdin
151 #define stdout stdout
152 #define stderr stderr
153 #endif
155 __BEGIN_NAMESPACE_STD
156 /* Remove file FILENAME. */
157 extern int remove (__const char *__filename) __THROW;
158 /* Rename file OLD to NEW. */
159 extern int rename (__const char *__old, __const char *__new) __THROW;
160 __END_NAMESPACE_STD
162 #ifdef __USE_ATFILE
163 /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
164 extern int renameat (int __oldfd, __const char *__old, int __newfd,
165 __const char *__new) __THROW;
166 #endif
168 __BEGIN_NAMESPACE_STD
169 /* Create a temporary file and open it read/write.
171 This function is a possible cancellation points and therefore not
172 marked with __THROW. */
173 #ifndef __USE_FILE_OFFSET64
174 extern FILE *tmpfile (void) __wur;
175 #else
176 # ifdef __REDIRECT
177 extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;
178 # else
179 # define tmpfile tmpfile64
180 # endif
181 #endif
183 #ifdef __USE_LARGEFILE64
184 extern FILE *tmpfile64 (void) __wur;
185 #endif
187 /* Generate a temporary filename. */
188 extern char *tmpnam (char *__s) __THROW __wur;
189 __END_NAMESPACE_STD
191 #ifdef __USE_MISC
192 /* This is the reentrant variant of `tmpnam'. The only difference is
193 that it does not allow S to be NULL. */
194 extern char *tmpnam_r (char *__s) __THROW __wur;
195 #endif
198 #if defined __USE_SVID || defined __USE_XOPEN
199 /* Generate a unique temporary filename using up to five characters of PFX
200 if it is not NULL. The directory to put this file in is searched for
201 as follows: First the environment variable "TMPDIR" is checked.
202 If it contains the name of a writable directory, that directory is used.
203 If not and if DIR is not NULL, that value is checked. If that fails,
204 P_tmpdir is tried and finally "/tmp". The storage for the filename
205 is allocated by `malloc'. */
206 extern char *tempnam (__const char *__dir, __const char *__pfx)
207 __THROW __attribute_malloc__ __wur;
208 #endif
211 __BEGIN_NAMESPACE_STD
212 /* Close STREAM.
214 This function is a possible cancellation point and therefore not
215 marked with __THROW. */
216 extern int fclose (FILE *__stream);
217 /* Flush STREAM, or all streams if STREAM is NULL.
219 This function is a possible cancellation point and therefore not
220 marked with __THROW. */
221 extern int fflush (FILE *__stream);
222 __END_NAMESPACE_STD
224 #ifdef __USE_MISC
225 /* Faster versions when locking is not required.
227 This function is not part of POSIX and therefore no official
228 cancellation point. But due to similarity with an POSIX interface
229 or due to the implementation it is a cancellation point and
230 therefore not marked with __THROW. */
231 extern int fflush_unlocked (FILE *__stream);
232 #endif
234 #ifdef __USE_GNU
235 /* Close all streams.
237 This function is not part of POSIX and therefore no official
238 cancellation point. But due to similarity with an POSIX interface
239 or due to the implementation it is a cancellation point and
240 therefore not marked with __THROW. */
241 extern int fcloseall (void);
242 #endif
245 __BEGIN_NAMESPACE_STD
246 #ifndef __USE_FILE_OFFSET64
247 /* Open a file and create a new stream for it.
249 This function is a possible cancellation point and therefore not
250 marked with __THROW. */
251 extern FILE *fopen (__const char *__restrict __filename,
252 __const char *__restrict __modes) __wur;
253 /* Open a file, replacing an existing stream with it.
255 This function is a possible cancellation point and therefore not
256 marked with __THROW. */
257 extern FILE *freopen (__const char *__restrict __filename,
258 __const char *__restrict __modes,
259 FILE *__restrict __stream) __wur;
260 #else
261 # ifdef __REDIRECT
262 extern FILE *__REDIRECT (fopen, (__const char *__restrict __filename,
263 __const char *__restrict __modes), fopen64)
264 __wur;
265 extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
266 __const char *__restrict __modes,
267 FILE *__restrict __stream), freopen64)
268 __wur;
269 # else
270 # define fopen fopen64
271 # define freopen freopen64
272 # endif
273 #endif
274 __END_NAMESPACE_STD
275 #ifdef __USE_LARGEFILE64
276 extern FILE *fopen64 (__const char *__restrict __filename,
277 __const char *__restrict __modes) __wur;
278 extern FILE *freopen64 (__const char *__restrict __filename,
279 __const char *__restrict __modes,
280 FILE *__restrict __stream) __wur;
281 #endif
283 #ifdef __USE_POSIX
284 /* Create a new stream that refers to an existing system file descriptor. */
285 extern FILE *fdopen (int __fd, __const char *__modes) __THROW __wur;
286 #endif
288 #ifdef __USE_GNU
289 /* Create a new stream that refers to the given magic cookie,
290 and uses the given functions for input and output. */
291 extern FILE *fopencookie (void *__restrict __magic_cookie,
292 __const char *__restrict __modes,
293 _IO_cookie_io_functions_t __io_funcs) __THROW __wur;
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;
386 /* Write formatted output to a file descriptor.
388 These functions are not part of POSIX and therefore no official
389 cancellation point. But due to similarity with an POSIX interface
390 or due to the implementation they are cancellation points and
391 therefore not marked with __THROW. */
392 extern int vdprintf (int __fd, __const char *__restrict __fmt,
393 _G_va_list __arg)
394 __attribute__ ((__format__ (__printf__, 2, 0)));
395 extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
396 __attribute__ ((__format__ (__printf__, 2, 3)));
397 #endif
400 __BEGIN_NAMESPACE_STD
401 /* Read formatted input from STREAM.
403 This function is a possible cancellation point and therefore not
404 marked with __THROW. */
405 extern int fscanf (FILE *__restrict __stream,
406 __const char *__restrict __format, ...) __wur;
407 /* Read formatted input from stdin.
409 This function is a possible cancellation point and therefore not
410 marked with __THROW. */
411 extern int scanf (__const char *__restrict __format, ...) __wur;
412 /* Read formatted input from S. */
413 extern int sscanf (__const char *__restrict __s,
414 __const char *__restrict __format, ...) __THROW;
415 __END_NAMESPACE_STD
417 #ifdef __USE_ISOC99
418 __BEGIN_NAMESPACE_C99
419 /* Read formatted input from S into argument list ARG.
421 This function is a possible cancellation point and therefore not
422 marked with __THROW. */
423 extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
424 _G_va_list __arg)
425 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
427 /* Read formatted input from stdin into argument list ARG.
429 This function is a possible cancellation point and therefore not
430 marked with __THROW. */
431 extern int vscanf (__const char *__restrict __format, _G_va_list __arg)
432 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
434 /* Read formatted input from S into argument list ARG. */
435 extern int vsscanf (__const char *__restrict __s,
436 __const char *__restrict __format, _G_va_list __arg)
437 __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
438 __END_NAMESPACE_C99
439 #endif /* Use ISO C9x. */
442 __BEGIN_NAMESPACE_STD
443 /* Read a character from STREAM.
445 These functions are possible cancellation points and therefore not
446 marked with __THROW. */
447 extern int fgetc (FILE *__stream);
448 extern int getc (FILE *__stream);
450 /* Read a character from stdin.
452 This function is a possible cancellation point and therefore not
453 marked with __THROW. */
454 extern int getchar (void);
455 __END_NAMESPACE_STD
457 /* The C standard explicitly says this is a macro, so we always do the
458 optimization for it. */
459 #define getc(_fp) _IO_getc (_fp)
461 #if defined __USE_POSIX || defined __USE_MISC
462 /* These are defined in POSIX.1:1996.
464 These functions are possible cancellation points and therefore not
465 marked with __THROW. */
466 extern int getc_unlocked (FILE *__stream);
467 extern int getchar_unlocked (void);
468 #endif /* Use POSIX or MISC. */
470 #ifdef __USE_MISC
471 /* Faster version when locking is not necessary.
473 This function is not part of POSIX and therefore no official
474 cancellation point. But due to similarity with an POSIX interface
475 or due to the implementation it is a cancellation point and
476 therefore not marked with __THROW. */
477 extern int fgetc_unlocked (FILE *__stream);
478 #endif /* Use MISC. */
481 __BEGIN_NAMESPACE_STD
482 /* Write a character to STREAM.
484 These functions are possible cancellation points and therefore not
485 marked with __THROW.
487 These functions is a possible cancellation point and therefore not
488 marked with __THROW. */
489 extern int fputc (int __c, FILE *__stream);
490 extern int putc (int __c, FILE *__stream);
492 /* Write a character to stdout.
494 This function is a possible cancellation point and therefore not
495 marked with __THROW. */
496 extern int putchar (int __c);
497 __END_NAMESPACE_STD
499 /* The C standard explicitly says this can be a macro,
500 so we always do the optimization for it. */
501 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
503 #ifdef __USE_MISC
504 /* Faster version when locking is not necessary.
506 This function is not part of POSIX and therefore no official
507 cancellation point. But due to similarity with an POSIX interface
508 or due to the implementation it is a cancellation point and
509 therefore not marked with __THROW. */
510 extern int fputc_unlocked (int __c, FILE *__stream);
511 #endif /* Use MISC. */
513 #if defined __USE_POSIX || defined __USE_MISC
514 /* These are defined in POSIX.1:1996.
516 These functions are possible cancellation points and therefore not
517 marked with __THROW. */
518 extern int putc_unlocked (int __c, FILE *__stream);
519 extern int putchar_unlocked (int __c);
520 #endif /* Use POSIX or MISC. */
523 #if defined __USE_SVID || defined __USE_MISC \
524 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
525 /* Get a word (int) from STREAM. */
526 extern int getw (FILE *__stream);
528 /* Write a word (int) to STREAM. */
529 extern int putw (int __w, FILE *__stream);
530 #endif
533 __BEGIN_NAMESPACE_STD
534 /* Get a newline-terminated string of finite length from STREAM.
536 This function is a possible cancellation point and therefore not
537 marked with __THROW. */
538 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
539 __wur;
541 /* Get a newline-terminated string from stdin, removing the newline.
542 DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
544 This function is a possible cancellation point and therefore not
545 marked with __THROW. */
546 extern char *gets (char *__s) __wur;
547 __END_NAMESPACE_STD
549 #ifdef __USE_GNU
550 /* This function does the same as `fgets' but does not lock the stream.
552 This function is not part of POSIX and therefore no official
553 cancellation point. But due to similarity with an POSIX interface
554 or due to the implementation it is a cancellation point and
555 therefore not marked with __THROW. */
556 extern char *fgets_unlocked (char *__restrict __s, int __n,
557 FILE *__restrict __stream) __wur;
558 #endif
561 #ifdef __USE_GNU
562 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
563 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
564 NULL), pointing to *N characters of space. It is realloc'd as
565 necessary. Returns the number of characters read (not including the
566 null terminator), or -1 on error or EOF.
568 These functions are not part of POSIX and therefore no official
569 cancellation point. But due to similarity with an POSIX interface
570 or due to the implementation they are cancellation points and
571 therefore not marked with __THROW. */
572 extern _IO_ssize_t __getdelim (char **__restrict __lineptr,
573 size_t *__restrict __n, int __delimiter,
574 FILE *__restrict __stream) __wur;
575 extern _IO_ssize_t getdelim (char **__restrict __lineptr,
576 size_t *__restrict __n, int __delimiter,
577 FILE *__restrict __stream) __wur;
579 /* Like `getdelim', but reads up to a newline.
581 This function is not part of POSIX and therefore no official
582 cancellation point. But due to similarity with an POSIX interface
583 or due to the implementation it is a cancellation point and
584 therefore not marked with __THROW. */
585 extern _IO_ssize_t getline (char **__restrict __lineptr,
586 size_t *__restrict __n,
587 FILE *__restrict __stream) __wur;
588 #endif
591 __BEGIN_NAMESPACE_STD
592 /* Write a string to STREAM.
594 This function is a possible cancellation points and therefore not
595 marked with __THROW. */
596 extern int fputs (__const char *__restrict __s, FILE *__restrict __stream);
598 /* Write a string, followed by a newline, to stdout.
600 This function is a possible cancellation points and therefore not
601 marked with __THROW. */
602 extern int puts (__const char *__s);
605 /* Push a character back onto the input buffer of STREAM.
607 This function is a possible cancellation points and therefore not
608 marked with __THROW. */
609 extern int ungetc (int __c, FILE *__stream);
612 /* Read chunks of generic data from STREAM.
614 This function is a possible cancellation points and therefore not
615 marked with __THROW. */
616 extern size_t fread (void *__restrict __ptr, size_t __size,
617 size_t __n, FILE *__restrict __stream) __wur;
618 /* Write chunks of generic data to STREAM.
620 This function is a possible cancellation points and therefore not
621 marked with __THROW. */
622 extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
623 size_t __n, FILE *__restrict __s) __wur;
624 __END_NAMESPACE_STD
626 #ifdef __USE_GNU
627 /* This function does the same as `fputs' but does not lock the stream.
629 This function is not part of POSIX and therefore no official
630 cancellation point. But due to similarity with an POSIX interface
631 or due to the implementation it is a cancellation point and
632 therefore not marked with __THROW. */
633 extern int fputs_unlocked (__const char *__restrict __s,
634 FILE *__restrict __stream);
635 #endif
637 #ifdef __USE_MISC
638 /* Faster versions when locking is not necessary.
640 These functions are not part of POSIX and therefore no official
641 cancellation point. But due to similarity with an POSIX interface
642 or due to the implementation they are cancellation points and
643 therefore not marked with __THROW. */
644 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
645 size_t __n, FILE *__restrict __stream) __wur;
646 extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
647 size_t __n, FILE *__restrict __stream) __wur;
648 #endif
651 __BEGIN_NAMESPACE_STD
652 /* Seek to a certain position on STREAM.
654 This function is a possible cancellation point and therefore not
655 marked with __THROW. */
656 extern int fseek (FILE *__stream, long int __off, int __whence);
657 /* Return the current position of STREAM.
659 This function is a possible cancellation point and therefore not
660 marked with __THROW. */
661 extern long int ftell (FILE *__stream) __wur;
662 /* Rewind to the beginning of STREAM.
664 This function is a possible cancellation point and therefore not
665 marked with __THROW. */
666 extern void rewind (FILE *__stream);
667 __END_NAMESPACE_STD
669 /* The Single Unix Specification, Version 2, specifies an alternative,
670 more adequate interface for the two functions above which deal with
671 file offset. `long int' is not the right type. These definitions
672 are originally defined in the Large File Support API. */
674 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
675 # ifndef __USE_FILE_OFFSET64
676 /* Seek to a certain position on STREAM.
678 This function is a possible cancellation point and therefore not
679 marked with __THROW. */
680 extern int fseeko (FILE *__stream, __off_t __off, int __whence);
681 /* Return the current position of STREAM.
683 This function is a possible cancellation point and therefore not
684 marked with __THROW. */
685 extern __off_t ftello (FILE *__stream) __wur;
686 # else
687 # ifdef __REDIRECT
688 extern int __REDIRECT (fseeko,
689 (FILE *__stream, __off64_t __off, int __whence),
690 fseeko64);
691 extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
692 # else
693 # define fseeko fseeko64
694 # define ftello ftello64
695 # endif
696 # endif
697 #endif
699 __BEGIN_NAMESPACE_STD
700 #ifndef __USE_FILE_OFFSET64
701 /* Get STREAM's position.
703 This function is a possible cancellation point and therefore not
704 marked with __THROW. */
705 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
706 /* Set STREAM's position.
708 This function is a possible cancellation point and therefore not
709 marked with __THROW. */
710 extern int fsetpos (FILE *__stream, __const fpos_t *__pos);
711 #else
712 # ifdef __REDIRECT
713 extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
714 fpos_t *__restrict __pos), fgetpos64);
715 extern int __REDIRECT (fsetpos,
716 (FILE *__stream, __const fpos_t *__pos), fsetpos64);
717 # else
718 # define fgetpos fgetpos64
719 # define fsetpos fsetpos64
720 # endif
721 #endif
722 __END_NAMESPACE_STD
724 #ifdef __USE_LARGEFILE64
725 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
726 extern __off64_t ftello64 (FILE *__stream) __wur;
727 extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
728 extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos);
729 #endif
731 __BEGIN_NAMESPACE_STD
732 /* Clear the error and EOF indicators for STREAM. */
733 extern void clearerr (FILE *__stream) __THROW;
734 /* Return the EOF indicator for STREAM. */
735 extern int feof (FILE *__stream) __THROW __wur;
736 /* Return the error indicator for STREAM. */
737 extern int ferror (FILE *__stream) __THROW __wur;
738 __END_NAMESPACE_STD
740 #ifdef __USE_MISC
741 /* Faster versions when locking is not required. */
742 extern void clearerr_unlocked (FILE *__stream) __THROW;
743 extern int feof_unlocked (FILE *__stream) __THROW __wur;
744 extern int ferror_unlocked (FILE *__stream) __THROW __wur;
745 #endif
748 __BEGIN_NAMESPACE_STD
749 /* Print a message describing the meaning of the value of errno.
751 This function is a possible cancellation point and therefore not
752 marked with __THROW. */
753 extern void perror (__const char *__s);
754 __END_NAMESPACE_STD
756 /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
757 are available on this system. Even if available, these variables
758 should not be used directly. The `strerror' function provides
759 all the necessary functionality. */
760 #include <bits/sys_errlist.h>
763 #ifdef __USE_POSIX
764 /* Return the system file descriptor for STREAM. */
765 extern int fileno (FILE *__stream) __THROW __wur;
766 #endif /* Use POSIX. */
768 #ifdef __USE_MISC
769 /* Faster version when locking is not required. */
770 extern int fileno_unlocked (FILE *__stream) __THROW __wur;
771 #endif
774 #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
775 defined __USE_MISC)
776 /* Create a new stream connected to a pipe running the given command.
778 This function is a possible cancellation point and therefore not
779 marked with __THROW. */
780 extern FILE *popen (__const char *__command, __const char *__modes) __wur;
782 /* Close a stream opened by popen and return the status of its child.
784 This function is a possible cancellation point and therefore not
785 marked with __THROW. */
786 extern int pclose (FILE *__stream);
787 #endif
790 #ifdef __USE_POSIX
791 /* Return the name of the controlling terminal. */
792 extern char *ctermid (char *__s) __THROW;
793 #endif /* Use POSIX. */
796 #ifdef __USE_XOPEN
797 /* Return the name of the current user. */
798 extern char *cuserid (char *__s);
799 #endif /* Use X/Open, but not issue 6. */
802 #ifdef __USE_GNU
803 struct obstack; /* See <obstack.h>. */
805 /* Write formatted output to an obstack. */
806 extern int obstack_printf (struct obstack *__restrict __obstack,
807 __const char *__restrict __format, ...)
808 __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
809 extern int obstack_vprintf (struct obstack *__restrict __obstack,
810 __const char *__restrict __format,
811 _G_va_list __args)
812 __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
813 #endif /* Use GNU. */
816 #if defined __USE_POSIX || defined __USE_MISC
817 /* These are defined in POSIX.1:1996. */
819 /* Acquire ownership of STREAM. */
820 extern void flockfile (FILE *__stream) __THROW;
822 /* Try to acquire ownership of STREAM but do not block if it is not
823 possible. */
824 extern int ftrylockfile (FILE *__stream) __THROW __wur;
826 /* Relinquish the ownership granted for STREAM. */
827 extern void funlockfile (FILE *__stream) __THROW;
828 #endif /* POSIX || misc */
830 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
831 /* The X/Open standard requires some functions and variables to be
832 declared here which do not belong into this header. But we have to
833 follow. In GNU mode we don't do this nonsense. */
834 # define __need_getopt
835 # include <getopt.h>
836 #endif /* X/Open, but not issue 6 and not for GNU. */
838 /* If we are compiling with optimizing read this file. It contains
839 several optimizing inline functions and macros. */
840 #ifdef __USE_EXTERN_INLINES
841 # include <bits/stdio.h>
842 #endif
843 #if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus
844 # include <bits/stdio2.h>
845 #endif
846 #ifdef __LDBL_COMPAT
847 # include <bits/stdio-ldbl.h>
848 #endif
850 __END_DECLS
852 #endif /* <stdio.h> included. */
854 #endif /* !_STDIO_H */