stdio.h 31 KB

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