stdio.h 31 KB

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