Fix the _WCTYPE_T_DEFINED sentry for compatibility.
[wine/wine-gecko.git] / include / msvcrt / stdio.h
blobdf92ca66791c8a71363120d64ac62c2bdb2a773a
1 /*
2 * Standard I/O definitions.
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
14 #ifndef RC_INVOKED
15 #include <stdarg.h>
16 #endif
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
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 */
47 #ifndef NULL
48 #ifdef __cplusplus
49 #define NULL 0
50 #else
51 #define NULL ((void *)0)
52 #endif
53 #endif
55 #ifndef USE_MSVCRT_PREFIX
57 #define STDIN_FILENO 0
58 #define STDOUT_FILENO 1
59 #define STDERR_FILENO 2
61 /* more file._flag flags, but these conflict with Unix */
62 #define _IOFBF 0x0000
63 #define _IONBF 0x0004
64 #define _IOLBF 0x0040
66 #define EOF (-1)
67 #define FILENAME_MAX 260
68 #define TMP_MAX 0x7fff
69 #define FOPEN_MAX 20
70 #define L_tmpnam 260
72 #define BUFSIZ 512
74 #ifndef SEEK_SET
75 #define SEEK_SET 0
76 #define SEEK_CUR 1
77 #define SEEK_END 2
78 #endif
80 #else
82 #define MSVCRT_STDIN_FILENO 0
83 #define MSVCRT_STDOUT_FILENO 1
84 #define MSVCRT_STDERR_FILENO 2
86 /* more file._flag flags, but these conflict with Unix */
87 #define MSVCRT__IOFBF 0x0000
88 #define MSVCRT__IONBF 0x0004
89 #define MSVCRT__IOLBF 0x0040
91 #define MSVCRT_FILENAME_MAX 260
92 #define MSVCRT_TMP_MAX 0x7fff
94 #define MSVCRT_EOF (-1)
96 #define MSVCRT_BUFSIZ 512
98 #endif /* USE_MSVCRT_PREFIX */
100 #ifndef MSVCRT_FILE_DEFINED
101 #define MSVCRT_FILE_DEFINED
102 typedef struct MSVCRT(_iobuf)
104 char* _ptr;
105 int _cnt;
106 char* _base;
107 int _flag;
108 int _file;
109 int _charbuf;
110 int _bufsiz;
111 char* _tmpfname;
112 } MSVCRT(FILE);
113 #endif /* MSVCRT_FILE_DEFINED */
115 #ifndef MSVCRT_FPOS_T_DEFINED
116 typedef long MSVCRT(fpos_t);
117 #define MSVCRT_FPOS_T_DEFINED
118 #endif
120 #ifndef MSVCRT_SIZE_T_DEFINED
121 typedef unsigned int MSVCRT(size_t);
122 #define MSVCRT_SIZE_T_DEFINED
123 #endif
125 #ifndef MSVCRT_WCHAR_T_DEFINED
126 #define MSVCRT_WCHAR_T_DEFINED
127 #ifndef __cplusplus
128 typedef unsigned short MSVCRT(wchar_t);
129 #endif
130 #endif
132 #ifndef _WCTYPE_T_DEFINED
133 typedef unsigned short MSVCRT(wint_t);
134 typedef unsigned short MSVCRT(wctype_t);
135 #define _WCTYPE_T_DEFINED
136 #endif
138 #ifdef __cplusplus
139 extern "C" {
140 #endif
142 #ifndef MSVCRT_STDIO_DEFINED
143 MSVCRT(FILE)* MSVCRT(__p__iob)(void);
144 #define _iob (__p__iob())
145 #endif /* MSVCRT_STDIO_DEFINED */
147 #ifndef USE_MSVCRT_PREFIX
148 #define stdin (_iob+STDIN_FILENO)
149 #define stdout (_iob+STDOUT_FILENO)
150 #define stderr (_iob+STDERR_FILENO)
151 #else
152 #define MSVCRT_stdin (MSVCRT__iob+MSVCRT_STDIN_FILENO)
153 #define MSVCRT_stdout (MSVCRT__iob+MSVCRT_STDOUT_FILENO)
154 #define MSVCRT_stderr (MSVCRT__iob+MSVCRT_STDERR_FILENO)
155 #endif /* USE_MSVCRT_PREFIX */
157 #ifndef MSVCRT_STDIO_DEFINED
158 #define MSVCRT_STDIO_DEFINED
159 int MSVCRT(_fcloseall)(void);
160 MSVCRT(FILE)* MSVCRT(_fdopen)(int,const char*);
161 int _fgetchar(void);
162 int MSVCRT(_filbuf)(MSVCRT(FILE*));
163 int MSVCRT(_fileno)(MSVCRT(FILE)*);
164 int MSVCRT(_flsbuf)(int,MSVCRT(FILE)*);
165 int _flushall(void);
166 int _fputchar(int);
167 MSVCRT(FILE)* _fsopen(const char*,const char*,int);
168 int _getmaxstdio(void);
169 int MSVCRT(_getw)(MSVCRT(FILE)*);
170 int MSVCRT(_pclose)(MSVCRT(FILE)*);
171 MSVCRT(FILE)* MSVCRT(_popen)(const char*,const char*);
172 int MSVCRT(_putw)(int,MSVCRT(FILE)*);
173 int _rmtmp(void);
174 int _setmaxstdio(int);
175 int _snprintf(char*,MSVCRT(size_t),const char*,...);
176 char* _tempnam(const char*,const char*);
177 int _unlink(const char*);
178 int _vsnprintf(char*,MSVCRT(size_t),const char*,va_list);
180 void MSVCRT(clearerr)(MSVCRT(FILE)*);
181 int MSVCRT(fclose)(MSVCRT(FILE)*);
182 int MSVCRT(feof)(MSVCRT(FILE)*);
183 int MSVCRT(ferror)(MSVCRT(FILE)*);
184 int MSVCRT(fflush)(MSVCRT(FILE)*);
185 int MSVCRT(fgetc)(MSVCRT(FILE)*);
186 int MSVCRT(fgetpos)(MSVCRT(FILE)*,MSVCRT(fpos_t)*);
187 char* MSVCRT(fgets)(char*,int,MSVCRT(FILE)*);
188 MSVCRT(FILE)* MSVCRT(fopen)(const char*,const char*);
189 int MSVCRT(fprintf)(MSVCRT(FILE)*,const char*,...);
190 int MSVCRT(fputc)(int,MSVCRT(FILE)*);
191 int MSVCRT(fputs)(const char*,MSVCRT(FILE)*);
192 MSVCRT(size_t) MSVCRT(fread)(void*,MSVCRT(size_t),MSVCRT(size_t),MSVCRT(FILE)*);
193 MSVCRT(FILE)* MSVCRT(freopen)(const char*,const char*,MSVCRT(FILE)*);
194 int MSVCRT(fscanf)(MSVCRT(FILE)*,const char*,...);
195 int MSVCRT(fseek)(MSVCRT(FILE)*,long,int);
196 int MSVCRT(fsetpos)(MSVCRT(FILE)*,MSVCRT(fpos_t)*);
197 long MSVCRT(ftell)(MSVCRT(FILE)*);
198 MSVCRT(size_t) MSVCRT(fwrite)(const void*,MSVCRT(size_t),MSVCRT(size_t),MSVCRT(FILE)*);
199 int MSVCRT(getc)(MSVCRT(FILE)*);
200 int MSVCRT(getchar)(void);
201 char* MSVCRT(gets)(char*);
202 void MSVCRT(perror)(const char*);
203 int MSVCRT(printf)(const char*,...);
204 int MSVCRT(putc)(int,MSVCRT(FILE)*);
205 int MSVCRT(putchar)(int);
206 int MSVCRT(puts)(const char*);
207 int MSVCRT(remove)(const char*);
208 int MSVCRT(rename)(const char*,const char*);
209 void MSVCRT(rewind)(MSVCRT(FILE)*);
210 int MSVCRT(scanf)(const char*,...);
211 void MSVCRT(setbuf)(MSVCRT(FILE)*,char*);
212 int MSVCRT(setvbuf)(MSVCRT(FILE)*,char*,int,MSVCRT(size_t));
213 int MSVCRT(sprintf)(char*,const char*,...);
214 int MSVCRT(sscanf)(const char*,const char*,...);
215 MSVCRT(FILE)* MSVCRT(tmpfile)(void);
216 char* MSVCRT(tmpnam)(char*);
217 int MSVCRT(ungetc)(int,MSVCRT(FILE)*);
218 int MSVCRT(vfprintf)(MSVCRT(FILE)*,const char*,va_list);
219 int MSVCRT(vprintf)(const char*,va_list);
220 int MSVCRT(vsprintf)(char*,const char*,va_list);
222 #ifndef MSVCRT_WSTDIO_DEFINED
223 #define MSVCRT_WSTDIO_DEFINED
224 MSVCRT(wint_t) _fgetwchar(void);
225 MSVCRT(wint_t) _fputwchar(MSVCRT(wint_t));
226 MSVCRT(wchar_t)*_getws(MSVCRT(wchar_t)*);
227 int _putws(const MSVCRT(wchar_t)*);
228 int _snwprintf(MSVCRT(wchar_t)*,MSVCRT(size_t),const MSVCRT(wchar_t)*,...);
229 int _vsnwprintf(MSVCRT(wchar_t)*,MSVCRT(size_t),const MSVCRT(wchar_t)*,va_list);
230 MSVCRT(FILE)* MSVCRT(_wfdopen)(int,const MSVCRT(wchar_t)*);
231 MSVCRT(FILE)* MSVCRT(_wfopen)(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*);
232 MSVCRT(FILE)* MSVCRT(_wfreopen)(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,MSVCRT(FILE)*);
233 MSVCRT(FILE)* MSVCRT(_wfsopen)(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,int);
234 void _wperror(const MSVCRT(wchar_t)*);
235 MSVCRT(FILE)* MSVCRT(_wpopen)(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*);
236 int _wremove(const MSVCRT(wchar_t)*);
237 MSVCRT(wchar_t)*_wtempnam(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*);
238 MSVCRT(wchar_t)*_wtmpnam(MSVCRT(wchar_t)*);
240 MSVCRT(wint_t) MSVCRT(fgetwc)(MSVCRT(FILE)*);
241 MSVCRT(wchar_t)*MSVCRT(fgetws)(MSVCRT(wchar_t)*,int,MSVCRT(FILE)*);
242 MSVCRT(wint_t) MSVCRT(fputwc)(MSVCRT(wint_t),MSVCRT(FILE)*);
243 int MSVCRT(fputws)(const MSVCRT(wchar_t)*,MSVCRT(FILE)*);
244 int MSVCRT(fwprintf)(MSVCRT(FILE)*,const MSVCRT(wchar_t)*,...);
245 int MSVCRT(fputws)(const MSVCRT(wchar_t)*,MSVCRT(FILE)*);
246 int MSVCRT(fwscanf)(MSVCRT(FILE)*,const MSVCRT(wchar_t)*,...);
247 MSVCRT(wint_t) MSVCRT(getwc)(MSVCRT(FILE)*);
248 MSVCRT(wint_t) MSVCRT(getwchar)(void);
249 MSVCRT(wchar_t)*MSVCRT(getws)(MSVCRT(wchar_t)*);
250 MSVCRT(wint_t) MSVCRT(putwc)(MSVCRT(wint_t),MSVCRT(FILE)*);
251 MSVCRT(wint_t) MSVCRT(putwchar)(MSVCRT(wint_t));
252 int MSVCRT(putws)(const MSVCRT(wchar_t)*);
253 int MSVCRT(swprintf)(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,...);
254 int MSVCRT(swscanf)(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,...);
255 MSVCRT(wint_t) MSVCRT(ungetwc)(MSVCRT(wint_t),MSVCRT(FILE)*);
256 int MSVCRT(vfwprintf)(MSVCRT(FILE)*,const MSVCRT(wchar_t)*,va_list);
257 int MSVCRT(vswprintf)(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,va_list);
258 int MSVCRT(vwprintf)(const MSVCRT(wchar_t)*,va_list);
259 int MSVCRT(wprintf)(const MSVCRT(wchar_t)*,...);
260 int MSVCRT(wscanf)(const MSVCRT(wchar_t)*,...);
261 #endif /* MSVCRT_WSTDIO_DEFINED */
263 #endif /* MSVCRT_STDIO_DEFINED */
265 #ifdef __cplusplus
267 #endif
270 #ifndef USE_MSVCRT_PREFIX
271 static inline MSVCRT(FILE)* fdopen(int fd, const char *mode) { return _fdopen(fd, mode); }
272 static inline int fgetchar(void) { return _fgetchar(); }
273 static inline int fileno(MSVCRT(FILE)* file) { return _fileno(file); }
274 static inline int fputchar(int c) { return _fputchar(c); }
275 static inline int pclose(MSVCRT(FILE)* file) { return _pclose(file); }
276 static inline MSVCRT(FILE)* popen(const char* command, const char* mode) { return _popen(command, mode); }
277 static inline char* tempnam(const char *dir, const char *prefix) { return _tempnam(dir, prefix); }
278 #ifndef MSVCRT_UNLINK_DEFINED
279 static inline int unlink(const char* path) { return _unlink(path); }
280 #define MSVCRT_UNLINK_DEFINED
281 #endif
282 static inline int vsnprintf(char *buffer, size_t size, const char *format, va_list args) { return _vsnprintf(buffer,size,format,args); }
284 static inline MSVCRT(wint_t) fgetwchar(void) { return _fgetwchar(); }
285 static inline MSVCRT(wint_t) fputwchar(MSVCRT(wint_t) wc) { return _fputwchar(wc); }
286 static inline int getw(MSVCRT(FILE)* file) { return _getw(file); }
287 static inline int putw(int val, MSVCRT(FILE)* file) { return _putw(val, file); }
288 static inline MSVCRT(FILE)* wpopen(const MSVCRT(wchar_t)* command,const MSVCRT(wchar_t)* mode) { return _wpopen(command, mode); }
289 #endif /* USE_MSVCRT_PREFIX */
291 #endif /* __WINE_STDIO_H */