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