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