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