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