stdio.h 22 KB

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