test: sync tst-atfork2 with GNU libc
[uclibc-ng.git] / include / stdio.h
blob9aae5abf41c9b2f801d99039f38722024b8cd19a
1 /*
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, see
17 <http://www.gnu.org/licenses/>. */
20 * ISO C99 Standard: 7.19 Input/output <stdio.h>
23 #ifndef _STDIO_H
25 #if !defined __need_FILE && !defined __need___FILE
26 # define _STDIO_H 1
27 # include <features.h>
29 __BEGIN_DECLS
31 # define __need_size_t
32 # define __need_NULL
33 # include <stddef.h>
35 # include <bits/types.h>
36 # define __need_FILE
37 # define __need___FILE
38 #endif /* Don't need FILE. */
41 #if !defined __FILE_defined && defined __need_FILE
43 __BEGIN_NAMESPACE_STD
44 /* The opaque type of streams. This is the definition used elsewhere. */
45 typedef struct __STDIO_FILE_STRUCT FILE;
46 __END_NAMESPACE_STD
47 #if defined __USE_LARGEFILE64 || defined __USE_SVID || defined __USE_POSIX \
48 || defined __USE_BSD || defined __USE_ISOC99 || defined __USE_XOPEN \
49 || defined __USE_POSIX2
50 __USING_NAMESPACE_STD(FILE)
51 #endif
53 # define __FILE_defined 1
54 #endif /* FILE not defined. */
55 #undef __need_FILE
58 #if !defined ____FILE_defined && defined __need___FILE
60 /* The opaque type of streams. This is the definition used elsewhere. */
61 typedef struct __STDIO_FILE_STRUCT __FILE;
63 # define ____FILE_defined 1
64 #endif /* __FILE not defined. */
65 #undef __need___FILE
68 #ifdef _STDIO_H
69 #undef _STDIO_USES_IOSTREAM
71 #include <bits/uClibc_stdio.h>
73 /* This define avoids name pollution if we're using GNU stdarg.h */
74 # define __need___va_list
75 #include <stdarg.h>
77 /* The type of the second argument to `fgetpos' and `fsetpos'. */
78 __BEGIN_NAMESPACE_STD
79 #ifndef __USE_FILE_OFFSET64
80 typedef __STDIO_fpos_t fpos_t;
81 #else
82 typedef __STDIO_fpos64_t fpos_t;
83 #endif
84 __END_NAMESPACE_STD
85 #ifdef __USE_LARGEFILE64
86 typedef __STDIO_fpos64_t fpos64_t;
87 #endif
89 /* The possibilities for the third argument to `setvbuf'. */
90 #define _IOFBF __STDIO_IOFBF /* Fully buffered. */
91 #define _IOLBF __STDIO_IOLBF /* Line buffered. */
92 #define _IONBF __STDIO_IONBF /* No buffering. */
95 /* Default buffer size. */
96 #ifndef BUFSIZ
97 # define BUFSIZ __STDIO_BUFSIZ
98 #endif
101 /* End of file character.
102 Some things throughout the library rely on this being -1. */
103 #ifndef EOF
104 # define EOF (-1)
105 #endif
108 /* The possibilities for the third argument to `fseek'.
109 These values should not be changed. */
110 #define SEEK_SET 0 /* Seek from beginning of file. */
111 #define SEEK_CUR 1 /* Seek from current position. */
112 #define SEEK_END 2 /* Seek from end of file. */
115 #if defined __USE_SVID || defined __USE_XOPEN
116 /* Default path prefix for `mkstemp'. */
117 # define P_tmpdir "/tmp"
118 #endif
121 /* Get the values:
122 L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
123 TMP_MAX The minimum number of unique filenames generated by tmpnam
124 (and tempnam when it uses tmpnam's name space),
125 or tempnam (the two are separate).
126 L_ctermid How long an array to pass to `ctermid'.
127 L_cuserid How long an array to pass to `cuserid'.
128 FOPEN_MAX Minimum number of files that can be open at once.
129 FILENAME_MAX Maximum length of a filename. */
130 #include <bits/stdio_lim.h>
133 /* Standard streams. */
134 extern FILE *stdin; /* Standard input stream. */
135 extern FILE *stdout; /* Standard output stream. */
136 extern FILE *stderr; /* Standard error output stream. */
137 /* C89/C99 say they're macros. Make them happy. */
138 #define stdin stdin
139 #define stdout stdout
140 #define stderr stderr
142 __BEGIN_NAMESPACE_STD
143 /* Remove file FILENAME. */
144 extern int remove (const char *__filename) __THROW;
145 libc_hidden_proto(remove)
146 /* Rename file OLD to NEW. */
147 extern int rename (const char *__old, const char *__new) __THROW;
148 __END_NAMESPACE_STD
150 #ifdef __USE_ATFILE
151 /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
152 extern int renameat (int __oldfd, const char *__old, int __newfd,
153 const char *__new) __THROW;
154 libc_hidden_proto(renameat)
155 #endif
157 __BEGIN_NAMESPACE_STD
158 /* Create a temporary file and open it read/write.
160 This function is a possible cancellation point and therefore not
161 marked with __THROW. */
162 #ifndef __USE_FILE_OFFSET64
163 extern FILE *tmpfile (void) __wur;
164 #else
165 # ifdef __REDIRECT
166 extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;
167 # else
168 # define tmpfile tmpfile64
169 # endif
170 #endif
172 #ifdef __USE_LARGEFILE64
173 extern FILE *tmpfile64 (void) __wur;
174 #endif
176 #ifdef __UCLIBC_SUSV4_LEGACY__
177 /* Generate a temporary filename. */
178 extern char *tmpnam (char *__s) __THROW __wur;
179 #endif
180 __END_NAMESPACE_STD
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;
186 #endif
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;
199 #endif
202 __BEGIN_NAMESPACE_STD
203 /* Close STREAM.
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)
215 __END_NAMESPACE_STD
217 #ifdef __USE_MISC
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)
226 #endif
228 #ifdef __USE_GNU
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);
236 #endif
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;
255 #else
256 # ifdef __REDIRECT
257 extern FILE *__REDIRECT (fopen, (const char *__restrict __filename,
258 const char *__restrict __modes), fopen64)
259 __wur;
260 extern FILE *__REDIRECT (freopen, (const char *__restrict __filename,
261 const char *__restrict __modes,
262 FILE *__restrict __stream), freopen64)
263 __wur;
264 # else
265 # define fopen fopen64
266 # define freopen freopen64
267 # endif
268 #endif
269 __END_NAMESPACE_STD
270 #ifdef __USE_LARGEFILE64
271 extern FILE *fopen64 (const char *__restrict __filename,
272 const char *__restrict __modes) __wur;
273 libc_hidden_proto(fopen64)
274 extern FILE *freopen64 (const char *__restrict __filename,
275 const char *__restrict __modes,
276 FILE *__restrict __stream) __wur;
277 #endif
279 #ifdef __USE_POSIX
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)
283 #endif
285 #ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
286 #ifdef __USE_GNU
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)
293 #endif
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)
298 __THROW __wur;
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)
305 #endif
306 #endif
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)
319 __END_NAMESPACE_STD
321 #ifdef __USE_BSD
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;
329 #endif
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, ...) __THROWNL
349 __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) __THROWNL
367 __attribute__ ((__format__ (__printf__, 2, 0)));
368 __END_NAMESPACE_STD
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 __THROWNL __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 __THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));
381 libc_hidden_proto(vsnprintf)
382 __END_NAMESPACE_C99
383 #endif
385 #ifdef __USE_GNU
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 __THROWNL __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 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
396 #endif
397 extern int asprintf (char **__restrict __ptr,
398 const char *__restrict __fmt, ...)
399 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
400 libc_hidden_proto(asprintf)
401 #endif
403 #ifdef __USE_XOPEN2K8
404 /* Write formatted output to a file descriptor.
406 This function is a possible cancellation point and therefore not
407 marked with __THROW. */
408 extern int vdprintf (int __fd, const char *__restrict __fmt,
409 __gnuc_va_list __arg)
410 __attribute__ ((__format__ (__printf__, 2, 0)));
411 libc_hidden_proto(vdprintf)
412 extern int dprintf (int __fd, const char *__restrict __fmt, ...)
413 __attribute__ ((__format__ (__printf__, 2, 3)));
414 #endif
417 __BEGIN_NAMESPACE_STD
418 /* Read formatted input from STREAM.
420 This function is a possible cancellation point and therefore not
421 marked with __THROW. */
422 extern int fscanf (FILE *__restrict __stream,
423 const char *__restrict __format, ...)
424 __attribute__ ((__format__ (__scanf__, 2, 3))) __wur;
425 libc_hidden_proto(fscanf)
426 /* Read formatted input from stdin.
428 This function is a possible cancellation point and therefore not
429 marked with __THROW. */
430 extern int scanf (const char *__restrict __format, ...)
431 __attribute__ ((__format__ (__scanf__, 1, 2))) __wur;
432 /* Read formatted input from S. */
433 extern int sscanf (const char *__restrict __s,
434 const char *__restrict __format, ...)
435 __THROW __attribute__ ((__format__ (__scanf__, 2, 3)));
436 libc_hidden_proto(sscanf)
437 __END_NAMESPACE_STD
439 #ifdef __USE_ISOC99
440 __BEGIN_NAMESPACE_C99
441 /* Read formatted input from S into argument list ARG.
443 This function is a possible cancellation point and therefore not
444 marked with __THROW. */
445 extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
446 __gnuc_va_list __arg)
447 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
448 libc_hidden_proto(vfscanf)
450 /* Read formatted input from stdin into argument list ARG.
452 This function is a possible cancellation point and therefore not
453 marked with __THROW. */
454 extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)
455 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
457 /* Read formatted input from S into argument list ARG. */
458 extern int vsscanf (const char *__restrict __s,
459 const char *__restrict __format, __gnuc_va_list __arg)
460 __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
461 libc_hidden_proto(vsscanf)
462 __END_NAMESPACE_C99
463 #endif /* Use ISO C9x. */
466 __BEGIN_NAMESPACE_STD
467 /* Read a character from STREAM.
469 These functions are possible cancellation points and therefore not
470 marked with __THROW. */
471 extern int fgetc (FILE *__stream);
472 libc_hidden_proto(fgetc)
473 extern int getc (FILE *__stream);
475 /* Read a character from stdin.
477 This function is a possible cancellation point and therefore not
478 marked with __THROW. */
479 extern int getchar (void);
480 __END_NAMESPACE_STD
482 /* The C standard explicitly says this is a macro, so we always do the
483 optimization for it. */
484 #define getc(_fp) __GETC(_fp)
486 #if defined __USE_POSIX || defined __USE_MISC
487 /* These are defined in POSIX.1:1996.
489 These functions are possible cancellation points and therefore not
490 marked with __THROW. */
491 extern int getc_unlocked (FILE *__stream);
492 libc_hidden_proto(getc_unlocked)
493 extern int getchar_unlocked (void);
494 libc_hidden_proto(getchar_unlocked)
495 #endif /* Use POSIX or MISC. */
497 #ifdef __USE_MISC
498 /* Faster version when locking is not necessary.
500 This function is not part of POSIX and therefore no official
501 cancellation point. But due to similarity with an POSIX interface
502 or due to the implementation it is a cancellation point and
503 therefore not marked with __THROW. */
504 extern int fgetc_unlocked (FILE *__stream);
505 libc_hidden_proto(fgetc_unlocked)
506 #endif /* Use MISC. */
509 __BEGIN_NAMESPACE_STD
510 /* Write a character to STREAM.
512 These functions are possible cancellation points and therefore not
513 marked with __THROW.
515 These functions is a possible cancellation point and therefore not
516 marked with __THROW. */
517 extern int fputc (int __c, FILE *__stream);
518 libc_hidden_proto(fputc)
519 extern int putc (int __c, FILE *__stream);
521 /* Write a character to stdout.
523 This function is a possible cancellation point and therefore not
524 marked with __THROW. */
525 extern int putchar (int __c);
526 __END_NAMESPACE_STD
528 /* The C standard explicitly says this can be a macro,
529 so we always do the optimization for it. */
530 #define putc(_ch, _fp) __PUTC(_ch, _fp)
532 #ifdef __USE_MISC
533 /* Faster version when locking is not necessary.
535 This function is not part of POSIX and therefore no official
536 cancellation point. But due to similarity with an POSIX interface
537 or due to the implementation it is a cancellation point and
538 therefore not marked with __THROW. */
539 extern int fputc_unlocked (int __c, FILE *__stream);
540 #endif /* Use MISC. */
542 #if defined __USE_POSIX || defined __USE_MISC
543 /* These are defined in POSIX.1:1996.
545 These functions are possible cancellation points and therefore not
546 marked with __THROW. */
547 extern int putc_unlocked (int __c, FILE *__stream);
548 extern int putchar_unlocked (int __c);
549 #endif /* Use POSIX or MISC. */
552 #if defined __USE_SVID || defined __USE_MISC \
553 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
554 /* Get a word (int) from STREAM. */
555 extern int getw (FILE *__stream);
557 /* Write a word (int) to STREAM. */
558 extern int putw (int __w, FILE *__stream);
559 #endif
562 __BEGIN_NAMESPACE_STD
563 /* Get a newline-terminated string of finite length from STREAM.
565 This function is a possible cancellation point and therefore not
566 marked with __THROW. */
567 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
568 __wur;
569 libc_hidden_proto(fgets)
571 #if !defined __USE_ISOC11 \
572 || (defined __cplusplus && __cplusplus <= 201103L)
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 The function has been officially removed in ISO C11. This opportunity
577 is used to also remove it from the GNU feature list. It is now only
578 available when explicitly using an old ISO C, Unix, or POSIX standard.
579 GCC defines _GNU_SOURCE when building C++ code and the function is still
580 in C++11, so it is also available for C++.
582 This function is a possible cancellation point and therefore not
583 marked with __THROW. */
584 extern char *gets (char *__s) __wur __attribute_deprecated__;
585 #endif
586 __END_NAMESPACE_STD
588 #ifdef __USE_GNU
589 /* This function does the same as `fgets' but does not lock the stream.
591 This function is not part of POSIX and therefore no official
592 cancellation point. But due to similarity with an POSIX interface
593 or due to the implementation it is a cancellation point and
594 therefore not marked with __THROW. */
595 extern char *fgets_unlocked (char *__restrict __s, int __n,
596 FILE *__restrict __stream) __wur;
597 libc_hidden_proto(fgets_unlocked)
598 #endif
601 #ifdef __USE_XOPEN2K8
602 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
603 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
604 NULL), pointing to *N characters of space. It is realloc'd as
605 necessary. Returns the number of characters read (not including the
606 null terminator), or -1 on error or EOF.
608 These functions are not part of POSIX and therefore no official
609 cancellation point. But due to similarity with an POSIX interface
610 or due to the implementation they are cancellation points and
611 therefore not marked with __THROW. */
612 #if 0 /* uClibc: disabled */
613 extern __ssize_t __getdelim (char **__restrict __lineptr,
614 size_t *__restrict __n, int __delimiter,
615 FILE *__restrict __stream) __wur;
616 #endif
617 extern __ssize_t getdelim (char **__restrict __lineptr,
618 size_t *__restrict __n, int __delimiter,
619 FILE *__restrict __stream) __wur;
620 libc_hidden_proto(getdelim)
622 /* Like `getdelim', but reads up to a newline.
624 This function is not part of POSIX and therefore no official
625 cancellation point. But due to similarity with an POSIX interface
626 or due to the implementation it is a cancellation point and
627 therefore not marked with __THROW. */
628 extern __ssize_t getline (char **__restrict __lineptr,
629 size_t *__restrict __n,
630 FILE *__restrict __stream) __wur;
631 libc_hidden_proto(getline)
632 #endif
635 __BEGIN_NAMESPACE_STD
636 /* Write a string to STREAM.
638 This function is a possible cancellation point and therefore not
639 marked with __THROW. */
640 extern int fputs (const char *__restrict __s, FILE *__restrict __stream);
641 libc_hidden_proto(fputs)
643 /* Write a string, followed by a newline, to stdout.
645 This function is a possible cancellation point and therefore not
646 marked with __THROW. */
647 extern int puts (const char *__s);
650 /* Push a character back onto the input buffer of STREAM.
652 This function is a possible cancellation point and therefore not
653 marked with __THROW. */
654 extern int ungetc (int __c, FILE *__stream);
655 libc_hidden_proto(ungetc)
658 /* Read chunks of generic data from STREAM.
660 This function is a possible cancellation point and therefore not
661 marked with __THROW. */
662 extern size_t fread (void *__restrict __ptr, size_t __size,
663 size_t __n, FILE *__restrict __stream) __wur;
664 libc_hidden_proto(fread)
665 /* Write chunks of generic data to STREAM.
667 This function is a possible cancellation point and therefore not
668 marked with __THROW. */
669 extern size_t fwrite (const void *__restrict __ptr, size_t __size,
670 size_t __n, FILE *__restrict __s) __wur;
671 libc_hidden_proto(fwrite)
672 __END_NAMESPACE_STD
674 #ifdef __USE_GNU
675 /* This function does the same as `fputs' but does not lock the stream.
677 This function is not part of POSIX and therefore no official
678 cancellation point. But due to similarity with an POSIX interface
679 or due to the implementation it is a cancellation point and
680 therefore not marked with __THROW. */
681 extern int fputs_unlocked (const char *__restrict __s,
682 FILE *__restrict __stream);
683 libc_hidden_proto(fputs_unlocked)
684 #endif
686 #ifdef __USE_MISC
687 /* Faster versions when locking is not necessary.
689 These functions are not part of POSIX and therefore no official
690 cancellation point. But due to similarity with an POSIX interface
691 or due to the implementation they are cancellation points and
692 therefore not marked with __THROW. */
693 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
694 size_t __n, FILE *__restrict __stream) __wur;
695 libc_hidden_proto(fread_unlocked)
696 extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
697 size_t __n, FILE *__restrict __stream) __wur;
698 libc_hidden_proto(fwrite_unlocked)
699 #endif
702 __BEGIN_NAMESPACE_STD
703 /* Seek to a certain position on STREAM.
705 This function is a possible cancellation point and therefore not
706 marked with __THROW. */
707 extern int fseek (FILE *__stream, long int __off, int __whence);
708 libc_hidden_proto(fseek)
709 /* Return the current position of STREAM.
711 This function is a possible cancellation point and therefore not
712 marked with __THROW. */
713 extern long int ftell (FILE *__stream) __wur;
714 libc_hidden_proto(ftell)
715 /* Rewind to the beginning of STREAM.
717 This function is a possible cancellation point and therefore not
718 marked with __THROW. */
719 extern void rewind (FILE *__stream);
720 libc_hidden_proto(rewind)
721 __END_NAMESPACE_STD
723 /* The Single Unix Specification, Version 2, specifies an alternative,
724 more adequate interface for the two functions above which deal with
725 file offset. `long int' is not the right type. These definitions
726 are originally defined in the Large File Support API. */
728 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
729 # ifndef __USE_FILE_OFFSET64
730 /* Seek to a certain position on STREAM.
732 This function is a possible cancellation point and therefore not
733 marked with __THROW. */
734 extern int fseeko (FILE *__stream, __off_t __off, int __whence);
735 /* Return the current position of STREAM.
737 This function is a possible cancellation point and therefore not
738 marked with __THROW. */
739 extern __off_t ftello (FILE *__stream) __wur;
740 # else
741 # ifdef __REDIRECT
742 extern int __REDIRECT (fseeko,
743 (FILE *__stream, __off64_t __off, int __whence),
744 fseeko64);
745 extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
746 # else
747 # define fseeko fseeko64
748 # define ftello ftello64
749 # endif
750 # endif
751 #endif
753 __BEGIN_NAMESPACE_STD
754 #ifndef __USE_FILE_OFFSET64
755 /* Get STREAM's position.
757 This function is a possible cancellation point and therefore not
758 marked with __THROW. */
759 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
760 /* Set STREAM's position.
762 This function is a possible cancellation point and therefore not
763 marked with __THROW. */
764 extern int fsetpos (FILE *__stream, const fpos_t *__pos);
765 #else
766 # ifdef __REDIRECT
767 extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
768 fpos_t *__restrict __pos), fgetpos64);
769 extern int __REDIRECT (fsetpos,
770 (FILE *__stream, const fpos_t *__pos), fsetpos64);
771 # else
772 # define fgetpos fgetpos64
773 # define fsetpos fsetpos64
774 # endif
775 #endif
776 __END_NAMESPACE_STD
778 #ifdef __USE_LARGEFILE64
779 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
780 libc_hidden_proto(fseeko64)
781 extern __off64_t ftello64 (FILE *__stream) __wur;
782 libc_hidden_proto(ftello64)
783 extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
784 extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos);
785 #endif
787 __BEGIN_NAMESPACE_STD
788 /* Clear the error and EOF indicators for STREAM. */
789 extern void clearerr (FILE *__stream) __THROW;
790 /* Return the EOF indicator for STREAM. */
791 extern int feof (FILE *__stream) __THROW __wur;
792 /* Return the error indicator for STREAM. */
793 extern int ferror (FILE *__stream) __THROW __wur;
794 __END_NAMESPACE_STD
796 #ifdef __USE_MISC
797 /* Faster versions when locking is not required. */
798 extern void clearerr_unlocked (FILE *__stream) __THROW;
799 extern int feof_unlocked (FILE *__stream) __THROW __wur;
800 extern int ferror_unlocked (FILE *__stream) __THROW __wur;
801 #endif
804 __BEGIN_NAMESPACE_STD
805 /* Print a message describing the meaning of the value of errno.
807 This function is a possible cancellation point and therefore not
808 marked with __THROW. */
809 extern void perror (const char *__s);
810 libc_hidden_proto(perror)
811 __END_NAMESPACE_STD
813 #ifdef __UCLIBC_HAS_SYS_ERRLIST__
814 /* These variables normally should not be used directly. The `strerror'
815 function provides all the needed functionality. */
816 #ifdef __USE_BSD
817 extern int sys_nerr;
818 extern const char *const sys_errlist[];
819 #endif
820 #endif /* __UCLIBC_HAS_SYS_ERRLIST__ */
823 #ifdef __USE_POSIX
824 /* Return the system file descriptor for STREAM. */
825 extern int fileno (FILE *__stream) __THROW __wur;
826 libc_hidden_proto(fileno)
827 #endif /* Use POSIX. */
829 #ifdef __USE_MISC
830 /* Faster version when locking is not required. */
831 extern int fileno_unlocked (FILE *__stream) __THROW __wur;
832 libc_hidden_proto(fileno_unlocked)
833 #endif
836 #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
837 defined __USE_MISC)
838 /* Create a new stream connected to a pipe running the given command.
840 This function is a possible cancellation point and therefore not
841 marked with __THROW. */
842 extern FILE *popen (const char *__command, const char *__modes) __wur;
844 /* Close a stream opened by popen and return the status of its child.
846 This function is a possible cancellation point and therefore not
847 marked with __THROW. */
848 extern int pclose (FILE *__stream);
849 #endif
852 #ifdef __USE_POSIX
853 /* Return the name of the controlling terminal. */
854 extern char *ctermid (char *__s) __THROW;
855 #endif /* Use POSIX. */
858 #ifdef __USE_XOPEN
859 /* Return the name of the current user. */
860 extern char *cuserid (char *__s);
861 #endif /* Use X/Open, but not issue 6. */
864 #if defined __USE_GNU && defined __UCLIBC_HAS_OBSTACK__
865 struct obstack; /* See <obstack.h>. */
867 /* Write formatted output to an obstack. */
868 extern int obstack_printf (struct obstack *__restrict __obstack,
869 const char *__restrict __format, ...)
870 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3)));
871 extern int obstack_vprintf (struct obstack *__restrict __obstack,
872 const char *__restrict __format,
873 __gnuc_va_list __args)
874 __THROWNL __attribute__ ((__format__ (__printf__, 2, 0)));
875 libc_hidden_proto(obstack_vprintf)
876 #endif /* USE_GNU && UCLIBC_HAS_OBSTACK. */
879 #if defined __USE_POSIX || defined __USE_MISC
880 /* These are defined in POSIX.1:1996. */
882 /* Acquire ownership of STREAM. */
883 extern void flockfile (FILE *__stream) __THROW;
885 /* Try to acquire ownership of STREAM but do not block if it is not
886 possible. */
887 extern int ftrylockfile (FILE *__stream) __THROW __wur;
889 /* Relinquish the ownership granted for STREAM. */
890 extern void funlockfile (FILE *__stream) __THROW;
891 #endif /* POSIX || misc */
893 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
894 /* The X/Open standard requires some functions and variables to be
895 declared here which do not belong into this header. But we have to
896 follow. In GNU mode we don't do this nonsense. */
897 # define __need_getopt
898 /* keep this on uClibc in bits/, we need it when GNU_GETOPT is disabled */
899 # include <bits/getopt.h>
900 #endif /* X/Open, but not issue 6 and not for GNU. */
902 /* If we are compiling with optimizing read this file. It contains
903 several optimizing inline functions and macros. */
905 #ifdef __UCLIBC__
907 #define fgetc(_fp) __FGETC(_fp)
908 #define fputc(_ch, _fp) __FPUTC(_ch, _fp)
910 #if defined __USE_POSIX || defined __USE_MISC
911 /* SUSv3 allows getc_unlocked to be a macro */
912 #define getc_unlocked(_fp) __GETC_UNLOCKED(_fp)
913 /* SUSv3 allows putc_unlocked to be a macro */
914 #define putc_unlocked(_ch, _fp) __PUTC_UNLOCKED(_ch, _fp)
915 #endif
917 #ifdef __USE_MISC
918 #define fgetc_unlocked(_fp) __FGETC_UNLOCKED(_fp)
919 #define fputc_unlocked(_ch, _fp) __FPUTC_UNLOCKED(_ch, _fp)
920 #endif
922 #define getchar() __GETC(__stdin)
923 #define putchar(_ch) __PUTC((_ch), __stdout)
925 #if defined __USE_POSIX || defined __USE_MISC
926 #define getchar_unlocked() __GETC_UNLOCKED(__stdin)
927 #define putchar_unlocked(_ch) __PUTC_UNLOCKED((_ch), __stdout)
928 #endif
930 /* Clear the error and EOF indicators for STREAM. */
931 #define clearerr(_fp) __CLEARERR(_fp)
932 #define feof(_fp) __FEOF(_fp)
933 #define ferror(_fp) __FERROR(_fp)
935 #ifdef __USE_MISC
936 #define clearerr_unlocked(_fp) __CLEARERR_UNLOCKED(_fp)
937 #define feof_unlocked(_fp) __FEOF_UNLOCKED(_fp)
938 #define ferror_unlocked(_fp) __FERROR_UNLOCKED(_fp)
939 #endif
941 #endif
943 __END_DECLS
945 #endif /* <stdio.h> included. */
947 #endif /* !_STDIO_H */