]> git.ipfire.org Git - thirdparty/glibc.git/blob - libio/stdio.h
Update.
[thirdparty/glibc.git] / libio / stdio.h
1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
18
19 /*
20 * ISO C Standard: 4.9 INPUT/OUTPUT <stdio.h>
21 */
22
23 #ifndef _STDIO_H
24
25 #ifndef __need_FILE
26 # define _STDIO_H 1
27 # include <features.h>
28
29 __BEGIN_DECLS
30
31 # define __need_size_t
32 # define __need_NULL
33 # include <stddef.h>
34
35 # define __need___va_list
36 # include <stdarg.h>
37
38 # include <bits/types.h>
39 #endif /* Don't need FILE. */
40 #undef __need_FILE
41
42
43 #ifndef __FILE_defined
44
45 /* The opaque type of streams. */
46 typedef struct _IO_FILE FILE;
47
48 # define __FILE_defined 1
49 #endif /* FILE not defined. */
50
51
52 #ifdef _STDIO_H
53 #define _STDIO_USES_IOSTREAM
54
55 #include <libio.h>
56
57 #ifdef __cplusplus
58 # define __STDIO_INLINE inline
59 #else
60 # define __STDIO_INLINE extern __inline
61 #endif
62
63 /* The type of the second argument to `fgetpos' and `fsetpos'. */
64 #ifndef __USE_FILE_OFFSET64
65 typedef _G_fpos_t fpos_t;
66 #else
67 typedef _G_fpos64_t fpos_t;
68 #endif
69 #ifdef __USE_LARGEFILE64
70 typedef _G_fpos64_t fpos64_t;
71 #endif
72
73 /* Generate a unique file name (and possibly open it with mode "w+b"). */
74 extern char *__stdio_gen_tempname __P ((char *__buf, size_t __bufsize,
75 __const char *__dir,
76 __const char *__pfx,
77 int __dir_search,
78 size_t *__lenptr,
79 FILE **__streamptr,
80 int __large_file));
81
82
83 /* Print out MESSAGE on the error output and abort. */
84 extern void __libc_fatal __P ((__const char *__message))
85 __attribute__ ((__noreturn__));
86
87
88 /* The possibilities for the third argument to `setvbuf'. */
89 #define _IOFBF 0 /* Fully buffered. */
90 #define _IOLBF 1 /* Line buffered. */
91 #define _IONBF 2 /* No buffering. */
92
93
94 /* Default buffer size. */
95 #ifndef BUFSIZ
96 # define BUFSIZ _IO_BUFSIZ
97 #endif
98
99
100 /* End of file character.
101 Some things throughout the library rely on this being -1. */
102 #ifndef EOF
103 # define EOF (-1)
104 #endif
105
106
107 /* The possibilities for the third argument to `fseek'.
108 These values should not be changed. */
109 #define SEEK_SET 0 /* Seek from beginning of file. */
110 #define SEEK_CUR 1 /* Seek from current position. */
111 #define SEEK_END 2 /* Seek from end of file. */
112
113
114 #ifdef __USE_SVID
115 /* Default path prefix for `tempnam' and `tmpnam'. */
116 # define P_tmpdir "/tmp"
117 #endif
118
119
120 /* Get the values:
121 L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
122 TMP_MAX The minimum number of unique filenames generated by tmpnam
123 (and tempnam when it uses tmpnam's name space),
124 or tempnam (the two are separate).
125 L_ctermid How long an array to pass to `ctermid'.
126 L_cuserid How long an array to pass to `cuserid'.
127 FOPEN_MAX Minimum number of files that can be open at once.
128 FILENAME_MAX Maximum length of a filename. */
129 #include <bits/stdio_lim.h>
130
131
132 /* Standard streams. */
133 extern FILE *stdin; /* Standard input stream. */
134 extern FILE *stdout; /* Standard output stream. */
135 extern FILE *stderr; /* Standard error output stream. */
136
137
138 /* Remove file FILENAME. */
139 extern int remove __P ((__const char *__filename));
140 /* Rename file OLD to NEW. */
141 extern int rename __P ((__const char *__old, __const char *__new));
142
143
144 /* Create a temporary file and open it read/write. */
145 #ifndef __USE_FILE_OFFSET64
146 extern FILE *tmpfile __P ((void));
147 #else
148 # ifdef __REDIRECT
149 extern FILE *__REDIRECT (tmpfile, __P ((void)), tmpfile64);
150 # else
151 # define tmpfile tmpfile64
152 # endif
153 #endif
154 #ifdef __USE_LARGEFILE64
155 extern FILE *tmpfile64 __P ((void));
156 #endif
157 /* Generate a temporary filename. */
158 extern char *tmpnam __P ((char *__s));
159
160 #ifdef __USE_MISC
161 /* This is the reentrant variant of `tmpnam'. The only difference is
162 that it does not allow S to be NULL. */
163 extern char *tmpnam_r __P ((char *__s));
164 #endif
165
166
167 #if defined __USE_SVID || defined __USE_XOPEN
168 /* Generate a unique temporary filename using up to five characters of PFX
169 if it is not NULL. The directory to put this file in is searched for
170 as follows: First the environment variable "TMPDIR" is checked.
171 If it contains the name of a writable directory, that directory is used.
172 If not and if DIR is not NULL, that value is checked. If that fails,
173 P_tmpdir is tried and finally "/tmp". The storage for the filename
174 is allocated by `malloc'. */
175 extern char *tempnam __P ((__const char *__dir, __const char *__pfx));
176 #endif
177
178
179 /* Close STREAM. */
180 extern int fclose __P ((FILE *__stream));
181 /* Flush STREAM, or all streams if STREAM is NULL. */
182 extern int fflush __P ((FILE *__stream));
183
184 #ifdef __USE_MISC
185 /* Faster versions when locking is not required. */
186 extern int fclose_unlocked __P ((FILE *__stream));
187 extern int fflush_unlocked __P ((FILE *__stream));
188 #endif
189
190 #ifdef __USE_GNU
191 /* Close all streams. */
192 extern int __fcloseall __P ((void));
193 extern int fcloseall __P ((void));
194 #endif
195
196
197 #ifndef __USE_FILE_OFFSET64
198 /* Open a file and create a new stream for it. */
199 extern FILE *fopen __P ((__const char *__restrict __filename,
200 __const char *__restrict __modes));
201 /* Open a file, replacing an existing stream with it. */
202 extern FILE *freopen __P ((__const char *__restrict __filename,
203 __const char *__restrict __modes,
204 FILE *__restrict __stream));
205 #else
206 # ifdef __REDIRECT
207 extern FILE *__REDIRECT (fopen, __P ((__const char *__restrict __filename,
208 __const char *__restrict __modes)),
209 fopen64);
210 extern FILE *__REDIRECT (freopen, __P ((__const char *__restrict __filename,
211 __const char *__restrict __modes,
212 FILE *__restrict __stream)),
213 freopen64);
214 # else
215 # define fopen fopen64
216 # define freopen freopen64
217 # endif
218 #endif
219 #ifdef __USE_LARGEFILE64
220 extern FILE *fopen64 __P ((__const char *__restrict __filename,
221 __const char *__restrict __modes));
222 extern FILE *freopen64 __P ((__const char *__restrict __filename,
223 __const char *__restrict __modes,
224 FILE *__restrict __stream));
225 #endif
226
227 #ifdef __USE_POSIX
228 /* Create a new stream that refers to an existing system file descriptor. */
229 extern FILE *fdopen __P ((int __fd, __const char *__modes));
230 #endif
231
232 #ifdef __USE_GNU
233 /* Create a new stream that refers to the given magic cookie,
234 and uses the given functions for input and output. */
235 extern FILE *fopencookie __P ((void *__magic_cookie, __const char *__modes,
236 _IO_cookie_io_functions_t __io_funcs));
237
238 /* Open a stream that writes into a malloc'd buffer that is expanded as
239 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
240 and the number of characters written on fflush or fclose. */
241 extern FILE *open_memstream __P ((char **__bufloc, size_t *__sizeloc));
242 #endif
243
244
245 /* If BUF is NULL, make STREAM unbuffered.
246 Else make it use buffer BUF, of size BUFSIZ. */
247 extern void setbuf __P ((FILE *__restrict __stream, char *__restrict __buf));
248 /* Make STREAM use buffering mode MODE.
249 If BUF is not NULL, use N bytes of it for buffering;
250 else allocate an internal buffer N bytes long. */
251 extern int setvbuf __P ((FILE *__restrict __stream, char *__restrict __buf,
252 int __modes, size_t __n));
253
254 #ifdef __USE_BSD
255 /* If BUF is NULL, make STREAM unbuffered.
256 Else make it use SIZE bytes of BUF for buffering. */
257 extern void setbuffer __P ((FILE *__stream, char *__buf, size_t __size));
258
259 /* Make STREAM line-buffered. */
260 extern void setlinebuf __P ((FILE *__stream));
261 #endif
262
263
264 /* Write formatted output to STREAM. */
265 extern int fprintf __P ((FILE *__restrict __stream,
266 __const char *__restrict __format, ...));
267 /* Write formatted output to stdout. */
268 extern int printf __P ((__const char *__restrict __format, ...));
269 /* Write formatted output to S. */
270 extern int sprintf __P ((char *__restrict __s,
271 __const char *__restrict __format, ...));
272
273 /* Write formatted output to S from argument list ARG. */
274 extern int vfprintf __P ((FILE *__restrict __s,
275 __const char *__restrict __format,
276 _G_va_list __arg));
277 /* Write formatted output to stdout from argument list ARG. */
278 extern int vprintf __P ((__const char *__restrict __format,
279 _G_va_list __arg));
280 /* Write formatted output to S from argument list ARG. */
281 extern int vsprintf __P ((char *__restrict __s,
282 __const char *__restrict __format,
283 _G_va_list __arg));
284
285 #ifdef __OPTIMIZE__
286 __STDIO_INLINE int
287 vprintf (__const char *__restrict __fmt, _G_va_list __arg)
288 {
289 return vfprintf (stdout, __fmt, __arg);
290 }
291 #endif /* Optimizing. */
292
293 #if defined __USE_BSD || defined __USE_ISOC9X || defined __USE_UNIX98
294 /* Maximum chars of output to write in MAXLEN. */
295 extern int __snprintf __P ((char *__restrict __s, size_t __maxlen,
296 __const char *__restrict __format, ...))
297 __attribute__ ((__format__ (__printf__, 3, 4)));
298 extern int snprintf __P ((char *__restrict __s, size_t __maxlen,
299 __const char *__restrict __format, ...))
300 __attribute__ ((__format__ (__printf__, 3, 4)));
301
302 extern int __vsnprintf __P ((char *__restrict __s, size_t __maxlen,
303 __const char *__restrict __format,
304 _G_va_list __arg))
305 __attribute__ ((__format__ (__printf__, 3, 0)));
306 extern int vsnprintf __P ((char *__restrict __s, size_t __maxlen,
307 __const char *__restrict __format,
308 _G_va_list __arg))
309 __attribute__ ((__format__ (__printf__, 3, 0)));
310 #endif
311
312 #ifdef __USE_GNU
313 /* Write formatted output to a string dynamically allocated with `malloc'.
314 Store the address of the string in *PTR. */
315 extern int vasprintf __P ((char **__restrict __ptr,
316 __const char *__restrict __f, _G_va_list __arg))
317 __attribute__ ((__format__ (__printf__, 2, 0)));
318 extern int __asprintf __P ((char **__restrict __ptr,
319 __const char *__restrict __fmt, ...))
320 __attribute__ ((__format__ (__printf__, 2, 3)));
321 extern int asprintf __P ((char **__restrict __ptr,
322 __const char *__restrict __fmt, ...))
323 __attribute__ ((__format__ (__printf__, 2, 3)));
324
325 /* Write formatted output to a file descriptor. */
326 extern int vdprintf __P ((int __fd, __const char *__restrict __fmt,
327 _G_va_list __arg))
328 __attribute__ ((__format__ (__printf__, 2, 0)));
329 extern int dprintf __P ((int __fd, __const char *__restrict __fmt, ...))
330 __attribute__ ((__format__ (__printf__, 2, 3)));
331 #endif
332
333
334 /* Read formatted input from STREAM. */
335 extern int fscanf __P ((FILE *__restrict __stream,
336 __const char *__restrict __format, ...));
337 /* Read formatted input from stdin. */
338 extern int scanf __P ((__const char *__restrict __format, ...));
339 /* Read formatted input from S. */
340 extern int sscanf __P ((__const char *__restrict __s,
341 __const char *__restrict __format, ...));
342
343 #ifdef __USE_GNU
344 /* Read formatted input from S into argument list ARG. */
345 extern int __vfscanf __P ((FILE *__restrict __s,
346 __const char *__restrict __format,
347 _G_va_list __arg))
348 __attribute__ ((__format__ (__scanf__, 2, 0)));
349 extern int vfscanf __P ((FILE *__restrict __s,
350 __const char *__restrict __format,
351 _G_va_list __arg))
352 __attribute__ ((__format__ (__scanf__, 2, 0)));
353
354 /* Read formatted input from stdin into argument list ARG. */
355 extern int __vscanf __P ((__const char *__restrict __format,
356 _G_va_list __arg))
357 __attribute__ ((__format__ (__scanf__, 1, 0)));
358 extern int vscanf __P ((__const char *__restrict __format, _G_va_list __arg))
359 __attribute__ ((__format__ (__scanf__, 1, 0)));
360
361 /* Read formatted input from S into argument list ARG. */
362 extern int __vsscanf __P ((__const char *__restrict __s,
363 __const char *__restrict __format,
364 _G_va_list __arg))
365 __attribute__ ((__format__ (__scanf__, 2, 0)));
366 extern int vsscanf __P ((__const char *__restrict __s,
367 __const char *__restrict __format,
368 _G_va_list __arg))
369 __attribute__ ((__format__ (__scanf__, 2, 0)));
370 #endif /* Use GNU. */
371
372
373 /* Read a character from STREAM. */
374 extern int fgetc __P ((FILE *__stream));
375 extern int getc __P ((FILE *__stream));
376
377 /* Read a character from stdin. */
378 extern int getchar __P ((void));
379
380 /* The C standard explicitly says this is a macro, so we always do the
381 optimization for it. */
382 #define getc(_fp) _IO_getc (_fp)
383
384 #ifdef __OPTIMIZE__
385 __STDIO_INLINE int
386 getchar (void)
387 {
388 return _IO_getc (stdin);
389 }
390 #endif /* Optimizing. */
391
392 #if defined __USE_POSIX || defined __USE_MISC
393 /* These are defined in POSIX.1:1996. */
394 extern int getc_unlocked __P ((FILE *__stream));
395 extern int getchar_unlocked __P ((void));
396
397 # ifdef __OPTIMIZE__
398 __STDIO_INLINE int
399 getc_unlocked (FILE *__fp)
400 {
401 return _IO_getc_unlocked (__fp);
402 }
403
404 __STDIO_INLINE int
405 getchar_unlocked (void)
406 {
407 return _IO_getc_unlocked (stdin);
408 }
409 # endif /* Optimizing. */
410 #endif /* Use POSIX or MISC. */
411
412
413 /* Write a character to STREAM. */
414 extern int fputc __P ((int __c, FILE *__stream));
415 extern int putc __P ((int __c, FILE *__stream));
416
417 /* Write a character to stdout. */
418 extern int putchar __P ((int __c));
419
420 /* The C standard explicitly says this can be a macro,
421 so we always do the optimization for it. */
422 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
423
424 #ifdef __OPTIMIZE__
425 __STDIO_INLINE int
426 putchar (int __c)
427 {
428 return _IO_putc (__c, stdout);
429 }
430 #endif
431
432 #ifdef __USE_MISC
433 /* Faster version when locking is not necessary. */
434 extern int fputc_unlocked __P ((int __c, FILE *__stream));
435
436 # ifdef __OPTIMIZE__
437 __STDIO_INLINE int
438 fputc_unlocked (int __c, FILE *__stream)
439 {
440 return _IO_putc_unlocked (__c, __stream);
441 }
442 # endif /* Optimizing. */
443 #endif /* Use MISC. */
444
445 #if defined __USE_POSIX || defined __USE_MISC
446 /* These are defined in POSIX.1:1996. */
447 extern int putc_unlocked __P ((int __c, FILE *__stream));
448 extern int putchar_unlocked __P ((int __c));
449
450 # ifdef __OPTIMIZE__
451 __STDIO_INLINE int
452 putc_unlocked (int __c, FILE *__stream)
453 {
454 return _IO_putc_unlocked (__c, __stream);
455 }
456
457 __STDIO_INLINE int
458 putchar_unlocked (int __c)
459 {
460 return _IO_putc_unlocked (__c, stdout);
461 }
462 # endif /* Optimizing. */
463 #endif /* Use POSIX or MISc. */
464
465
466 #if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
467 /* Get a word (int) from STREAM. */
468 extern int getw __P ((FILE *__stream));
469
470 /* Write a word (int) to STREAM. */
471 extern int putw __P ((int __w, FILE *__stream));
472 #endif
473
474
475 /* Get a newline-terminated string of finite length from STREAM. */
476 extern char *fgets __P ((char *__restrict __s, int __n,
477 FILE *__restrict __stream));
478
479 /* Get a newline-terminated string from stdin, removing the newline.
480 DO NOT USE THIS FUNCTION!! There is no limit on how much it will read. */
481 extern char *gets __P ((char *__s));
482
483
484 #ifdef __USE_GNU
485 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
486 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
487 NULL), pointing to *N characters of space. It is realloc'd as
488 necessary. Returns the number of characters read (not including the
489 null terminator), or -1 on error or EOF. */
490 _IO_ssize_t __getdelim __P ((char **__lineptr, size_t *__n,
491 int __delimiter, FILE *__stream));
492 _IO_ssize_t getdelim __P ((char **__lineptr, size_t *__n,
493 int __delimiter, FILE *__stream));
494
495 /* Like `getdelim', but reads up to a newline. */
496 _IO_ssize_t __getline __P ((char **__lineptr, size_t *__n, FILE *__stream));
497 _IO_ssize_t getline __P ((char **__lineptr, size_t *__n, FILE *__stream));
498
499 # ifdef __OPTIMIZE__
500 __STDIO_INLINE _IO_ssize_t
501 getline (char **__lineptr, size_t *__n, FILE *__stream)
502 {
503 return __getdelim (__lineptr, __n, '\n', __stream);
504 }
505 # endif /* Optimizing. */
506 #endif
507
508
509 /* Write a string to STREAM. */
510 extern int fputs __P ((__const char *__restrict __s,
511 FILE *__restrict __stream));
512 /* Write a string, followed by a newline, to stdout. */
513 extern int puts __P ((__const char *__s));
514
515
516 /* Push a character back onto the input buffer of STREAM. */
517 extern int ungetc __P ((int __c, FILE *__stream));
518
519
520 /* Read chunks of generic data from STREAM. */
521 extern size_t fread __P ((void *__restrict __ptr, size_t __size,
522 size_t __n, FILE *__restrict __stream));
523 /* Write chunks of generic data to STREAM. */
524 extern size_t fwrite __P ((__const void *__restrict __ptr, size_t __size,
525 size_t __n, FILE *__restrict __s));
526
527 #ifdef __USE_MISC
528 /* Faster versions when locking is not necessary. */
529 extern size_t fread_unlocked __P ((void *__restrict __ptr, size_t __size,
530 size_t __n, FILE *__restrict __stream));
531 extern size_t fwrite_unlocked __P ((__const void *__restrict __ptr,
532 size_t __size, size_t __n,
533 FILE *__restrict __stream));
534 #endif
535
536
537 /* Seek to a certain position on STREAM. */
538 extern int fseek __P ((FILE *__stream, long int __off, int __whence));
539 /* Return the current position of STREAM. */
540 extern long int ftell __P ((FILE *__stream));
541 /* Rewind to the beginning of STREAM. */
542 extern void rewind __P ((FILE *__stream));
543
544 #if (defined __USE_LARGEFILE || defined __USE_LARGEFILE64 \
545 || defined __USE_FILE_OFFSET64)
546 /* The Single Unix Specification, Version 2, specifies an alternative,
547 more adequate interface for the two functions above which deal with
548 file offset. `long int' is not the right type. These definitions
549 are originally defined in the Large File Support API. */
550
551 /* Types needed in these functions. */
552 # ifndef off_t
553 # ifndef __USE_FILE_OFFSET64
554 typedef __off_t off_t;
555 # else
556 typedef __off64_t off_t;
557 # endif
558 # define off_t off_t
559 # endif
560
561 # if defined __USE_LARGEFILE64 && !defined off64_t
562 typedef __off64_t off64_t;
563 # define off64_t off64_t
564 # endif
565
566
567 # ifndef __USE_FILE_OFFSET64
568 /* Seek to a certain position on STREAM. */
569 extern int fseeko __P ((FILE *__stream, __off_t __off, int __whence));
570 /* Return the current position of STREAM. */
571 extern __off_t ftello __P ((FILE *__stream));
572 /* Get STREAM's position. */
573 extern int fgetpos __P ((FILE *__restrict __stream,
574 fpos_t *__restrict __pos));
575 /* Set STREAM's position. */
576 extern int fsetpos __P ((FILE *__stream, __const fpos_t *__pos));
577 # else
578 # ifdef __REDIRECT
579 extern int __REDIRECT (fseeko,
580 __P ((FILE *__stream, __off64_t __off, int __whence)),
581 fseeko64);
582 extern __off64_t __REDIRECT (ftello, __P ((FILE *__stream)), ftello64);
583 extern int __REDIRECT (fgetpos, __P ((FILE *__restrict __stream,
584 fpos_t *__restrict __pos)), fgetpos64);
585 extern int __REDIRECT (fsetpos, __P ((FILE *__stream, __const fpos_t *__pos)),
586 fsetpos64);
587 # else
588 # define fseeko fseeko64
589 # define ftello ftello64
590 # define fgetpos fgetpos64
591 # define fsetpos fsetpos64
592 # endif
593 # endif
594
595 # ifdef __USE_LARGEFILE64
596 extern int fseeko64 __P ((FILE *__stream, __off64_t __off, int __whence));
597 extern __off64_t ftello64 __P ((FILE *__stream));
598 extern int fgetpos64 __P ((FILE *__restrict __stream,
599 fpos64_t *__restrict __pos));
600 extern int fsetpos64 __P ((FILE *__stream, __const fpos64_t *__pos));
601 # endif
602 #endif
603
604 /* Clear the error and EOF indicators for STREAM. */
605 extern void clearerr __P ((FILE *__stream));
606 /* Return the EOF indicator for STREAM. */
607 extern int feof __P ((FILE *__stream));
608 /* Return the error indicator for STREAM. */
609 extern int ferror __P ((FILE *__stream));
610
611 #ifdef __USE_MISC
612 /* Faster versions when locking is not required. */
613 extern void clearerr_unlocked __P ((FILE *__stream));
614 extern int feof_unlocked __P ((FILE *__stream));
615 extern int ferror_unlocked __P ((FILE *__stream));
616
617 # ifdef __OPTIMIZE__
618 __STDIO_INLINE int
619 feof_unlocked (FILE *__stream)
620 {
621 return _IO_feof_unlocked (__stream);
622 }
623
624 __STDIO_INLINE int
625 ferror_unlocked (FILE *__stream)
626 {
627 return _IO_ferror_unlocked (__stream);
628 }
629 # endif /* Optimizing. */
630 #endif
631
632
633 /* Print a message describing the meaning of the value of errno. */
634 extern void perror __P ((__const char *__s));
635
636 /* These variables normally should not be used directly. The `strerror'
637 function provides all the needed functionality. */
638 #ifdef __USE_BSD
639 extern int sys_nerr;
640 extern __const char *__const sys_errlist[];
641 #endif
642 #ifdef __USE_GNU
643 extern int _sys_nerr;
644 extern __const char *__const _sys_errlist[];
645 #endif
646
647
648 #ifdef __USE_POSIX
649 /* Return the system file descriptor for STREAM. */
650 extern int fileno __P ((FILE *__stream));
651 #endif /* Use POSIX. */
652
653 #ifdef __USE_MISC
654 /* Faster version when locking is not required. */
655 extern int fileno_unlocked __P ((FILE *__stream));
656 #endif
657
658
659 #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
660 defined __USE_MISC)
661 /* Create a new stream connected to a pipe running the given command. */
662 extern FILE *popen __P ((__const char *__command, __const char *__modes));
663
664 /* Close a stream opened by popen and return the status of its child. */
665 extern int pclose __P ((FILE *__stream));
666 #endif
667
668
669 #ifdef __USE_POSIX
670 /* Return the name of the controlling terminal. */
671 extern char *ctermid __P ((char *__s));
672 #endif /* Use POSIX. */
673
674
675 #ifdef __USE_XOPEN
676 /* Return the name of the current user. */
677 extern char *cuserid __P ((char *__s));
678 #endif /* Use X/Open. */
679
680
681 #ifdef __USE_GNU
682 struct obstack; /* See <obstack.h>. */
683
684 /* Write formatted output to an obstack. */
685 extern int obstack_printf __P ((struct obstack *__obstack,
686 __const char *__format, ...));
687 extern int obstack_vprintf __P ((struct obstack *__obstack,
688 __const char *__format,
689 _G_va_list __args));
690 #endif /* Use GNU. */
691
692
693 #if defined __USE_POSIX || defined __USE_MISC
694 /* These are defined in POSIX.1:1996. */
695
696 /* Acquire ownership of STREAM. */
697 extern void flockfile __P ((FILE *__stream));
698
699 /* Try to acquire ownership of STREAM but do not block if it is not
700 possible. */
701 extern int ftrylockfile __P ((FILE *__stream));
702
703 /* Relinquish the ownership granted for STREAM. */
704 extern void funlockfile __P ((FILE *__stream));
705 #endif /* POSIX || misc */
706
707 #if defined __USE_XOPEN && !defined __USE_GNU
708 /* The X/Open standard requires some functions and variables to be
709 declared here which do not belong into this header. But we have to
710 follow. In GNU mode we don't do this nonsense. */
711
712 /* For more information on these symbols look in <getopt.h>. */
713 extern char *optarg;
714 extern int optind;
715 extern int opterr;
716 extern int optopt;
717
718 extern int getopt __P ((int __argc, char *__const *__argv,
719 __const char *__shortopts));
720 #endif
721
722 __END_DECLS
723
724 /* Define helper macro. */
725 #undef __STDIO_INLINE
726
727 #endif /* <stdio.h> included. */
728
729 #endif /* !_STDIO_H */