Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 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 |
Jon Griffiths | 5f17550 | 2003-07-18 22:57:15 +0000 | [diff] [blame] | 10 | #ifndef __WINE_USE_MSVCRT |
Francois Gouget | a45907c | 2001-10-22 18:59:23 +0000 | [diff] [blame] | 11 | #define __WINE_USE_MSVCRT |
Jon Griffiths | 5f17550 | 2003-07-18 22:57:15 +0000 | [diff] [blame] | 12 | #endif |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 13 | |
Dmitry Timoshkov | 2af96fe | 2007-02-20 16:35:41 +0800 | [diff] [blame] | 14 | #include <pshpack8.h> |
| 15 | |
Francois Gouget | fcba601 | 2001-05-07 18:18:33 +0000 | [diff] [blame] | 16 | #ifndef RC_INVOKED |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 17 | #include <stdarg.h> |
Francois Gouget | fcba601 | 2001-05-07 18:18:33 +0000 | [diff] [blame] | 18 | #endif |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 19 | |
Alexandre Julliard | 9abd885 | 2006-10-16 21:29:23 +0200 | [diff] [blame] | 20 | #if defined(__x86_64__) && !defined(_WIN64) |
| 21 | #define _WIN64 |
| 22 | #endif |
| 23 | |
Dmitry Timoshkov | 70015ab | 2007-06-06 20:12:57 +0900 | [diff] [blame] | 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 | |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 32 | /* file._flag flags */ |
Francois Gouget | 0a26d42 | 2001-10-15 17:50:55 +0000 | [diff] [blame] | 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 |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 40 | |
Alexandre Julliard | 3f5ff2f | 2002-12-18 20:17:20 +0000 | [diff] [blame] | 41 | #ifndef NULL |
| 42 | #ifdef __cplusplus |
| 43 | #define NULL 0 |
| 44 | #else |
| 45 | #define NULL ((void *)0) |
| 46 | #endif |
| 47 | #endif |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 48 | |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 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 |
Pavel Roskin | 9661d05 | 2003-10-24 00:23:51 +0000 | [diff] [blame] | 60 | #define TMP_MAX 0x7fff |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 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 | |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 72 | #ifndef _FILE_DEFINED |
| 73 | #define _FILE_DEFINED |
| 74 | typedef struct _iobuf |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 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; |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 84 | } FILE; |
| 85 | #endif /* _FILE_DEFINED */ |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 86 | |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 87 | #ifndef _FPOS_T_DEFINED |
Lionel Ulmer | cc89feb | 2005-01-04 20:38:14 +0000 | [diff] [blame] | 88 | typedef __int64 fpos_t; |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 89 | #define _FPOS_T_DEFINED |
Alexandre Julliard | 3f5ff2f | 2002-12-18 20:17:20 +0000 | [diff] [blame] | 90 | #endif |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 91 | |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 92 | #ifndef _SIZE_T_DEFINED |
Alexandre Julliard | 9452927 | 2006-07-10 12:28:25 +0200 | [diff] [blame] | 93 | #ifdef _WIN64 |
| 94 | typedef unsigned __int64 size_t; |
| 95 | #else |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 96 | typedef unsigned int size_t; |
Alexandre Julliard | 9452927 | 2006-07-10 12:28:25 +0200 | [diff] [blame] | 97 | #endif |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 98 | #define _SIZE_T_DEFINED |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 99 | #endif |
| 100 | |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 101 | #ifndef _WCHAR_T_DEFINED |
| 102 | #define _WCHAR_T_DEFINED |
Alexandre Julliard | 3f5ff2f | 2002-12-18 20:17:20 +0000 | [diff] [blame] | 103 | #ifndef __cplusplus |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 104 | typedef unsigned short wchar_t; |
Alexandre Julliard | 3f5ff2f | 2002-12-18 20:17:20 +0000 | [diff] [blame] | 105 | #endif |
| 106 | #endif |
| 107 | |
Dimitrie O. Paun | adb4cb3 | 2004-04-26 23:31:39 +0000 | [diff] [blame] | 108 | #ifndef _WCTYPE_T_DEFINED |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 109 | typedef unsigned short wint_t; |
| 110 | typedef unsigned short wctype_t; |
Dimitrie O. Paun | adb4cb3 | 2004-04-26 23:31:39 +0000 | [diff] [blame] | 111 | #define _WCTYPE_T_DEFINED |
Alexandre Julliard | 3f5ff2f | 2002-12-18 20:17:20 +0000 | [diff] [blame] | 112 | #endif |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 113 | |
| 114 | #ifdef __cplusplus |
| 115 | extern "C" { |
| 116 | #endif |
| 117 | |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 118 | #ifndef _STDIO_DEFINED |
| 119 | FILE* __p__iob(void); |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 120 | #define _iob (__p__iob()) |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 121 | #endif /* _STDIO_DEFINED */ |
Alexandre Julliard | 3f5ff2f | 2002-12-18 20:17:20 +0000 | [diff] [blame] | 122 | |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 123 | #define stdin (_iob+STDIN_FILENO) |
| 124 | #define stdout (_iob+STDOUT_FILENO) |
| 125 | #define stderr (_iob+STDERR_FILENO) |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 126 | |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 127 | #ifndef _STDIO_DEFINED |
| 128 | #define _STDIO_DEFINED |
| 129 | int _fcloseall(void); |
| 130 | FILE* _fdopen(int,const char*); |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 131 | int _fgetchar(void); |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 132 | int _filbuf(FILE*); |
| 133 | int _fileno(FILE*); |
| 134 | int _flsbuf(int,FILE*); |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 135 | int _flushall(void); |
| 136 | int _fputchar(int); |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 137 | FILE* _fsopen(const char*,const char*,int); |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 138 | int _getmaxstdio(void); |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 139 | int _getw(FILE*); |
| 140 | int _pclose(FILE*); |
| 141 | FILE* _popen(const char*,const char*); |
| 142 | int _putw(int,FILE*); |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 143 | int _rmtmp(void); |
| 144 | int _setmaxstdio(int); |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 145 | int _snprintf(char*,size_t,const char*,...); |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 146 | char* _tempnam(const char*,const char*); |
| 147 | int _unlink(const char*); |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 148 | int _vsnprintf(char*,size_t,const char*,va_list); |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 149 | |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 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); |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 191 | |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 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*); |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 209 | |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 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 */ |
Alexandre Julliard | 3f5ff2f | 2002-12-18 20:17:20 +0000 | [diff] [blame] | 232 | |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 233 | #endif /* _STDIO_DEFINED */ |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 234 | |
| 235 | #ifdef __cplusplus |
| 236 | } |
| 237 | #endif |
| 238 | |
| 239 | |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 240 | static inline FILE* fdopen(int fd, const char *mode) { return _fdopen(fd, mode); } |
Madhura Sahasrabudhe | 992d1b9 | 2003-03-22 21:15:41 +0000 | [diff] [blame] | 241 | static inline int fgetchar(void) { return _fgetchar(); } |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 242 | static inline int fileno(FILE* file) { return _fileno(file); } |
Madhura Sahasrabudhe | 992d1b9 | 2003-03-22 21:15:41 +0000 | [diff] [blame] | 243 | static inline int fputchar(int c) { return _fputchar(c); } |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 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); } |
Madhura Sahasrabudhe | 992d1b9 | 2003-03-22 21:15:41 +0000 | [diff] [blame] | 246 | static inline char* tempnam(const char *dir, const char *prefix) { return _tempnam(dir, prefix); } |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 247 | #ifndef _UNLINK_DEFINED |
Dimitrie O. Paun | df9537e | 2003-01-11 22:49:54 +0000 | [diff] [blame] | 248 | static inline int unlink(const char* path) { return _unlink(path); } |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 249 | #define _UNLINK_DEFINED |
Dimitrie O. Paun | df9537e | 2003-01-11 22:49:54 +0000 | [diff] [blame] | 250 | #endif |
Dimitrie O. Paun | 2703584 | 2003-08-13 22:01:12 +0000 | [diff] [blame] | 251 | static inline int vsnprintf(char *buffer, size_t size, const char *format, va_list args) { return _vsnprintf(buffer,size,format,args); } |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 252 | |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 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); } |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 258 | |
Dmitry Timoshkov | 2af96fe | 2007-02-20 16:35:41 +0800 | [diff] [blame] | 259 | #include <poppack.h> |
| 260 | |
Francois Gouget | eee695d | 2001-04-10 23:21:43 +0000 | [diff] [blame] | 261 | #endif /* __WINE_STDIO_H */ |