(__getlogin_r_loginuid): Also fail if tpwd after pwuid call is NULL.
[glibc.git] / libio / stdio.h
blobbf16b3fff781c9475544ede4dc73264db2bebbfa
1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991, 1994-2008, 2009, 2010 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
21 * ISO C99 Standard: 7.19 Input/output <stdio.h>
24 #ifndef _STDIO_H
26 #if !defined __need_FILE && !defined __need___FILE
27 # define _STDIO_H 1
28 # include <features.h>
30 __BEGIN_DECLS
32 # define __need_size_t
33 # define __need_NULL
34 # include <stddef.h>
36 # include <bits/types.h>
37 # define __need_FILE
38 # define __need___FILE
39 #endif /* Don't need FILE. */
42 #if !defined __FILE_defined && defined __need_FILE
44 /* Define outside of namespace so the C++ is happy. */
45 struct _IO_FILE;
47 __BEGIN_NAMESPACE_STD
48 /* The opaque type of streams. This is the definition used elsewhere. */
49 typedef struct _IO_FILE FILE;
50 __END_NAMESPACE_STD
51 #if defined __USE_LARGEFILE64 || defined __USE_SVID || defined __USE_POSIX \
52 || defined __USE_BSD || defined __USE_ISOC99 || defined __USE_XOPEN \
53 || defined __USE_POSIX2
54 __USING_NAMESPACE_STD(FILE)
55 #endif
57 # define __FILE_defined 1
58 #endif /* FILE not defined. */
59 #undef __need_FILE
62 #if !defined ____FILE_defined && defined __need___FILE
64 /* The opaque type of streams. This is the definition used elsewhere. */
65 typedef struct _IO_FILE __FILE;
67 # define ____FILE_defined 1
68 #endif /* __FILE not defined. */
69 #undef __need___FILE
72 #ifdef _STDIO_H
73 #define _STDIO_USES_IOSTREAM
75 #include <libio.h>
77 #if defined __USE_XOPEN || defined __USE_XOPEN2K8
78 # ifdef __GNUC__
79 # ifndef _VA_LIST_DEFINED
80 typedef _G_va_list va_list;
81 # define _VA_LIST_DEFINED
82 # endif
83 # else
84 # include <stdarg.h>
85 # endif
86 #endif
88 #ifdef __USE_XOPEN2K8
89 # ifndef __off_t_defined
90 # ifndef __USE_FILE_OFFSET64
91 typedef __off_t off_t;
92 # else
93 typedef __off64_t off_t;
94 # endif
95 # define __off_t_defined
96 # endif
97 # if defined __USE_LARGEFILE64 && !defined __off64_t_defined
98 typedef __off64_t off64_t;
99 # define __off64_t_defined
100 # endif
102 # ifndef __ssize_t_defined
103 typedef __ssize_t ssize_t;
104 # define __ssize_t_defined
105 # endif
106 #endif
108 /* The type of the second argument to `fgetpos' and `fsetpos'. */
109 __BEGIN_NAMESPACE_STD
110 #ifndef __USE_FILE_OFFSET64
111 typedef _G_fpos_t fpos_t;
112 #else
113 typedef _G_fpos64_t fpos_t;
114 #endif
115 __END_NAMESPACE_STD
116 #ifdef __USE_LARGEFILE64
117 typedef _G_fpos64_t fpos64_t;
118 #endif
120 /* The possibilities for the third argument to `setvbuf'. */
121 #define _IOFBF 0 /* Fully buffered. */
122 #define _IOLBF 1 /* Line buffered. */
123 #define _IONBF 2 /* No buffering. */
126 /* Default buffer size. */
127 #ifndef BUFSIZ
128 # define BUFSIZ _IO_BUFSIZ
129 #endif
132 /* End of file character.
133 Some things throughout the library rely on this being -1. */
134 #ifndef EOF
135 # define EOF (-1)
136 #endif
139 /* The possibilities for the third argument to `fseek'.
140 These values should not be changed. */
141 #define SEEK_SET 0 /* Seek from beginning of file. */
142 #define SEEK_CUR 1 /* Seek from current position. */
143 #define SEEK_END 2 /* Seek from end of file. */
146 #if defined __USE_SVID || defined __USE_XOPEN
147 /* Default path prefix for `tempnam' and `tmpnam'. */
148 # define P_tmpdir "/tmp"
149 #endif
152 /* Get the values:
153 L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
154 TMP_MAX The minimum number of unique filenames generated by tmpnam
155 (and tempnam when it uses tmpnam's name space),
156 or tempnam (the two are separate).
157 L_ctermid How long an array to pass to `ctermid'.
158 L_cuserid How long an array to pass to `cuserid'.
159 FOPEN_MAX Minimum number of files that can be open at once.
160 FILENAME_MAX Maximum length of a filename. */
161 #include <bits/stdio_lim.h>
164 /* Standard streams. */
165 extern struct _IO_FILE *stdin; /* Standard input stream. */
166 extern struct _IO_FILE *stdout; /* Standard output stream. */
167 extern struct _IO_FILE *stderr; /* Standard error output stream. */
168 /* C89/C99 say they're macros. Make them happy. */
169 #define stdin stdin
170 #define stdout stdout
171 #define stderr stderr
173 __BEGIN_NAMESPACE_STD
174 /* Remove file FILENAME. */
175 extern int remove (__const char *__filename) __THROW;
176 /* Rename file OLD to NEW. */
177 extern int rename (__const char *__old, __const char *__new) __THROW;
178 __END_NAMESPACE_STD
180 #ifdef __USE_ATFILE
181 /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
182 extern int renameat (int __oldfd, __const char *__old, int __newfd,
183 __const char *__new) __THROW;
184 #endif
186 __BEGIN_NAMESPACE_STD
187 /* Create a temporary file and open it read/write.
189 This function is a possible cancellation points and therefore not
190 marked with __THROW. */
191 #ifndef __USE_FILE_OFFSET64
192 extern FILE *tmpfile (void) __wur;
193 #else
194 # ifdef __REDIRECT
195 extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;
196 # else
197 # define tmpfile tmpfile64
198 # endif
199 #endif
201 #ifdef __USE_LARGEFILE64
202 extern FILE *tmpfile64 (void) __wur;
203 #endif
205 /* Generate a temporary filename. */
206 extern char *tmpnam (char *__s) __THROW __wur;
207 __END_NAMESPACE_STD
209 #ifdef __USE_MISC
210 /* This is the reentrant variant of `tmpnam'. The only difference is
211 that it does not allow S to be NULL. */
212 extern char *tmpnam_r (char *__s) __THROW __wur;
213 #endif
216 #if defined __USE_SVID || defined __USE_XOPEN
217 /* Generate a unique temporary filename using up to five characters of PFX
218 if it is not NULL. The directory to put this file in is searched for
219 as follows: First the environment variable "TMPDIR" is checked.
220 If it contains the name of a writable directory, that directory is used.
221 If not and if DIR is not NULL, that value is checked. If that fails,
222 P_tmpdir is tried and finally "/tmp". The storage for the filename
223 is allocated by `malloc'. */
224 extern char *tempnam (__const char *__dir, __const char *__pfx)
225 __THROW __attribute_malloc__ __wur;
226 #endif
229 __BEGIN_NAMESPACE_STD
230 /* Close STREAM.
232 This function is a possible cancellation point and therefore not
233 marked with __THROW. */
234 extern int fclose (FILE *__stream);
235 /* Flush STREAM, or all streams if STREAM is NULL.
237 This function is a possible cancellation point and therefore not
238 marked with __THROW. */
239 extern int fflush (FILE *__stream);
240 __END_NAMESPACE_STD
242 #ifdef __USE_MISC
243 /* Faster versions when locking is not required.
245 This function is not part of POSIX and therefore no official
246 cancellation point. But due to similarity with an POSIX interface
247 or due to the implementation it is a cancellation point and
248 therefore not marked with __THROW. */
249 extern int fflush_unlocked (FILE *__stream);
250 #endif
252 #ifdef __USE_GNU
253 /* Close all streams.
255 This function is not part of POSIX and therefore no official
256 cancellation point. But due to similarity with an POSIX interface
257 or due to the implementation it is a cancellation point and
258 therefore not marked with __THROW. */
259 extern int fcloseall (void);
260 #endif
263 __BEGIN_NAMESPACE_STD
264 #ifndef __USE_FILE_OFFSET64
265 /* Open a file and create a new stream for it.
267 This function is a possible cancellation point and therefore not
268 marked with __THROW. */
269 extern FILE *fopen (__const char *__restrict __filename,
270 __const char *__restrict __modes) __wur;
271 /* Open a file, replacing an existing stream with it.
273 This function is a possible cancellation point and therefore not
274 marked with __THROW. */
275 extern FILE *freopen (__const char *__restrict __filename,
276 __const char *__restrict __modes,
277 FILE *__restrict __stream) __wur;
278 #else
279 # ifdef __REDIRECT
280 extern FILE *__REDIRECT (fopen, (__const char *__restrict __filename,
281 __const char *__restrict __modes), fopen64)
282 __wur;
283 extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
284 __const char *__restrict __modes,
285 FILE *__restrict __stream), freopen64)
286 __wur;
287 # else
288 # define fopen fopen64
289 # define freopen freopen64
290 # endif
291 #endif
292 __END_NAMESPACE_STD
293 #ifdef __USE_LARGEFILE64
294 extern FILE *fopen64 (__const char *__restrict __filename,
295 __const char *__restrict __modes) __wur;
296 extern FILE *freopen64 (__const char *__restrict __filename,
297 __const char *__restrict __modes,
298 FILE *__restrict __stream) __wur;
299 #endif
301 #ifdef __USE_POSIX
302 /* Create a new stream that refers to an existing system file descriptor. */
303 extern FILE *fdopen (int __fd, __const char *__modes) __THROW __wur;
304 #endif
306 #ifdef __USE_GNU
307 /* Create a new stream that refers to the given magic cookie,
308 and uses the given functions for input and output. */
309 extern FILE *fopencookie (void *__restrict __magic_cookie,
310 __const char *__restrict __modes,
311 _IO_cookie_io_functions_t __io_funcs) __THROW __wur;
312 #endif
314 #ifdef __USE_XOPEN2K8
315 /* Create a new stream that refers to a memory buffer. */
316 extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes)
317 __THROW __wur;
319 /* Open a stream that writes into a malloc'd buffer that is expanded as
320 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
321 and the number of characters written on fflush or fclose. */
322 extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;
323 #endif
326 __BEGIN_NAMESPACE_STD
327 /* If BUF is NULL, make STREAM unbuffered.
328 Else make it use buffer BUF, of size BUFSIZ. */
329 extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
330 /* Make STREAM use buffering mode MODE.
331 If BUF is not NULL, use N bytes of it for buffering;
332 else allocate an internal buffer N bytes long. */
333 extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
334 int __modes, size_t __n) __THROW;
335 __END_NAMESPACE_STD
337 #ifdef __USE_BSD
338 /* If BUF is NULL, make STREAM unbuffered.
339 Else make it use SIZE bytes of BUF for buffering. */
340 extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
341 size_t __size) __THROW;
343 /* Make STREAM line-buffered. */
344 extern void setlinebuf (FILE *__stream) __THROW;
345 #endif
348 __BEGIN_NAMESPACE_STD
349 /* Write formatted output to STREAM.
351 This function is a possible cancellation point and therefore not
352 marked with __THROW. */
353 extern int fprintf (FILE *__restrict __stream,
354 __const char *__restrict __format, ...);
355 /* Write formatted output to stdout.
357 This function is a possible cancellation point and therefore not
358 marked with __THROW. */
359 extern int printf (__const char *__restrict __format, ...);
360 /* Write formatted output to S. */
361 extern int sprintf (char *__restrict __s,
362 __const char *__restrict __format, ...) __THROW;
364 /* Write formatted output to S from argument list ARG.
366 This function is a possible cancellation point and therefore not
367 marked with __THROW. */
368 extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
369 _G_va_list __arg);
370 /* Write formatted output to stdout from argument list ARG.
372 This function is a possible cancellation point and therefore not
373 marked with __THROW. */
374 extern int vprintf (__const char *__restrict __format, _G_va_list __arg);
375 /* Write formatted output to S from argument list ARG. */
376 extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
377 _G_va_list __arg) __THROW;
378 __END_NAMESPACE_STD
380 #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
381 __BEGIN_NAMESPACE_C99
382 /* Maximum chars of output to write in MAXLEN. */
383 extern int snprintf (char *__restrict __s, size_t __maxlen,
384 __const char *__restrict __format, ...)
385 __THROW __attribute__ ((__format__ (__printf__, 3, 4)));
387 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
388 __const char *__restrict __format, _G_va_list __arg)
389 __THROW __attribute__ ((__format__ (__printf__, 3, 0)));
390 __END_NAMESPACE_C99
391 #endif
393 #ifdef __USE_GNU
394 /* Write formatted output to a string dynamically allocated with `malloc'.
395 Store the address of the string in *PTR. */
396 extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f,
397 _G_va_list __arg)
398 __THROW __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
399 extern int __asprintf (char **__restrict __ptr,
400 __const char *__restrict __fmt, ...)
401 __THROW __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
402 extern int asprintf (char **__restrict __ptr,
403 __const char *__restrict __fmt, ...)
404 __THROW __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
405 #endif
407 #ifdef __USE_XOPEN2K8
408 /* Write formatted output to a file descriptor.
410 These functions are not part of POSIX and therefore no official
411 cancellation point. But due to similarity with an POSIX interface
412 or due to the implementation they are cancellation points and
413 therefore not marked with __THROW. */
414 extern int vdprintf (int __fd, __const char *__restrict __fmt,
415 _G_va_list __arg)
416 __attribute__ ((__format__ (__printf__, 2, 0)));
417 extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
418 __attribute__ ((__format__ (__printf__, 2, 3)));
419 #endif
422 __BEGIN_NAMESPACE_STD
423 /* Read formatted input from STREAM.
425 This function is a possible cancellation point and therefore not
426 marked with __THROW. */
427 extern int fscanf (FILE *__restrict __stream,
428 __const char *__restrict __format, ...) __wur;
429 /* Read formatted input from stdin.
431 This function is a possible cancellation point and therefore not
432 marked with __THROW. */
433 extern int scanf (__const char *__restrict __format, ...) __wur;
434 /* Read formatted input from S. */
435 extern int sscanf (__const char *__restrict __s,
436 __const char *__restrict __format, ...) __THROW;
438 #if defined __USE_ISOC99 && !defined __USE_GNU \
439 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
440 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
441 # ifdef __REDIRECT
442 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
443 GNU extension which conflicts with valid %a followed by letter
444 s, S or [. */
445 extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
446 __const char *__restrict __format, ...),
447 __isoc99_fscanf) __wur;
448 extern int __REDIRECT (scanf, (__const char *__restrict __format, ...),
449 __isoc99_scanf) __wur;
450 extern int __REDIRECT_NTH (sscanf, (__const char *__restrict __s,
451 __const char *__restrict __format, ...),
452 __isoc99_sscanf);
453 # else
454 extern int __isoc99_fscanf (FILE *__restrict __stream,
455 __const char *__restrict __format, ...) __wur;
456 extern int __isoc99_scanf (__const char *__restrict __format, ...) __wur;
457 extern int __isoc99_sscanf (__const char *__restrict __s,
458 __const char *__restrict __format, ...) __THROW;
459 # define fscanf __isoc99_fscanf
460 # define scanf __isoc99_scanf
461 # define sscanf __isoc99_sscanf
462 # endif
463 #endif
465 __END_NAMESPACE_STD
467 #ifdef __USE_ISOC99
468 __BEGIN_NAMESPACE_C99
469 /* Read formatted input from S into argument list ARG.
471 This function is a possible cancellation point and therefore not
472 marked with __THROW. */
473 extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
474 _G_va_list __arg)
475 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
477 /* Read formatted input from stdin into argument list ARG.
479 This function is a possible cancellation point and therefore not
480 marked with __THROW. */
481 extern int vscanf (__const char *__restrict __format, _G_va_list __arg)
482 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
484 /* Read formatted input from S into argument list ARG. */
485 extern int vsscanf (__const char *__restrict __s,
486 __const char *__restrict __format, _G_va_list __arg)
487 __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
489 # if !defined __USE_GNU \
490 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
491 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
492 # ifdef __REDIRECT
493 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
494 GNU extension which conflicts with valid %a followed by letter
495 s, S or [. */
496 extern int __REDIRECT (vfscanf,
497 (FILE *__restrict __s,
498 __const char *__restrict __format, _G_va_list __arg),
499 __isoc99_vfscanf)
500 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
501 extern int __REDIRECT (vscanf, (__const char *__restrict __format,
502 _G_va_list __arg), __isoc99_vscanf)
503 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
504 extern int __REDIRECT_NTH (vsscanf,
505 (__const char *__restrict __s,
506 __const char *__restrict __format,
507 _G_va_list __arg), __isoc99_vsscanf)
508 __attribute__ ((__format__ (__scanf__, 2, 0)));
509 # else
510 extern int __isoc99_vfscanf (FILE *__restrict __s,
511 __const char *__restrict __format,
512 _G_va_list __arg) __wur;
513 extern int __isoc99_vscanf (__const char *__restrict __format,
514 _G_va_list __arg) __wur;
515 extern int __isoc99_vsscanf (__const char *__restrict __s,
516 __const char *__restrict __format,
517 _G_va_list __arg) __THROW;
518 # define vfscanf __isoc99_vfscanf
519 # define vscanf __isoc99_vscanf
520 # define vsscanf __isoc99_vsscanf
521 # endif
522 # endif
524 __END_NAMESPACE_C99
525 #endif /* Use ISO C9x. */
528 __BEGIN_NAMESPACE_STD
529 /* Read a character from STREAM.
531 These functions are possible cancellation points and therefore not
532 marked with __THROW. */
533 extern int fgetc (FILE *__stream);
534 extern int getc (FILE *__stream);
536 /* Read a character from stdin.
538 This function is a possible cancellation point and therefore not
539 marked with __THROW. */
540 extern int getchar (void);
541 __END_NAMESPACE_STD
543 /* The C standard explicitly says this is a macro, so we always do the
544 optimization for it. */
545 #define getc(_fp) _IO_getc (_fp)
547 #if defined __USE_POSIX || defined __USE_MISC
548 /* These are defined in POSIX.1:1996.
550 These functions are possible cancellation points and therefore not
551 marked with __THROW. */
552 extern int getc_unlocked (FILE *__stream);
553 extern int getchar_unlocked (void);
554 #endif /* Use POSIX or MISC. */
556 #ifdef __USE_MISC
557 /* Faster version when locking is not necessary.
559 This function is not part of POSIX and therefore no official
560 cancellation point. But due to similarity with an POSIX interface
561 or due to the implementation it is a cancellation point and
562 therefore not marked with __THROW. */
563 extern int fgetc_unlocked (FILE *__stream);
564 #endif /* Use MISC. */
567 __BEGIN_NAMESPACE_STD
568 /* Write a character to STREAM.
570 These functions are possible cancellation points and therefore not
571 marked with __THROW.
573 These functions is a possible cancellation point and therefore not
574 marked with __THROW. */
575 extern int fputc (int __c, FILE *__stream);
576 extern int putc (int __c, FILE *__stream);
578 /* Write a character to stdout.
580 This function is a possible cancellation point and therefore not
581 marked with __THROW. */
582 extern int putchar (int __c);
583 __END_NAMESPACE_STD
585 /* The C standard explicitly says this can be a macro,
586 so we always do the optimization for it. */
587 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
589 #ifdef __USE_MISC
590 /* Faster version when locking is not necessary.
592 This function is not part of POSIX and therefore no official
593 cancellation point. But due to similarity with an POSIX interface
594 or due to the implementation it is a cancellation point and
595 therefore not marked with __THROW. */
596 extern int fputc_unlocked (int __c, FILE *__stream);
597 #endif /* Use MISC. */
599 #if defined __USE_POSIX || defined __USE_MISC
600 /* These are defined in POSIX.1:1996.
602 These functions are possible cancellation points and therefore not
603 marked with __THROW. */
604 extern int putc_unlocked (int __c, FILE *__stream);
605 extern int putchar_unlocked (int __c);
606 #endif /* Use POSIX or MISC. */
609 #if defined __USE_SVID || defined __USE_MISC \
610 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
611 /* Get a word (int) from STREAM. */
612 extern int getw (FILE *__stream);
614 /* Write a word (int) to STREAM. */
615 extern int putw (int __w, FILE *__stream);
616 #endif
619 __BEGIN_NAMESPACE_STD
620 /* Get a newline-terminated string of finite length from STREAM.
622 This function is a possible cancellation point and therefore not
623 marked with __THROW. */
624 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
625 __wur;
627 /* Get a newline-terminated string from stdin, removing the newline.
628 DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
630 This function is a possible cancellation point and therefore not
631 marked with __THROW. */
632 extern char *gets (char *__s) __wur;
633 __END_NAMESPACE_STD
635 #ifdef __USE_GNU
636 /* This function does the same as `fgets' but does not lock the stream.
638 This function is not part of POSIX and therefore no official
639 cancellation point. But due to similarity with an POSIX interface
640 or due to the implementation it is a cancellation point and
641 therefore not marked with __THROW. */
642 extern char *fgets_unlocked (char *__restrict __s, int __n,
643 FILE *__restrict __stream) __wur;
644 #endif
647 #ifdef __USE_XOPEN2K8
648 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
649 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
650 NULL), pointing to *N characters of space. It is realloc'd as
651 necessary. Returns the number of characters read (not including the
652 null terminator), or -1 on error or EOF.
654 These functions are not part of POSIX and therefore no official
655 cancellation point. But due to similarity with an POSIX interface
656 or due to the implementation they are cancellation points and
657 therefore not marked with __THROW. */
658 extern _IO_ssize_t __getdelim (char **__restrict __lineptr,
659 size_t *__restrict __n, int __delimiter,
660 FILE *__restrict __stream) __wur;
661 extern _IO_ssize_t getdelim (char **__restrict __lineptr,
662 size_t *__restrict __n, int __delimiter,
663 FILE *__restrict __stream) __wur;
665 /* Like `getdelim', but reads up to a newline.
667 This function is not part of POSIX and therefore no official
668 cancellation point. But due to similarity with an POSIX interface
669 or due to the implementation it is a cancellation point and
670 therefore not marked with __THROW. */
671 extern _IO_ssize_t getline (char **__restrict __lineptr,
672 size_t *__restrict __n,
673 FILE *__restrict __stream) __wur;
674 #endif
677 __BEGIN_NAMESPACE_STD
678 /* Write a string to STREAM.
680 This function is a possible cancellation points and therefore not
681 marked with __THROW. */
682 extern int fputs (__const char *__restrict __s, FILE *__restrict __stream);
684 /* Write a string, followed by a newline, to stdout.
686 This function is a possible cancellation points and therefore not
687 marked with __THROW. */
688 extern int puts (__const char *__s);
691 /* Push a character back onto the input buffer of STREAM.
693 This function is a possible cancellation points and therefore not
694 marked with __THROW. */
695 extern int ungetc (int __c, FILE *__stream);
698 /* Read chunks of generic data from STREAM.
700 This function is a possible cancellation points and therefore not
701 marked with __THROW. */
702 extern size_t fread (void *__restrict __ptr, size_t __size,
703 size_t __n, FILE *__restrict __stream) __wur;
704 /* Write chunks of generic data to STREAM.
706 This function is a possible cancellation points and therefore not
707 marked with __THROW. */
708 extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
709 size_t __n, FILE *__restrict __s) __wur;
710 __END_NAMESPACE_STD
712 #ifdef __USE_GNU
713 /* This function does the same as `fputs' but does not lock the stream.
715 This function is not part of POSIX and therefore no official
716 cancellation point. But due to similarity with an POSIX interface
717 or due to the implementation it is a cancellation point and
718 therefore not marked with __THROW. */
719 extern int fputs_unlocked (__const char *__restrict __s,
720 FILE *__restrict __stream);
721 #endif
723 #ifdef __USE_MISC
724 /* Faster versions when locking is not necessary.
726 These functions are not part of POSIX and therefore no official
727 cancellation point. But due to similarity with an POSIX interface
728 or due to the implementation they are cancellation points and
729 therefore not marked with __THROW. */
730 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
731 size_t __n, FILE *__restrict __stream) __wur;
732 extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
733 size_t __n, FILE *__restrict __stream) __wur;
734 #endif
737 __BEGIN_NAMESPACE_STD
738 /* Seek to a certain position on STREAM.
740 This function is a possible cancellation point and therefore not
741 marked with __THROW. */
742 extern int fseek (FILE *__stream, long int __off, int __whence);
743 /* Return the current position of STREAM.
745 This function is a possible cancellation point and therefore not
746 marked with __THROW. */
747 extern long int ftell (FILE *__stream) __wur;
748 /* Rewind to the beginning of STREAM.
750 This function is a possible cancellation point and therefore not
751 marked with __THROW. */
752 extern void rewind (FILE *__stream);
753 __END_NAMESPACE_STD
755 /* The Single Unix Specification, Version 2, specifies an alternative,
756 more adequate interface for the two functions above which deal with
757 file offset. `long int' is not the right type. These definitions
758 are originally defined in the Large File Support API. */
760 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
761 # ifndef __USE_FILE_OFFSET64
762 /* Seek to a certain position on STREAM.
764 This function is a possible cancellation point and therefore not
765 marked with __THROW. */
766 extern int fseeko (FILE *__stream, __off_t __off, int __whence);
767 /* Return the current position of STREAM.
769 This function is a possible cancellation point and therefore not
770 marked with __THROW. */
771 extern __off_t ftello (FILE *__stream) __wur;
772 # else
773 # ifdef __REDIRECT
774 extern int __REDIRECT (fseeko,
775 (FILE *__stream, __off64_t __off, int __whence),
776 fseeko64);
777 extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
778 # else
779 # define fseeko fseeko64
780 # define ftello ftello64
781 # endif
782 # endif
783 #endif
785 __BEGIN_NAMESPACE_STD
786 #ifndef __USE_FILE_OFFSET64
787 /* Get STREAM's position.
789 This function is a possible cancellation point and therefore not
790 marked with __THROW. */
791 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
792 /* Set STREAM's position.
794 This function is a possible cancellation point and therefore not
795 marked with __THROW. */
796 extern int fsetpos (FILE *__stream, __const fpos_t *__pos);
797 #else
798 # ifdef __REDIRECT
799 extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
800 fpos_t *__restrict __pos), fgetpos64);
801 extern int __REDIRECT (fsetpos,
802 (FILE *__stream, __const fpos_t *__pos), fsetpos64);
803 # else
804 # define fgetpos fgetpos64
805 # define fsetpos fsetpos64
806 # endif
807 #endif
808 __END_NAMESPACE_STD
810 #ifdef __USE_LARGEFILE64
811 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
812 extern __off64_t ftello64 (FILE *__stream) __wur;
813 extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
814 extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos);
815 #endif
817 __BEGIN_NAMESPACE_STD
818 /* Clear the error and EOF indicators for STREAM. */
819 extern void clearerr (FILE *__stream) __THROW;
820 /* Return the EOF indicator for STREAM. */
821 extern int feof (FILE *__stream) __THROW __wur;
822 /* Return the error indicator for STREAM. */
823 extern int ferror (FILE *__stream) __THROW __wur;
824 __END_NAMESPACE_STD
826 #ifdef __USE_MISC
827 /* Faster versions when locking is not required. */
828 extern void clearerr_unlocked (FILE *__stream) __THROW;
829 extern int feof_unlocked (FILE *__stream) __THROW __wur;
830 extern int ferror_unlocked (FILE *__stream) __THROW __wur;
831 #endif
834 __BEGIN_NAMESPACE_STD
835 /* Print a message describing the meaning of the value of errno.
837 This function is a possible cancellation point and therefore not
838 marked with __THROW. */
839 extern void perror (__const char *__s);
840 __END_NAMESPACE_STD
842 /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
843 are available on this system. Even if available, these variables
844 should not be used directly. The `strerror' function provides
845 all the necessary functionality. */
846 #include <bits/sys_errlist.h>
849 #ifdef __USE_POSIX
850 /* Return the system file descriptor for STREAM. */
851 extern int fileno (FILE *__stream) __THROW __wur;
852 #endif /* Use POSIX. */
854 #ifdef __USE_MISC
855 /* Faster version when locking is not required. */
856 extern int fileno_unlocked (FILE *__stream) __THROW __wur;
857 #endif
860 #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
861 defined __USE_MISC)
862 /* Create a new stream connected to a pipe running the given command.
864 This function is a possible cancellation point and therefore not
865 marked with __THROW. */
866 extern FILE *popen (__const char *__command, __const char *__modes) __wur;
868 /* Close a stream opened by popen and return the status of its child.
870 This function is a possible cancellation point and therefore not
871 marked with __THROW. */
872 extern int pclose (FILE *__stream);
873 #endif
876 #ifdef __USE_POSIX
877 /* Return the name of the controlling terminal. */
878 extern char *ctermid (char *__s) __THROW;
879 #endif /* Use POSIX. */
882 #ifdef __USE_XOPEN
883 /* Return the name of the current user. */
884 extern char *cuserid (char *__s);
885 #endif /* Use X/Open, but not issue 6. */
888 #ifdef __USE_GNU
889 struct obstack; /* See <obstack.h>. */
891 /* Write formatted output to an obstack. */
892 extern int obstack_printf (struct obstack *__restrict __obstack,
893 __const char *__restrict __format, ...)
894 __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
895 extern int obstack_vprintf (struct obstack *__restrict __obstack,
896 __const char *__restrict __format,
897 _G_va_list __args)
898 __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
899 #endif /* Use GNU. */
902 #if defined __USE_POSIX || defined __USE_MISC
903 /* These are defined in POSIX.1:1996. */
905 /* Acquire ownership of STREAM. */
906 extern void flockfile (FILE *__stream) __THROW;
908 /* Try to acquire ownership of STREAM but do not block if it is not
909 possible. */
910 extern int ftrylockfile (FILE *__stream) __THROW __wur;
912 /* Relinquish the ownership granted for STREAM. */
913 extern void funlockfile (FILE *__stream) __THROW;
914 #endif /* POSIX || misc */
916 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
917 /* The X/Open standard requires some functions and variables to be
918 declared here which do not belong into this header. But we have to
919 follow. In GNU mode we don't do this nonsense. */
920 # define __need_getopt
921 # include <getopt.h>
922 #endif /* X/Open, but not issue 6 and not for GNU. */
924 /* If we are compiling with optimizing read this file. It contains
925 several optimizing inline functions and macros. */
926 #ifdef __USE_EXTERN_INLINES
927 # include <bits/stdio.h>
928 #endif
929 #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
930 # include <bits/stdio2.h>
931 #endif
932 #ifdef __LDBL_COMPAT
933 # include <bits/stdio-ldbl.h>
934 #endif
936 __END_DECLS
938 #endif /* <stdio.h> included. */
940 #endif /* !_STDIO_H */