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