stdio.h 31 KB

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