Hi Alexandre, Welcome back! I did this last Friday, but I didn't want to continue before running it by you. I'm sending here just the first cut of the definitions I needed to duplicate in msvcrt.h, to compile the entire msvcrt DLL without the MSVCRT() define in the public headers.
Looking at the changes it seems to me: 1. There aren't that many 2. We can easily add a test file to check for consistency with the public headers (ideally, this file would be automatically generated by a script) 3. We should be able to actually drop some of them, this is just the first cut, and I've tried to keep the number of changes to the source code to a minimum. Should I carry on? -- Dimi. Index: dlls/msvcrt/msvcrt.h =================================================================== RCS file: /var/cvs/wine/dlls/msvcrt/msvcrt.h,v retrieving revision 1.25 diff -u -r1.25 msvcrt.h --- dlls/msvcrt/msvcrt.h 16 Mar 2004 19:17:11 -0000 1.25 +++ dlls/msvcrt/msvcrt.h 4 Jun 2004 23:05:05 -0000 @@ -28,8 +28,27 @@ #include "winerror.h" #include "winnls.h" -#include "msvcrt/string.h" -#include "msvcrt/eh.h" +typedef unsigned short MSVCRT_wchar_t; +typedef unsigned short MSVCRT_wint_t; +typedef unsigned short MSVCRT_wctype_t; +typedef unsigned short MSVCRT__ino_t; +typedef unsigned long MSVCRT__fsize_t; +typedef unsigned int MSVCRT_size_t; +typedef unsigned int MSVCRT__dev_t; +typedef int MSVCRT__off_t; +typedef long MSVCRT_clock_t; +typedef long MSVCRT_time_t; +typedef long MSVCRT_fpos_t; + +typedef void (*terminate_handler)(); +typedef void (*terminate_function)(); +typedef void (*unexpected_handler)(); +typedef void (*unexpected_function)(); +typedef void (*_se_translator_function)(unsigned int code, struct _EXCEPTION_POINTERS *info); +typedef void (*_beginthread_start_routine_t)(void *); +typedef unsigned int (__stdcall *_beginthreadex_start_routine_t)(void *); +typedef int (*MSVCRT__onexit_t)(void); + /* TLS data */ extern DWORD MSVCRT_tls_index; @@ -123,4 +142,363 @@ #define _RT_CRNL 252 #define _RT_BANNER 255 +struct MSVCRT_tm { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; +}; + +struct _timeb +{ + MSVCRT_time_t time; + unsigned short millitm; + short timezone; + short dstflag; +}; + +typedef struct MSVCRT_iobuf +{ + char* _ptr; + int _cnt; + char* _base; + int _flag; + int _file; + int _charbuf; + int _bufsiz; + char* _tmpfname; +} MSVCRT_FILE; + +struct MSVCRT_lconv +{ + char* decimal_point; + char* thousands_sep; + char* grouping; + char* int_curr_symbol; + char* currency_symbol; + char* mon_decimal_point; + char* mon_thousands_sep; + char* mon_grouping; + char* positive_sign; + char* negative_sign; + char int_frac_digits; + char frac_digits; + char p_cs_precedes; + char p_sep_by_space; + char n_cs_precedes; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; +}; + +struct MSVCRT__exception +{ + int type; + char *name; + double arg1; + double arg2; + double retval; +}; + +struct MSVCRT__complex +{ + double x; /* Real part */ + double y; /* Imaginary part */ +}; + +typedef struct _heapinfo +{ + int* _pentry; + MSVCRT_size_t _size; + int _useflag; +} _HEAPINFO; + +#ifdef __i386__ +typedef struct __JUMP_BUFFER +{ + unsigned long Ebp; + unsigned long Ebx; + unsigned long Edi; + unsigned long Esi; + unsigned long Esp; + unsigned long Eip; + unsigned long Registration; + unsigned long TryLevel; + /* Start of new struct members */ + unsigned long Cookie; + unsigned long UnwindFunc; + unsigned long UnwindData[6]; +} _JUMP_BUFFER; +#endif /* __i386__ */ + +struct MSVCRT__diskfree_t { + unsigned int total_clusters; + unsigned int avail_clusters; + unsigned int sectors_per_cluster; + unsigned int bytes_per_sector; +}; + +struct MSVCRT__finddata_t +{ + unsigned attrib; + MSVCRT_time_t time_create; + MSVCRT_time_t time_access; + MSVCRT_time_t time_write; + MSVCRT__fsize_t size; + char name[260]; +}; + +struct MSVCRT__finddatai64_t +{ + unsigned attrib; + MSVCRT_time_t time_create; + MSVCRT_time_t time_access; + MSVCRT_time_t time_write; + __int64 size; + char name[260]; +}; + +struct MSVCRT__wfinddata_t { + unsigned attrib; + MSVCRT_time_t time_create; + MSVCRT_time_t time_access; + MSVCRT_time_t time_write; + MSVCRT__fsize_t size; + MSVCRT_wchar_t name[260]; +}; + +struct MSVCRT__wfinddatai64_t { + unsigned attrib; + MSVCRT_time_t time_create; + MSVCRT_time_t time_access; + MSVCRT_time_t time_write; + __int64 size; + MSVCRT_wchar_t name[260]; +}; + +struct _utimbuf +{ + MSVCRT_time_t actime; + MSVCRT_time_t modtime; +}; + +/* for FreeBSD */ +#undef st_atime +#undef st_ctime +#undef st_mtime + +struct MSVCRT__stat { + MSVCRT__dev_t st_dev; + MSVCRT__ino_t st_ino; + unsigned short st_mode; + short st_nlink; + short st_uid; + short st_gid; + MSVCRT__dev_t st_rdev; + MSVCRT__off_t st_size; + MSVCRT_time_t st_atime; + MSVCRT_time_t st_mtime; + MSVCRT_time_t st_ctime; +}; + +struct MSVCRT_stat { + MSVCRT__dev_t st_dev; + MSVCRT__ino_t st_ino; + unsigned short st_mode; + short st_nlink; + short st_uid; + short st_gid; + MSVCRT__dev_t st_rdev; + MSVCRT__off_t st_size; + MSVCRT_time_t st_atime; + MSVCRT_time_t st_mtime; + MSVCRT_time_t st_ctime; +}; + +struct MSVCRT__stati64 { + MSVCRT__dev_t st_dev; + MSVCRT__ino_t st_ino; + unsigned short st_mode; + short st_nlink; + short st_uid; + short st_gid; + MSVCRT__dev_t st_rdev; + __int64 st_size; + MSVCRT_time_t st_atime; + MSVCRT_time_t st_mtime; + MSVCRT_time_t st_ctime; +}; + +#define MSVCRT_WEOF (MSVCRT_wint_t)(0xFFFF) +#define MSVCRT_EOF (-1) +#define MSVCRT_TMP_MAX 0x7fff +#define MSVCRT_BUFSIZ 512 + +#define MSVCRT_STDIN_FILENO 0 +#define MSVCRT_STDOUT_FILENO 1 +#define MSVCRT_STDERR_FILENO 2 + +/* more file._flag flags, but these conflict with Unix */ +#define MSVCRT__IOFBF 0x0000 +#define MSVCRT__IONBF 0x0004 +#define MSVCRT__IOLBF 0x0040 + +#define MSVCRT_FILENAME_MAX 260 +#define MSVCRT_stdin (MSVCRT__iob+MSVCRT_STDIN_FILENO) +#define MSVCRT_stdout (MSVCRT__iob+MSVCRT_STDOUT_FILENO) +#define MSVCRT_stderr (MSVCRT__iob+MSVCRT_STDERR_FILENO) + +#define _P_WAIT 0 +#define _P_NOWAIT 1 +#define _P_OVERLAY 2 +#define _P_NOWAITO 3 +#define _P_DETACH 4 + +#define MSVCRT_EPERM 1 +#define MSVCRT_ENOENT 2 +#define MSVCRT_ESRCH 3 +#define MSVCRT_EINTR 4 +#define MSVCRT_EIO 5 +#define MSVCRT_ENXIO 6 +#define MSVCRT_E2BIG 7 +#define MSVCRT_ENOEXEC 8 +#define MSVCRT_EBADF 9 +#define MSVCRT_ECHILD 10 +#define MSVCRT_EAGAIN 11 +#define MSVCRT_ENOMEM 12 +#define MSVCRT_EACCES 13 +#define MSVCRT_EFAULT 14 +#define MSVCRT_EBUSY 16 +#define MSVCRT_EEXIST 17 +#define MSVCRT_EXDEV 18 +#define MSVCRT_ENODEV 19 +#define MSVCRT_ENOTDIR 20 +#define MSVCRT_EISDIR 21 +#define MSVCRT_EINVAL 22 +#define MSVCRT_ENFILE 23 +#define MSVCRT_EMFILE 24 +#define MSVCRT_ENOTTY 25 +#define MSVCRT_EFBIG 27 +#define MSVCRT_ENOSPC 28 +#define MSVCRT_ESPIPE 29 +#define MSVCRT_EROFS 30 +#define MSVCRT_EMLINK 31 +#define MSVCRT_EPIPE 32 +#define MSVCRT_EDOM 33 +#define MSVCRT_ERANGE 34 +#define MSVCRT_EDEADLK 36 +#define MSVCRT_EDEADLOCK MSVCRT_EDEADLK +#define MSVCRT_ENAMETOOLONG 38 +#define MSVCRT_ENOLCK 39 +#define MSVCRT_ENOSYS 40 +#define MSVCRT_ENOTEMPTY 41 + +#define MSVCRT_LC_ALL 0 +#define MSVCRT_LC_COLLATE 1 +#define MSVCRT_LC_CTYPE 2 +#define MSVCRT_LC_MONETARY 3 +#define MSVCRT_LC_NUMERIC 4 +#define MSVCRT_LC_TIME 5 +#define MSVCRT_LC_MIN MSVCRT_LC_ALL +#define MSVCRT_LC_MAX MSVCRT_LC_TIME + +#define _HEAPEMPTY -1 +#define _HEAPOK -2 +#define _HEAPBADBEGIN -3 +#define _HEAPBADNODE -4 +#define _HEAPEND -5 +#define _HEAPBADPTR -6 + +#define _FREEENTRY 0 +#define _USEDENTRY 1 + +#define _OUT_TO_DEFAULT 0 +#define _REPORT_ERRMODE 3 + +/* ASCII char classification table - binary compatible */ +#define _UPPER 0x0001 /* C1_UPPER */ +#define _LOWER 0x0002 /* C1_LOWER */ +#define _DIGIT 0x0004 /* C1_DIGIT */ +#define _SPACE 0x0008 /* C1_SPACE */ +#define _PUNCT 0x0010 /* C1_PUNCT */ +#define _CONTROL 0x0020 /* C1_CNTRL */ +#define _BLANK 0x0040 /* C1_BLANK */ +#define _HEX 0x0080 /* C1_XDIGIT */ +#define _LEADBYTE 0x8000 +#define _ALPHA (0x0100|_UPPER|_LOWER) /* (C1_ALPHA|_UPPER|_LOWER) */ + +#define MSVCRT__IOREAD 0x0001 +#define MSVCRT__IOWRT 0x0002 +#define MSVCRT__IOMYBUF 0x0008 +#define MSVCRT__IOEOF 0x0010 +#define MSVCRT__IOERR 0x0020 +#define MSVCRT__IOSTRG 0x0040 +#define MSVCRT__IORW 0x0080 + +#define _S_IEXEC 0x0040 +#define _S_IWRITE 0x0080 +#define _S_IREAD 0x0100 +#define _S_IFIFO 0x1000 +#define _S_IFCHR 0x2000 +#define _S_IFDIR 0x4000 +#define _S_IFREG 0x8000 +#define _S_IFMT 0xF000 + +void MSVCRT_free(void*); +void* MSVCRT_malloc(MSVCRT_size_t); +void* MSVCRT_calloc(MSVCRT_size_t,MSVCRT_size_t); +void* MSVCRT_realloc(void*,MSVCRT_size_t); + +int MSVCRT_iswalpha(MSVCRT_wint_t); +int MSVCRT_iswspace(MSVCRT_wint_t); +int MSVCRT_iswdigit(MSVCRT_wint_t); +int MSVCRT_isleadbyte(int); + +int MSVCRT_fgetc(MSVCRT_FILE*); +int MSVCRT_ungetc(int,MSVCRT_FILE*); +MSVCRT_wint_t MSVCRT_fgetwc(MSVCRT_FILE*); +MSVCRT_wint_t MSVCRT_ungetwc(MSVCRT_wint_t,MSVCRT_FILE*); +void MSVCRT__exit(int); +void MSVCRT_abort(); +unsigned long* MSVCRT___doserrno(void); +int* MSVCRT__errno(void); +char* MSVCRT_getenv(const char*); +char* MSVCRT_setlocale(int,const char*); +int MSVCRT_fclose(MSVCRT_FILE*); +void MSVCRT_terminate(); +MSVCRT_FILE* MSVCRT__p__iob(void); +MSVCRT_time_t MSVCRT_time(MSVCRT_time_t*); + +MSVCRT_wchar_t* _wcsdup(const MSVCRT_wchar_t*); +MSVCRT_wchar_t*** __p__wenviron(void); + +int _write(int,const void*,unsigned int); +int _vsnwprintf(MSVCRT_wchar_t*,MSVCRT_size_t,const MSVCRT_wchar_t*,va_list); +void _splitpath(const char*,char*,char*,char*,char*); +int _ismbstrail(const unsigned char* start, const unsigned char* str); +int _spawnve(int,const char*,const char* const *,const char* const *); +void _searchenv(const char*,const char*,char*); +void _sleep(unsigned long); +int _getdrive(void); +int _futime(int,struct _utimbuf*); +char* _strdup(const char*); +char* _strlwr(char*); +char* _strupr(char*); +char* _strnset(char*,int,MSVCRT_size_t); +char* _strset(char*,int); +int _getch(void); +int _ungetch(int); +int _cputs(const char*); +int _cprintf(const char*,...); +int _snprintf(char*,MSVCRT_size_t,const char*,...); + +char*** __p__environ(void); +int* __p___mb_cur_max(void); +unsigned int* __p__fmode(void); + #endif /* __WINE_MSVCRT_H */