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