]> git.ipfire.org Git - thirdparty/glibc.git/blame - libio/stdio.h
update from main archvie 961013
[thirdparty/glibc.git] / libio / stdio.h
CommitLineData
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
5This library is free software; you can redistribute it and/or
6modify it under the terms of the GNU Library General Public
7License as published by the Free Software Foundation; either
8version 2 of the License, or (at your option) any later version.
9
10
11This library is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14Library General Public License for more details.
15
16You should have received a copy of the GNU Library General Public
17License along with this library; if not, write to the Free Software
18Foundation, 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_
66typedef _IO_size_t size_t;
67#endif
68#endif
69#endif
70
71typedef struct _IO_FILE FILE;
72typedef _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. */
79extern 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
86extern "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
97extern void clearerr __P ((FILE*));
98extern int fclose __P ((FILE*));
99extern int feof __P ((FILE*));
100extern int ferror __P ((FILE*));
101extern int fflush __P ((FILE*));
102extern int fgetc __P ((FILE *));
103extern int fgetpos __P ((FILE* fp, fpos_t *pos));
104extern char* fgets __P ((char*, int, FILE*));
105extern FILE* fopen __P ((__const char*, __const char*));
76060ec0 106extern FILE* fopencookie __P ((void *cookie, __const char *mode,
fa0bc87c 107 _IO_cookie_io_functions_t io_functions));
96aa2d94
RM
108extern int fprintf __P ((FILE*, __const char* format, ...));
109extern int fputc __P ((int, FILE*));
110extern int fputs __P ((__const char *str, FILE *fp));
111extern size_t fread __P ((void*, size_t, size_t, FILE*));
112extern FILE* freopen __P ((__const char*, __const char*, FILE*));
113extern int fscanf __P ((FILE *fp, __const char* format, ...));
114extern int fseek __P ((FILE* fp, long int offset, int whence));
115extern int fsetpos __P ((FILE* fp, __const fpos_t *pos));
116extern long int ftell __P ((FILE* fp));
117extern size_t fwrite __P ((__const void*, size_t, size_t, FILE*));
118extern int getc __P ((FILE *));
119extern int getchar __P ((void));
120extern char* gets __P ((char*));
121extern void perror __P ((__const char *));
122extern int printf __P ((__const char* format, ...));
123extern int putc __P ((int, FILE *));
124extern int putchar __P ((int));
125extern int puts __P ((__const char *str));
126extern int remove __P ((__const char*));
127extern int rename __P ((__const char* _old, __const char* _new));
128extern void rewind __P ((FILE*));
129extern int scanf __P ((__const char* format, ...));
130extern void setbuf __P ((FILE*, char*));
131extern void setlinebuf __P ((FILE*));
132extern void setbuffer __P ((FILE*, char*, int));
133extern int setvbuf __P ((FILE*, char*, int mode, size_t size));
134extern int sprintf __P ((char*, __const char* format, ...));
135extern int sscanf __P ((__const char* string, __const char* format, ...));
136extern FILE* tmpfile __P ((void));
137extern char* tmpnam __P ((char*));
d68171ed
UD
138#ifdef __USE_REENTRANT
139extern char* tmpnam_r __P ((char*));
140#endif
2cc7dc4d
RM
141#ifdef __USE_SVID
142extern char *tempnam __P ((__const char *__dir, __const char *__pfx));
143#endif
d68171ed
UD
144extern 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
148extern int ungetc __P ((int c, FILE* fp));
149extern int vfprintf __P ((FILE *fp, char __const *fmt0, _G_va_list));
150extern int vprintf __P ((char __const *fmt, _G_va_list));
151extern int vsprintf __P ((char* string, __const char* format, _G_va_list));
a1470b6f
RM
152extern void __libc_fatal __P ((__const char *__message))
153 __attribute__ ((__noreturn__));
96aa2d94
RM
154
155#ifndef __STRICT_ANSI__
156extern int dprintf __P ((int, __const char *, ...));
157extern int vdprintf __P ((int, __const char *, _G_va_list));
158extern int vfscanf __P ((FILE*, __const char *, _G_va_list));
fa0bc87c 159extern int __vfscanf __P ((FILE*, __const char *, _G_va_list));
96aa2d94
RM
160extern int vscanf __P ((__const char *, _G_va_list));
161extern int vsscanf __P ((__const char *, __const char *, _G_va_list));
fa0bc87c 162extern int __vsscanf __P ((__const char *, __const char *, _G_va_list));
96aa2d94
RM
163#endif
164
165#if !defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE)
166extern FILE *fdopen __P ((int, __const char *));
167extern int fileno __P ((FILE*));
168extern FILE* popen __P ((__const char*, __const char*));
169extern 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. */
175extern char *ctermid __P ((char *__buf));
176
177/* Get character login name of the user. */
178extern char *cuserid __P ((char * __buf));
96aa2d94
RM
179#endif
180
181#ifdef __USE_GNU
182extern _IO_ssize_t getdelim __P ((char **, size_t *, int, FILE*));
183extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
7c713e28 184extern _IO_ssize_t __getline __P ((char **, size_t *, FILE *));
96aa2d94
RM
185
186extern int snprintf __P ((char *, size_t, __const char *, ...));
187extern int __snprintf __P ((char *, size_t, __const char *, ...));
188extern int vsnprintf __P ((char *, size_t, __const char *, _G_va_list));
fa0bc87c 189extern int __vsnprintf __P ((char *, size_t, __const char *, _G_va_list));
96aa2d94 190
7a12c6bb
RM
191extern int asprintf __P ((char **, const char *, ...));
192extern 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. */
197extern FILE *open_memstream __P ((char **__bufloc, size_t *__sizeloc));
198#endif
199
200extern int __underflow __P ((struct _IO_FILE*));
201extern int __overflow __P ((struct _IO_FILE*, int));
202
96aa2d94
RM
203#ifdef __USE_BSD
204extern int sys_nerr;
205extern const char *const sys_errlist[];
206#endif
207#ifdef __USE_GNU
208extern int _sys_nerr;
209extern const char *const _sys_errlist[];
210#endif
211
7c713e28 212/* Handle locking of streams. */
edf5b2d7
UD
213#ifdef __USE_REENTRANT
214extern void clearerr_locked __P ((FILE *));
7c713e28 215extern void clearerr_unlocked __P ((FILE *));
edf5b2d7
UD
216extern int feof_locked __P ((FILE *));
217extern int feof_unlocked __P ((FILE *));
218extern int ferror_locked __P ((FILE*));
219extern int ferror_unlocked __P ((FILE*));
220extern int fileno_locked __P ((FILE *));
221extern int fileno_unlocked __P ((FILE *));
7c713e28
RM
222extern void flockfile __P ((FILE *));
223extern void funlockfile __P ((FILE *));
d41c6f61 224extern int ftrylockfile __P ((FILE *));
7c713e28 225extern int fclose_unlocked __P ((FILE *));
edf5b2d7 226extern int fflush_locked __P ((FILE *));
7c713e28
RM
227extern int fflush_unlocked __P ((FILE *));
228extern size_t fread_unlocked __P ((void *, size_t, size_t, FILE *));
229extern size_t fwrite_unlocked __P ((const void *, size_t, size_t, FILE *));
230
edf5b2d7
UD
231extern int fputc_locked __P ((int, FILE*));
232extern int fputc_unlocked __P ((int, FILE*));
233extern int getc_locked __P ((FILE *));
234extern int getc_unlocked __P ((FILE *));
235extern int getchar_locked __P ((void));
236extern int getchar_unlocked __P ((void));
237extern int putc_locked __P ((int, FILE *));
238extern int putc_unlocked __P ((int, FILE *));
239extern int putchar_locked __P ((int));
240extern 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 */