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