1 /* This is part of the iostream/stdio library, providing -*- C -*- I/O.
2 Define ANSI C stdio on top of C++ iostreams.
3 Copyright (C) 1991, 1994, 1995, 1996 Free Software Foundation, Inc.
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.
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.
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.
22 * ISO C Standard: 4.9 INPUT/OUTPUT <stdio.h>
27 #define _STDIO_USES_IOSTREAM
43 #define BUFSIZ _IO_BUFSIZ
46 #define _IOFBF 0 /* Fully buffered. */
47 #define _IOLBF 1 /* Line buffered. */
48 #define _IONBF 2 /* No buffering. */
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_)
63 #define ___int_size_t_h
66 typedef _IO_size_t
size_t;
71 typedef struct _IO_FILE
FILE;
72 typedef _IO_fpos_t
fpos_t;
74 #include <stdio_lim.h>
76 #define P_tmpdir "/tmp"
78 /* For use by debuggers. These are linked in if printf or fprintf are used. */
79 extern FILE *stdin
, *stdout
, *stderr
; /* TODO */
81 #define stdin _IO_stdin
82 #define stdout _IO_stdout
83 #define stderr _IO_stderr
90 #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
91 #define __P(args) args
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*));
106 extern FILE* fopencookie
__P ((void *cookie
, __const
char *mode
,
107 _IO_cookie_io_functions_t io_functions
));
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*));
138 #ifdef __USE_REENTRANT
139 extern char* tmpnam_r
__P ((char*));
141 #if defined(__USE_SVID) || defined(__USE_XOPEN)
142 extern char *tempnam
__P ((__const
char *__dir
, __const
char *__pfx
));
144 extern char *__stdio_gen_tempname
__P ((char *__buf
, size_t bufsize
,
145 __const
char *dir
, __const
char *pfx
,
146 int dir_search
, size_t *lenptr
,
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
));
152 extern void __libc_fatal
__P ((__const
char *__message
))
153 __attribute__ ((__noreturn__
));
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
));
159 extern int __vfscanf
__P ((FILE*, __const
char *, _G_va_list
));
160 extern int vscanf
__P ((__const
char *, _G_va_list
));
161 extern int vsscanf
__P ((__const
char *, __const
char *, _G_va_list
));
162 extern int __vsscanf
__P ((__const
char *, __const
char *, _G_va_list
));
167 extern int obstack_vprintf
__P ((struct obstack
*__obstack
,
168 __const
char *__fmt
, _G_va_list
));
169 extern int obstack_printf
__P ((struct obstack
*__obstack
, __const
char *__fmt
,
173 #if !defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE)
174 extern FILE *fdopen
__P ((int, __const
char *));
175 extern int fileno
__P ((FILE*));
176 extern FILE* popen
__P ((__const
char*, __const
char*));
177 extern int pclose
__P ((FILE*));
182 /* Return the name of the controlling terminal. */
183 extern char *ctermid
__P ((char *__buf
));
185 /* Get character login name of the user. */
186 extern char *cuserid
__P ((char * __buf
));
190 extern _IO_ssize_t getdelim
__P ((char **, size_t *, int, FILE*));
191 extern _IO_ssize_t getline
__P ((char **, size_t *, FILE *));
192 extern _IO_ssize_t __getline
__P ((char **, size_t *, FILE *));
194 extern int snprintf
__P ((char *, size_t, __const
char *, ...));
195 extern int __snprintf
__P ((char *, size_t, __const
char *, ...));
196 extern int vsnprintf
__P ((char *, size_t, __const
char *, _G_va_list
));
197 extern int __vsnprintf
__P ((char *, size_t, __const
char *, _G_va_list
));
199 extern int asprintf
__P ((char **, const char *, ...));
200 extern int vasprintf
__P ((char **, const char *, _G_va_list
));
202 /* Open a stream that writes into a malloc'd buffer that is expanded as
203 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
204 and the number of characters written on fflush or fclose. */
205 extern FILE *open_memstream
__P ((char **__bufloc
, size_t *__sizeloc
));
208 extern int __underflow
__P ((struct _IO_FILE
*));
209 extern int __overflow
__P ((struct _IO_FILE
*, int));
213 extern const char *const sys_errlist
[];
216 extern int _sys_nerr
;
217 extern const char *const _sys_errlist
[];
220 /* Handle locking of streams. */
221 #ifdef __USE_REENTRANT
222 extern void clearerr_locked
__P ((FILE *));
223 extern void clearerr_unlocked
__P ((FILE *));
224 extern int feof_locked
__P ((FILE *));
225 extern int feof_unlocked
__P ((FILE *));
226 extern int ferror_locked
__P ((FILE*));
227 extern int ferror_unlocked
__P ((FILE*));
228 extern int fileno_locked
__P ((FILE *));
229 extern int fileno_unlocked
__P ((FILE *));
230 extern void flockfile
__P ((FILE *));
231 extern void funlockfile
__P ((FILE *));
232 extern int ftrylockfile
__P ((FILE *));
233 extern int fclose_unlocked
__P ((FILE *));
234 extern int fflush_locked
__P ((FILE *));
235 extern int fflush_unlocked
__P ((FILE *));
236 extern size_t fread_unlocked
__P ((void *, size_t, size_t, FILE *));
237 extern size_t fwrite_unlocked
__P ((const void *, size_t, size_t, FILE *));
239 extern int fputc_locked
__P ((int, FILE*));
240 extern int fputc_unlocked
__P ((int, FILE*));
241 extern int getc_locked
__P ((FILE *));
242 extern int getc_unlocked
__P ((FILE *));
243 extern int getchar_locked
__P ((void));
244 extern int getchar_unlocked
__P ((void));
245 extern int putc_locked
__P ((int, FILE *));
246 extern int putc_unlocked
__P ((int, FILE *));
247 extern int putchar_locked
__P ((int));
248 extern int putchar_unlocked
__P ((int));
251 # define getc_unlocked(fp) _IO_getc_unlocked (fp)
252 # define getc_locked(fp) _IO_getc (fp)
253 # define getchar_unlocked() _IO_getc_unlocked (stdin)
254 # define getchar_locked() _IO_getc (stdin)
255 # define putchar_unlocked(c) _IO_putc_unlocked (c, stdout)
256 # define putchar_locked(c) _IO_putc (c, stdout)
259 #endif /* __USE_REENTRANT */
261 #define getc(_fp) _IO_getc (_fp)
262 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
263 #define putchar(_ch) _IO_putc (_ch, stdout)
264 #define getchar() _IO_getc (stdin)
273 #endif /* !_STDIO_H */