stdio.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. /*
  2. Copyright (C) 1991, 1994-1999, 2000, 2001, 2002 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. /*
  17. * ISO C99 Standard: 7.19 Input/output <stdio.h>
  18. */
  19. #ifndef _STDIO_H
  20. #if !defined __need_FILE && !defined __need___FILE
  21. # define _STDIO_H 1
  22. # include <features.h>
  23. __BEGIN_DECLS
  24. # define __need_size_t
  25. # define __need_NULL
  26. # include <stddef.h>
  27. # include <bits/types.h>
  28. # define __need_FILE
  29. # define __need___FILE
  30. #endif /* Don't need FILE. */
  31. #if !defined __FILE_defined && defined __need_FILE
  32. /* The opaque type of streams. This is the definition used elsewhere. */
  33. typedef struct __STDIO_FILE_STRUCT FILE;
  34. # define __FILE_defined 1
  35. #endif /* FILE not defined. */
  36. #undef __need_FILE
  37. #if !defined ____FILE_defined && defined __need___FILE
  38. /* The opaque type of streams. This is the definition used elsewhere. */
  39. typedef struct __STDIO_FILE_STRUCT __FILE;
  40. # define ____FILE_defined 1
  41. #endif /* __FILE not defined. */
  42. #undef __need___FILE
  43. #ifdef _STDIO_H
  44. #undef _STDIO_USES_IOSTREAM
  45. #include <bits/uClibc_stdio.h>
  46. /* This define avoids name pollution if we're using GNU stdarg.h */
  47. # define __need___va_list
  48. #include <stdarg.h>
  49. /* The type of the second argument to `fgetpos' and `fsetpos'. */
  50. #ifndef __USE_FILE_OFFSET64
  51. typedef __STDIO_fpos_t fpos_t;
  52. #else
  53. typedef __STDIO_fpos64_t fpos_t;
  54. #endif
  55. #ifdef __USE_LARGEFILE64
  56. typedef __STDIO_fpos64_t fpos64_t;
  57. #endif
  58. /* The possibilities for the third argument to `setvbuf'. */
  59. #define _IOFBF __STDIO_IOFBF /* Fully buffered. */
  60. #define _IOLBF __STDIO_IOLBF /* Line buffered. */
  61. #define _IONBF __STDIO_IONBF /* No buffering. */
  62. /* Default buffer size. */
  63. #ifndef BUFSIZ
  64. # define BUFSIZ __STDIO_BUFSIZ
  65. #endif
  66. /* End of file character.
  67. Some things throughout the library rely on this being -1. */
  68. #ifndef EOF
  69. # define EOF (-1)
  70. #endif
  71. /* The possibilities for the third argument to `fseek'.
  72. These values should not be changed. */
  73. #define SEEK_SET 0 /* Seek from beginning of file. */
  74. #define SEEK_CUR 1 /* Seek from current position. */
  75. #define SEEK_END 2 /* Seek from end of file. */
  76. #if defined __USE_SVID || defined __USE_XOPEN
  77. /* Default path prefix for `tempnam' and `tmpnam'. */
  78. # define P_tmpdir "/tmp"
  79. #endif
  80. /* Get the values:
  81. L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
  82. TMP_MAX The minimum number of unique filenames generated by tmpnam
  83. (and tempnam when it uses tmpnam's name space),
  84. or tempnam (the two are separate).
  85. L_ctermid How long an array to pass to `ctermid'.
  86. L_cuserid How long an array to pass to `cuserid'.
  87. FOPEN_MAX Minimum number of files that can be open at once.
  88. FILENAME_MAX Maximum length of a filename. */
  89. #include <bits/stdio_lim.h>
  90. /* Standard streams. */
  91. extern FILE *stdin; /* Standard input stream. */
  92. extern FILE *stdout; /* Standard output stream. */
  93. extern FILE *stderr; /* Standard error output stream. */
  94. #ifdef __STDC__
  95. /* C89/C99 say they're macros. Make them happy. */
  96. #define stdin stdin
  97. #define stdout stdout
  98. #define stderr stderr
  99. #endif
  100. /* Remove file FILENAME. */
  101. extern int remove (__const char *__filename) __THROW;
  102. /* Rename file OLD to NEW. */
  103. extern int rename (__const char *__old, __const char *__new) __THROW;
  104. /* Create a temporary file and open it read/write. */
  105. #ifndef __USE_FILE_OFFSET64
  106. extern FILE *tmpfile (void) __THROW;
  107. #else
  108. # ifdef __REDIRECT
  109. extern FILE *__REDIRECT (tmpfile, (void) __THROW, tmpfile64);
  110. # else
  111. # define tmpfile tmpfile64
  112. # endif
  113. #endif
  114. #ifdef __USE_LARGEFILE64
  115. extern FILE *tmpfile64 (void) __THROW;
  116. #endif
  117. /* Generate a temporary filename. */
  118. extern char *tmpnam (char *__s) __THROW;
  119. #ifdef __USE_MISC
  120. /* This is the reentrant variant of `tmpnam'. The only difference is
  121. that it does not allow S to be NULL. */
  122. extern char *tmpnam_r (char *__s) __THROW;
  123. #endif
  124. #if defined __USE_SVID || defined __USE_XOPEN
  125. /* Generate a unique temporary filename using up to five characters of PFX
  126. if it is not NULL. The directory to put this file in is searched for
  127. as follows: First the environment variable "TMPDIR" is checked.
  128. If it contains the name of a writable directory, that directory is used.
  129. If not and if DIR is not NULL, that value is checked. If that fails,
  130. P_tmpdir is tried and finally "/tmp". The storage for the filename
  131. is allocated by `malloc'. */
  132. extern char *tempnam (__const char *__dir, __const char *__pfx)
  133. __THROW __attribute_malloc__;
  134. #endif
  135. /* Close STREAM. */
  136. extern int fclose (FILE *__stream) __THROW;
  137. /* Flush STREAM, or all streams if STREAM is NULL. */
  138. extern int fflush (FILE *__stream) __THROW;
  139. #ifdef __USE_MISC
  140. /* Faster versions when locking is not required. */
  141. extern int fflush_unlocked (FILE *__stream) __THROW;
  142. #endif
  143. #ifdef __USE_GNU
  144. /* Close all streams. */
  145. extern int fcloseall (void) __THROW;
  146. #endif
  147. #ifndef __USE_FILE_OFFSET64
  148. /* Open a file and create a new stream for it. */
  149. extern FILE *fopen (__const char *__restrict __filename,
  150. __const char *__restrict __modes) __THROW;
  151. /* Open a file, replacing an existing stream with it. */
  152. extern FILE *freopen (__const char *__restrict __filename,
  153. __const char *__restrict __modes,
  154. FILE *__restrict __stream) __THROW;
  155. #else
  156. # ifdef __REDIRECT
  157. extern FILE *__REDIRECT (fopen, (__const char *__restrict __filename,
  158. __const char *__restrict __modes) __THROW,
  159. fopen64);
  160. extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
  161. __const char *__restrict __modes,
  162. FILE *__restrict __stream) __THROW,
  163. freopen64);
  164. # else
  165. # define fopen fopen64
  166. # define freopen freopen64
  167. # endif
  168. #endif
  169. #ifdef __USE_LARGEFILE64
  170. extern FILE *fopen64 (__const char *__restrict __filename,
  171. __const char *__restrict __modes) __THROW;
  172. extern FILE *freopen64 (__const char *__restrict __filename,
  173. __const char *__restrict __modes,
  174. FILE *__restrict __stream) __THROW;
  175. #endif
  176. #ifdef __USE_POSIX
  177. /* Create a new stream that refers to an existing system file descriptor. */
  178. extern FILE *fdopen (int __fd, __const char *__modes) __THROW;
  179. #endif
  180. #ifdef __USE_GNU
  181. #ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
  182. /* Create a new stream that refers to the given magic cookie,
  183. and uses the given functions for input and output. */
  184. extern FILE *fopencookie (void *__restrict __magic_cookie,
  185. __const char *__restrict __modes,
  186. _IO_cookie_io_functions_t __io_funcs) __THROW;
  187. /* Create a new stream that refers to a memory buffer. */
  188. extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes) __THROW;
  189. /* Open a stream that writes into a malloc'd buffer that is expanded as
  190. necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
  191. and the number of characters written on fflush or fclose. */
  192. extern FILE *open_memstream (char **__restrict __bufloc,
  193. size_t *__restrict __sizeloc) __THROW;
  194. #endif
  195. #endif
  196. /* If BUF is NULL, make STREAM unbuffered.
  197. Else make it use buffer BUF, of size BUFSIZ. */
  198. extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
  199. /* Make STREAM use buffering mode MODE.
  200. If BUF is not NULL, use N bytes of it for buffering;
  201. else allocate an internal buffer N bytes long. */
  202. extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
  203. int __modes, size_t __n) __THROW;
  204. #ifdef __USE_BSD
  205. /* If BUF is NULL, make STREAM unbuffered.
  206. Else make it use SIZE bytes of BUF for buffering. */
  207. extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
  208. size_t __size) __THROW;
  209. /* Make STREAM line-buffered. */
  210. extern void setlinebuf (FILE *__stream) __THROW;
  211. #endif
  212. /* Write formatted output to STREAM. */
  213. extern int fprintf (FILE *__restrict __stream,
  214. __const char *__restrict __format, ...) __THROW;
  215. /* Write formatted output to stdout. */
  216. extern int printf (__const char *__restrict __format, ...) __THROW;
  217. /* Write formatted output to S. */
  218. extern int sprintf (char *__restrict __s,
  219. __const char *__restrict __format, ...) __THROW;
  220. /* Write formatted output to S from argument list ARG. */
  221. extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
  222. __gnuc_va_list __arg) __THROW;
  223. /* Write formatted output to stdout from argument list ARG. */
  224. extern int vprintf (__const char *__restrict __format, __gnuc_va_list __arg)
  225. __THROW;
  226. /* Write formatted output to S from argument list ARG. */
  227. extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
  228. __gnuc_va_list __arg) __THROW;
  229. #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
  230. /* Maximum chars of output to write in MAXLEN. */
  231. extern int snprintf (char *__restrict __s, size_t __maxlen,
  232. __const char *__restrict __format, ...)
  233. __THROW __attribute__ ((__format__ (__printf__, 3, 4)));
  234. extern int vsnprintf (char *__restrict __s, size_t __maxlen,
  235. __const char *__restrict __format, __gnuc_va_list __arg)
  236. __THROW __attribute__ ((__format__ (__printf__, 3, 0)));
  237. #endif
  238. #ifdef __USE_GNU
  239. /* Write formatted output to a string dynamically allocated with `malloc'.
  240. Store the address of the string in *PTR. */
  241. extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f,
  242. __gnuc_va_list __arg)
  243. __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
  244. extern int __asprintf (char **__restrict __ptr,
  245. __const char *__restrict __fmt, ...)
  246. __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
  247. extern int asprintf (char **__restrict __ptr,
  248. __const char *__restrict __fmt, ...)
  249. __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
  250. /* Write formatted output to a file descriptor. */
  251. extern int vdprintf (int __fd, __const char *__restrict __fmt,
  252. __gnuc_va_list __arg)
  253. __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
  254. extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
  255. __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
  256. #endif
  257. /* Read formatted input from STREAM. */
  258. extern int fscanf (FILE *__restrict __stream,
  259. __const char *__restrict __format, ...) __THROW;
  260. /* Read formatted input from stdin. */
  261. extern int scanf (__const char *__restrict __format, ...) __THROW;
  262. /* Read formatted input from S. */
  263. extern int sscanf (__const char *__restrict __s,
  264. __const char *__restrict __format, ...) __THROW;
  265. #ifdef __USE_ISOC99
  266. /* Read formatted input from S into argument list ARG. */
  267. extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
  268. __gnuc_va_list __arg)
  269. __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
  270. /* Read formatted input from stdin into argument list ARG. */
  271. extern int vscanf (__const char *__restrict __format, __gnuc_va_list __arg)
  272. __THROW __attribute__ ((__format__ (__scanf__, 1, 0)));
  273. /* Read formatted input from S into argument list ARG. */
  274. extern int vsscanf (__const char *__restrict __s,
  275. __const char *__restrict __format, __gnuc_va_list __arg)
  276. __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
  277. #endif /* Use ISO C9x. */
  278. /* Read a character from STREAM. */
  279. extern int fgetc (FILE *__stream) __THROW;
  280. extern int getc (FILE *__stream) __THROW;
  281. /* Read a character from stdin. */
  282. extern int getchar (void) __THROW;
  283. /* The C standard explicitly says this is a macro, so we always do the
  284. optimization for it. */
  285. #define getc(_fp) __GETC(_fp)
  286. #if defined __USE_POSIX || defined __USE_MISC
  287. /* These are defined in POSIX.1:1996. */
  288. extern int getc_unlocked (FILE *__stream) __THROW;
  289. extern int getchar_unlocked (void) __THROW;
  290. /* SUSv3 allows getc_unlocked to be a macro */
  291. #define getc_unlocked(_fp) __GETC_UNLOCKED(_fp)
  292. #endif /* Use POSIX or MISC. */
  293. #ifdef __USE_MISC
  294. /* Faster version when locking is not necessary. */
  295. extern int fgetc_unlocked (FILE *__stream) __THROW;
  296. #endif /* Use MISC. */
  297. /* Write a character to STREAM. */
  298. extern int fputc (int __c, FILE *__stream) __THROW;
  299. extern int putc (int __c, FILE *__stream) __THROW;
  300. /* Write a character to stdout. */
  301. extern int putchar (int __c) __THROW;
  302. /* The C standard explicitly says this can be a macro,
  303. so we always do the optimization for it. */
  304. #define putc(_ch, _fp) __PUTC(_ch, _fp)
  305. #ifdef __USE_MISC
  306. /* Faster version when locking is not necessary. */
  307. extern int fputc_unlocked (int __c, FILE *__stream) __THROW;
  308. #endif /* Use MISC. */
  309. #if defined __USE_POSIX || defined __USE_MISC
  310. /* These are defined in POSIX.1:1996. */
  311. extern int putc_unlocked (int __c, FILE *__stream) __THROW;
  312. extern int putchar_unlocked (int __c) __THROW;
  313. /* SUSv3 allows putc_unlocked to be a macro */
  314. #define putc_unlocked(_ch, _fp) __PUTC_UNLOCKED(_ch, _fp)
  315. #endif /* Use POSIX or MISC. */
  316. #if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
  317. /* Get a word (int) from STREAM. */
  318. extern int getw (FILE *__stream) __THROW;
  319. /* Write a word (int) to STREAM. */
  320. extern int putw (int __w, FILE *__stream) __THROW;
  321. #endif
  322. /* Get a newline-terminated string of finite length from STREAM. */
  323. extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
  324. __THROW;
  325. #if defined(__USE_GNU) || defined(__USE_MISC)
  326. /* This function does the same as `fgets' but does not lock the stream. */
  327. extern char *fgets_unlocked (char *__restrict __s, int __n,
  328. FILE *__restrict __stream) __THROW;
  329. #endif
  330. /* Get a newline-terminated string from stdin, removing the newline.
  331. DO NOT USE THIS FUNCTION!! There is no limit on how much it will read. */
  332. extern char *gets (char *__s) __THROW;
  333. #ifdef __USE_GNU
  334. /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
  335. (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
  336. NULL), pointing to *N characters of space. It is realloc'd as
  337. necessary. Returns the number of characters read (not including the
  338. null terminator), or -1 on error or EOF. */
  339. extern __ssize_t __getdelim (char **__restrict __lineptr,
  340. size_t *__restrict __n, int __delimiter,
  341. FILE *__restrict __stream) __THROW;
  342. extern __ssize_t getdelim (char **__restrict __lineptr,
  343. size_t *__restrict __n, int __delimiter,
  344. FILE *__restrict __stream) __THROW;
  345. /* Like `getdelim', but reads up to a newline. */
  346. extern __ssize_t getline (char **__restrict __lineptr,
  347. size_t *__restrict __n,
  348. FILE *__restrict __stream) __THROW;
  349. #endif
  350. /* Write a string to STREAM. */
  351. extern int fputs (__const char *__restrict __s, FILE *__restrict __stream)
  352. __THROW;
  353. #ifdef __USE_GNU
  354. /* This function does the same as `fputs' but does not lock the stream. */
  355. extern int fputs_unlocked (__const char *__restrict __s,
  356. FILE *__restrict __stream) __THROW;
  357. #endif
  358. /* Write a string, followed by a newline, to stdout. */
  359. extern int puts (__const char *__s) __THROW;
  360. /* Push a character back onto the input buffer of STREAM. */
  361. extern int ungetc (int __c, FILE *__stream) __THROW;
  362. /* Read chunks of generic data from STREAM. */
  363. extern size_t fread (void *__restrict __ptr, size_t __size,
  364. size_t __n, FILE *__restrict __stream) __THROW;
  365. /* Write chunks of generic data to STREAM. */
  366. extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
  367. size_t __n, FILE *__restrict __s) __THROW;
  368. #ifdef __USE_MISC
  369. /* Faster versions when locking is not necessary. */
  370. extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
  371. size_t __n, FILE *__restrict __stream) __THROW;
  372. extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
  373. size_t __n, FILE *__restrict __stream) __THROW;
  374. #endif
  375. /* Seek to a certain position on STREAM. */
  376. extern int fseek (FILE *__stream, long int __off, int __whence) __THROW;
  377. /* Return the current position of STREAM. */
  378. extern long int ftell (FILE *__stream) __THROW;
  379. /* Rewind to the beginning of STREAM. */
  380. extern void rewind (FILE *__stream) __THROW;
  381. /* The Single Unix Specification, Version 2, specifies an alternative,
  382. more adequate interface for the two functions above which deal with
  383. file offset. `long int' is not the right type. These definitions
  384. are originally defined in the Large File Support API. */
  385. #ifndef __USE_FILE_OFFSET64
  386. # ifdef __USE_LARGEFILE
  387. /* Seek to a certain position on STREAM. */
  388. extern int fseeko (FILE *__stream, __off_t __off, int __whence) __THROW;
  389. /* Return the current position of STREAM. */
  390. extern __off_t ftello (FILE *__stream) __THROW;
  391. # endif
  392. /* Get STREAM's position. */
  393. extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos)
  394. __THROW;
  395. /* Set STREAM's position. */
  396. extern int fsetpos (FILE *__stream, __const fpos_t *__pos) __THROW;
  397. #else
  398. # ifdef __REDIRECT
  399. # ifdef __USE_LARGEFILE
  400. extern int __REDIRECT (fseeko,
  401. (FILE *__stream, __off64_t __off, int __whence) __THROW,
  402. fseeko64);
  403. extern __off64_t __REDIRECT (ftello, (FILE *__stream) __THROW, ftello64);
  404. # endif
  405. extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
  406. fpos_t *__restrict __pos) __THROW, fgetpos64);
  407. extern int __REDIRECT (fsetpos,
  408. (FILE *__stream, __const fpos_t *__pos) __THROW,
  409. fsetpos64);
  410. # else
  411. # ifdef __USE_LARGEFILE
  412. # define fseeko fseeko64
  413. # define ftello ftello64
  414. # endif
  415. # define fgetpos fgetpos64
  416. # define fsetpos fsetpos64
  417. # endif
  418. #endif
  419. #ifdef __USE_LARGEFILE64
  420. extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence) __THROW;
  421. extern __off64_t ftello64 (FILE *__stream) __THROW;
  422. extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos)
  423. __THROW;
  424. extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos) __THROW;
  425. #endif
  426. /* Clear the error and EOF indicators for STREAM. */
  427. extern void clearerr (FILE *__stream) __THROW;
  428. /* Return the EOF indicator for STREAM. */
  429. extern int feof (FILE *__stream) __THROW;
  430. /* Return the error indicator for STREAM. */
  431. extern int ferror (FILE *__stream) __THROW;
  432. #ifdef __USE_MISC
  433. /* Faster versions when locking is not required. */
  434. extern void clearerr_unlocked (FILE *__stream) __THROW;
  435. extern int feof_unlocked (FILE *__stream) __THROW;
  436. extern int ferror_unlocked (FILE *__stream) __THROW;
  437. #endif
  438. /* Print a message describing the meaning of the value of errno. */
  439. extern void perror (__const char *__s) __THROW;
  440. #ifdef __UCLIBC_HAS_SYS_ERRLIST__
  441. /* These variables normally should not be used directly. The `strerror'
  442. function provides all the needed functionality. */
  443. #ifdef __USE_BSD
  444. extern int sys_nerr;
  445. extern __const char *__const sys_errlist[];
  446. #endif
  447. #endif /* __UCLIBC_HAS_SYS_ERRLIST__ */
  448. #ifdef __USE_POSIX
  449. /* Return the system file descriptor for STREAM. */
  450. extern int fileno (FILE *__stream) __THROW;
  451. #endif /* Use POSIX. */
  452. #ifdef __USE_MISC
  453. /* Faster version when locking is not required. */
  454. extern int fileno_unlocked (FILE *__stream) __THROW;
  455. #endif
  456. #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
  457. defined __USE_MISC)
  458. /* Create a new stream connected to a pipe running the given command. */
  459. extern FILE *popen (__const char *__command, __const char *__modes) __THROW;
  460. /* Close a stream opened by popen and return the status of its child. */
  461. extern int pclose (FILE *__stream) __THROW;
  462. #endif
  463. #ifdef __USE_POSIX
  464. /* Return the name of the controlling terminal. */
  465. extern char *ctermid (char *__s) __THROW;
  466. #endif /* Use POSIX. */
  467. #ifdef __USE_XOPEN
  468. /* Return the name of the current user. */
  469. extern char *cuserid (char *__s) __THROW;
  470. #endif /* Use X/Open, but not issue 6. */
  471. #ifdef __USE_GNU
  472. struct obstack; /* See <obstack.h>. */
  473. /* Write formatted output to an obstack. */
  474. extern int obstack_printf (struct obstack *__restrict __obstack,
  475. __const char *__restrict __format, ...)
  476. __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
  477. extern int obstack_vprintf (struct obstack *__restrict __obstack,
  478. __const char *__restrict __format,
  479. _G_va_list __args)
  480. __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
  481. #endif /* Use GNU. */
  482. #if defined __USE_POSIX || defined __USE_MISC
  483. /* These are defined in POSIX.1:1996. */
  484. /* Acquire ownership of STREAM. */
  485. extern void flockfile (FILE *__stream) __THROW;
  486. /* Try to acquire ownership of STREAM but do not block if it is not
  487. possible. */
  488. extern int ftrylockfile (FILE *__stream) __THROW;
  489. /* Relinquish the ownership granted for STREAM. */
  490. extern void funlockfile (FILE *__stream) __THROW;
  491. #endif /* POSIX || misc */
  492. #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
  493. /* The X/Open standard requires some functions and variables to be
  494. declared here which do not belong into this header. But we have to
  495. follow. In GNU mode we don't do this nonsense. */
  496. # define __need_getopt
  497. # include <bits/getopt.h>
  498. #endif /* X/Open, but not issue 6 and not for GNU. */
  499. /* If we are compiling with optimizing read this file. It contains
  500. several optimizing inline functions and macros. */
  501. #define fgetc(_fp) __FGETC(_fp)
  502. #define fputc(_ch, _fp) __FPUTC(_ch, _fp)
  503. #ifdef __USE_MISC
  504. #define fgetc_unlocked(_fp) __FGETC_UNLOCKED(_fp)
  505. #define fputc_unlocked(_ch, _fp) __FPUTC_UNLOCKED(_ch, _fp)
  506. #endif
  507. #define getchar() __GETC(__stdin)
  508. #define putchar(_ch) __PUTC((_ch), __stdout)
  509. #if defined __USE_POSIX || defined __USE_MISC
  510. #define getchar_unlocked() __GETC_UNLOCKED(__stdin)
  511. #define putchar_unlocked(_ch) __PUTC_UNLOCKED((_ch), __stdout)
  512. #endif
  513. /* Clear the error and EOF indicators for STREAM. */
  514. #define clearerr(_fp) __CLEARERR(_fp)
  515. #define feof(_fp) __FEOF(_fp)
  516. #define ferror(_fp) __FERROR(_fp)
  517. #ifdef __USE_MISC
  518. #define clearerr_unlocked(_fp) __CLEARERR_UNLOCKED(_fp)
  519. #define feof_unlocked(_fp) __FEOF_UNLOCKED(_fp)
  520. #define ferror_unlocked(_fp) __FERROR_UNLOCKED(_fp)
  521. #endif
  522. __END_DECLS
  523. #endif /* <stdio.h> included. */
  524. #endif /* !_STDIO_H */