OSDN Git Service

The 'Somebody Else's Problem Field' was just activated
[uclinux-h8/uclibc-ng.git] / include / stdio.h
1 /*
2    Copyright (C) 1991,1994-2002,2003,2004 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
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.
9
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.
14
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.  */
19
20 /*
21  *      ISO C99 Standard: 7.19 Input/output     <stdio.h>
22  */
23
24 #ifndef _STDIO_H
25
26 #if !defined __need_FILE && !defined __need___FILE
27 # define _STDIO_H       1
28 # include <features.h>
29
30 __BEGIN_DECLS
31
32 # define __need_size_t
33 # define __need_NULL
34 # include <stddef.h>
35
36 # include <bits/types.h>
37 # define __need_FILE
38 # define __need___FILE
39 #endif /* Don't need FILE.  */
40
41
42 #if !defined __FILE_defined && defined __need_FILE
43
44 __BEGIN_NAMESPACE_STD
45 /* The opaque type of streams.  This is the definition used elsewhere.  */
46 typedef struct __STDIO_FILE_STRUCT 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
53
54 # define __FILE_defined 1
55 #endif /* FILE not defined.  */
56 #undef  __need_FILE
57
58
59 #if !defined ____FILE_defined && defined __need___FILE
60
61 /* The opaque type of streams.  This is the definition used elsewhere.  */
62 typedef struct __STDIO_FILE_STRUCT __FILE;
63
64 # define ____FILE_defined       1
65 #endif /* __FILE not defined.  */
66 #undef  __need___FILE
67
68
69 #ifdef  _STDIO_H
70 #undef _STDIO_USES_IOSTREAM
71
72 #include <bits/uClibc_stdio.h>
73
74 /* This define avoids name pollution if we're using GNU stdarg.h */
75 # define __need___va_list
76 #include <stdarg.h>
77
78 /* The type of the second argument to `fgetpos' and `fsetpos'.  */
79 __BEGIN_NAMESPACE_STD
80 #ifndef __USE_FILE_OFFSET64
81 typedef __STDIO_fpos_t fpos_t;
82 #else
83 typedef __STDIO_fpos64_t fpos_t;
84 #endif
85 __END_NAMESPACE_STD
86 #ifdef __USE_LARGEFILE64
87 typedef __STDIO_fpos64_t fpos64_t;
88 #endif
89
90 /* The possibilities for the third argument to `setvbuf'.  */
91 #define _IOFBF __STDIO_IOFBF            /* Fully buffered.  */
92 #define _IOLBF __STDIO_IOLBF            /* Line buffered.  */
93 #define _IONBF __STDIO_IONBF            /* No buffering.  */
94
95
96 /* Default buffer size.  */
97 #ifndef BUFSIZ
98 # define BUFSIZ __STDIO_BUFSIZ
99 #endif
100
101
102 /* End of file character.
103    Some things throughout the library rely on this being -1.  */
104 #ifndef EOF
105 # define EOF (-1)
106 #endif
107
108
109 /* The possibilities for the third argument to `fseek'.
110    These values should not be changed.  */
111 #define SEEK_SET        0       /* Seek from beginning of file.  */
112 #define SEEK_CUR        1       /* Seek from current position.  */
113 #define SEEK_END        2       /* Seek from end of file.  */
114
115
116 #if defined __USE_SVID || defined __USE_XOPEN
117 /* Default path prefix for `tempnam' and `tmpnam'.  */
118 # define P_tmpdir       "/tmp"
119 #endif
120
121
122 /* Get the values:
123    L_tmpnam     How long an array of chars must be to be passed to `tmpnam'.
124    TMP_MAX      The minimum number of unique filenames generated by tmpnam
125                 (and tempnam when it uses tmpnam's name space),
126                 or tempnam (the two are separate).
127    L_ctermid    How long an array to pass to `ctermid'.
128    L_cuserid    How long an array to pass to `cuserid'.
129    FOPEN_MAX    Minimum number of files that can be open at once.
130    FILENAME_MAX Maximum length of a filename.  */
131 #include <bits/stdio_lim.h>
132
133
134 /* Standard streams.  */
135 extern FILE *stdin;             /* Standard input stream.  */
136 extern FILE *stdout;        /* Standard output stream.  */
137 extern FILE *stderr;        /* Standard error output stream.  */
138 /* C89/C99 say they're macros.  Make them happy.  */
139 #define stdin stdin
140 #define stdout stdout
141 #define stderr stderr
142
143 __BEGIN_NAMESPACE_STD
144 /* Remove file FILENAME.  */
145 extern int remove (__const char *__filename) __THROW;
146 /* Rename file OLD to NEW.  */
147 extern int rename (__const char *__old, __const char *__new) __THROW;
148 __END_NAMESPACE_STD
149
150
151 __BEGIN_NAMESPACE_STD
152 /* Create a temporary file and open it read/write.
153
154    This function is a possible cancellation points and therefore not
155    marked with __THROW.  */
156 #ifndef __USE_FILE_OFFSET64
157 extern FILE *tmpfile (void);
158 #else
159 # ifdef __REDIRECT
160 extern FILE *__REDIRECT (tmpfile, (void), tmpfile64);
161 # else
162 #  define tmpfile tmpfile64
163 # endif
164 #endif
165
166 #ifdef __USE_LARGEFILE64
167 extern FILE *tmpfile64 (void);
168 #endif
169
170 /* Generate a temporary filename.  */
171 extern char *tmpnam (char *__s) __THROW;
172 __END_NAMESPACE_STD
173
174 #ifdef __USE_MISC
175 /* This is the reentrant variant of `tmpnam'.  The only difference is
176    that it does not allow S to be NULL.  */
177 extern char *tmpnam_r (char *__s) __THROW;
178 #endif
179
180
181 #if defined __USE_SVID || defined __USE_XOPEN
182 /* Generate a unique temporary filename using up to five characters of PFX
183    if it is not NULL.  The directory to put this file in is searched for
184    as follows: First the environment variable "TMPDIR" is checked.
185    If it contains the name of a writable directory, that directory is used.
186    If not and if DIR is not NULL, that value is checked.  If that fails,
187    P_tmpdir is tried and finally "/tmp".  The storage for the filename
188    is allocated by `malloc'.  */
189 extern char *tempnam (__const char *__dir, __const char *__pfx)
190      __THROW __attribute_malloc__;
191 #endif
192
193
194 __BEGIN_NAMESPACE_STD
195 /* Close STREAM.
196
197    This function is a possible cancellation point and therefore not
198    marked with __THROW.  */
199 extern int fclose (FILE *__stream);
200 /* Flush STREAM, or all streams if STREAM is NULL.
201
202    This function is a possible cancellation point and therefore not
203    marked with __THROW.  */
204 extern int fflush (FILE *__stream);
205 __END_NAMESPACE_STD
206
207 #ifdef __USE_MISC
208 /* Faster versions when locking is not required.
209
210    This function is not part of POSIX and therefore no official
211    cancellation point.  But due to similarity with an POSIX interface
212    or due to the implementation it is a cancellation point and
213    therefore not marked with __THROW.  */
214 extern int fflush_unlocked (FILE *__stream);
215 #endif
216
217 #ifdef __USE_GNU
218 /* Close all streams.
219
220    This function is not part of POSIX and therefore no official
221    cancellation point.  But due to similarity with an POSIX interface
222    or due to the implementation it is a cancellation point and
223    therefore not marked with __THROW.  */
224 extern int fcloseall (void);
225 #endif
226
227
228 __BEGIN_NAMESPACE_STD
229 #ifndef __USE_FILE_OFFSET64
230 /* Open a file and create a new stream for it.
231
232    This function is a possible cancellation point and therefore not
233    marked with __THROW.  */
234 extern FILE *fopen (__const char *__restrict __filename,
235                     __const char *__restrict __modes);
236 /* Open a file, replacing an existing stream with it.
237
238    This function is a possible cancellation point and therefore not
239    marked with __THROW.  */
240 extern FILE *freopen (__const char *__restrict __filename,
241                       __const char *__restrict __modes,
242                       FILE *__restrict __stream);
243 #else
244 # ifdef __REDIRECT
245 extern FILE *__REDIRECT (fopen, (__const char *__restrict __filename,
246                                  __const char *__restrict __modes), fopen64);
247 extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
248                                    __const char *__restrict __modes,
249                                    FILE *__restrict __stream), freopen64);
250 # else
251 #  define fopen fopen64
252 #  define freopen freopen64
253 # endif
254 #endif
255 __END_NAMESPACE_STD
256 #ifdef __USE_LARGEFILE64
257 extern FILE *fopen64 (__const char *__restrict __filename,
258                       __const char *__restrict __modes);
259 extern FILE *freopen64 (__const char *__restrict __filename,
260                         __const char *__restrict __modes,
261                         FILE *__restrict __stream);
262 #endif
263
264 #ifdef  __USE_POSIX
265 /* Create a new stream that refers to an existing system file descriptor.  */
266 extern FILE *fdopen (int __fd, __const char *__modes) __THROW;
267 #endif
268
269 #ifdef  __USE_GNU
270 #ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
271 /* Create a new stream that refers to the given magic cookie,
272    and uses the given functions for input and output.  */
273 extern FILE *fopencookie (void *__restrict __magic_cookie,
274                           __const char *__restrict __modes,
275                           _IO_cookie_io_functions_t __io_funcs) __THROW;
276
277 /* Create a new stream that refers to a memory buffer.  */
278 extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes) __THROW;
279
280 /* Open a stream that writes into a malloc'd buffer that is expanded as
281    necessary.  *BUFLOC and *SIZELOC are updated with the buffer's location
282    and the number of characters written on fflush or fclose.  */
283 extern FILE *open_memstream (char **__restrict __bufloc,
284                              size_t *__restrict __sizeloc) __THROW;
285 #endif
286 #endif
287
288
289 __BEGIN_NAMESPACE_STD
290 /* If BUF is NULL, make STREAM unbuffered.
291    Else make it use buffer BUF, of size BUFSIZ.  */
292 extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
293 /* Make STREAM use buffering mode MODE.
294    If BUF is not NULL, use N bytes of it for buffering;
295    else allocate an internal buffer N bytes long.  */
296 extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
297                     int __modes, size_t __n) __THROW;
298 __END_NAMESPACE_STD
299
300 #ifdef  __USE_BSD
301 /* If BUF is NULL, make STREAM unbuffered.
302    Else make it use SIZE bytes of BUF for buffering.  */
303 extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
304                        size_t __size) __THROW;
305
306 /* Make STREAM line-buffered.  */
307 extern void setlinebuf (FILE *__stream) __THROW;
308 #endif
309
310
311 __BEGIN_NAMESPACE_STD
312 /* Write formatted output to STREAM.
313
314    This function is a possible cancellation point and therefore not
315    marked with __THROW.  */
316 extern int fprintf (FILE *__restrict __stream,
317                     __const char *__restrict __format, ...);
318 /* Write formatted output to stdout.
319
320    This function is a possible cancellation point and therefore not
321    marked with __THROW.  */
322 extern int printf (__const char *__restrict __format, ...);
323 /* Write formatted output to S.  */
324 extern int sprintf (char *__restrict __s,
325                     __const char *__restrict __format, ...) __THROW;
326
327 /* Write formatted output to S from argument list ARG.
328
329    This function is a possible cancellation point and therefore not
330    marked with __THROW.  */
331 extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
332                      __gnuc_va_list __arg);
333 /* Write formatted output to stdout from argument list ARG.
334
335    This function is a possible cancellation point and therefore not
336    marked with __THROW.  */
337 extern int vprintf (__const char *__restrict __format, __gnuc_va_list __arg);
338 /* Write formatted output to S from argument list ARG.  */
339 extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
340                      __gnuc_va_list __arg) __THROW;
341 __END_NAMESPACE_STD
342
343 #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
344 __BEGIN_NAMESPACE_C99
345 /* Maximum chars of output to write in MAXLEN.  */
346 extern int snprintf (char *__restrict __s, size_t __maxlen,
347                      __const char *__restrict __format, ...)
348      __THROW __attribute__ ((__format__ (__printf__, 3, 4)));
349
350 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
351                       __const char *__restrict __format, __gnuc_va_list __arg)
352      __THROW __attribute__ ((__format__ (__printf__, 3, 0)));
353 __END_NAMESPACE_C99
354 #endif
355
356 #ifdef __USE_GNU
357 /* Write formatted output to a string dynamically allocated with `malloc'.
358    Store the address of the string in *PTR.  */
359 extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f,
360                       __gnuc_va_list __arg)
361      __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
362 extern int __asprintf (char **__restrict __ptr,
363                        __const char *__restrict __fmt, ...)
364      __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
365 extern int asprintf (char **__restrict __ptr,
366                      __const char *__restrict __fmt, ...)
367      __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
368
369 /* Write formatted output to a file descriptor.
370
371    These functions are not part of POSIX and therefore no official
372    cancellation point.  But due to similarity with an POSIX interface
373    or due to the implementation they are cancellation points and
374    therefore not marked with __THROW.  */
375 extern int vdprintf (int __fd, __const char *__restrict __fmt,
376                      __gnuc_va_list __arg)
377      __attribute__ ((__format__ (__printf__, 2, 0)));
378 extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
379      __attribute__ ((__format__ (__printf__, 2, 3)));
380 #endif
381
382
383 __BEGIN_NAMESPACE_STD
384 /* Read formatted input from STREAM.
385
386    This function is a possible cancellation point and therefore not
387    marked with __THROW.  */
388 extern int fscanf (FILE *__restrict __stream,
389                    __const char *__restrict __format, ...);
390 /* Read formatted input from stdin.
391
392    This function is a possible cancellation point and therefore not
393    marked with __THROW.  */
394 extern int scanf (__const char *__restrict __format, ...);
395 /* Read formatted input from S.  */
396 extern int sscanf (__const char *__restrict __s,
397                    __const char *__restrict __format, ...) __THROW;
398 __END_NAMESPACE_STD
399
400 #ifdef  __USE_ISOC99
401 __BEGIN_NAMESPACE_C99
402 /* Read formatted input from S into argument list ARG.
403
404    This function is a possible cancellation point and therefore not
405    marked with __THROW.  */
406 extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
407                     __gnuc_va_list __arg)
408      __attribute__ ((__format__ (__scanf__, 2, 0)));
409
410 /* Read formatted input from stdin into argument list ARG.
411
412    This function is a possible cancellation point and therefore not
413    marked with __THROW.  */
414 extern int vscanf (__const char *__restrict __format, __gnuc_va_list __arg)
415      __attribute__ ((__format__ (__scanf__, 1, 0)));
416
417 /* Read formatted input from S into argument list ARG.  */
418 extern int vsscanf (__const char *__restrict __s,
419                     __const char *__restrict __format, __gnuc_va_list __arg)
420      __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
421 __END_NAMESPACE_C99
422 #endif /* Use ISO C9x.  */
423
424
425 __BEGIN_NAMESPACE_STD
426 /* Read a character from STREAM.
427
428    These functions are possible cancellation points and therefore not
429    marked with __THROW.  */
430 extern int fgetc (FILE *__stream);
431 extern int getc (FILE *__stream);
432
433 /* Read a character from stdin.
434
435    This function is a possible cancellation point and therefore not
436    marked with __THROW.  */
437 extern int getchar (void);
438 __END_NAMESPACE_STD
439
440 /* The C standard explicitly says this is a macro, so we always do the
441    optimization for it.  */
442 #define getc(_fp) __GETC(_fp)
443
444 #if defined __USE_POSIX || defined __USE_MISC
445 /* These are defined in POSIX.1:1996.
446
447    These functions are possible cancellation points and therefore not
448    marked with __THROW.  */
449 extern int getc_unlocked (FILE *__stream);
450 extern int getchar_unlocked (void);
451
452 /* SUSv3 allows getc_unlocked to be a macro */
453 #define getc_unlocked(_fp) __GETC_UNLOCKED(_fp)
454 #endif /* Use POSIX or MISC.  */
455
456 #ifdef __USE_MISC
457 /* Faster version when locking is not necessary.
458
459    This function is not part of POSIX and therefore no official
460    cancellation point.  But due to similarity with an POSIX interface
461    or due to the implementation it is a cancellation point and
462    therefore not marked with __THROW.  */
463 extern int fgetc_unlocked (FILE *__stream);
464 #endif /* Use MISC.  */
465
466
467 __BEGIN_NAMESPACE_STD
468 /* Write a character to STREAM.
469
470    These functions are possible cancellation points and therefore not
471    marked with __THROW.
472
473    These functions is a possible cancellation point and therefore not
474    marked with __THROW.  */
475 extern int fputc (int __c, FILE *__stream);
476 extern int putc (int __c, FILE *__stream);
477
478 /* Write a character to stdout.
479
480    This function is a possible cancellation point and therefore not
481    marked with __THROW.  */
482 extern int putchar (int __c);
483 __END_NAMESPACE_STD
484
485 /* The C standard explicitly says this can be a macro,
486    so we always do the optimization for it.  */
487 #define putc(_ch, _fp) __PUTC(_ch, _fp)
488
489 #ifdef __USE_MISC
490 /* Faster version when locking is not necessary.
491
492    This function is not part of POSIX and therefore no official
493    cancellation point.  But due to similarity with an POSIX interface
494    or due to the implementation it is a cancellation point and
495    therefore not marked with __THROW.  */
496 extern int fputc_unlocked (int __c, FILE *__stream);
497 #endif /* Use MISC.  */
498
499 #if defined __USE_POSIX || defined __USE_MISC
500 /* These are defined in POSIX.1:1996.
501
502    These functions are possible cancellation points and therefore not
503    marked with __THROW.  */
504 extern int putc_unlocked (int __c, FILE *__stream);
505 extern int putchar_unlocked (int __c);
506
507 /* SUSv3 allows putc_unlocked to be a macro */
508 #define putc_unlocked(_ch, _fp) __PUTC_UNLOCKED(_ch, _fp)
509 #endif /* Use POSIX or MISC.  */
510
511
512 #if defined __USE_SVID || defined __USE_MISC \
513     || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
514 /* Get a word (int) from STREAM.  */
515 extern int getw (FILE *__stream);
516
517 /* Write a word (int) to STREAM.  */
518 extern int putw (int __w, FILE *__stream);
519 #endif
520
521
522 __BEGIN_NAMESPACE_STD
523 /* Get a newline-terminated string of finite length from STREAM.
524
525    This function is a possible cancellation point and therefore not
526    marked with __THROW.  */
527 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream);
528
529 /* Get a newline-terminated string from stdin, removing the newline.
530    DO NOT USE THIS FUNCTION!!  There is no limit on how much it will read.
531
532    This function is a possible cancellation point and therefore not
533    marked with __THROW.  */
534 extern char *gets (char *__s);
535 __END_NAMESPACE_STD
536
537 #ifdef __USE_GNU
538 /* This function does the same as `fgets' but does not lock the stream.
539
540    This function is not part of POSIX and therefore no official
541    cancellation point.  But due to similarity with an POSIX interface
542    or due to the implementation it is a cancellation point and
543    therefore not marked with __THROW.  */
544 extern char *fgets_unlocked (char *__restrict __s, int __n,
545                              FILE *__restrict __stream);
546 #endif
547
548
549 #ifdef  __USE_GNU
550 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
551    (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
552    NULL), pointing to *N characters of space.  It is realloc'd as
553    necessary.  Returns the number of characters read (not including the
554    null terminator), or -1 on error or EOF.
555
556    These functions are not part of POSIX and therefore no official
557    cancellation point.  But due to similarity with an POSIX interface
558    or due to the implementation they are cancellation points and
559    therefore not marked with __THROW.  */
560 extern __ssize_t __getdelim (char **__restrict __lineptr,
561                                size_t *__restrict __n, int __delimiter,
562                                FILE *__restrict __stream);
563 extern __ssize_t getdelim (char **__restrict __lineptr,
564                              size_t *__restrict __n, int __delimiter,
565                              FILE *__restrict __stream);
566
567 /* Like `getdelim', but reads up to a newline.
568
569    This function is not part of POSIX and therefore no official
570    cancellation point.  But due to similarity with an POSIX interface
571    or due to the implementation it is a cancellation point and
572    therefore not marked with __THROW.  */
573 extern __ssize_t getline (char **__restrict __lineptr,
574                             size_t *__restrict __n,
575                             FILE *__restrict __stream);
576 #endif
577
578
579 __BEGIN_NAMESPACE_STD
580 /* Write a string to STREAM.
581
582    This function is a possible cancellation points and therefore not
583    marked with __THROW.  */
584 extern int fputs (__const char *__restrict __s, FILE *__restrict __stream);
585
586 /* Write a string, followed by a newline, to stdout.
587
588    This function is a possible cancellation points and therefore not
589    marked with __THROW.  */
590 extern int puts (__const char *__s);
591
592
593 /* Push a character back onto the input buffer of STREAM.
594
595    This function is a possible cancellation points and therefore not
596    marked with __THROW.  */
597 extern int ungetc (int __c, FILE *__stream);
598
599
600 /* Read chunks of generic data from STREAM.
601
602    This function is a possible cancellation points and therefore not
603    marked with __THROW.  */
604 extern size_t fread (void *__restrict __ptr, size_t __size,
605                      size_t __n, FILE *__restrict __stream);
606 /* Write chunks of generic data to STREAM.
607
608    This function is a possible cancellation points and therefore not
609    marked with __THROW.  */
610 extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
611                       size_t __n, FILE *__restrict __s);
612 __END_NAMESPACE_STD
613
614 #ifdef __USE_GNU
615 /* This function does the same as `fputs' but does not lock the stream.
616
617    This function is not part of POSIX and therefore no official
618    cancellation point.  But due to similarity with an POSIX interface
619    or due to the implementation it is a cancellation point and
620    therefore not marked with __THROW.  */
621 extern int fputs_unlocked (__const char *__restrict __s,
622                            FILE *__restrict __stream);
623 #endif
624
625 #ifdef __USE_MISC
626 /* Faster versions when locking is not necessary.
627
628    These functions are not part of POSIX and therefore no official
629    cancellation point.  But due to similarity with an POSIX interface
630    or due to the implementation they are cancellation points and
631    therefore not marked with __THROW.  */
632 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
633                               size_t __n, FILE *__restrict __stream);
634 extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
635                                size_t __n, FILE *__restrict __stream);
636 #endif
637
638
639 __BEGIN_NAMESPACE_STD
640 /* Seek to a certain position on STREAM.
641
642    This function is a possible cancellation point and therefore not
643    marked with __THROW.  */
644 extern int fseek (FILE *__stream, long int __off, int __whence);
645 /* Return the current position of STREAM.
646
647    This function is a possible cancellation point and therefore not
648    marked with __THROW.  */
649 extern long int ftell (FILE *__stream);
650 /* Rewind to the beginning of STREAM.
651
652    This function is a possible cancellation point and therefore not
653    marked with __THROW.  */
654 extern void rewind (FILE *__stream);
655 __END_NAMESPACE_STD
656
657 /* The Single Unix Specification, Version 2, specifies an alternative,
658    more adequate interface for the two functions above which deal with
659    file offset.  `long int' is not the right type.  These definitions
660    are originally defined in the Large File Support API.  */
661
662 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
663 # ifndef __USE_FILE_OFFSET64
664 /* Seek to a certain position on STREAM.
665
666    This function is a possible cancellation point and therefore not
667    marked with __THROW.  */
668 extern int fseeko (FILE *__stream, __off_t __off, int __whence);
669 /* Return the current position of STREAM.
670
671    This function is a possible cancellation point and therefore not
672    marked with __THROW.  */
673 extern __off_t ftello (FILE *__stream);
674 # else
675 #  ifdef __REDIRECT
676 extern int __REDIRECT (fseeko,
677                        (FILE *__stream, __off64_t __off, int __whence),
678                        fseeko64);
679 extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
680 #  else
681 #   define fseeko fseeko64
682 #   define ftello ftello64
683 #  endif
684 # endif
685 #endif
686
687 __BEGIN_NAMESPACE_STD
688 #ifndef __USE_FILE_OFFSET64
689 /* Get STREAM's position.
690
691    This function is a possible cancellation point and therefore not
692    marked with __THROW.  */
693 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
694 /* Set STREAM's position.
695
696    This function is a possible cancellation point and therefore not
697    marked with __THROW.  */
698 extern int fsetpos (FILE *__stream, __const fpos_t *__pos);
699 #else
700 # ifdef __REDIRECT
701 extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
702                                  fpos_t *__restrict __pos), fgetpos64);
703 extern int __REDIRECT (fsetpos,
704                        (FILE *__stream, __const fpos_t *__pos), fsetpos64);
705 # else
706 #  define fgetpos fgetpos64
707 #  define fsetpos fsetpos64
708 # endif
709 #endif
710 __END_NAMESPACE_STD
711
712 #ifdef __USE_LARGEFILE64
713 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
714 extern __off64_t ftello64 (FILE *__stream);
715 extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
716 extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos);
717 #endif
718
719 __BEGIN_NAMESPACE_STD
720 /* Clear the error and EOF indicators for STREAM.  */
721 extern void clearerr (FILE *__stream) __THROW;
722 /* Return the EOF indicator for STREAM.  */
723 extern int feof (FILE *__stream) __THROW;
724 /* Return the error indicator for STREAM.  */
725 extern int ferror (FILE *__stream) __THROW;
726 __END_NAMESPACE_STD
727
728 #ifdef __USE_MISC
729 /* Faster versions when locking is not required.  */
730 extern void clearerr_unlocked (FILE *__stream) __THROW;
731 extern int feof_unlocked (FILE *__stream) __THROW;
732 extern int ferror_unlocked (FILE *__stream) __THROW;
733 #endif
734
735
736 __BEGIN_NAMESPACE_STD
737 /* Print a message describing the meaning of the value of errno.
738
739    This function is a possible cancellation point and therefore not
740    marked with __THROW.  */
741 extern void perror (__const char *__s);
742 __END_NAMESPACE_STD
743
744 #ifdef __UCLIBC_HAS_SYS_ERRLIST__
745 /* These variables normally should not be used directly.  The `strerror'
746    function provides all the needed functionality.  */
747 #ifdef  __USE_BSD
748 extern int sys_nerr;
749 extern __const char *__const sys_errlist[];
750 #endif
751 #endif /* __UCLIBC_HAS_SYS_ERRLIST__ */
752
753
754 #ifdef  __USE_POSIX
755 /* Return the system file descriptor for STREAM.  */
756 extern int fileno (FILE *__stream) __THROW;
757 #endif /* Use POSIX.  */
758
759 #ifdef __USE_MISC
760 /* Faster version when locking is not required.  */
761 extern int fileno_unlocked (FILE *__stream) __THROW;
762 #endif
763
764
765 #if (defined __USE_POSIX2 || defined __USE_SVID  || defined __USE_BSD || \
766      defined __USE_MISC)
767 /* Create a new stream connected to a pipe running the given command.
768
769    This function is a possible cancellation point and therefore not
770    marked with __THROW.  */
771 extern FILE *popen (__const char *__command, __const char *__modes);
772
773 /* Close a stream opened by popen and return the status of its child.
774
775    This function is a possible cancellation point and therefore not
776    marked with __THROW.  */
777 extern int pclose (FILE *__stream);
778 #endif
779
780
781 #ifdef  __USE_POSIX
782 /* Return the name of the controlling terminal.  */
783 extern char *ctermid (char *__s) __THROW;
784 #endif /* Use POSIX.  */
785
786
787 #ifdef __USE_XOPEN
788 /* Return the name of the current user.  */
789 extern char *cuserid (char *__s);
790 #endif /* Use X/Open, but not issue 6.  */
791
792
793 #ifdef  __USE_GNU
794 struct obstack;                 /* See <obstack.h>.  */
795
796 /* Write formatted output to an obstack.  */
797 extern int obstack_printf (struct obstack *__restrict __obstack,
798                            __const char *__restrict __format, ...)
799      __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
800 extern int obstack_vprintf (struct obstack *__restrict __obstack,
801                             __const char *__restrict __format,
802                             __gnuc_va_list __args)
803      __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
804 #endif /* Use GNU.  */
805
806
807 #if defined __USE_POSIX || defined __USE_MISC
808 /* These are defined in POSIX.1:1996.  */
809
810 /* Acquire ownership of STREAM.  */
811 extern void flockfile (FILE *__stream) __THROW;
812
813 /* Try to acquire ownership of STREAM but do not block if it is not
814    possible.  */
815 extern int ftrylockfile (FILE *__stream) __THROW;
816
817 /* Relinquish the ownership granted for STREAM.  */
818 extern void funlockfile (FILE *__stream) __THROW;
819 #endif /* POSIX || misc */
820
821 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
822 /* The X/Open standard requires some functions and variables to be
823    declared here which do not belong into this header.  But we have to
824    follow.  In GNU mode we don't do this nonsense.  */
825 # define __need_getopt
826 # include <bits/getopt.h>
827 #endif  /* X/Open, but not issue 6 and not for GNU.  */
828
829 /* If we are compiling with optimizing read this file.  It contains
830    several optimizing inline functions and macros.  */
831 #define fgetc(_fp)                   __FGETC(_fp)
832 #define fputc(_ch, _fp)              __FPUTC(_ch, _fp)
833
834 #ifdef __USE_MISC
835 #define fgetc_unlocked(_fp)          __FGETC_UNLOCKED(_fp)
836 #define fputc_unlocked(_ch, _fp)     __FPUTC_UNLOCKED(_ch, _fp)
837 #endif
838
839 #define getchar()                    __GETC(__stdin)
840 #define putchar(_ch)                 __PUTC((_ch), __stdout)
841
842 #if defined __USE_POSIX || defined __USE_MISC
843 #define getchar_unlocked()           __GETC_UNLOCKED(__stdin)
844 #define putchar_unlocked(_ch)        __PUTC_UNLOCKED((_ch), __stdout)
845 #endif
846
847 /* Clear the error and EOF indicators for STREAM.  */
848 #define clearerr(_fp)                __CLEARERR(_fp)
849 #define feof(_fp)                    __FEOF(_fp)
850 #define ferror(_fp)                  __FERROR(_fp)
851
852 #ifdef __USE_MISC
853 #define clearerr_unlocked(_fp)       __CLEARERR_UNLOCKED(_fp)
854 #define feof_unlocked(_fp)           __FEOF_UNLOCKED(_fp)
855 #define ferror_unlocked(_fp)         __FERROR_UNLOCKED(_fp)
856 #endif
857
858 __END_DECLS
859
860 #endif /* <stdio.h> included.  */
861
862 #endif /* !_STDIO_H */