stdio.h 9.01 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/*
 * Standard I/O definitions.
 *
 * Derived from the mingw header written by Colin Peters.
 * Modified for Wine use by Jon Griffiths and Francois Gouget.
 * This file is in the public domain.
 */
#ifndef __WINE_STDIO_H
#define __WINE_STDIO_H

11
#include <crtdefs.h>
12

13
#ifndef RC_INVOKED
14
#include <stdarg.h>
15
#endif
16

17
#include <pshpack8.h>
18

19
/* file._flag flags */
20 21 22 23 24 25 26
#define _IOREAD          0x0001
#define _IOWRT           0x0002
#define _IOMYBUF         0x0008
#define _IOEOF           0x0010
#define _IOERR           0x0020
#define _IOSTRG          0x0040
#define _IORW            0x0080
27

28 29 30 31 32 33 34
#ifndef NULL
#ifdef  __cplusplus
#define NULL  0
#else
#define NULL  ((void *)0)
#endif
#endif
35 36 37 38 39 40 41 42 43 44 45 46

#define STDIN_FILENO  0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2

/* more file._flag flags, but these conflict with Unix */
#define _IOFBF    0x0000
#define _IONBF    0x0004
#define _IOLBF    0x0040

#define EOF       (-1)
#define FILENAME_MAX 260
47
#define TMP_MAX   0x7fff
48 49 50 51 52 53 54 55 56 57 58
#define FOPEN_MAX 20
#define L_tmpnam  260

#define BUFSIZ    512

#ifndef SEEK_SET
#define SEEK_SET  0
#define SEEK_CUR  1
#define SEEK_END  2
#endif

59 60 61
#ifndef _FILE_DEFINED
#define _FILE_DEFINED
typedef struct _iobuf
62 63 64 65 66 67 68 69 70
{
  char* _ptr;
  int   _cnt;
  char* _base;
  int   _flag;
  int   _file;
  int   _charbuf;
  int   _bufsiz;
  char* _tmpfname;
71 72
} FILE;
#endif  /* _FILE_DEFINED */
73

74
#ifndef _FPOS_T_DEFINED
75
typedef __int64 DECLSPEC_ALIGN(8) fpos_t;
76
#define _FPOS_T_DEFINED
77
#endif
78 79 80 81 82

#ifdef __cplusplus
extern "C" {
#endif

83
#ifndef _STDIO_DEFINED
84 85 86 87
# ifdef __i386__
FILE* __cdecl __p__iob(void);
#  define _iob (__p__iob())
# else
88
FILE* __cdecl __iob_func(void);
89 90
#  define _iob (__iob_func())
# endif
91
#endif /* _STDIO_DEFINED */
92

93 94 95 96
#define stdin              (_iob+STDIN_FILENO)
#define stdout             (_iob+STDOUT_FILENO)
#define stderr             (_iob+STDERR_FILENO)

97 98 99
/* return value for _get_output_format */
#define _TWO_DIGIT_EXPONENT 0x1

100 101
#ifndef _STDIO_DEFINED
#define _STDIO_DEFINED
102 103 104 105 106 107 108 109 110
int    __cdecl _fcloseall(void);
FILE*  __cdecl _fdopen(int,const char*);
int    __cdecl _fgetchar(void);
int    __cdecl _filbuf(FILE*);
int    __cdecl _fileno(FILE*);
int    __cdecl _flsbuf(int,FILE*);
int    __cdecl _flushall(void);
int    __cdecl _fputchar(int);
FILE*  __cdecl _fsopen(const char*,const char*,int);
111
int    __cdecl _get_printf_count_output(void);
112 113 114 115 116 117
int    __cdecl _getmaxstdio(void);
int    __cdecl _getw(FILE*);
int    __cdecl _pclose(FILE*);
FILE*  __cdecl _popen(const char*,const char*);
int    __cdecl _putw(int,FILE*);
int    __cdecl _rmtmp(void);
118
int    __cdecl _set_printf_count_output(int);
119 120
int    __cdecl _setmaxstdio(int);
int    __cdecl _snprintf(char*,size_t,const char*,...);
121
int    __cdecl _snprintf_s(char*,size_t,size_t,const char*,...);
122 123
char*  __cdecl _tempnam(const char*,const char*);
int    __cdecl _unlink(const char*);
124
int    __cdecl _vscprintf(const char*,__ms_va_list);
125
int    __cdecl _vsnprintf(char*,size_t,const char*,__ms_va_list);
126
int    __cdecl _vsnprintf_s(char*,size_t,size_t,const char*,__ms_va_list);
127 128 129 130 131 132 133 134 135 136

void   __cdecl clearerr(FILE*);
int    __cdecl fclose(FILE*);
int    __cdecl feof(FILE*);
int    __cdecl ferror(FILE*);
int    __cdecl fflush(FILE*);
int    __cdecl fgetc(FILE*);
int    __cdecl fgetpos(FILE*,fpos_t*);
char*  __cdecl fgets(char*,int,FILE*);
FILE*  __cdecl fopen(const char*,const char*);
137
errno_t __cdecl fopen_s(FILE**,const char*,const char*);
138
int    __cdecl fprintf(FILE*,const char*,...);
139
int    __cdecl fprintf_s(FILE*,const char*,...);
140 141 142 143 144
int    __cdecl fputc(int,FILE*);
int    __cdecl fputs(const char*,FILE*);
size_t __cdecl fread(void*,size_t,size_t,FILE*);
FILE*  __cdecl freopen(const char*,const char*,FILE*);
int    __cdecl fscanf(FILE*,const char*,...);
145
int    __cdecl fscanf_s(FILE*,const char*,...);
146
int    __cdecl fseek(FILE*,__msvcrt_long,int);
147
int    __cdecl _fseeki64(FILE*,__int64,int);
148
int    __cdecl fsetpos(FILE*,fpos_t*);
149
__msvcrt_long __cdecl ftell(FILE*);
150
__int64 __cdecl _ftelli64(FILE*);
151 152 153 154 155 156
size_t __cdecl fwrite(const void*,size_t,size_t,FILE*);
int    __cdecl getc(FILE*);
int    __cdecl getchar(void);
char*  __cdecl gets(char*);
void   __cdecl perror(const char*);
int    __cdecl printf(const char*,...);
157
int    __cdecl printf_s(const char*,...);
158 159 160 161 162 163 164
int    __cdecl putc(int,FILE*);
int    __cdecl putchar(int);
int    __cdecl puts(const char*);
int    __cdecl remove(const char*);
int    __cdecl rename(const char*,const char*);
void   __cdecl rewind(FILE*);
int    __cdecl scanf(const char*,...);
165
int    __cdecl scanf_s(const char*,...);
166 167 168
void   __cdecl setbuf(FILE*,char*);
int    __cdecl setvbuf(FILE*,char*,int,size_t);
int    __cdecl sprintf(char*,const char*,...);
169
int    __cdecl sprintf_s(char*,size_t,const char*,...);
170
int    __cdecl sscanf(const char*,const char*,...);
171
int    __cdecl sscanf_s(const char*,const char*,...);
172 173 174
FILE*  __cdecl tmpfile(void);
char*  __cdecl tmpnam(char*);
int    __cdecl ungetc(int,FILE*);
175
int    __cdecl vfprintf(FILE*,const char*,__ms_va_list);
176
int    __cdecl vfprintf_s(FILE*,const char*,__ms_va_list);
177
int    __cdecl vprintf(const char*,__ms_va_list);
178
int    __cdecl vprintf_s(const char*,__ms_va_list);
179
int    __cdecl vsprintf(char*,const char*,__ms_va_list);
180
int    __cdecl vsprintf_s(char*,size_t,const char*,__ms_va_list);
181
unsigned int __cdecl _get_output_format(void);
182 183 184

#ifndef _WSTDIO_DEFINED
#define _WSTDIO_DEFINED
185 186 187 188 189
wint_t   __cdecl _fgetwchar(void);
wint_t   __cdecl _fputwchar(wint_t);
wchar_t* __cdecl _getws(wchar_t*);
int      __cdecl _putws(const wchar_t*);
int      __cdecl _snwprintf(wchar_t*,size_t,const wchar_t*,...);
190
int      __cdecl _snwprintf_s(wchar_t*,size_t,size_t,const wchar_t*,...);
191
int      __cdecl _vscwprintf(const wchar_t*,__ms_va_list);
192
int      __cdecl _vsnwprintf(wchar_t*,size_t,const wchar_t*,__ms_va_list);
193
int      __cdecl _vsnwprintf_s(wchar_t*,size_t,size_t,const wchar_t*,__ms_va_list);
194
int      __cdecl _vswprintf_p_l(wchar_t*,size_t,const wchar_t*,_locale_t,__ms_va_list);
195 196
FILE*    __cdecl _wfdopen(int,const wchar_t*);
FILE*    __cdecl _wfopen(const wchar_t*,const wchar_t*);
197
errno_t  __cdecl _wfopen_s(FILE**,const wchar_t*,const wchar_t*);
198 199 200 201 202 203 204 205 206 207 208 209 210
FILE*    __cdecl _wfreopen(const wchar_t*,const wchar_t*,FILE*);
FILE*    __cdecl _wfsopen(const wchar_t*,const wchar_t*,int);
void     __cdecl _wperror(const wchar_t*);
FILE*    __cdecl _wpopen(const wchar_t*,const wchar_t*);
int      __cdecl _wremove(const wchar_t*);
wchar_t* __cdecl _wtempnam(const wchar_t*,const wchar_t*);
wchar_t* __cdecl _wtmpnam(wchar_t*);

wint_t   __cdecl fgetwc(FILE*);
wchar_t* __cdecl fgetws(wchar_t*,int,FILE*);
wint_t   __cdecl fputwc(wint_t,FILE*);
int      __cdecl fputws(const wchar_t*,FILE*);
int      __cdecl fwprintf(FILE*,const wchar_t*,...);
211
int      __cdecl fwprintf_s(FILE*,const wchar_t*,...);
212 213
int      __cdecl fputws(const wchar_t*,FILE*);
int      __cdecl fwscanf(FILE*,const wchar_t*,...);
214
int      __cdecl fwscanf_s(FILE*,const wchar_t*,...);
215 216 217 218 219 220 221
wint_t   __cdecl getwc(FILE*);
wint_t   __cdecl getwchar(void);
wchar_t* __cdecl getws(wchar_t*);
wint_t   __cdecl putwc(wint_t,FILE*);
wint_t   __cdecl putwchar(wint_t);
int      __cdecl putws(const wchar_t*);
int      __cdecl swprintf(wchar_t*,const wchar_t*,...);
222
int      __cdecl swprintf_s(wchar_t*,size_t,const wchar_t*,...);
223
int      __cdecl swscanf(const wchar_t*,const wchar_t*,...);
224
int      __cdecl swscanf_s(const wchar_t*,const wchar_t*,...);
225
wint_t   __cdecl ungetwc(wint_t,FILE*);
226
int      __cdecl vfwprintf(FILE*,const wchar_t*,__ms_va_list);
227
int      __cdecl vfwprintf_s(FILE*,const wchar_t*,__ms_va_list);
228
int      __cdecl vswprintf(wchar_t*,const wchar_t*,__ms_va_list);
229
int      __cdecl vswprintf_s(wchar_t*,size_t,const wchar_t*,__ms_va_list);
230
int      __cdecl vwprintf(const wchar_t*,__ms_va_list);
231
int      __cdecl vwprintf_s(const wchar_t*,__ms_va_list);
232
int      __cdecl wprintf(const wchar_t*,...);
233
int      __cdecl wprintf_s(const wchar_t*,...);
234
int      __cdecl wscanf(const wchar_t*,...);
235
int      __cdecl wscanf_s(const wchar_t*,...);
236 237 238
#endif /* _WSTDIO_DEFINED */

#endif /* _STDIO_DEFINED */
239 240 241 242 243 244

#ifdef __cplusplus
}
#endif


245
static inline FILE* fdopen(int fd, const char *mode) { return _fdopen(fd, mode); }
246
static inline int fgetchar(void) { return _fgetchar(); }
247
static inline int fileno(FILE* file) { return _fileno(file); }
248
static inline int fputchar(int c) { return _fputchar(c); }
249 250
static inline int pclose(FILE* file) { return _pclose(file); }
static inline FILE* popen(const char* command, const char* mode) { return _popen(command, mode); }
251
static inline char* tempnam(const char *dir, const char *prefix) { return _tempnam(dir, prefix); }
252
#ifndef _UNLINK_DEFINED
253
static inline int unlink(const char* path) { return _unlink(path); }
254
#define _UNLINK_DEFINED
255
#endif
256
static inline int vsnprintf(char *buffer, size_t size, const char *format, __ms_va_list args) { return _vsnprintf(buffer,size,format,args); }
257

258 259 260 261 262
static inline wint_t fgetwchar(void) { return _fgetwchar(); }
static inline wint_t fputwchar(wint_t wc) { return _fputwchar(wc); }
static inline int getw(FILE* file) { return _getw(file); }
static inline int putw(int val, FILE* file) { return _putw(val, file); }
static inline FILE* wpopen(const wchar_t* command,const wchar_t* mode) { return _wpopen(command, mode); }
263

264 265
#include <poppack.h>

266
#endif /* __WINE_STDIO_H */