update from main archive 961208
[glibc.git] / libio / stdio.h
blobba5fa5438ee060d52e2adbc34f02d1fd61ec03de
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>
25 #ifndef _STDIO_H
26 #define _STDIO_H
27 #define _STDIO_USES_IOSTREAM
29 #include <libio.h>
31 #ifndef NULL
32 #ifdef __cplusplus
33 #define NULL 0
34 #else
35 #define NULL (void*)0
36 #endif
37 #endif
39 #ifndef EOF
40 #define EOF (-1)
41 #endif
42 #ifndef BUFSIZ
43 #define BUFSIZ _IO_BUFSIZ
44 #endif
46 #define _IOFBF 0 /* Fully buffered. */
47 #define _IOLBF 1 /* Line buffered. */
48 #define _IONBF 2 /* No buffering. */
50 #define SEEK_SET 0
51 #define SEEK_CUR 1
52 #define SEEK_END 2
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
71 typedef struct _IO_FILE FILE;
72 typedef _IO_fpos_t fpos_t;
74 #include <stdio_lim.h>
76 #ifdef __USE_SVID
77 /* Default path prefix for `tempnam' and `tmpnam'. */
78 #define P_tmpdir "/tmp"
79 #endif
81 /* For use by debuggers. These are linked in if printf or fprintf are used. */
82 extern FILE *stdin, *stdout, *stderr; /* TODO */
84 #define stdin _IO_stdin
85 #define stdout _IO_stdout
86 #define stderr _IO_stderr
88 #ifdef __cplusplus
89 extern "C" {
90 #endif
92 #ifndef __P
93 #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
94 #define __P(args) args
95 #else
96 #define __P(args) ()
97 #endif
98 #endif /*!__P*/
100 extern void clearerr __P ((FILE*));
101 extern int fclose __P ((FILE*));
102 extern int feof __P ((FILE*));
103 extern int ferror __P ((FILE*));
104 extern int fflush __P ((FILE*));
105 extern int fgetc __P ((FILE *));
106 extern int fgetpos __P ((FILE* fp, fpos_t *pos));
107 extern char* fgets __P ((char*, int, FILE*));
108 extern FILE* fopen __P ((__const char*, __const char*));
109 extern FILE* fopencookie __P ((void *cookie, __const char *mode,
110 _IO_cookie_io_functions_t io_functions));
111 extern int fprintf __P ((FILE*, __const char* format, ...));
112 extern int fputc __P ((int, FILE*));
113 extern int fputs __P ((__const char *str, FILE *fp));
114 extern size_t fread __P ((void*, size_t, size_t, FILE*));
115 extern FILE* freopen __P ((__const char*, __const char*, FILE*));
116 extern int fscanf __P ((FILE *fp, __const char* format, ...));
117 extern int fseek __P ((FILE* fp, long int offset, int whence));
118 extern int fsetpos __P ((FILE* fp, __const fpos_t *pos));
119 extern long int ftell __P ((FILE* fp));
120 extern size_t fwrite __P ((__const void*, size_t, size_t, FILE*));
121 extern int getc __P ((FILE *));
122 extern int getchar __P ((void));
123 extern char* gets __P ((char*));
124 extern void perror __P ((__const char *));
125 extern int printf __P ((__const char* format, ...));
126 extern int putc __P ((int, FILE *));
127 extern int putchar __P ((int));
128 extern int puts __P ((__const char *str));
129 extern int remove __P ((__const char*));
130 extern int rename __P ((__const char* _old, __const char* _new));
131 extern void rewind __P ((FILE*));
132 extern int scanf __P ((__const char* format, ...));
133 extern void setbuf __P ((FILE*, char*));
134 extern void setlinebuf __P ((FILE*));
135 extern void setbuffer __P ((FILE*, char*, int));
136 extern int setvbuf __P ((FILE*, char*, int mode, size_t size));
137 extern int sprintf __P ((char*, __const char* format, ...));
138 extern int sscanf __P ((__const char* string, __const char* format, ...));
139 extern FILE* tmpfile __P ((void));
140 extern char* tmpnam __P ((char*));
141 #ifdef __USE_REENTRANT
142 extern char* tmpnam_r __P ((char*));
143 #endif
144 #if defined(__USE_SVID) || defined(__USE_XOPEN)
145 extern char *tempnam __P ((__const char *__dir, __const char *__pfx));
146 #endif
147 extern char *__stdio_gen_tempname __P ((char *__buf, size_t bufsize,
148 __const char *dir, __const char *pfx,
149 int dir_search, size_t *lenptr,
150 FILE **streamptr));
151 extern int ungetc __P ((int c, FILE* fp));
152 extern int vfprintf __P ((FILE *fp, char __const *fmt0, _G_va_list));
153 extern int vprintf __P ((char __const *fmt, _G_va_list));
154 extern int vsprintf __P ((char* string, __const char* format, _G_va_list));
155 extern void __libc_fatal __P ((__const char *__message))
156 __attribute__ ((__noreturn__));
158 #ifndef __STRICT_ANSI__
159 extern int dprintf __P ((int, __const char *, ...));
160 extern int vdprintf __P ((int, __const char *, _G_va_list));
161 extern int vfscanf __P ((FILE*, __const char *, _G_va_list));
162 extern int __vfscanf __P ((FILE*, __const char *, _G_va_list));
163 extern int vscanf __P ((__const char *, _G_va_list));
164 extern int vsscanf __P ((__const char *, __const char *, _G_va_list));
165 extern int __vsscanf __P ((__const char *, __const char *, _G_va_list));
166 #endif
168 #ifdef __USE_GNU
169 struct obstack;
170 extern int obstack_vprintf __P ((struct obstack *__obstack,
171 __const char *__fmt, _G_va_list));
172 extern int obstack_printf __P ((struct obstack *__obstack, __const char *__fmt,
173 ...));
174 #endif
176 #if !defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE)
177 extern FILE *fdopen __P ((int, __const char *));
178 extern int fileno __P ((FILE*));
179 extern FILE* popen __P ((__const char*, __const char*));
180 extern int pclose __P ((FILE*));
182 #define L_ctermid 9
183 #define L_cuserid 9
185 /* Return the name of the controlling terminal. */
186 extern char *ctermid __P ((char *__buf));
188 /* Get character login name of the user. */
189 extern char *cuserid __P ((char * __buf));
190 #endif
192 #ifdef __USE_GNU
193 extern _IO_ssize_t getdelim __P ((char **, size_t *, int, FILE*));
194 extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
195 extern _IO_ssize_t __getline __P ((char **, size_t *, FILE *));
197 extern int snprintf __P ((char *, size_t, __const char *, ...));
198 extern int __snprintf __P ((char *, size_t, __const char *, ...));
199 extern int vsnprintf __P ((char *, size_t, __const char *, _G_va_list));
200 extern int __vsnprintf __P ((char *, size_t, __const char *, _G_va_list));
202 extern int asprintf __P ((char **, const char *, ...));
203 extern int vasprintf __P ((char **, const char *, _G_va_list));
205 /* Open a stream that writes into a malloc'd buffer that is expanded as
206 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
207 and the number of characters written on fflush or fclose. */
208 extern FILE *open_memstream __P ((char **__bufloc, size_t *__sizeloc));
209 #endif
211 extern int __underflow __P ((struct _IO_FILE*));
212 extern int __overflow __P ((struct _IO_FILE*, int));
214 #ifdef __USE_BSD
215 extern int sys_nerr;
216 extern const char *const sys_errlist[];
217 #endif
218 #ifdef __USE_GNU
219 extern int _sys_nerr;
220 extern const char *const _sys_errlist[];
221 #endif
223 /* Handle locking of streams. */
224 #ifdef __USE_REENTRANT
225 extern void clearerr_locked __P ((FILE *));
226 extern void clearerr_unlocked __P ((FILE *));
227 extern int feof_locked __P ((FILE *));
228 extern int feof_unlocked __P ((FILE *));
229 extern int ferror_locked __P ((FILE*));
230 extern int ferror_unlocked __P ((FILE*));
231 extern int fileno_locked __P ((FILE *));
232 extern int fileno_unlocked __P ((FILE *));
233 extern void flockfile __P ((FILE *));
234 extern void funlockfile __P ((FILE *));
235 extern int ftrylockfile __P ((FILE *));
236 extern int fclose_unlocked __P ((FILE *));
237 extern int fflush_locked __P ((FILE *));
238 extern int fflush_unlocked __P ((FILE *));
239 extern size_t fread_unlocked __P ((void *, size_t, size_t, FILE *));
240 extern size_t fwrite_unlocked __P ((const void *, size_t, size_t, FILE *));
242 extern int fputc_locked __P ((int, FILE*));
243 extern int fputc_unlocked __P ((int, FILE*));
244 extern int getc_locked __P ((FILE *));
245 extern int getc_unlocked __P ((FILE *));
246 extern int getchar_locked __P ((void));
247 extern int getchar_unlocked __P ((void));
248 extern int putc_locked __P ((int, FILE *));
249 extern int putc_unlocked __P ((int, FILE *));
250 extern int putchar_locked __P ((int));
251 extern int putchar_unlocked __P ((int));
253 # ifndef _LIBC
254 # define getc_unlocked(fp) _IO_getc_unlocked (fp)
255 # define getc_locked(fp) _IO_getc (fp)
256 # define getchar_unlocked() _IO_getc_unlocked (stdin)
257 # define getchar_locked() _IO_getc (stdin)
258 # define putchar_unlocked(c) _IO_putc_unlocked (c, stdout)
259 # define putchar_locked(c) _IO_putc (c, stdout)
260 # endif
262 #endif /* __USE_REENTRANT */
264 #define getc(_fp) _IO_getc (_fp)
265 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
266 #define putchar(_ch) _IO_putc (_ch, stdout)
267 #define getchar() _IO_getc (stdin)
270 #ifdef __cplusplus
272 #endif
276 #endif /* !_STDIO_H */