stdio.h 31 KB

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