2 Copyright (C) 1991,1994-2002,2003,2004 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
21 * ISO C99 Standard: 7.19 Input/output <stdio.h>
26 #if !defined __need_FILE && !defined __need___FILE
28 # include <features.h>
32 # define __need_size_t
36 # include <bits/types.h>
38 # define __need___FILE
39 #endif /* Don't need FILE. */
42 #if !defined __FILE_defined && defined __need_FILE
45 /* The opaque type of streams. This is the definition used elsewhere. */
46 typedef struct __STDIO_FILE_STRUCT FILE;
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)
54 # define __FILE_defined 1
55 #endif /* FILE not defined. */
59 #if !defined ____FILE_defined && defined __need___FILE
61 /* The opaque type of streams. This is the definition used elsewhere. */
62 typedef struct __STDIO_FILE_STRUCT __FILE;
64 # define ____FILE_defined 1
65 #endif /* __FILE not defined. */
70 #undef _STDIO_USES_IOSTREAM
72 #include <bits/uClibc_stdio.h>
74 /* This define avoids name pollution if we're using GNU stdarg.h */
75 # define __need___va_list
78 /* The type of the second argument to `fgetpos' and `fsetpos'. */
80 #ifndef __USE_FILE_OFFSET64
81 typedef __STDIO_fpos_t fpos_t;
83 typedef __STDIO_fpos64_t fpos_t;
86 #ifdef __USE_LARGEFILE64
87 typedef __STDIO_fpos64_t fpos64_t;
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. */
96 /* Default buffer size. */
98 # define BUFSIZ __STDIO_BUFSIZ
102 /* End of file character.
103 Some things throughout the library rely on this being -1. */
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. */
116 #if defined __USE_SVID || defined __USE_XOPEN
117 /* Default path prefix for `mkstemp'. */
118 # define P_tmpdir "/tmp"
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>
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. */
140 #define stdout stdout
141 #define stderr stderr
143 __BEGIN_NAMESPACE_STD
144 /* Remove file FILENAME. */
145 extern int remove (__const char *__filename) __THROW;
146 libc_hidden_proto(remove)
147 /* Rename file OLD to NEW. */
148 extern int rename (__const char *__old, __const char *__new) __THROW;
152 /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
153 extern int renameat (int __oldfd, __const char *__old, int __newfd,
154 __const char *__new) __THROW;
157 __BEGIN_NAMESPACE_STD
158 /* Create a temporary file and open it read/write.
160 This function is a possible cancellation points and therefore not
161 marked with __THROW. */
162 #ifndef __USE_FILE_OFFSET64
163 extern FILE *tmpfile (void) __wur;
166 extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;
168 # define tmpfile tmpfile64
172 #ifdef __USE_LARGEFILE64
173 extern FILE *tmpfile64 (void) __wur;
176 #ifdef __UCLIBC_SUSV4_LEGACY__
177 /* Generate a temporary filename. */
178 extern char *tmpnam (char *__s) __THROW __wur;
182 #if defined __USE_MISC && defined __UCLIBC_SUSV4_LEGACY__
183 /* This is the reentrant variant of `tmpnam'. The only difference is
184 that it does not allow S to be NULL. */
185 extern char *tmpnam_r (char *__s) __THROW __wur;
189 #if (defined __USE_SVID || defined __USE_XOPEN) && defined __UCLIBC_SUSV4_LEGACY__
190 /* Generate a unique temporary filename using up to five characters of PFX
191 if it is not NULL. The directory to put this file in is searched for
192 as follows: First the environment variable "TMPDIR" is checked.
193 If it contains the name of a writable directory, that directory is used.
194 If not and if DIR is not NULL, that value is checked. If that fails,
195 P_tmpdir is tried and finally "/tmp". The storage for the filename
196 is allocated by `malloc'. */
197 extern char *tempnam (__const char *__dir, __const char *__pfx)
198 __THROW __attribute_malloc__ __wur;
202 __BEGIN_NAMESPACE_STD
205 This function is a possible cancellation point and therefore not
206 marked with __THROW. */
207 extern int fclose (FILE *__stream);
208 libc_hidden_proto(fclose)
209 /* Flush STREAM, or all streams if STREAM is NULL.
211 This function is a possible cancellation point and therefore not
212 marked with __THROW. */
213 extern int fflush (FILE *__stream);
214 libc_hidden_proto(fflush)
218 /* Faster versions when locking is not required.
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 fflush_unlocked (FILE *__stream);
225 libc_hidden_proto(fflush_unlocked)
229 /* Close all streams.
231 This function is not part of POSIX and therefore no official
232 cancellation point. But due to similarity with an POSIX interface
233 or due to the implementation it is a cancellation point and
234 therefore not marked with __THROW. */
235 extern int fcloseall (void);
239 __BEGIN_NAMESPACE_STD
240 #ifndef __USE_FILE_OFFSET64
241 /* Open a file and create a new stream for it.
243 This function is a possible cancellation point and therefore not
244 marked with __THROW. */
245 extern FILE *fopen (__const char *__restrict __filename,
246 __const char *__restrict __modes) __wur;
247 libc_hidden_proto(fopen)
248 /* Open a file, replacing an existing stream with it.
250 This function is a possible cancellation point and therefore not
251 marked with __THROW. */
252 extern FILE *freopen (__const char *__restrict __filename,
253 __const char *__restrict __modes,
254 FILE *__restrict __stream) __wur;
257 extern FILE *__REDIRECT (fopen, (__const char *__restrict __filename,
258 __const char *__restrict __modes), fopen64)
260 extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
261 __const char *__restrict __modes,
262 FILE *__restrict __stream), freopen64)
265 # define fopen fopen64
266 # define freopen freopen64
270 #ifdef __USE_LARGEFILE64
271 extern FILE *fopen64 (__const char *__restrict __filename,
272 __const char *__restrict __modes) __wur;
273 libc_hidden_proto(fopen64)
274 extern FILE *freopen64 (__const char *__restrict __filename,
275 __const char *__restrict __modes,
276 FILE *__restrict __stream) __wur;
280 /* Create a new stream that refers to an existing system file descriptor. */
281 extern FILE *fdopen (int __fd, __const char *__modes) __THROW __wur;
282 libc_hidden_proto(fdopen)
285 #ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
287 /* Create a new stream that refers to the given magic cookie,
288 and uses the given functions for input and output. */
289 extern FILE *fopencookie (void *__restrict __magic_cookie,
290 __const char *__restrict __modes,
291 _IO_cookie_io_functions_t __io_funcs) __THROW __wur;
292 libc_hidden_proto(fopencookie)
295 #ifdef __USE_XOPEN2K8
296 /* Create a new stream that refers to a memory buffer. */
297 extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes)
300 /* Open a stream that writes into a malloc'd buffer that is expanded as
301 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
302 and the number of characters written on fflush or fclose. */
303 extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;
304 libc_hidden_proto(open_memstream)
309 __BEGIN_NAMESPACE_STD
310 /* If BUF is NULL, make STREAM unbuffered.
311 Else make it use buffer BUF, of size BUFSIZ. */
312 extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
313 /* Make STREAM use buffering mode MODE.
314 If BUF is not NULL, use N bytes of it for buffering;
315 else allocate an internal buffer N bytes long. */
316 extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
317 int __modes, size_t __n) __THROW;
318 libc_hidden_proto(setvbuf)
322 /* If BUF is NULL, make STREAM unbuffered.
323 Else make it use SIZE bytes of BUF for buffering. */
324 extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
325 size_t __size) __THROW;
327 /* Make STREAM line-buffered. */
328 extern void setlinebuf (FILE *__stream) __THROW;
332 __BEGIN_NAMESPACE_STD
333 /* Write formatted output to STREAM.
335 This function is a possible cancellation point and therefore not
336 marked with __THROW. */
337 extern int fprintf (FILE *__restrict __stream,
338 __const char *__restrict __format, ...);
339 libc_hidden_proto(fprintf)
340 /* Write formatted output to stdout.
342 This function is a possible cancellation point and therefore not
343 marked with __THROW. */
344 extern int printf (__const char *__restrict __format, ...);
345 libc_hidden_proto(printf)
346 /* Write formatted output to S. */
347 extern int sprintf (char *__restrict __s,
348 __const char *__restrict __format, ...)
349 __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
350 libc_hidden_proto(sprintf)
352 /* Write formatted output to S from argument list ARG.
354 This function is a possible cancellation point and therefore not
355 marked with __THROW. */
356 extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
357 __gnuc_va_list __arg);
358 libc_hidden_proto(vfprintf)
359 /* Write formatted output to stdout from argument list ARG.
361 This function is a possible cancellation point and therefore not
362 marked with __THROW. */
363 extern int vprintf (__const char *__restrict __format, __gnuc_va_list __arg);
364 /* Write formatted output to S from argument list ARG. */
365 extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
366 __gnuc_va_list __arg)
367 __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
370 #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
371 __BEGIN_NAMESPACE_C99
372 /* Maximum chars of output to write in MAXLEN. */
373 extern int snprintf (char *__restrict __s, size_t __maxlen,
374 __const char *__restrict __format, ...)
375 __THROW __attribute__ ((__format__ (__printf__, 3, 4)));
376 libc_hidden_proto(snprintf)
378 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
379 __const char *__restrict __format, __gnuc_va_list __arg)
380 __THROW __attribute__ ((__format__ (__printf__, 3, 0)));
381 libc_hidden_proto(vsnprintf)
386 /* Write formatted output to a string dynamically allocated with `malloc'.
387 Store the address of the string in *PTR. */
388 extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f,
389 __gnuc_va_list __arg)
390 __THROW __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
391 libc_hidden_proto(vasprintf)
392 #if 0 /* uClibc: disabled */
393 extern int __asprintf (char **__restrict __ptr,
394 __const char *__restrict __fmt, ...)
395 __THROW __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
397 extern int asprintf (char **__restrict __ptr,
398 __const char *__restrict __fmt, ...)
399 __THROW __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
400 libc_hidden_proto(asprintf)
403 #ifdef __USE_XOPEN2K8
404 /* Write formatted output to a file descriptor.
406 These functions are not part of POSIX and therefore no official
407 cancellation point. But due to similarity with an POSIX interface
408 or due to the implementation they are cancellation points and
409 therefore not marked with __THROW. */
410 extern int vdprintf (int __fd, __const char *__restrict __fmt,
411 __gnuc_va_list __arg)
412 __attribute__ ((__format__ (__printf__, 2, 0)));
413 libc_hidden_proto(vdprintf)
414 extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
415 __attribute__ ((__format__ (__printf__, 2, 3)));
419 __BEGIN_NAMESPACE_STD
420 /* Read formatted input from STREAM.
422 This function is a possible cancellation point and therefore not
423 marked with __THROW. */
424 extern int fscanf (FILE *__restrict __stream,
425 __const char *__restrict __format, ...)
426 __attribute__ ((__format__ (__scanf__, 2, 3))) __wur;
427 libc_hidden_proto(fscanf)
428 /* Read formatted input from stdin.
430 This function is a possible cancellation point and therefore not
431 marked with __THROW. */
432 extern int scanf (__const char *__restrict __format, ...)
433 __attribute__ ((__format__ (__scanf__, 1, 2))) __wur;
434 /* Read formatted input from S. */
435 extern int sscanf (__const char *__restrict __s,
436 __const char *__restrict __format, ...)
437 __THROW __attribute__ ((__format__ (__scanf__, 2, 3)));
438 libc_hidden_proto(sscanf)
442 __BEGIN_NAMESPACE_C99
443 /* Read formatted input from S into argument list ARG.
445 This function is a possible cancellation point and therefore not
446 marked with __THROW. */
447 extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
448 __gnuc_va_list __arg)
449 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
450 libc_hidden_proto(vfscanf)
452 /* Read formatted input from stdin into argument list ARG.
454 This function is a possible cancellation point and therefore not
455 marked with __THROW. */
456 extern int vscanf (__const char *__restrict __format, __gnuc_va_list __arg)
457 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
459 /* Read formatted input from S into argument list ARG. */
460 extern int vsscanf (__const char *__restrict __s,
461 __const char *__restrict __format, __gnuc_va_list __arg)
462 __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
463 libc_hidden_proto(vsscanf)
465 #endif /* Use ISO C9x. */
468 __BEGIN_NAMESPACE_STD
469 /* Read a character from STREAM.
471 These functions are possible cancellation points and therefore not
472 marked with __THROW. */
473 extern int fgetc (FILE *__stream);
474 libc_hidden_proto(fgetc)
475 extern int getc (FILE *__stream);
477 /* Read a character from stdin.
479 This function is a possible cancellation point and therefore not
480 marked with __THROW. */
481 extern int getchar (void);
484 /* The C standard explicitly says this is a macro, so we always do the
485 optimization for it. */
486 #define getc(_fp) __GETC(_fp)
488 #if defined __USE_POSIX || defined __USE_MISC
489 /* These are defined in POSIX.1:1996.
491 These functions are possible cancellation points and therefore not
492 marked with __THROW. */
493 extern int getc_unlocked (FILE *__stream);
494 libc_hidden_proto(getc_unlocked)
495 extern int getchar_unlocked (void);
496 libc_hidden_proto(getchar_unlocked)
497 #endif /* Use POSIX or MISC. */
500 /* Faster version when locking is not necessary.
502 This function is not part of POSIX and therefore no official
503 cancellation point. But due to similarity with an POSIX interface
504 or due to the implementation it is a cancellation point and
505 therefore not marked with __THROW. */
506 extern int fgetc_unlocked (FILE *__stream);
507 libc_hidden_proto(fgetc_unlocked)
508 #endif /* Use MISC. */
511 __BEGIN_NAMESPACE_STD
512 /* Write a character to STREAM.
514 These functions are possible cancellation points and therefore not
517 These functions is a possible cancellation point and therefore not
518 marked with __THROW. */
519 extern int fputc (int __c, FILE *__stream);
520 libc_hidden_proto(fputc)
521 extern int putc (int __c, FILE *__stream);
523 /* Write a character to stdout.
525 This function is a possible cancellation point and therefore not
526 marked with __THROW. */
527 extern int putchar (int __c);
530 /* The C standard explicitly says this can be a macro,
531 so we always do the optimization for it. */
532 #define putc(_ch, _fp) __PUTC(_ch, _fp)
535 /* Faster version when locking is not necessary.
537 This function is not part of POSIX and therefore no official
538 cancellation point. But due to similarity with an POSIX interface
539 or due to the implementation it is a cancellation point and
540 therefore not marked with __THROW. */
541 extern int fputc_unlocked (int __c, FILE *__stream);
542 #endif /* Use MISC. */
544 #if defined __USE_POSIX || defined __USE_MISC
545 /* These are defined in POSIX.1:1996.
547 These functions are possible cancellation points and therefore not
548 marked with __THROW. */
549 extern int putc_unlocked (int __c, FILE *__stream);
550 extern int putchar_unlocked (int __c);
551 #endif /* Use POSIX or MISC. */
554 #if defined __USE_SVID || defined __USE_MISC \
555 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
556 /* Get a word (int) from STREAM. */
557 extern int getw (FILE *__stream);
559 /* Write a word (int) to STREAM. */
560 extern int putw (int __w, FILE *__stream);
564 __BEGIN_NAMESPACE_STD
565 /* Get a newline-terminated string of finite length from STREAM.
567 This function is a possible cancellation point and therefore not
568 marked with __THROW. */
569 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
571 libc_hidden_proto(fgets)
573 /* Get a newline-terminated string from stdin, removing the newline.
574 DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
576 This function is a possible cancellation point and therefore not
577 marked with __THROW. */
578 extern char *gets (char *__s) __wur;
582 /* This function does the same as `fgets' but does not lock the stream.
584 This function is not part of POSIX and therefore no official
585 cancellation point. But due to similarity with an POSIX interface
586 or due to the implementation it is a cancellation point and
587 therefore not marked with __THROW. */
588 extern char *fgets_unlocked (char *__restrict __s, int __n,
589 FILE *__restrict __stream) __wur;
590 libc_hidden_proto(fgets_unlocked)
594 #ifdef __USE_XOPEN2K8
595 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
596 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
597 NULL), pointing to *N characters of space. It is realloc'd as
598 necessary. Returns the number of characters read (not including the
599 null terminator), or -1 on error or EOF.
601 These functions are not part of POSIX and therefore no official
602 cancellation point. But due to similarity with an POSIX interface
603 or due to the implementation they are cancellation points and
604 therefore not marked with __THROW. */
605 #if 0 /* uClibc: disabled */
606 extern __ssize_t __getdelim (char **__restrict __lineptr,
607 size_t *__restrict __n, int __delimiter,
608 FILE *__restrict __stream) __wur;
610 extern __ssize_t getdelim (char **__restrict __lineptr,
611 size_t *__restrict __n, int __delimiter,
612 FILE *__restrict __stream) __wur;
613 libc_hidden_proto(getdelim)
615 /* Like `getdelim', but reads up to a newline.
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 __ssize_t getline (char **__restrict __lineptr,
622 size_t *__restrict __n,
623 FILE *__restrict __stream) __wur;
624 libc_hidden_proto(getline)
628 __BEGIN_NAMESPACE_STD
629 /* Write a string to STREAM.
631 This function is a possible cancellation points and therefore not
632 marked with __THROW. */
633 extern int fputs (__const char *__restrict __s, FILE *__restrict __stream);
634 libc_hidden_proto(fputs)
636 /* Write a string, followed by a newline, to stdout.
638 This function is a possible cancellation points and therefore not
639 marked with __THROW. */
640 extern int puts (__const char *__s);
643 /* Push a character back onto the input buffer of STREAM.
645 This function is a possible cancellation points and therefore not
646 marked with __THROW. */
647 extern int ungetc (int __c, FILE *__stream);
648 libc_hidden_proto(ungetc)
651 /* Read chunks of generic data from STREAM.
653 This function is a possible cancellation points and therefore not
654 marked with __THROW. */
655 extern size_t fread (void *__restrict __ptr, size_t __size,
656 size_t __n, FILE *__restrict __stream) __wur;
657 libc_hidden_proto(fread)
658 /* Write chunks of generic data to STREAM.
660 This function is a possible cancellation points and therefore not
661 marked with __THROW. */
662 extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
663 size_t __n, FILE *__restrict __s) __wur;
664 libc_hidden_proto(fwrite)
668 /* This function does the same as `fputs' but does not lock the stream.
670 This function is not part of POSIX and therefore no official
671 cancellation point. But due to similarity with an POSIX interface
672 or due to the implementation it is a cancellation point and
673 therefore not marked with __THROW. */
674 extern int fputs_unlocked (__const char *__restrict __s,
675 FILE *__restrict __stream);
676 libc_hidden_proto(fputs_unlocked)
680 /* Faster versions when locking is not necessary.
682 These functions are not part of POSIX and therefore no official
683 cancellation point. But due to similarity with an POSIX interface
684 or due to the implementation they are cancellation points and
685 therefore not marked with __THROW. */
686 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
687 size_t __n, FILE *__restrict __stream) __wur;
688 libc_hidden_proto(fread_unlocked)
689 extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
690 size_t __n, FILE *__restrict __stream) __wur;
691 libc_hidden_proto(fwrite_unlocked)
695 __BEGIN_NAMESPACE_STD
696 /* Seek to a certain position on STREAM.
698 This function is a possible cancellation point and therefore not
699 marked with __THROW. */
700 extern int fseek (FILE *__stream, long int __off, int __whence);
701 libc_hidden_proto(fseek)
702 /* Return the current position of STREAM.
704 This function is a possible cancellation point and therefore not
705 marked with __THROW. */
706 extern long int ftell (FILE *__stream) __wur;
707 libc_hidden_proto(ftell)
708 /* Rewind to the beginning of STREAM.
710 This function is a possible cancellation point and therefore not
711 marked with __THROW. */
712 extern void rewind (FILE *__stream);
713 libc_hidden_proto(rewind)
716 /* The Single Unix Specification, Version 2, specifies an alternative,
717 more adequate interface for the two functions above which deal with
718 file offset. `long int' is not the right type. These definitions
719 are originally defined in the Large File Support API. */
721 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
722 # ifndef __USE_FILE_OFFSET64
723 /* Seek to a certain position on STREAM.
725 This function is a possible cancellation point and therefore not
726 marked with __THROW. */
727 extern int fseeko (FILE *__stream, __off_t __off, int __whence);
728 /* Return the current position of STREAM.
730 This function is a possible cancellation point and therefore not
731 marked with __THROW. */
732 extern __off_t ftello (FILE *__stream) __wur;
735 extern int __REDIRECT (fseeko,
736 (FILE *__stream, __off64_t __off, int __whence),
738 extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
740 # define fseeko fseeko64
741 # define ftello ftello64
746 __BEGIN_NAMESPACE_STD
747 #ifndef __USE_FILE_OFFSET64
748 /* Get STREAM's position.
750 This function is a possible cancellation point and therefore not
751 marked with __THROW. */
752 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
753 /* Set STREAM's position.
755 This function is a possible cancellation point and therefore not
756 marked with __THROW. */
757 extern int fsetpos (FILE *__stream, __const fpos_t *__pos);
760 extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
761 fpos_t *__restrict __pos), fgetpos64);
762 extern int __REDIRECT (fsetpos,
763 (FILE *__stream, __const fpos_t *__pos), fsetpos64);
765 # define fgetpos fgetpos64
766 # define fsetpos fsetpos64
771 #ifdef __USE_LARGEFILE64
772 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
773 libc_hidden_proto(fseeko64)
774 extern __off64_t ftello64 (FILE *__stream) __wur;
775 libc_hidden_proto(ftello64)
776 extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
777 extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos);
780 __BEGIN_NAMESPACE_STD
781 /* Clear the error and EOF indicators for STREAM. */
782 extern void clearerr (FILE *__stream) __THROW;
783 /* Return the EOF indicator for STREAM. */
784 extern int feof (FILE *__stream) __THROW __wur;
785 /* Return the error indicator for STREAM. */
786 extern int ferror (FILE *__stream) __THROW __wur;
790 /* Faster versions when locking is not required. */
791 extern void clearerr_unlocked (FILE *__stream) __THROW;
792 extern int feof_unlocked (FILE *__stream) __THROW __wur;
793 extern int ferror_unlocked (FILE *__stream) __THROW __wur;
797 __BEGIN_NAMESPACE_STD
798 /* Print a message describing the meaning of the value of errno.
800 This function is a possible cancellation point and therefore not
801 marked with __THROW. */
802 extern void perror (__const char *__s);
803 libc_hidden_proto(perror)
806 #ifdef __UCLIBC_HAS_SYS_ERRLIST__
807 /* These variables normally should not be used directly. The `strerror'
808 function provides all the needed functionality. */
811 extern __const char *__const sys_errlist[];
813 #endif /* __UCLIBC_HAS_SYS_ERRLIST__ */
817 /* Return the system file descriptor for STREAM. */
818 extern int fileno (FILE *__stream) __THROW __wur;
819 libc_hidden_proto(fileno)
820 #endif /* Use POSIX. */
823 /* Faster version when locking is not required. */
824 extern int fileno_unlocked (FILE *__stream) __THROW __wur;
825 libc_hidden_proto(fileno_unlocked)
829 #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
831 /* Create a new stream connected to a pipe running the given command.
833 This function is a possible cancellation point and therefore not
834 marked with __THROW. */
835 extern FILE *popen (__const char *__command, __const char *__modes) __wur;
837 /* Close a stream opened by popen and return the status of its child.
839 This function is a possible cancellation point and therefore not
840 marked with __THROW. */
841 extern int pclose (FILE *__stream);
846 /* Return the name of the controlling terminal. */
847 extern char *ctermid (char *__s) __THROW;
848 #endif /* Use POSIX. */
852 /* Return the name of the current user. */
853 extern char *cuserid (char *__s);
854 #endif /* Use X/Open, but not issue 6. */
857 #if 0 /* def __USE_GNU uClibc note: not supported */
858 struct obstack; /* See <obstack.h>. */
860 /* Write formatted output to an obstack. */
861 extern int obstack_printf (struct obstack *__restrict __obstack,
862 __const char *__restrict __format, ...)
863 __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
864 extern int obstack_vprintf (struct obstack *__restrict __obstack,
865 __const char *__restrict __format,
866 __gnuc_va_list __args)
867 __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
868 #endif /* Use GNU. */
871 #if defined __USE_POSIX || defined __USE_MISC
872 /* These are defined in POSIX.1:1996. */
874 /* Acquire ownership of STREAM. */
875 extern void flockfile (FILE *__stream) __THROW;
877 /* Try to acquire ownership of STREAM but do not block if it is not
879 extern int ftrylockfile (FILE *__stream) __THROW __wur;
881 /* Relinquish the ownership granted for STREAM. */
882 extern void funlockfile (FILE *__stream) __THROW;
883 #endif /* POSIX || misc */
885 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
886 /* The X/Open standard requires some functions and variables to be
887 declared here which do not belong into this header. But we have to
888 follow. In GNU mode we don't do this nonsense. */
889 # define __need_getopt
890 /* keep this on uClibc in bits/, we need it when GNU_GETOPT is disabled */
891 # include <bits/getopt.h>
892 #endif /* X/Open, but not issue 6 and not for GNU. */
894 /* If we are compiling with optimizing read this file. It contains
895 several optimizing inline functions and macros. */
899 #define fgetc(_fp) __FGETC(_fp)
900 #define fputc(_ch, _fp) __FPUTC(_ch, _fp)
902 #if defined __USE_POSIX || defined __USE_MISC
903 /* SUSv3 allows getc_unlocked to be a macro */
904 #define getc_unlocked(_fp) __GETC_UNLOCKED(_fp)
905 /* SUSv3 allows putc_unlocked to be a macro */
906 #define putc_unlocked(_ch, _fp) __PUTC_UNLOCKED(_ch, _fp)
910 #define fgetc_unlocked(_fp) __FGETC_UNLOCKED(_fp)
911 #define fputc_unlocked(_ch, _fp) __FPUTC_UNLOCKED(_ch, _fp)
914 #define getchar() __GETC(__stdin)
915 #define putchar(_ch) __PUTC((_ch), __stdout)
917 #if defined __USE_POSIX || defined __USE_MISC
918 #define getchar_unlocked() __GETC_UNLOCKED(__stdin)
919 #define putchar_unlocked(_ch) __PUTC_UNLOCKED((_ch), __stdout)
922 /* Clear the error and EOF indicators for STREAM. */
923 #define clearerr(_fp) __CLEARERR(_fp)
924 #define feof(_fp) __FEOF(_fp)
925 #define ferror(_fp) __FERROR(_fp)
928 #define clearerr_unlocked(_fp) __CLEARERR_UNLOCKED(_fp)
929 #define feof_unlocked(_fp) __FEOF_UNLOCKED(_fp)
930 #define ferror_unlocked(_fp) __FERROR_UNLOCKED(_fp)
937 #endif /* <stdio.h> included. */
939 #endif /* !_STDIO_H */