stdio.h 31 KB

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