stdio.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949
  1. /* Define ISO C stdio on top of C++ iostreams.
  2. Copyright (C) 1991-2017 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. # define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
  22. # include <bits/libc-header-start.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_POSIX \
  39. || 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. #if defined __USE_UNIX98 || defined __USE_XOPEN2K
  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. #endif
  79. #ifdef __USE_XOPEN2K8
  80. # ifndef __ssize_t_defined
  81. typedef __ssize_t ssize_t;
  82. # define __ssize_t_defined
  83. # endif
  84. #endif
  85. /* The type of the second argument to `fgetpos' and `fsetpos'. */
  86. __BEGIN_NAMESPACE_STD
  87. #ifndef __USE_FILE_OFFSET64
  88. typedef _G_fpos_t fpos_t;
  89. #else
  90. typedef _G_fpos64_t fpos_t;
  91. #endif
  92. __END_NAMESPACE_STD
  93. #ifdef __USE_LARGEFILE64
  94. typedef _G_fpos64_t fpos64_t;
  95. #endif
  96. /* The possibilities for the third argument to `setvbuf'. */
  97. #define _IOFBF 0 /* Fully buffered. */
  98. #define _IOLBF 1 /* Line buffered. */
  99. #define _IONBF 2 /* No buffering. */
  100. /* Default buffer size. */
  101. #ifndef BUFSIZ
  102. # define BUFSIZ _IO_BUFSIZ
  103. #endif
  104. /* End of file character.
  105. Some things throughout the library rely on this being -1. */
  106. #ifndef EOF
  107. # define EOF (-1)
  108. #endif
  109. /* The possibilities for the third argument to `fseek'.
  110. These values should not be changed. */
  111. #define SEEK_SET 0 /* Seek from beginning of file. */
  112. #define SEEK_CUR 1 /* Seek from current position. */
  113. #define SEEK_END 2 /* Seek from end of file. */
  114. #ifdef __USE_GNU
  115. # define SEEK_DATA 3 /* Seek to next data. */
  116. # define SEEK_HOLE 4 /* Seek to next hole. */
  117. #endif
  118. #if defined __USE_MISC || defined __USE_XOPEN
  119. /* Default path prefix for `tempnam' and `tmpnam'. */
  120. # define P_tmpdir "/tmp"
  121. #endif
  122. /* Get the values:
  123. L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
  124. TMP_MAX The minimum number of unique filenames generated by tmpnam
  125. (and tempnam when it uses tmpnam's name space),
  126. or tempnam (the two are separate).
  127. L_ctermid How long an array to pass to `ctermid'.
  128. L_cuserid How long an array to pass to `cuserid'.
  129. FOPEN_MAX Minimum number of files that can be open at once.
  130. FILENAME_MAX Maximum length of a filename. */
  131. #include <bits/stdio_lim.h>
  132. /* Standard streams. */
  133. extern struct _IO_FILE *stdin; /* Standard input stream. */
  134. extern struct _IO_FILE *stdout; /* Standard output stream. */
  135. extern struct _IO_FILE *stderr; /* Standard error output stream. */
  136. /* C89/C99 say they're macros. Make them happy. */
  137. #define stdin stdin
  138. #define stdout stdout
  139. #define stderr stderr
  140. __BEGIN_NAMESPACE_STD
  141. /* Remove file FILENAME. */
  142. extern int remove (const char *__filename) __THROW;
  143. /* Rename file OLD to NEW. */
  144. extern int rename (const char *__old, const char *__new) __THROW;
  145. __END_NAMESPACE_STD
  146. #ifdef __USE_ATFILE
  147. /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
  148. extern int renameat (int __oldfd, const char *__old, int __newfd,
  149. const char *__new) __THROW;
  150. #endif
  151. __BEGIN_NAMESPACE_STD
  152. /* Create a temporary file and open it read/write.
  153. This function is a possible cancellation point and therefore not
  154. marked with __THROW. */
  155. #ifndef __USE_FILE_OFFSET64
  156. extern FILE *tmpfile (void) __wur;
  157. #else
  158. # ifdef __REDIRECT
  159. extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;
  160. # else
  161. # define tmpfile tmpfile64
  162. # endif
  163. #endif
  164. #ifdef __USE_LARGEFILE64
  165. extern FILE *tmpfile64 (void) __wur;
  166. #endif
  167. /* Generate a temporary filename. */
  168. extern char *tmpnam (char *__s) __THROW __wur;
  169. __END_NAMESPACE_STD
  170. #ifdef __USE_MISC
  171. /* This is the reentrant variant of `tmpnam'. The only difference is
  172. that it does not allow S to be NULL. */
  173. extern char *tmpnam_r (char *__s) __THROW __wur;
  174. #endif
  175. #if defined __USE_MISC || defined __USE_XOPEN
  176. /* Generate a unique temporary filename using up to five characters of PFX
  177. if it is not NULL. The directory to put this file in is searched for
  178. as follows: First the environment variable "TMPDIR" is checked.
  179. If it contains the name of a writable directory, that directory is used.
  180. If not and if DIR is not NULL, that value is checked. If that fails,
  181. P_tmpdir is tried and finally "/tmp". The storage for the filename
  182. is allocated by `malloc'. */
  183. extern char *tempnam (const char *__dir, const char *__pfx)
  184. __THROW __attribute_malloc__ __wur;
  185. #endif
  186. __BEGIN_NAMESPACE_STD
  187. /* Close STREAM.
  188. This function is a possible cancellation point and therefore not
  189. marked with __THROW. */
  190. extern int fclose (FILE *__stream);
  191. /* Flush STREAM, or all streams if STREAM is NULL.
  192. This function is a possible cancellation point and therefore not
  193. marked with __THROW. */
  194. extern int fflush (FILE *__stream);
  195. __END_NAMESPACE_STD
  196. #ifdef __USE_MISC
  197. /* Faster versions when locking is not required.
  198. This function is not part of POSIX and therefore no official
  199. cancellation point. But due to similarity with an POSIX interface
  200. or due to the implementation it is a cancellation point and
  201. therefore not marked with __THROW. */
  202. extern int fflush_unlocked (FILE *__stream);
  203. #endif
  204. #ifdef __USE_GNU
  205. /* Close all streams.
  206. This function is not part of POSIX and therefore no official
  207. cancellation point. But due to similarity with an POSIX interface
  208. or due to the implementation it is a cancellation point and
  209. therefore not marked with __THROW. */
  210. extern int fcloseall (void);
  211. #endif
  212. __BEGIN_NAMESPACE_STD
  213. #ifndef __USE_FILE_OFFSET64
  214. /* Open a file and create a new stream for it.
  215. This function is a possible cancellation point and therefore not
  216. marked with __THROW. */
  217. extern FILE *fopen (const char *__restrict __filename,
  218. const char *__restrict __modes) __wur;
  219. /* Open a file, replacing an existing stream with it.
  220. This function is a possible cancellation point and therefore not
  221. marked with __THROW. */
  222. extern FILE *freopen (const char *__restrict __filename,
  223. const char *__restrict __modes,
  224. FILE *__restrict __stream) __wur;
  225. #else
  226. # ifdef __REDIRECT
  227. extern FILE *__REDIRECT (fopen, (const char *__restrict __filename,
  228. const char *__restrict __modes), fopen64)
  229. __wur;
  230. extern FILE *__REDIRECT (freopen, (const char *__restrict __filename,
  231. const char *__restrict __modes,
  232. FILE *__restrict __stream), freopen64)
  233. __wur;
  234. # else
  235. # define fopen fopen64
  236. # define freopen freopen64
  237. # endif
  238. #endif
  239. __END_NAMESPACE_STD
  240. #ifdef __USE_LARGEFILE64
  241. extern FILE *fopen64 (const char *__restrict __filename,
  242. const char *__restrict __modes) __wur;
  243. extern FILE *freopen64 (const char *__restrict __filename,
  244. const char *__restrict __modes,
  245. FILE *__restrict __stream) __wur;
  246. #endif
  247. #ifdef __USE_POSIX
  248. /* Create a new stream that refers to an existing system file descriptor. */
  249. extern FILE *fdopen (int __fd, const char *__modes) __THROW __wur;
  250. #endif
  251. #ifdef __USE_GNU
  252. /* Create a new stream that refers to the given magic cookie,
  253. and uses the given functions for input and output. */
  254. extern FILE *fopencookie (void *__restrict __magic_cookie,
  255. const char *__restrict __modes,
  256. _IO_cookie_io_functions_t __io_funcs) __THROW __wur;
  257. #endif
  258. #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
  259. /* Create a new stream that refers to a memory buffer. */
  260. extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
  261. __THROW __wur;
  262. /* Open a stream that writes into a malloc'd buffer that is expanded as
  263. necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
  264. and the number of characters written on fflush or fclose. */
  265. extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;
  266. #endif
  267. __BEGIN_NAMESPACE_STD
  268. /* If BUF is NULL, make STREAM unbuffered.
  269. Else make it use buffer BUF, of size BUFSIZ. */
  270. extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
  271. /* Make STREAM use buffering mode MODE.
  272. If BUF is not NULL, use N bytes of it for buffering;
  273. else allocate an internal buffer N bytes long. */
  274. extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
  275. int __modes, size_t __n) __THROW;
  276. __END_NAMESPACE_STD
  277. #ifdef __USE_MISC
  278. /* If BUF is NULL, make STREAM unbuffered.
  279. Else make it use SIZE bytes of BUF for buffering. */
  280. extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
  281. size_t __size) __THROW;
  282. /* Make STREAM line-buffered. */
  283. extern void setlinebuf (FILE *__stream) __THROW;
  284. #endif
  285. __BEGIN_NAMESPACE_STD
  286. /* Write formatted output to STREAM.
  287. This function is a possible cancellation point and therefore not
  288. marked with __THROW. */
  289. extern int fprintf (FILE *__restrict __stream,
  290. const char *__restrict __format, ...);
  291. /* Write formatted output to stdout.
  292. This function is a possible cancellation point and therefore not
  293. marked with __THROW. */
  294. extern int printf (const char *__restrict __format, ...);
  295. /* Write formatted output to S. */
  296. extern int sprintf (char *__restrict __s,
  297. const char *__restrict __format, ...) __THROWNL;
  298. /* Write formatted output to S from argument list ARG.
  299. This function is a possible cancellation point and therefore not
  300. marked with __THROW. */
  301. extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
  302. _G_va_list __arg);
  303. /* Write formatted output to stdout from argument list ARG.
  304. This function is a possible cancellation point and therefore not
  305. marked with __THROW. */
  306. extern int vprintf (const char *__restrict __format, _G_va_list __arg);
  307. /* Write formatted output to S from argument list ARG. */
  308. extern int vsprintf (char *__restrict __s, const char *__restrict __format,
  309. _G_va_list __arg) __THROWNL;
  310. __END_NAMESPACE_STD
  311. #if defined __USE_ISOC99 || defined __USE_UNIX98
  312. __BEGIN_NAMESPACE_C99
  313. /* Maximum chars of output to write in MAXLEN. */
  314. extern int snprintf (char *__restrict __s, size_t __maxlen,
  315. const char *__restrict __format, ...)
  316. __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));
  317. extern int vsnprintf (char *__restrict __s, size_t __maxlen,
  318. const char *__restrict __format, _G_va_list __arg)
  319. __THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));
  320. __END_NAMESPACE_C99
  321. #endif
  322. #if __GLIBC_USE (LIB_EXT2)
  323. /* Write formatted output to a string dynamically allocated with `malloc'.
  324. Store the address of the string in *PTR. */
  325. extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,
  326. _G_va_list __arg)
  327. __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
  328. extern int __asprintf (char **__restrict __ptr,
  329. const char *__restrict __fmt, ...)
  330. __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
  331. extern int asprintf (char **__restrict __ptr,
  332. const char *__restrict __fmt, ...)
  333. __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
  334. #endif
  335. #ifdef __USE_XOPEN2K8
  336. /* Write formatted output to a file descriptor. */
  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_NTH (sscanf, (const char *__restrict __s,
  369. const char *__restrict __format, ...),
  370. __isoc99_sscanf);
  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_NTH (vsscanf,
  416. (const char *__restrict __s,
  417. const char *__restrict __format,
  418. _G_va_list __arg), __isoc99_vsscanf)
  419. __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. #ifdef __USE_POSIX199506
  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. */
  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. #ifdef __USE_POSIX199506
  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. */
  496. #if 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. #if !defined __USE_ISOC11 \
  510. || (defined __cplusplus && __cplusplus <= 201103L)
  511. /* Get a newline-terminated string from stdin, removing the newline.
  512. DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
  513. The function has been officially removed in ISO C11. This opportunity
  514. is used to also remove it from the GNU feature list. It is now only
  515. available when explicitly using an old ISO C, Unix, or POSIX standard.
  516. GCC defines _GNU_SOURCE when building C++ code and the function is still
  517. in C++11, so it is also available for C++.
  518. This function is a possible cancellation point and therefore not
  519. marked with __THROW. */
  520. extern char *gets (char *__s) __wur __attribute_deprecated__;
  521. #endif
  522. __END_NAMESPACE_STD
  523. #ifdef __USE_GNU
  524. /* This function does the same as `fgets' but does not lock the stream.
  525. This function is not part of POSIX and therefore no official
  526. cancellation point. But due to similarity with an POSIX interface
  527. or due to the implementation it is a cancellation point and
  528. therefore not marked with __THROW. */
  529. extern char *fgets_unlocked (char *__restrict __s, int __n,
  530. FILE *__restrict __stream) __wur;
  531. #endif
  532. #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
  533. /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
  534. (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
  535. NULL), pointing to *N characters of space. It is realloc'd as
  536. necessary. Returns the number of characters read (not including the
  537. null terminator), or -1 on error or EOF.
  538. These functions are not part of POSIX and therefore no official
  539. cancellation point. But due to similarity with an POSIX interface
  540. or due to the implementation they are cancellation points and
  541. therefore not marked with __THROW. */
  542. extern _IO_ssize_t __getdelim (char **__restrict __lineptr,
  543. size_t *__restrict __n, int __delimiter,
  544. FILE *__restrict __stream) __wur;
  545. extern _IO_ssize_t getdelim (char **__restrict __lineptr,
  546. size_t *__restrict __n, int __delimiter,
  547. FILE *__restrict __stream) __wur;
  548. /* Like `getdelim', but reads up to a newline.
  549. This function is not part of POSIX and therefore no official
  550. cancellation point. But due to similarity with an POSIX interface
  551. or due to the implementation it is a cancellation point and
  552. therefore not marked with __THROW. */
  553. extern _IO_ssize_t getline (char **__restrict __lineptr,
  554. size_t *__restrict __n,
  555. FILE *__restrict __stream) __wur;
  556. #endif
  557. __BEGIN_NAMESPACE_STD
  558. /* Write a string to STREAM.
  559. This function is a possible cancellation point and therefore not
  560. marked with __THROW. */
  561. extern int fputs (const char *__restrict __s, FILE *__restrict __stream);
  562. /* Write a string, followed by a newline, to stdout.
  563. This function is a possible cancellation point and therefore not
  564. marked with __THROW. */
  565. extern int puts (const char *__s);
  566. /* Push a character back onto the input buffer of STREAM.
  567. This function is a possible cancellation point and therefore not
  568. marked with __THROW. */
  569. extern int ungetc (int __c, FILE *__stream);
  570. /* Read chunks of generic data from STREAM.
  571. This function is a possible cancellation point and therefore not
  572. marked with __THROW. */
  573. extern size_t fread (void *__restrict __ptr, size_t __size,
  574. size_t __n, FILE *__restrict __stream) __wur;
  575. /* Write chunks of generic data to STREAM.
  576. This function is a possible cancellation point and therefore not
  577. marked with __THROW. */
  578. extern size_t fwrite (const void *__restrict __ptr, size_t __size,
  579. size_t __n, FILE *__restrict __s);
  580. __END_NAMESPACE_STD
  581. #ifdef __USE_GNU
  582. /* This function does the same as `fputs' but does not lock the stream.
  583. This function is not part of POSIX and therefore no official
  584. cancellation point. But due to similarity with an POSIX interface
  585. or due to the implementation it is a cancellation point and
  586. therefore not marked with __THROW. */
  587. extern int fputs_unlocked (const char *__restrict __s,
  588. FILE *__restrict __stream);
  589. #endif
  590. #ifdef __USE_MISC
  591. /* Faster versions when locking is not necessary.
  592. These functions are not part of POSIX and therefore no official
  593. cancellation point. But due to similarity with an POSIX interface
  594. or due to the implementation they are cancellation points and
  595. therefore not marked with __THROW. */
  596. extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
  597. size_t __n, FILE *__restrict __stream) __wur;
  598. extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
  599. size_t __n, FILE *__restrict __stream);
  600. #endif
  601. __BEGIN_NAMESPACE_STD
  602. /* Seek to a certain position on STREAM.
  603. This function is a possible cancellation point and therefore not
  604. marked with __THROW. */
  605. extern int fseek (FILE *__stream, long int __off, int __whence);
  606. /* Return the current position of STREAM.
  607. This function is a possible cancellation point and therefore not
  608. marked with __THROW. */
  609. extern long int ftell (FILE *__stream) __wur;
  610. /* Rewind to the beginning of STREAM.
  611. This function is a possible cancellation point and therefore not
  612. marked with __THROW. */
  613. extern void rewind (FILE *__stream);
  614. __END_NAMESPACE_STD
  615. /* The Single Unix Specification, Version 2, specifies an alternative,
  616. more adequate interface for the two functions above which deal with
  617. file offset. `long int' is not the right type. These definitions
  618. are originally defined in the Large File Support API. */
  619. #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
  620. # ifndef __USE_FILE_OFFSET64
  621. /* Seek to a certain position on STREAM.
  622. This function is a possible cancellation point and therefore not
  623. marked with __THROW. */
  624. extern int fseeko (FILE *__stream, __off_t __off, int __whence);
  625. /* Return the current position of STREAM.
  626. This function is a possible cancellation point and therefore not
  627. marked with __THROW. */
  628. extern __off_t ftello (FILE *__stream) __wur;
  629. # else
  630. # ifdef __REDIRECT
  631. extern int __REDIRECT (fseeko,
  632. (FILE *__stream, __off64_t __off, int __whence),
  633. fseeko64);
  634. extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
  635. # else
  636. # define fseeko fseeko64
  637. # define ftello ftello64
  638. # endif
  639. # endif
  640. #endif
  641. __BEGIN_NAMESPACE_STD
  642. #ifndef __USE_FILE_OFFSET64
  643. /* Get STREAM's position.
  644. This function is a possible cancellation point and therefore not
  645. marked with __THROW. */
  646. extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
  647. /* Set STREAM's position.
  648. This function is a possible cancellation point and therefore not
  649. marked with __THROW. */
  650. extern int fsetpos (FILE *__stream, const fpos_t *__pos);
  651. #else
  652. # ifdef __REDIRECT
  653. extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
  654. fpos_t *__restrict __pos), fgetpos64);
  655. extern int __REDIRECT (fsetpos,
  656. (FILE *__stream, const fpos_t *__pos), fsetpos64);
  657. # else
  658. # define fgetpos fgetpos64
  659. # define fsetpos fsetpos64
  660. # endif
  661. #endif
  662. __END_NAMESPACE_STD
  663. #ifdef __USE_LARGEFILE64
  664. extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
  665. extern __off64_t ftello64 (FILE *__stream) __wur;
  666. extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
  667. extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos);
  668. #endif
  669. __BEGIN_NAMESPACE_STD
  670. /* Clear the error and EOF indicators for STREAM. */
  671. extern void clearerr (FILE *__stream) __THROW;
  672. /* Return the EOF indicator for STREAM. */
  673. extern int feof (FILE *__stream) __THROW __wur;
  674. /* Return the error indicator for STREAM. */
  675. extern int ferror (FILE *__stream) __THROW __wur;
  676. __END_NAMESPACE_STD
  677. #ifdef __USE_MISC
  678. /* Faster versions when locking is not required. */
  679. extern void clearerr_unlocked (FILE *__stream) __THROW;
  680. extern int feof_unlocked (FILE *__stream) __THROW __wur;
  681. extern int ferror_unlocked (FILE *__stream) __THROW __wur;
  682. #endif
  683. __BEGIN_NAMESPACE_STD
  684. /* Print a message describing the meaning of the value of errno.
  685. This function is a possible cancellation point and therefore not
  686. marked with __THROW. */
  687. extern void perror (const char *__s);
  688. __END_NAMESPACE_STD
  689. /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
  690. are available on this system. Even if available, these variables
  691. should not be used directly. The `strerror' function provides
  692. all the necessary functionality. */
  693. #include <bits/sys_errlist.h>
  694. #ifdef __USE_POSIX
  695. /* Return the system file descriptor for STREAM. */
  696. extern int fileno (FILE *__stream) __THROW __wur;
  697. #endif /* Use POSIX. */
  698. #ifdef __USE_MISC
  699. /* Faster version when locking is not required. */
  700. extern int fileno_unlocked (FILE *__stream) __THROW __wur;
  701. #endif
  702. #ifdef __USE_POSIX2
  703. /* Create a new stream connected to a pipe running the given command.
  704. This function is a possible cancellation point and therefore not
  705. marked with __THROW. */
  706. extern FILE *popen (const char *__command, const char *__modes) __wur;
  707. /* Close a stream opened by popen and return the status of its child.
  708. This function is a possible cancellation point and therefore not
  709. marked with __THROW. */
  710. extern int pclose (FILE *__stream);
  711. #endif
  712. #ifdef __USE_POSIX
  713. /* Return the name of the controlling terminal. */
  714. extern char *ctermid (char *__s) __THROW;
  715. #endif /* Use POSIX. */
  716. #if (defined __USE_XOPEN && !defined __USE_XOPEN2K) || defined __USE_GNU
  717. /* Return the name of the current user. */
  718. extern char *cuserid (char *__s);
  719. #endif /* Use X/Open, but not issue 6. */
  720. #ifdef __USE_GNU
  721. struct obstack; /* See <obstack.h>. */
  722. /* Write formatted output to an obstack. */
  723. extern int obstack_printf (struct obstack *__restrict __obstack,
  724. const char *__restrict __format, ...)
  725. __THROWNL __attribute__ ((__format__ (__printf__, 2, 3)));
  726. extern int obstack_vprintf (struct obstack *__restrict __obstack,
  727. const char *__restrict __format,
  728. _G_va_list __args)
  729. __THROWNL __attribute__ ((__format__ (__printf__, 2, 0)));
  730. #endif /* Use GNU. */
  731. #ifdef __USE_POSIX199506
  732. /* These are defined in POSIX.1:1996. */
  733. /* Acquire ownership of STREAM. */
  734. extern void flockfile (FILE *__stream) __THROW;
  735. /* Try to acquire ownership of STREAM but do not block if it is not
  736. possible. */
  737. extern int ftrylockfile (FILE *__stream) __THROW __wur;
  738. /* Relinquish the ownership granted for STREAM. */
  739. extern void funlockfile (FILE *__stream) __THROW;
  740. #endif /* POSIX */
  741. #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
  742. /* The X/Open standard requires some functions and variables to be
  743. declared here which do not belong into this header. But we have to
  744. follow. In GNU mode we don't do this nonsense. */
  745. # define __need_getopt
  746. # include <getopt.h>
  747. #endif /* X/Open, but not issue 6 and not for GNU. */
  748. /* If we are compiling with optimizing read this file. It contains
  749. several optimizing inline functions and macros. */
  750. #ifdef __USE_EXTERN_INLINES
  751. # include <bits/stdio.h>
  752. #endif
  753. #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
  754. # include <bits/stdio2.h>
  755. #endif
  756. #ifdef __LDBL_COMPAT
  757. # include <bits/stdio-ldbl.h>
  758. #endif
  759. __END_DECLS
  760. #endif /* <stdio.h> included. */
  761. #endif /* !_STDIO_H */