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 Free Software Foundation
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 * ANSI Standard: 4.9 INPUT/OUTPUT <stdio.h>
27 #define _STDIO_USES_IOSTREAM
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 #define FOPEN_MAX _G_FOPEN_MAX
75 #define FILENAME_MAX _G_FILENAME_MAX
77 #define TMP_MAX 999 /* Only limited by filename length */
82 #define P_tmpdir "/tmp"
85 /* For use by debuggers. These are linked in if printf or fprintf are used. */
86 extern FILE *stdin
, *stdout
, *stderr
; /* TODO */
88 #define stdin _IO_stdin
89 #define stdout _IO_stdout
90 #define stderr _IO_stderr
97 #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
98 #define __P(args) args
104 extern void clearerr
__P((FILE*));
105 extern int fclose
__P((FILE*));
106 extern int feof
__P((FILE*));
107 extern int ferror
__P((FILE*));
108 extern int fflush
__P((FILE*));
109 extern int fgetc
__P((FILE *));
110 extern int fgetpos
__P((FILE* fp
, fpos_t *pos
));
111 extern char* fgets
__P((char*, int, FILE*));
112 extern FILE* fopen
__P((const char*, const char*));
113 extern int fprintf
__P((FILE*, const char* format
, ...));
114 extern int fputc
__P((int, FILE*));
115 extern int fputs
__P((const char *str
, FILE *fp
));
116 extern size_t fread
__P((void*, size_t, size_t, FILE*));
117 extern FILE* freopen
__P((const char*, const char*, FILE*));
118 extern int fscanf
__P((FILE *fp
, const char* format
, ...));
119 extern int fseek
__P((FILE* fp
, long int offset
, int whence
));
120 extern int fsetpos
__P((FILE* fp
, const fpos_t *pos
));
121 extern long int ftell
__P((FILE* fp
));
122 extern size_t fwrite
__P((const void*, size_t, size_t, FILE*));
123 extern int getc
__P((FILE *));
124 extern int getchar
__P((void));
125 extern char* gets
__P((char*));
126 extern void perror
__P((const char *));
127 extern int printf
__P((const char* format
, ...));
128 extern int putc
__P((int, FILE *));
129 extern int putchar
__P((int));
130 extern int puts
__P((const char *str
));
131 extern int remove
__P((const char*));
132 extern int rename
__P((const char* _old
, const char* _new
));
133 extern void rewind
__P((FILE*));
134 extern int scanf
__P((const char* format
, ...));
135 extern void setbuf
__P((FILE*, char*));
136 extern void setlinebuf
__P((FILE*));
137 extern void setbuffer
__P((FILE*, char*, int));
138 extern int setvbuf
__P((FILE*, char*, int mode
, size_t size
));
139 extern int sprintf
__P((char*, const char* format
, ...));
140 extern int sscanf
__P((const char* string
, const char* format
, ...));
141 extern FILE* tmpfile
__P((void));
142 extern char* tmpnam
__P((char*));
143 extern int ungetc
__P((int c
, FILE* fp
));
144 extern int vfprintf
__P((FILE *fp
, char const *fmt0
, _IO_va_list
));
145 extern int vprintf
__P((char const *fmt
, _IO_va_list
));
146 extern int vsprintf
__P((char* string
, const char* format
, _IO_va_list
));
148 #ifndef __STRICT_ANSI__
149 extern int vfscanf
__P((FILE*, const char *, _IO_va_list
));
150 extern int vscanf
__P((const char *, _IO_va_list
));
151 extern int vsscanf
__P((const char *, const char *, _IO_va_list
));
154 #if !defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE)
155 extern FILE *fdopen
__P((int, const char *));
156 extern int fileno
__P((FILE*));
157 extern FILE* popen
__P((const char*, const char*));
158 extern int pclose
__P((FILE*));
162 extern _IO_ssize_t getdelim
__P ((char **, size_t *, int, FILE*));
163 extern _IO_ssize_t getline
__P ((char **, size_t *, FILE *));
165 extern int snprintf
__P ((char *, size_t, const char *, ...));
166 extern int vsnprintf
__P ((char *, size_t, const char *, _IO_va_list
));
169 extern int __underflow
__P((struct _IO_FILE
*));
170 extern int __overflow
__P((struct _IO_FILE
*, int));
172 /* Handle locking of streams. */
173 #if defined _REENTRANT || defined _THREAD_SAFE
174 extern void clearerr_locked
__P ((FILE *));
175 extern void clearerr_unlocked
__P ((FILE *));
176 extern int feof_locked
__P ((FILE *));
177 extern int feof_unlocked
__P ((FILE *));
178 extern int ferror_locked
__P ((FILE*));
179 extern int ferror_unlocked
__P ((FILE*));
180 extern int fileno_locked
__P ((FILE *));
181 extern int fileno_unlocked
__P ((FILE *));
182 extern void flockfile
__P ((FILE *));
183 extern void funlockfile
__P ((FILE *));
184 extern int ftrylockfile
__P ((FILE *));
185 extern int fclose_unlocked
__P ((FILE *));
186 extern int fflush_locked
__P ((FILE *));
187 extern int fflush_unlocked
__P ((FILE *));
188 extern size_t fread_unlocked
__P ((void *, size_t, size_t, FILE *));
189 extern size_t fwrite_unlocked
__P ((const void *, size_t, size_t, FILE *));
191 extern int fputc_locked
__P ((int, FILE*));
192 extern int fputc_unlocked
__P ((int, FILE*));
193 extern int getc_locked
__P ((FILE *));
194 extern int getc_unlocked
__P ((FILE *));
195 extern int getchar_locked
__P ((void));
196 extern int getchar_unlocked
__P ((void));
197 extern int putc_locked
__P ((int, FILE *));
198 extern int putc_unlocked
__P ((int, FILE *));
199 extern int putchar_locked
__P ((int));
200 extern int putchar_unlocked
__P ((int));
202 # define getc_unlocked(fp) _IO_getc_unlocked (fp)
203 # define getc_locked(fp) _IO_getc (fp)
204 # define getchar_unlocked() _IO_getc_unlocked (stdin)
205 # define getchar_locked() _IO_getc (stdin)
206 # define putchar_unlocked(c) _IO_putc_unlocked (c, stdout)
207 # define putchar_locked(c) _IO_putc (c, stdout)
208 #endif /* __USE_REENTRANT */
210 #define getc(fp) _IO_getc(fp)
211 #define putc(c, fp) _IO_putc(c, fp)
212 #define putchar(c) _IO_putc(c, stdout)
213 #define getchar() _IO_getc(stdin)