Add some missing prototypes/defines.
[wine] / include / msvcrt / stdio.h
1 /*
2  * Standard I/O definitions.
3  *
4  * Derived from the mingw header written by Colin Peters.
5  * Modified for Wine use by Jon Griffiths and Francois Gouget.
6  * This file is in the public domain.
7  */
8 #ifndef __WINE_STDIO_H
9 #define __WINE_STDIO_H
10 #ifndef __WINE_USE_MSVCRT
11 #define __WINE_USE_MSVCRT
12 #endif
13
14 #ifndef RC_INVOKED
15 #include <stdarg.h>
16 #endif
17
18 #ifndef MSVCRT
19 # ifdef USE_MSVCRT_PREFIX
20 #  define MSVCRT(x)    MSVCRT_##x
21 # else
22 #  define MSVCRT(x)    x
23 # endif
24 #endif
25
26 /* file._flag flags */
27 #ifndef USE_MSVCRT_PREFIX
28 #define _IOREAD          0x0001
29 #define _IOWRT           0x0002
30 #define _IOMYBUF         0x0008
31 #define _IOEOF           0x0010
32 #define _IOERR           0x0020
33 #define _IOSTRG          0x0040
34 #define _IORW            0x0080
35 #define _IOAPPEND        0x0200
36 #else
37 #define MSVCRT__IOREAD   0x0001
38 #define MSVCRT__IOWRT    0x0002
39 #define MSVCRT__IOMYBUF  0x0008
40 #define MSVCRT__IOEOF    0x0010
41 #define MSVCRT__IOERR    0x0020
42 #define MSVCRT__IOSTRG   0x0040
43 #define MSVCRT__IORW     0x0080
44 #define MSVCRT__IOAPPEND 0x0200
45 #endif /* USE_MSVCRT_PREFIX */
46
47 #ifndef NULL
48 #ifdef  __cplusplus
49 #define NULL  0
50 #else
51 #define NULL  ((void *)0)
52 #endif
53 #endif
54
55 #ifndef USE_MSVCRT_PREFIX
56
57 #define STDIN_FILENO  0
58 #define STDOUT_FILENO 1
59 #define STDERR_FILENO 2
60
61 /* more file._flag flags, but these conflict with Unix */
62 #define _IOFBF    0x0000
63 #define _IONBF    0x0004
64 #define _IOLBF    0x0040
65
66 #define EOF       (-1)
67 #define FILENAME_MAX 260
68 #define TMP_MAX   0x7fff
69 #define FOPEN_MAX 20
70 #define L_tmpnam  260
71
72 #define BUFSIZ    512
73
74 #ifndef SEEK_SET
75 #define SEEK_SET  0
76 #define SEEK_CUR  1
77 #define SEEK_END  2
78 #endif
79
80 #else
81
82 /* more file._flag flags, but these conflict with Unix */
83 #define MSVCRT__IOFBF    0x0000
84 #define MSVCRT__IONBF    0x0004
85 #define MSVCRT__IOLBF    0x0040
86
87 #define MSVCRT_FILENAME_MAX 260
88 #define MSVCRT_TMP_MAX   0x7fff
89
90 #define MSVCRT_EOF       (-1)
91
92 #define MSVCRT_BUFSIZ    512
93
94 #endif /* USE_MSVCRT_PREFIX */
95
96 #ifndef MSVCRT_FILE_DEFINED
97 #define MSVCRT_FILE_DEFINED
98 typedef struct MSVCRT(_iobuf)
99 {
100   char* _ptr;
101   int   _cnt;
102   char* _base;
103   int   _flag;
104   int   _file;
105   int   _charbuf;
106   int   _bufsiz;
107   char* _tmpfname;
108 } MSVCRT(FILE);
109 #endif  /* MSVCRT_FILE_DEFINED */
110
111 #ifndef MSVCRT_FPOS_T_DEFINED
112 typedef long MSVCRT(fpos_t);
113 #define MSVCRT_FPOS_T_DEFINED
114 #endif
115
116 #ifndef MSVCRT_SIZE_T_DEFINED
117 typedef unsigned int MSVCRT(size_t);
118 #define MSVCRT_SIZE_T_DEFINED
119 #endif
120
121 #ifndef MSVCRT_WCHAR_T_DEFINED
122 #define MSVCRT_WCHAR_T_DEFINED
123 #ifndef __cplusplus
124 typedef unsigned short MSVCRT(wchar_t);
125 #endif
126 #endif
127
128 #ifndef MSVCRT_WCTYPE_T_DEFINED
129 typedef MSVCRT(wchar_t) MSVCRT(wint_t);
130 typedef MSVCRT(wchar_t) MSVCRT(wctype_t);
131 #define MSVCRT_WCTYPE_T_DEFINED
132 #endif
133
134 #ifdef __cplusplus
135 extern "C" {
136 #endif
137
138 #ifndef MSVCRT_STDIO_DEFINED
139 MSVCRT(FILE)*        MSVCRT(__p__iob)(void);
140 #define _iob               (__p__iob())
141 #endif /* MSVCRT_STDIO_DEFINED */
142
143 #ifndef USE_MSVCRT_PREFIX
144 #define stdin              (_iob+STDIN_FILENO)
145 #define stdout             (_iob+STDOUT_FILENO)
146 #define stderr             (_iob+STDERR_FILENO)
147 #endif /* USE_MSVCRT_PREFIX */
148
149 #ifndef MSVCRT_STDIO_DEFINED
150 #define MSVCRT_STDIO_DEFINED
151 int         _fcloseall(void);
152 MSVCRT(FILE)* _fdopen(int,const char*);
153 int         _fgetchar(void);
154 int         _filbuf(MSVCRT(FILE*));
155 int         _fileno(MSVCRT(FILE)*);
156 int         _flsbuf(int,MSVCRT(FILE)*);
157 int         _flushall(void);
158 int         _fputchar(int);
159 MSVCRT(FILE)* _fsopen(const char*,const char*,int);
160 int         _getmaxstdio(void);
161 int         _getw(MSVCRT(FILE)*);
162 int         _pclose(MSVCRT(FILE)*);
163 MSVCRT(FILE)* _popen(const char*,const char*);
164 int         _putw(int,MSVCRT(FILE)*);
165 int         _rmtmp(void);
166 int         _setmaxstdio(int);
167 int         _snprintf(char*,MSVCRT(size_t),const char*,...);
168 char*       _tempnam(const char*,const char*);
169 int         _unlink(const char*);
170 int         _vsnprintf(char*,MSVCRT(size_t),const char*,va_list);
171
172 void        MSVCRT(clearerr)(MSVCRT(FILE)*);
173 int         MSVCRT(fclose)(MSVCRT(FILE)*);
174 int         MSVCRT(feof)(MSVCRT(FILE)*);
175 int         MSVCRT(ferror)(MSVCRT(FILE)*);
176 int         MSVCRT(fflush)(MSVCRT(FILE)*);
177 int         MSVCRT(fgetc)(MSVCRT(FILE)*);
178 int         MSVCRT(fgetpos)(MSVCRT(FILE)*,MSVCRT(fpos_t)*);
179 char*       MSVCRT(fgets)(char*,int,MSVCRT(FILE)*);
180 MSVCRT(FILE)* MSVCRT(fopen)(const char*,const char*);
181 int         MSVCRT(fprintf)(MSVCRT(FILE)*,const char*,...);
182 int         MSVCRT(fputc)(int,MSVCRT(FILE)*);
183 int         MSVCRT(fputs)(const char*,MSVCRT(FILE)*);
184 MSVCRT(size_t) MSVCRT(fread)(void*,MSVCRT(size_t),MSVCRT(size_t),MSVCRT(FILE)*);
185 MSVCRT(FILE)* MSVCRT(freopen)(const char*,const char*,MSVCRT(FILE)*);
186 int         MSVCRT(fscanf)(MSVCRT(FILE)*,const char*,...);
187 int         MSVCRT(fseek)(MSVCRT(FILE)*,long,int);
188 int         MSVCRT(fsetpos)(MSVCRT(FILE)*,MSVCRT(fpos_t)*);
189 long        MSVCRT(ftell)(MSVCRT(FILE)*);
190 MSVCRT(size_t) MSVCRT(fwrite)(const void*,MSVCRT(size_t),MSVCRT(size_t),MSVCRT(FILE)*);
191 int         MSVCRT(getc)(MSVCRT(FILE)*);
192 int         MSVCRT(getchar)(void);
193 char*       MSVCRT(gets)(char*);
194 void        MSVCRT(perror)(const char*);
195 int         MSVCRT(printf)(const char*,...);
196 int         MSVCRT(putc)(int,MSVCRT(FILE)*);
197 int         MSVCRT(putchar)(int);
198 int         MSVCRT(puts)(const char*);
199 int         MSVCRT(remove)(const char*);
200 int         MSVCRT(rename)(const char*,const char*);
201 void        MSVCRT(rewind)(MSVCRT(FILE)*);
202 int         MSVCRT(scanf)(const char*,...);
203 void        MSVCRT(setbuf)(MSVCRT(FILE)*,char*);
204 int         MSVCRT(setvbuf)(MSVCRT(FILE)*,char*,int,MSVCRT(size_t));
205 int         MSVCRT(sprintf)(char*,const char*,...);
206 int         MSVCRT(sscanf)(const char*,const char*,...);
207 MSVCRT(FILE)* MSVCRT(tmpfile)(void);
208 char*       MSVCRT(tmpnam)(char*);
209 int         MSVCRT(ungetc)(int,MSVCRT(FILE)*);
210 int         MSVCRT(vfprintf)(MSVCRT(FILE)*,const char*,va_list);
211 int         MSVCRT(vprintf)(const char*,va_list);
212 int         MSVCRT(vsprintf)(char*,const char*,va_list);
213
214 #ifndef MSVCRT_WSTDIO_DEFINED
215 #define MSVCRT_WSTDIO_DEFINED
216 MSVCRT(wint_t)  _fgetwchar(void);
217 MSVCRT(wint_t)  _fputwchar(MSVCRT(wint_t));
218 MSVCRT(wchar_t)*_getws(MSVCRT(wchar_t)*);
219 int             _putws(const MSVCRT(wchar_t)*);
220 int             _snwprintf(MSVCRT(wchar_t)*,MSVCRT(size_t),const MSVCRT(wchar_t)*,...);
221 int             _vsnwprintf(MSVCRT(wchar_t)*,MSVCRT(size_t),const MSVCRT(wchar_t)*,va_list);
222 MSVCRT(FILE)*   _wfdopen(int,const MSVCRT(wchar_t)*);
223 MSVCRT(FILE)*   _wfopen(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*);
224 MSVCRT(FILE)*   _wfreopen(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,MSVCRT(FILE)*);
225 MSVCRT(FILE)*   _wfsopen(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,int);
226 void            _wperror(const MSVCRT(wchar_t)*);
227 MSVCRT(FILE)*   _wpopen(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*);
228 int             _wremove(const MSVCRT(wchar_t)*);
229 MSVCRT(wchar_t)*_wtempnam(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*);
230 MSVCRT(wchar_t)*_wtmpnam(MSVCRT(wchar_t)*);
231
232 MSVCRT(wint_t)  MSVCRT(fgetwc)(MSVCRT(FILE)*);
233 MSVCRT(wchar_t)*MSVCRT(fgetws)(MSVCRT(wchar_t)*,int,MSVCRT(FILE)*);
234 MSVCRT(wint_t)  MSVCRT(fputwc)(MSVCRT(wint_t),MSVCRT(FILE)*);
235 int             MSVCRT(fputws)(const MSVCRT(wchar_t)*,MSVCRT(FILE)*);
236 int             MSVCRT(fwprintf)(MSVCRT(FILE)*,const MSVCRT(wchar_t)*,...);
237 int             MSVCRT(fputws)(const MSVCRT(wchar_t)*,MSVCRT(FILE)*);
238 int             MSVCRT(fwscanf)(MSVCRT(FILE)*,const MSVCRT(wchar_t)*,...);
239 MSVCRT(wint_t)  MSVCRT(getwc)(MSVCRT(FILE)*);
240 MSVCRT(wint_t)  MSVCRT(getwchar)(void);
241 MSVCRT(wchar_t)*MSVCRT(getws)(MSVCRT(wchar_t)*);
242 MSVCRT(wint_t)  MSVCRT(putwc)(MSVCRT(wint_t),MSVCRT(FILE)*);
243 MSVCRT(wint_t)  MSVCRT(putwchar)(MSVCRT(wint_t));
244 int             MSVCRT(putws)(const MSVCRT(wchar_t)*);
245 int             MSVCRT(swprintf)(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,...);
246 int             MSVCRT(swscanf)(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,...);
247 MSVCRT(wint_t)  MSVCRT(ungetwc)(MSVCRT(wint_t),MSVCRT(FILE)*);
248 int             MSVCRT(vfwprintf)(MSVCRT(FILE)*,const MSVCRT(wchar_t)*,va_list);
249 int             MSVCRT(vswprintf)(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,va_list);
250 int             MSVCRT(vwprintf)(const MSVCRT(wchar_t)*,va_list);
251 int             MSVCRT(wprintf)(const MSVCRT(wchar_t)*,...);
252 int             MSVCRT(wscanf)(const MSVCRT(wchar_t)*,...);
253 #endif /* MSVCRT_WSTDIO_DEFINED */
254
255 #endif /* MSVCRT_STDIO_DEFINED */
256
257 #ifdef __cplusplus
258 }
259 #endif
260
261
262 #ifndef USE_MSVCRT_PREFIX
263 static inline MSVCRT(FILE)* fdopen(int fd, const char *mode) { return _fdopen(fd, mode); }
264 static inline int fgetchar(void) { return _fgetchar(); }
265 static inline int fileno(MSVCRT(FILE)* file) { return _fileno(file); }
266 static inline int fputchar(int c) { return _fputchar(c); }
267 static inline int pclose(MSVCRT(FILE)* file) { return _pclose(file); }
268 static inline MSVCRT(FILE)* popen(const char* command, const char* mode) { return _popen(command, mode); }
269 static inline char* tempnam(const char *dir, const char *prefix) { return _tempnam(dir, prefix); }
270 #ifndef MSVCRT_UNLINK_DEFINED
271 static inline int unlink(const char* path) { return _unlink(path); }
272 #define MSVCRT_UNLINK_DEFINED
273 #endif
274 static inline int vsnprintf(char *buffer, size_t size, const char *format, va_list args) { return _vsnprintf(buffer,size,format,args); }
275
276 static inline MSVCRT(wint_t) fgetwchar(void) { return _fgetwchar(); }
277 static inline MSVCRT(wint_t) fputwchar(MSVCRT(wint_t) wc) { return _fputwchar(wc); }
278 static inline int getw(MSVCRT(FILE)* file) { return _getw(file); }
279 static inline int putw(int val, MSVCRT(FILE)* file) { return _putw(val, file); }
280 static inline MSVCRT(FILE)* wpopen(const MSVCRT(wchar_t)* command,const MSVCRT(wchar_t)* mode) { return _wpopen(command, mode); }
281 #endif /* USE_MSVCRT_PREFIX */
282
283 #endif /* __WINE_STDIO_H */