]>
Commit | Line | Data |
---|---|---|
96aa2d94 RM |
1 | /* This is part of the iostream/stdio library, providing -*- C -*- I/O. |
2 | Define ANSI C stdio on top of C++ iostreams. | |
7a12c6bb | 3 | Copyright (C) 1991, 1994, 1995, 1996 Free Software Foundation, Inc. |
96aa2d94 RM |
4 | |
5 | This library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Library General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2 of the License, or (at your option) any later version. | |
9 | ||
10 | ||
11 | This library is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | Library General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU Library General Public | |
17 | License along with this library; if not, write to the Free Software | |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
19 | */ | |
20 | ||
21 | /* | |
22 | * ANSI Standard: 4.9 INPUT/OUTPUT <stdio.h> | |
23 | */ | |
24 | ||
25 | #ifndef _STDIO_H | |
26 | #define _STDIO_H | |
27 | #define _STDIO_USES_IOSTREAM | |
28 | ||
29 | #include <libio.h> | |
30 | ||
31 | #ifndef NULL | |
32 | #ifdef __cplusplus | |
33 | #define NULL 0 | |
34 | #else | |
35 | #define NULL (void*)0 | |
36 | #endif | |
37 | #endif | |
38 | ||
39 | #ifndef EOF | |
40 | #define EOF (-1) | |
41 | #endif | |
42 | #ifndef BUFSIZ | |
569c558c | 43 | #define BUFSIZ _IO_BUFSIZ |
96aa2d94 RM |
44 | #endif |
45 | ||
46 | #define _IOFBF 0 /* Fully buffered. */ | |
47 | #define _IOLBF 1 /* Line buffered. */ | |
48 | #define _IONBF 2 /* No buffering. */ | |
49 | ||
50 | #define SEEK_SET 0 | |
51 | #define SEEK_CUR 1 | |
52 | #define SEEK_END 2 | |
53 | ||
54 | /* define size_t. Crud in case <sys/types.h> has defined it. */ | |
55 | #if !defined(_SIZE_T) && !defined(_T_SIZE_) && !defined(_T_SIZE) | |
56 | #if !defined(__SIZE_T) && !defined(_SIZE_T_) && !defined(___int_size_t_h) | |
57 | #if !defined(_GCC_SIZE_T) && !defined(_SIZET_) | |
58 | #define _SIZE_T | |
59 | #define _T_SIZE_ | |
60 | #define _T_SIZE | |
61 | #define __SIZE_T | |
62 | #define _SIZE_T_ | |
63 | #define ___int_size_t_h | |
64 | #define _GCC_SIZE_T | |
65 | #define _SIZET_ | |
66 | typedef _IO_size_t size_t; | |
67 | #endif | |
68 | #endif | |
69 | #endif | |
70 | ||
71 | typedef struct _IO_FILE FILE; | |
72 | typedef _IO_fpos_t fpos_t; | |
73 | ||
fa00327f | 74 | #include <stdio_lim.h> |
96aa2d94 | 75 | |
96aa2d94 | 76 | #define P_tmpdir "/tmp" |
96aa2d94 RM |
77 | |
78 | /* For use by debuggers. These are linked in if printf or fprintf are used. */ | |
79 | extern FILE *stdin, *stdout, *stderr; /* TODO */ | |
80 | ||
81 | #define stdin _IO_stdin | |
82 | #define stdout _IO_stdout | |
83 | #define stderr _IO_stderr | |
84 | ||
85 | #ifdef __cplusplus | |
86 | extern "C" { | |
87 | #endif | |
88 | ||
89 | #ifndef __P | |
90 | #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) | |
91 | #define __P(args) args | |
92 | #else | |
93 | #define __P(args) () | |
94 | #endif | |
95 | #endif /*!__P*/ | |
96 | ||
97 | extern void clearerr __P ((FILE*)); | |
98 | extern int fclose __P ((FILE*)); | |
99 | extern int feof __P ((FILE*)); | |
100 | extern int ferror __P ((FILE*)); | |
101 | extern int fflush __P ((FILE*)); | |
102 | extern int fgetc __P ((FILE *)); | |
103 | extern int fgetpos __P ((FILE* fp, fpos_t *pos)); | |
104 | extern char* fgets __P ((char*, int, FILE*)); | |
105 | extern FILE* fopen __P ((__const char*, __const char*)); | |
76060ec0 | 106 | extern FILE* fopencookie __P ((void *cookie, __const char *mode, |
fa0bc87c | 107 | _IO_cookie_io_functions_t io_functions)); |
96aa2d94 RM |
108 | extern int fprintf __P ((FILE*, __const char* format, ...)); |
109 | extern int fputc __P ((int, FILE*)); | |
110 | extern int fputs __P ((__const char *str, FILE *fp)); | |
111 | extern size_t fread __P ((void*, size_t, size_t, FILE*)); | |
112 | extern FILE* freopen __P ((__const char*, __const char*, FILE*)); | |
113 | extern int fscanf __P ((FILE *fp, __const char* format, ...)); | |
114 | extern int fseek __P ((FILE* fp, long int offset, int whence)); | |
115 | extern int fsetpos __P ((FILE* fp, __const fpos_t *pos)); | |
116 | extern long int ftell __P ((FILE* fp)); | |
117 | extern size_t fwrite __P ((__const void*, size_t, size_t, FILE*)); | |
118 | extern int getc __P ((FILE *)); | |
119 | extern int getchar __P ((void)); | |
120 | extern char* gets __P ((char*)); | |
121 | extern void perror __P ((__const char *)); | |
122 | extern int printf __P ((__const char* format, ...)); | |
123 | extern int putc __P ((int, FILE *)); | |
124 | extern int putchar __P ((int)); | |
125 | extern int puts __P ((__const char *str)); | |
126 | extern int remove __P ((__const char*)); | |
127 | extern int rename __P ((__const char* _old, __const char* _new)); | |
128 | extern void rewind __P ((FILE*)); | |
129 | extern int scanf __P ((__const char* format, ...)); | |
130 | extern void setbuf __P ((FILE*, char*)); | |
131 | extern void setlinebuf __P ((FILE*)); | |
132 | extern void setbuffer __P ((FILE*, char*, int)); | |
133 | extern int setvbuf __P ((FILE*, char*, int mode, size_t size)); | |
134 | extern int sprintf __P ((char*, __const char* format, ...)); | |
135 | extern int sscanf __P ((__const char* string, __const char* format, ...)); | |
136 | extern FILE* tmpfile __P ((void)); | |
137 | extern char* tmpnam __P ((char*)); | |
d68171ed UD |
138 | #ifdef __USE_REENTRANT |
139 | extern char* tmpnam_r __P ((char*)); | |
140 | #endif | |
2cc7dc4d RM |
141 | #ifdef __USE_SVID |
142 | extern char *tempnam __P ((__const char *__dir, __const char *__pfx)); | |
143 | #endif | |
d68171ed UD |
144 | extern char *__stdio_gen_tempname __P ((char *__buf, size_t bufsize, |
145 | __const char *dir, __const char *pfx, | |
fa0bc87c RM |
146 | int dir_search, size_t *lenptr, |
147 | FILE **streamptr)); | |
96aa2d94 RM |
148 | extern int ungetc __P ((int c, FILE* fp)); |
149 | extern int vfprintf __P ((FILE *fp, char __const *fmt0, _G_va_list)); | |
150 | extern int vprintf __P ((char __const *fmt, _G_va_list)); | |
151 | extern int vsprintf __P ((char* string, __const char* format, _G_va_list)); | |
a1470b6f RM |
152 | extern void __libc_fatal __P ((__const char *__message)) |
153 | __attribute__ ((__noreturn__)); | |
96aa2d94 RM |
154 | |
155 | #ifndef __STRICT_ANSI__ | |
156 | extern int dprintf __P ((int, __const char *, ...)); | |
157 | extern int vdprintf __P ((int, __const char *, _G_va_list)); | |
158 | extern int vfscanf __P ((FILE*, __const char *, _G_va_list)); | |
fa0bc87c | 159 | extern int __vfscanf __P ((FILE*, __const char *, _G_va_list)); |
96aa2d94 RM |
160 | extern int vscanf __P ((__const char *, _G_va_list)); |
161 | extern int vsscanf __P ((__const char *, __const char *, _G_va_list)); | |
fa0bc87c | 162 | extern int __vsscanf __P ((__const char *, __const char *, _G_va_list)); |
96aa2d94 RM |
163 | #endif |
164 | ||
165 | #if !defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE) | |
166 | extern FILE *fdopen __P ((int, __const char *)); | |
167 | extern int fileno __P ((FILE*)); | |
168 | extern FILE* popen __P ((__const char*, __const char*)); | |
169 | extern int pclose __P ((FILE*)); | |
76060ec0 RM |
170 | |
171 | #define L_ctermid 9 | |
172 | #define L_cuserid 9 | |
173 | ||
174 | /* Return the name of the controlling terminal. */ | |
175 | extern char *ctermid __P ((char *__buf)); | |
176 | ||
177 | /* Get character login name of the user. */ | |
178 | extern char *cuserid __P ((char * __buf)); | |
96aa2d94 RM |
179 | #endif |
180 | ||
181 | #ifdef __USE_GNU | |
182 | extern _IO_ssize_t getdelim __P ((char **, size_t *, int, FILE*)); | |
183 | extern _IO_ssize_t getline __P ((char **, size_t *, FILE *)); | |
7c713e28 | 184 | extern _IO_ssize_t __getline __P ((char **, size_t *, FILE *)); |
96aa2d94 RM |
185 | |
186 | extern int snprintf __P ((char *, size_t, __const char *, ...)); | |
187 | extern int __snprintf __P ((char *, size_t, __const char *, ...)); | |
188 | extern int vsnprintf __P ((char *, size_t, __const char *, _G_va_list)); | |
fa0bc87c | 189 | extern int __vsnprintf __P ((char *, size_t, __const char *, _G_va_list)); |
96aa2d94 | 190 | |
7a12c6bb RM |
191 | extern int asprintf __P ((char **, const char *, ...)); |
192 | extern int vasprintf __P ((char **, const char *, _G_va_list)); | |
193 | ||
96aa2d94 RM |
194 | /* Open a stream that writes into a malloc'd buffer that is expanded as |
195 | necessary. *BUFLOC and *SIZELOC are updated with the buffer's location | |
196 | and the number of characters written on fflush or fclose. */ | |
197 | extern FILE *open_memstream __P ((char **__bufloc, size_t *__sizeloc)); | |
198 | #endif | |
199 | ||
200 | extern int __underflow __P ((struct _IO_FILE*)); | |
201 | extern int __overflow __P ((struct _IO_FILE*, int)); | |
202 | ||
96aa2d94 RM |
203 | #ifdef __USE_BSD |
204 | extern int sys_nerr; | |
205 | extern const char *const sys_errlist[]; | |
206 | #endif | |
207 | #ifdef __USE_GNU | |
208 | extern int _sys_nerr; | |
209 | extern const char *const _sys_errlist[]; | |
210 | #endif | |
211 | ||
7c713e28 | 212 | /* Handle locking of streams. */ |
edf5b2d7 UD |
213 | #ifdef __USE_REENTRANT |
214 | extern void clearerr_locked __P ((FILE *)); | |
7c713e28 | 215 | extern void clearerr_unlocked __P ((FILE *)); |
edf5b2d7 UD |
216 | extern int feof_locked __P ((FILE *)); |
217 | extern int feof_unlocked __P ((FILE *)); | |
218 | extern int ferror_locked __P ((FILE*)); | |
219 | extern int ferror_unlocked __P ((FILE*)); | |
220 | extern int fileno_locked __P ((FILE *)); | |
221 | extern int fileno_unlocked __P ((FILE *)); | |
7c713e28 RM |
222 | extern void flockfile __P ((FILE *)); |
223 | extern void funlockfile __P ((FILE *)); | |
d41c6f61 | 224 | extern int ftrylockfile __P ((FILE *)); |
7c713e28 | 225 | extern int fclose_unlocked __P ((FILE *)); |
edf5b2d7 | 226 | extern int fflush_locked __P ((FILE *)); |
7c713e28 RM |
227 | extern int fflush_unlocked __P ((FILE *)); |
228 | extern size_t fread_unlocked __P ((void *, size_t, size_t, FILE *)); | |
229 | extern size_t fwrite_unlocked __P ((const void *, size_t, size_t, FILE *)); | |
230 | ||
edf5b2d7 UD |
231 | extern int fputc_locked __P ((int, FILE*)); |
232 | extern int fputc_unlocked __P ((int, FILE*)); | |
233 | extern int getc_locked __P ((FILE *)); | |
234 | extern int getc_unlocked __P ((FILE *)); | |
235 | extern int getchar_locked __P ((void)); | |
236 | extern int getchar_unlocked __P ((void)); | |
237 | extern int putc_locked __P ((int, FILE *)); | |
238 | extern int putc_unlocked __P ((int, FILE *)); | |
239 | extern int putchar_locked __P ((int)); | |
240 | extern int putchar_unlocked __P ((int)); | |
241 | ||
569c558c UD |
242 | # ifndef _LIBC |
243 | # define getc_unlocked(fp) _IO_getc_unlocked (fp) | |
d41c6f61 | 244 | # define getc_locked(fp) _IO_getc (fp) |
f0f1bf85 | 245 | # define getchar_unlocked() _IO_getc_unlocked (stdin) |
d41c6f61 | 246 | # define getchar_locked() _IO_getc (stdin) |
f0f1bf85 | 247 | # define putchar_unlocked(c) _IO_putc_unlocked (c, stdout) |
d41c6f61 | 248 | # define putchar_locked(c) _IO_putc (c, stdout) |
569c558c | 249 | # endif |
7c713e28 | 250 | |
edf5b2d7 | 251 | #endif /* __USE_REENTRANT */ |
7c713e28 | 252 | |
d41c6f61 UD |
253 | #define getc(_fp) _IO_getc (_fp) |
254 | #define putc(_ch, _fp) _IO_putc (_ch, _fp) | |
255 | #define putchar(_ch) _IO_putc (_ch, stdout) | |
256 | #define getchar() _IO_getc (stdin) | |
7c713e28 RM |
257 | |
258 | ||
96aa2d94 RM |
259 | #ifdef __cplusplus |
260 | } | |
261 | #endif | |
262 | ||
7c713e28 RM |
263 | |
264 | ||
96aa2d94 | 265 | #endif /* !_STDIO_H */ |