update from main archvie 961013
[glibc.git] / libio / stdio.h
bloba47b663cae546a8ff6fd5eb3651eaaa6f4b16426
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 * ANSI 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 #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
85 #ifdef __cplusplus
86 extern "C" {
87 #endif
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*/
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*));
140 #endif
141 #ifdef __USE_SVID
142 extern char *tempnam __P ((__const char *__dir, __const char *__pfx));
143 #endif
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,
147 FILE **streamptr));
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));
163 #endif
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*));
171 #define L_ctermid 9
172 #define L_cuserid 9
174 /* Return the name of the controlling terminal. */
175 extern char *ctermid __P ((char *__buf));
177 /* Get character login name of the user. */
178 extern char *cuserid __P ((char * __buf));
179 #endif
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 *));
184 extern _IO_ssize_t __getline __P ((char **, size_t *, FILE *));
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));
189 extern int __vsnprintf __P ((char *, size_t, __const char *, _G_va_list));
191 extern int asprintf __P ((char **, const char *, ...));
192 extern int vasprintf __P ((char **, const char *, _G_va_list));
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
200 extern int __underflow __P ((struct _IO_FILE*));
201 extern int __overflow __P ((struct _IO_FILE*, int));
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
212 /* Handle locking of streams. */
213 #ifdef __USE_REENTRANT
214 extern void clearerr_locked __P ((FILE *));
215 extern void clearerr_unlocked __P ((FILE *));
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 *));
222 extern void flockfile __P ((FILE *));
223 extern void funlockfile __P ((FILE *));
224 extern int ftrylockfile __P ((FILE *));
225 extern int fclose_unlocked __P ((FILE *));
226 extern int fflush_locked __P ((FILE *));
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 *));
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));
242 # ifndef _LIBC
243 # define getc_unlocked(fp) _IO_getc_unlocked (fp)
244 # define getc_locked(fp) _IO_getc (fp)
245 # define getchar_unlocked() _IO_getc_unlocked (stdin)
246 # define getchar_locked() _IO_getc (stdin)
247 # define putchar_unlocked(c) _IO_putc_unlocked (c, stdout)
248 # define putchar_locked(c) _IO_putc (c, stdout)
249 # endif
251 #endif /* __USE_REENTRANT */
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)
259 #ifdef __cplusplus
261 #endif
265 #endif /* !_STDIO_H */