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