stdio.h 29 KB

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