include: Fix the C_ASSERT macro to not generate an unused variable warning when compi...
[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 #include <pshpack8.h>
15
16 #ifndef RC_INVOKED
17 #include <stdarg.h>
18 #endif
19
20 #if defined(__x86_64__) && !defined(_WIN64)
21 #define _WIN64
22 #endif
23
24 #if !defined(_MSC_VER) && !defined(__int64)
25 # ifdef _WIN64
26 #   define __int64 long
27 # else
28 #   define __int64 long long
29 # endif
30 #endif
31
32 /* file._flag flags */
33 #define _IOREAD          0x0001
34 #define _IOWRT           0x0002
35 #define _IOMYBUF         0x0008
36 #define _IOEOF           0x0010
37 #define _IOERR           0x0020
38 #define _IOSTRG          0x0040
39 #define _IORW            0x0080
40
41 #ifndef NULL
42 #ifdef  __cplusplus
43 #define NULL  0
44 #else
45 #define NULL  ((void *)0)
46 #endif
47 #endif
48
49 #define STDIN_FILENO  0
50 #define STDOUT_FILENO 1
51 #define STDERR_FILENO 2
52
53 /* more file._flag flags, but these conflict with Unix */
54 #define _IOFBF    0x0000
55 #define _IONBF    0x0004
56 #define _IOLBF    0x0040
57
58 #define EOF       (-1)
59 #define FILENAME_MAX 260
60 #define TMP_MAX   0x7fff
61 #define FOPEN_MAX 20
62 #define L_tmpnam  260
63
64 #define BUFSIZ    512
65
66 #ifndef SEEK_SET
67 #define SEEK_SET  0
68 #define SEEK_CUR  1
69 #define SEEK_END  2
70 #endif
71
72 #ifndef _FILE_DEFINED
73 #define _FILE_DEFINED
74 typedef struct _iobuf
75 {
76   char* _ptr;
77   int   _cnt;
78   char* _base;
79   int   _flag;
80   int   _file;
81   int   _charbuf;
82   int   _bufsiz;
83   char* _tmpfname;
84 } FILE;
85 #endif  /* _FILE_DEFINED */
86
87 #ifndef _FPOS_T_DEFINED
88 typedef __int64 fpos_t;
89 #define _FPOS_T_DEFINED
90 #endif
91
92 #ifndef _SIZE_T_DEFINED
93 #ifdef _WIN64
94 typedef unsigned __int64 size_t;
95 #else
96 typedef unsigned int size_t;
97 #endif
98 #define _SIZE_T_DEFINED
99 #endif
100
101 #ifndef _WCHAR_T_DEFINED
102 #define _WCHAR_T_DEFINED
103 #ifndef __cplusplus
104 typedef unsigned short wchar_t;
105 #endif
106 #endif
107
108 #ifndef _WCTYPE_T_DEFINED
109 typedef unsigned short  wint_t;
110 typedef unsigned short  wctype_t;
111 #define _WCTYPE_T_DEFINED
112 #endif
113
114 #ifdef __cplusplus
115 extern "C" {
116 #endif
117
118 #ifndef _STDIO_DEFINED
119 FILE*        __p__iob(void);
120 #define _iob               (__p__iob())
121 #endif /* _STDIO_DEFINED */
122
123 #define stdin              (_iob+STDIN_FILENO)
124 #define stdout             (_iob+STDOUT_FILENO)
125 #define stderr             (_iob+STDERR_FILENO)
126
127 #ifndef _STDIO_DEFINED
128 #define _STDIO_DEFINED
129 int         _fcloseall(void);
130 FILE* _fdopen(int,const char*);
131 int         _fgetchar(void);
132 int         _filbuf(FILE*);
133 int         _fileno(FILE*);
134 int         _flsbuf(int,FILE*);
135 int         _flushall(void);
136 int         _fputchar(int);
137 FILE* _fsopen(const char*,const char*,int);
138 int         _getmaxstdio(void);
139 int         _getw(FILE*);
140 int         _pclose(FILE*);
141 FILE* _popen(const char*,const char*);
142 int         _putw(int,FILE*);
143 int         _rmtmp(void);
144 int         _setmaxstdio(int);
145 int         _snprintf(char*,size_t,const char*,...);
146 char*       _tempnam(const char*,const char*);
147 int         _unlink(const char*);
148 int         _vsnprintf(char*,size_t,const char*,va_list);
149
150 void        clearerr(FILE*);
151 int         fclose(FILE*);
152 int         feof(FILE*);
153 int         ferror(FILE*);
154 int         fflush(FILE*);
155 int         fgetc(FILE*);
156 int         fgetpos(FILE*,fpos_t*);
157 char*       fgets(char*,int,FILE*);
158 FILE* fopen(const char*,const char*);
159 int         fprintf(FILE*,const char*,...);
160 int         fputc(int,FILE*);
161 int         fputs(const char*,FILE*);
162 size_t fread(void*,size_t,size_t,FILE*);
163 FILE* freopen(const char*,const char*,FILE*);
164 int         fscanf(FILE*,const char*,...);
165 int         fseek(FILE*,long,int);
166 int         fsetpos(FILE*,fpos_t*);
167 long        ftell(FILE*);
168 size_t fwrite(const void*,size_t,size_t,FILE*);
169 int         getc(FILE*);
170 int         getchar(void);
171 char*       gets(char*);
172 void        perror(const char*);
173 int         printf(const char*,...);
174 int         putc(int,FILE*);
175 int         putchar(int);
176 int         puts(const char*);
177 int         remove(const char*);
178 int         rename(const char*,const char*);
179 void        rewind(FILE*);
180 int         scanf(const char*,...);
181 void        setbuf(FILE*,char*);
182 int         setvbuf(FILE*,char*,int,size_t);
183 int         sprintf(char*,const char*,...);
184 int         sscanf(const char*,const char*,...);
185 FILE* tmpfile(void);
186 char*       tmpnam(char*);
187 int         ungetc(int,FILE*);
188 int         vfprintf(FILE*,const char*,va_list);
189 int         vprintf(const char*,va_list);
190 int         vsprintf(char*,const char*,va_list);
191
192 #ifndef _WSTDIO_DEFINED
193 #define _WSTDIO_DEFINED
194 wint_t  _fgetwchar(void);
195 wint_t  _fputwchar(wint_t);
196 wchar_t*_getws(wchar_t*);
197 int             _putws(const wchar_t*);
198 int             _snwprintf(wchar_t*,size_t,const wchar_t*,...);
199 int             _vsnwprintf(wchar_t*,size_t,const wchar_t*,va_list);
200 FILE*   _wfdopen(int,const wchar_t*);
201 FILE*   _wfopen(const wchar_t*,const wchar_t*);
202 FILE*   _wfreopen(const wchar_t*,const wchar_t*,FILE*);
203 FILE*   _wfsopen(const wchar_t*,const wchar_t*,int);
204 void            _wperror(const wchar_t*);
205 FILE*   _wpopen(const wchar_t*,const wchar_t*);
206 int             _wremove(const wchar_t*);
207 wchar_t*_wtempnam(const wchar_t*,const wchar_t*);
208 wchar_t*_wtmpnam(wchar_t*);
209
210 wint_t  fgetwc(FILE*);
211 wchar_t*fgetws(wchar_t*,int,FILE*);
212 wint_t  fputwc(wint_t,FILE*);
213 int             fputws(const wchar_t*,FILE*);
214 int             fwprintf(FILE*,const wchar_t*,...);
215 int             fputws(const wchar_t*,FILE*);
216 int             fwscanf(FILE*,const wchar_t*,...);
217 wint_t  getwc(FILE*);
218 wint_t  getwchar(void);
219 wchar_t*getws(wchar_t*);
220 wint_t  putwc(wint_t,FILE*);
221 wint_t  putwchar(wint_t);
222 int             putws(const wchar_t*);
223 int             swprintf(wchar_t*,const wchar_t*,...);
224 int             swscanf(const wchar_t*,const wchar_t*,...);
225 wint_t  ungetwc(wint_t,FILE*);
226 int             vfwprintf(FILE*,const wchar_t*,va_list);
227 int             vswprintf(wchar_t*,const wchar_t*,va_list);
228 int             vwprintf(const wchar_t*,va_list);
229 int             wprintf(const wchar_t*,...);
230 int             wscanf(const wchar_t*,...);
231 #endif /* _WSTDIO_DEFINED */
232
233 #endif /* _STDIO_DEFINED */
234
235 #ifdef __cplusplus
236 }
237 #endif
238
239
240 static inline FILE* fdopen(int fd, const char *mode) { return _fdopen(fd, mode); }
241 static inline int fgetchar(void) { return _fgetchar(); }
242 static inline int fileno(FILE* file) { return _fileno(file); }
243 static inline int fputchar(int c) { return _fputchar(c); }
244 static inline int pclose(FILE* file) { return _pclose(file); }
245 static inline FILE* popen(const char* command, const char* mode) { return _popen(command, mode); }
246 static inline char* tempnam(const char *dir, const char *prefix) { return _tempnam(dir, prefix); }
247 #ifndef _UNLINK_DEFINED
248 static inline int unlink(const char* path) { return _unlink(path); }
249 #define _UNLINK_DEFINED
250 #endif
251 static inline int vsnprintf(char *buffer, size_t size, const char *format, va_list args) { return _vsnprintf(buffer,size,format,args); }
252
253 static inline wint_t fgetwchar(void) { return _fgetwchar(); }
254 static inline wint_t fputwchar(wint_t wc) { return _fputwchar(wc); }
255 static inline int getw(FILE* file) { return _getw(file); }
256 static inline int putw(int val, FILE* file) { return _putw(val, file); }
257 static inline FILE* wpopen(const wchar_t* command,const wchar_t* mode) { return _wpopen(command, mode); }
258
259 #include <poppack.h>
260
261 #endif /* __WINE_STDIO_H */