| 1 | /* $Id: crtinc.h,v 1.1 2000-11-21 23:49:03 phaller Exp $ */ | 
|---|
| 2 |  | 
|---|
| 3 | /* Definitions for the CRTDLL library (CRTDLL.DLL) | 
|---|
| 4 | * | 
|---|
| 5 | * Copyright 1999-2000 Jens Wiessner | 
|---|
| 6 | * | 
|---|
| 7 | */ | 
|---|
| 8 |  | 
|---|
| 9 |  | 
|---|
| 10 | #ifndef MAX_PATHNAME_LEN | 
|---|
| 11 | #define MAX_PATHNAME_LEN 260 | 
|---|
| 12 | #endif | 
|---|
| 13 |  | 
|---|
| 14 | //SvL: Internal heap allocation definitions for NTDLL | 
|---|
| 15 | extern HANDLE CRTDLL_hHeap; | 
|---|
| 16 | #define Heap_Alloc(a)   HeapAlloc(CRTDLL_hHeap, HEAP_ZERO_MEMORY, a) | 
|---|
| 17 | #define Heap_Free(a)    HeapFree(CRTDLL_hHeap, 0, (PVOID)a) | 
|---|
| 18 |  | 
|---|
| 19 | //SvL: per process heap for CRTDLL | 
|---|
| 20 | HANDLE CRTDLL_hHeap = 0; | 
|---|
| 21 | int __fileno_alloc(HANDLE hFile, int mode); | 
|---|
| 22 |  | 
|---|
| 23 | // Defs | 
|---|
| 24 | #define DOSFS_GetFullName(a,b,c) strcpy(c,a) | 
|---|
| 25 |  | 
|---|
| 26 |  | 
|---|
| 27 | #if (__IBMCPP__ > 300) | 
|---|
| 28 | #define exception _exception | 
|---|
| 29 | #endif | 
|---|
| 30 |  | 
|---|
| 31 | typedef struct | 
|---|
| 32 | { | 
|---|
| 33 | HANDLE handle; | 
|---|
| 34 | int      pad[7]; | 
|---|
| 35 | } CRTDLL_FILE, *PCRTDLL_FILE; | 
|---|
| 36 |  | 
|---|
| 37 |  | 
|---|
| 38 | /* Definition of a full DOS file name */ | 
|---|
| 39 | typedef struct | 
|---|
| 40 | { | 
|---|
| 41 | char  long_name[MAX_PATHNAME_LEN];  /* Long pathname in Unix format */ | 
|---|
| 42 | char  short_name[MAX_PATHNAME_LEN]; /* Short pathname in DOS 8.3 format */ | 
|---|
| 43 | int   drive; | 
|---|
| 44 | } DOS_FULL_NAME; | 
|---|
| 45 |  | 
|---|
| 46 | /* Definition for _cabs */ | 
|---|
| 47 | struct complex | 
|---|
| 48 | { | 
|---|
| 49 | double  x;      /* Real part */ | 
|---|
| 50 | double  y;      /* Imaginary part */ | 
|---|
| 51 | }; | 
|---|
| 52 |  | 
|---|
| 53 | typedef VOID (*new_handler_type)(VOID); | 
|---|
| 54 | typedef void (*_INITTERMFUN)(); | 
|---|
| 55 |  | 
|---|
| 56 |  | 
|---|
| 57 | CRTDLL_FILE CRTDLL_iob[3]; | 
|---|
| 58 |  | 
|---|
| 59 | static CRTDLL_FILE * const CRTDLL_stdin  = &CRTDLL_iob[0]; | 
|---|
| 60 | static CRTDLL_FILE * const CRTDLL_stdout = &CRTDLL_iob[1]; | 
|---|
| 61 | static CRTDLL_FILE * const CRTDLL_stderr = &CRTDLL_iob[2]; | 
|---|
| 62 | static new_handler_type new_handler; | 
|---|
| 63 |  | 
|---|
| 64 |  | 
|---|
| 65 | // CRTDLL Exports | 
|---|
| 66 | double  *CRTDLL_HUGE_dll;        /* CRTDLL.20 */ | 
|---|
| 67 | UINT    CRTDLL_argc_dll;         /* CRTDLL.23 */ | 
|---|
| 68 | LPSTR   *CRTDLL_argv_dll;        /* CRTDLL.24 */ | 
|---|
| 69 | int     CRTDLL_mb_cur_max_dll;   /* CRTDLL.31 */ | 
|---|
| 70 | LPSTR   CRTDLL_acmdln_dll;       /* CRTDLL.38 */ | 
|---|
| 71 | UINT    CRTDLL_basemajor_dll;    /* CRTDLL.42 */ | 
|---|
| 72 | UINT    CRTDLL_baseminor_dll;    /* CRTDLL.43 */ | 
|---|
| 73 | UINT    CRTDLL_baseversion_dll;  /* CRTDLL.44 */ | 
|---|
| 74 | UINT    CRTDLL_commode_dll;      /* CRTDLL.59 */ | 
|---|
| 75 | UCHAR   *CRTDLL_cpumode_dll;     /* CRTDLL.64 */ | 
|---|
| 76 | USHORT  *CRTDLL_ctype;           /* CRTDLL.68 */ | 
|---|
| 77 | UINT    CRTDLL_daylight_dll;     /* CRTDLL.70 */ | 
|---|
| 78 | LPSTR   CRTDLL_environ_dll;      /* CRTDLL.75 */ | 
|---|
| 79 | LPSTR   CRTDLL_fileinfo_dll;     /* CRTDLL.95 */ | 
|---|
| 80 | UINT    CRTDLL_fmode_dll;        /* CRTDLL.104 */ | 
|---|
| 81 | LPSTR   CRTDLL_mbctype;          /* CRTDLL.193 */ | 
|---|
| 82 | UINT    CRTDLL_osmajor_dll;      /* CRTDLL.239 */ | 
|---|
| 83 | UINT    CRTDLL_osminor_dll;      /* CRTDLL.240 */ | 
|---|
| 84 | UINT    CRTDLL_osmode_dll;       /* CRTDLL.241 */ | 
|---|
| 85 | UINT    CRTDLL_osver_dll;        /* CRTDLL.242 */ | 
|---|
| 86 | UINT    CRTDLL_osversion_dll;    /* CRTDLL.243 */ | 
|---|
| 87 | USHORT CRTDLL_pctype_dll[] = {0,0}; /* CRTDLL.245 */ | 
|---|
| 88 | LPSTR   CRTDLL_pgmptr_dll;       /* CRTDLL.246 */ | 
|---|
| 89 | USHORT *CRTDLL_pwctype_dll;      /* CRTDLL.253 */ | 
|---|
| 90 | UINT    CRTDLL_timezone_dll;     /* CRTDLL.304 */ | 
|---|
| 91 | LPSTR   CRTDLL_tzname;           /* CRTDLL.307 */ | 
|---|
| 92 | UINT    CRTDLL_winmajor_dll;     /* CRTDLL.326 */ | 
|---|
| 93 | UINT    CRTDLL_winminor_dll;     /* CRTDLL.327 */ | 
|---|
| 94 | UINT    CRTDLL_winver_dll;       /* CRTDLL.328 */ | 
|---|
| 95 |  | 
|---|
| 96 |  | 
|---|
| 97 | // | 
|---|
| 98 | // Definitions for internal functions | 
|---|
| 99 | // | 
|---|
| 100 | void            qsort1 (char*, char*, size_t, | 
|---|
| 101 | int (* CDECL)(const void*, const void*)); | 
|---|
| 102 |  | 
|---|
| 103 |  | 
|---|
| 104 | // syserr / sysnerr Defs | 
|---|
| 105 | const char *CRTDLL_sys_errlist[] = { | 
|---|
| 106 | /*  0 EZERO          */ "Error 0", | 
|---|
| 107 | /*  1 EPERM          */ "Operation not permitted", | 
|---|
| 108 | /*  2 ENOENT         */ "No such file or directory", | 
|---|
| 109 | /*  3 ESRCH          */ "No such process", | 
|---|
| 110 | /*  4 EINTR          */ "Interrupted system call", | 
|---|
| 111 | /*  5 EIO            */ "I/O error", | 
|---|
| 112 | /*  6 ENXIO          */ "No such device or address", | 
|---|
| 113 | /*  7 E2BIG          */ "Arguments or environment too big", | 
|---|
| 114 | /*  8 ENOEXEC        */ "Invalid executable file format", | 
|---|
| 115 | /*  9 EBADF          */ "Bad file number", | 
|---|
| 116 | /* 10 ECHILD         */ "No children", | 
|---|
| 117 | /* 11 EAGAIN         */ "Resource temporarily unavailable", | 
|---|
| 118 | /* 12 ENOMEM         */ "Not enough memory", | 
|---|
| 119 | /* 13 EACCES         */ "Permission denied", | 
|---|
| 120 | /* 14 EFAULT         */ "Bad address", | 
|---|
| 121 | /* 15 ENOLCK         */ "No locks available", | 
|---|
| 122 | /* 16 EBUSY          */ "Resource busy", | 
|---|
| 123 | /* 17 EEXIST         */ "File exists", | 
|---|
| 124 | /* 18 EXDEV          */ "Cross-device link", | 
|---|
| 125 | /* 19 ENODEV         */ "No such device", | 
|---|
| 126 | /* 20 ENOTDIR        */ "Not a directory", | 
|---|
| 127 | /* 21 EISDIR         */ "Is a directory", | 
|---|
| 128 | /* 22 EINVAL         */ "Invalid argument", | 
|---|
| 129 | /* 23 ENFILE         */ "Too many open files in system", | 
|---|
| 130 | /* 24 EMFILE         */ "Too many open files", | 
|---|
| 131 | /* 25 ENOTTY         */ "Inappropriate ioctl", | 
|---|
| 132 | /* 26 EDEADLK        */ "Resource deadlock avoided", | 
|---|
| 133 | /* 27 EFBIG          */ "File too large", | 
|---|
| 134 | /* 28 ENOSPC         */ "Disk full", | 
|---|
| 135 | /* 29 ESPIPE         */ "Invalid seek", | 
|---|
| 136 | /* 30 EROFS          */ "Read-only file system", | 
|---|
| 137 | /* 31 EMLINK         */ "Too many links", | 
|---|
| 138 | /* 32 EPIPE          */ "Broken pipe", | 
|---|
| 139 | /* 33 EDOM           */ "Domain error", | 
|---|
| 140 | /* 34 ERANGE         */ "Result too large", | 
|---|
| 141 | /* 35 ENOTEMPTY      */ "Directory not empty", | 
|---|
| 142 | /* 36 EINPROGRESS    */ "Operation now in progress", | 
|---|
| 143 | /* 37 ENOSYS         */ "Function not implemented", | 
|---|
| 144 | /* 38 ENAMETOOLONG   */ "File name too long", | 
|---|
| 145 | /* 39 EDESTADDRREQ   */ "Destination address required", | 
|---|
| 146 | /* 40 EMSGSIZE       */ "Message too long", | 
|---|
| 147 | /* 41 EPROTOTYPE     */ "Protocol wrong type for socket", | 
|---|
| 148 | /* 42 ENOPROTOOPT    */ "Option not supported by protocol", | 
|---|
| 149 | /* 43 EPROTONOSUPPORT */ "Protocol not supported", | 
|---|
| 150 | /* 44 ESOCKTNOSUPPORT */ "Socket type not supported", | 
|---|
| 151 | /* 45 EOPNOTSUPP     */ "Operation not supported on socket", | 
|---|
| 152 | /* 46 EPFNOSUPPORT   */ "Protocol family not supported", | 
|---|
| 153 | /* 47 EAFNOSUPPORT   */ "Address family not supported by protocol family", | 
|---|
| 154 | /* 48 EADDRINUSE     */ "Address already in use", | 
|---|
| 155 | /* 49 EADDRNOTAVAIL  */ "Can't assign requested address", | 
|---|
| 156 | /* 50 ENETDOWN       */ "Network is down", | 
|---|
| 157 | /* 51 ENETUNREACH    */ "Network is unreachable", | 
|---|
| 158 | /* 52 ENETRESET      */ "Network dropped connection on reset", | 
|---|
| 159 | /* 53 ECONNABORTED   */ "Software caused connection abort", | 
|---|
| 160 | /* 54 ECONNRESET     */ "Connection reset by peer", | 
|---|
| 161 | /* 55 ENOBUFS        */ "No buffer space available", | 
|---|
| 162 | /* 56 EISCONN        */ "Socket is already connected", | 
|---|
| 163 | /* 57 ENOTCONN       */ "Socket is not connected", | 
|---|
| 164 | /* 58 ESHUTDOWN      */ "Can't send after socket shutdown", | 
|---|
| 165 | /* 59 ETOOMANYREFS   */ "Too many references: can't splice", | 
|---|
| 166 | /* 60 ETIMEDOUT      */ "Connection timed out", | 
|---|
| 167 | /* 61 ECONNREFUSED   */ "Connection refused", | 
|---|
| 168 | /* 62 ELOOP          */ "Too many levels of symbolic links", | 
|---|
| 169 | /* 63 ENOTSOCK       */ "Socket operation on non-socket", | 
|---|
| 170 | /* 64 EHOSTDOWN      */ "Host is down", | 
|---|
| 171 | /* 65 EHOSTUNREACH   */ "No route to host", | 
|---|
| 172 | /* 66 EALREADY       */ "Operation already in progress" | 
|---|
| 173 | }; | 
|---|
| 174 |  | 
|---|
| 175 | int __sys_nerr = sizeof(CRTDLL_sys_errlist) / sizeof(CRTDLL_sys_errlist[0]); | 
|---|
| 176 | int*    CRTDLL_sys_nerr_dll = &__sys_nerr; | 
|---|
| 177 |  | 
|---|
| 178 |  | 
|---|
| 179 | // atexit | 
|---|
| 180 | void (*_atexit_v[64])(void); | 
|---|
| 181 | int _atexit_n = 0; | 
|---|