stdio.h 30 KB

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