source: trunk/src/crtdll/crtinc.h@ 1875

Last change on this file since 1875 was 1868, checked in by sandervl, 26 years ago

Jens Weissner's changes

File size: 14.0 KB
Line 
1/* $Id: crtinc.h,v 1.8 1999-11-28 17:22:27 sandervl Exp $ */
2
3/* Definitions for the CRTDLL library (CRTDLL.DLL)
4 *
5 * Copyright 1999 Jens Wiessner
6 */
7
8#define MB_LEN_MAX 2
9#ifndef MAX_PATHNAME_LEN
10#define MAX_PATHNAME_LEN 260
11#endif
12
13// Errno Defs
14#define EPERM 1 /* Operation not permitted */
15#define ENOFILE 2 /* No such file or directory */
16#define ENOENT 2
17#define ESRCH 3 /* No such process */
18#define EINTR 4 /* Interrupted function call */
19#define EIO 5 /* Input/output error */
20#define ENXIO 6 /* No such device or address */
21#define E2BIG 7 /* Arg list too long */
22#define ENOEXEC 8 /* Exec format error */
23#define EBADF 9 /* Bad file descriptor */
24#define ECHILD 10 /* No child processes */
25#define EAGAIN 11 /* Resource temporarily unavailable */
26#define ENOMEM 12 /* Not enough space */
27#define EACCES 13 /* Permission denied */
28#define EFAULT 14 /* Bad address */
29/* 15 - Unknown Error */
30#define EBUSY 16 /* strerror reports "Resource device" */
31#define EEXIST 17 /* File exists */
32#define EXDEV 18 /* Improper link (cross-device link?) */
33#define ENODEV 19 /* No such device */
34#define ENOTDIR 20 /* Not a directory */
35#define EISDIR 21 /* Is a directory */
36#define EINVAL 22 /* Invalid argument */
37#define ENFILE 23 /* Too many open files in system */
38#define EMFILE 24 /* Too many open files */
39#define ENOTTY 25 /* Inappropriate I/O control operation */
40/* 26 - Unknown Error */
41#define EFBIG 27 /* File too large */
42#define ENOSPC 28 /* No space left on device */
43#define ESPIPE 29 /* Invalid seek (seek on a pipe?) */
44#define EROFS 30 /* Read-only file system */
45#define EMLINK 31 /* Too many links */
46#define EPIPE 32 /* Broken pipe */
47#define EDOM 33 /* Domain error (math functions) */
48#define ERANGE 34 /* Result too large (possibly too small) */
49/* 35 - Unknown Error */
50#define EDEADLOCK 36 /* Resource deadlock avoided (non-Cyg) */
51#define EDEADLK 36
52/* 37 - Unknown Error */
53#define ENAMETOOLONG 38 /* Filename too long (91 in Cyg?) */
54#define ENOLCK 39 /* No locks available (46 in Cyg?) */
55#define ENOSYS 40 /* Function not implemented (88 in Cyg?) */
56#define ENOTEMPTY 41 /* Directory not empty (90 in Cyg?) */
57#define EILSEQ 42 /* Illegal byte sequence */
58
59
60// MBC Defs
61#define _MBC_SINGLE 0
62#define _MBC_LEAD 1
63#define _MBC_TRAIL 2
64#define _MBC_ILLEGAL -1
65
66#define _MB_CP_SBCS 0
67#define _MB_CP_OEM -2
68#define _MB_CP_ANSI -3
69#define _MB_CP_LOCALE -4
70
71#define _KNJ_M ((char)0x01) /* Non-punctuation of Kana-set */
72#define _KNJ_P ((char)0x02) /* Punctuation of Kana-set */
73#define _KNJ_1 ((char)0x04) /* Legal 1st byte of double byte stream */
74#define _KNJ_2 ((char)0x08) /* Legal 2nd btye of double byte stream */
75
76#define ___ 0
77#define _1_ _KNJ_1 /* Legal 1st byte of double byte code */
78#define __2 _KNJ_2 /* Legal 2nd byte of double byte code */
79#define _M_ _KNJ_M /* Non-puntuation in Kana-set */
80#define _P_ _KNJ_P /* Punctuation of Kana-set */
81#define _12 (_1_|__2)
82#define _M2 (_M_|__2)
83#define _P2 (_P_|__2)
84
85#define CASE_DIFF (0x8281 - 0x8260)
86
87
88// fpclass Defs
89#define FP_SNAN 0x0001 // signaling NaN
90#define FP_QNAN 0x0002 // quiet NaN
91#define FP_NINF 0x0004 // negative infinity
92#define FP_PINF 0x0200 // positive infinity
93#define FP_NDENORM 0x0008 // negative denormalized non-zero
94#define FP_PDENORM 0x0010 // positive denormalized non-zero
95#define FP_NZERO 0x0020 // negative zero
96#define FP_PZERO 0x0040 // positive zero
97#define FP_NNORM 0x0080 // negative normalized non-zero
98#define FP_PNORM 0x0100 // positive normalized non-zero
99
100
101// Defs
102#define DOSFS_GetFullName(a,b,c) strcpy(c,a)
103
104#if defined(__GNUC__) && defined(__i386__)
105#define USING_REAL_FPU
106#define DO_FPU(x,y) __asm__ __volatile__( x " %0;fwait" : "=m" (y) : )
107#define POP_FPU(x) DO_FPU("fstpl",x)
108#endif
109
110typedef struct
111{
112 HANDLE handle;
113 int pad[7];
114} CRTDLL_FILE, *PCRTDLL_FILE;
115
116
117/* Definition of a full DOS file name */
118typedef struct
119{
120 char long_name[MAX_PATHNAME_LEN]; /* Long pathname in Unix format */
121 char short_name[MAX_PATHNAME_LEN]; /* Short pathname in DOS 8.3 format */
122 int drive;
123} DOS_FULL_NAME;
124
125/* Definition for _cabs */
126struct _complex
127{
128 double x; /* Real part */
129 double y; /* Imaginary part */
130};
131
132
133#ifndef _DISKFREE_T_DEFINED
134#define _DISKFREE_T_DEFINED
135#define _DISKFREE_T_DEFINED_
136struct _diskfree_t {
137 unsigned total_clusters;
138 unsigned avail_clusters;
139 unsigned sectors_per_cluster;
140 unsigned bytes_per_sector;
141};
142#define diskfree_t _diskfree_t
143#endif
144
145
146typedef VOID (*new_handler_type)(VOID);
147typedef void (*_INITTERMFUN)();
148
149
150CRTDLL_FILE CRTDLL_iob[3];
151
152static CRTDLL_FILE * const CRTDLL_stdin = &CRTDLL_iob[0];
153static CRTDLL_FILE * const CRTDLL_stdout = &CRTDLL_iob[1];
154static CRTDLL_FILE * const CRTDLL_stderr = &CRTDLL_iob[2];
155static new_handler_type new_handler;
156
157// CRTDLL Exports
158double *CRTDLL_HUGE_dll; /* CRTDLL.20 */
159UINT CRTDLL_argc_dll; /* CRTDLL.23 */
160LPSTR *CRTDLL_argv_dll; /* CRTDLL.24 */
161int CRTDLL_mb_cur_max_dll; /* CRTDLL.31 */
162LPSTR CRTDLL_acmdln_dll; /* CRTDLL.38 */
163UINT CRTDLL_basemajor_dll; /* CRTDLL.42 */
164UINT CRTDLL_baseminor_dll; /* CRTDLL.43 */
165UINT CRTDLL_baseversion_dll; /* CRTDLL.44 */
166UINT CRTDLL_commode_dll; /* CRTDLL.59 */
167UCHAR *CRTDLL_cpumode_dll; /* CRTDLL.64 */
168USHORT *CRTDLL_ctype; /* CRTDLL.68 */
169UINT CRTDLL_daylight_dll; /* CRTDLL.70 */
170LPSTR CRTDLL_environ_dll; /* CRTDLL.75 */
171LPSTR CRTDLL_fileinfo_dll; /* CRTDLL.95 */
172UINT CRTDLL_fmode_dll; /* CRTDLL.104 */
173LPSTR CRTDLL_mbctype; /* CRTDLL.193 */
174UINT CRTDLL_osmajor_dll; /* CRTDLL.239 */
175UINT CRTDLL_osminor_dll; /* CRTDLL.240 */
176UINT CRTDLL_osmode_dll; /* CRTDLL.241 */
177UINT CRTDLL_osver_dll; /* CRTDLL.242 */
178UINT CRTDLL_osversion_dll; /* CRTDLL.243 */
179USHORT CRTDLL_pctype_dll[] = {0,0}; /* CRTDLL.245 */
180LPSTR CRTDLL_pgmptr_dll; /* CRTDLL.246 */
181USHORT *CRTDLL_pwctype_dll; /* CRTDLL.253 */
182// UINT CRTDLL_sys_errlist; /* CRTDLL.300 */
183// UINT CRTDLL_sys_nerr_dll; /* CRTDLL.301 */
184UINT CRTDLL_timezone_dll; /* CRTDLL.304 */
185LPSTR CRTDLL_tzname; /* CRTDLL.307 */
186UINT CRTDLL_winmajor_dll; /* CRTDLL.326 */
187UINT CRTDLL_winminor_dll; /* CRTDLL.327 */
188UINT CRTDLL_winver_dll; /* CRTDLL.328 */
189
190
191// CRTDLL Functions
192CRTDLL_FILE * CDECL CRTDLL__fdopen(INT handle, LPCSTR mode);
193INT CDECL NTDLL__wcsicmp( LPCWSTR str1, LPCWSTR str2 );
194INT CDECL CRTDLL_vfprintf( CRTDLL_FILE *file, LPSTR format, va_list args );
195VOID * CDECL CRTDLL_malloc(DWORD size);
196long CDECL CRTDLL__lseek(int handle,long offset,int origin);
197long CDECL CRTDLL__filelength( int i );
198VOID CDECL CRTDLL__exit(DWORD ret);
199INT CDECL CRTDLL_isalnum(int i);
200int CDECL CRTDLL_isgraph(int i);
201int CDECL CRTDLL__access(const char *path,int mode);
202int CDECL CRTDLL__getch(void);
203size_t CDECL CRTDLL_fread( void *ptr, size_t size, size_t n, FILE *fp );
204int CDECL CRTDLL__mbbtype( unsigned char c, int type );
205unsigned char * CDECL CRTDLL__mbscpy( unsigned char *s1, const unsigned char *s2 );
206LPSTR CDECL CRTDLL__mbsinc( LPCSTR str );
207INT CDECL CRTDLL__mbslen( LPCSTR str );
208int CDECL CRTDLL__ismbbkalnum( unsigned int c );
209int CDECL CRTDLL__ismbbkana( unsigned int c );
210int CDECL CRTDLL__ismbbalpha( unsigned int c );
211int CDECL CRTDLL__ismbbtrail( unsigned int c );
212int CDECL CRTDLL__ismbblead( unsigned int c );
213char * CDECL CRTDLL_getenv( const char *name );
214int CDECL CRTDLL__isnan( double __x );
215
216
217//
218// Definitions for internal functions
219//
220int __set_errno (int error);
221unsigned int _mbbtoupper(unsigned int c);
222unsigned int _mbbtolower(unsigned int c);
223size_t _mbclen2(const unsigned int s);
224int _isinf(double __x);
225
226
227//
228// MBC Includes
229//
230static unsigned short han_to_zen_ascii_table[0x5f] = {
231 0x8140, 0x8149, 0x8168, 0x8194, 0x8190, 0x8193, 0x8195, 0x8166,
232 0x8169, 0x816a, 0x8196, 0x817b, 0x8143, 0x817c, 0x8144, 0x815e,
233 0x824f, 0x8250, 0x8251, 0x8252, 0x8253, 0x8254, 0x8255, 0x8256,
234 0x8257, 0x8258, 0x8146, 0x8147, 0x8183, 0x8181, 0x8184, 0x8148,
235 0x8197, 0x8260, 0x8261, 0x8262, 0x8263, 0x8264, 0x8265, 0x8266,
236 0x8267, 0x8268, 0x8269, 0x826a, 0x826b, 0x826c, 0x826d, 0x826e,
237 0x826f, 0x8270, 0x8271, 0x8272, 0x8273, 0x8274, 0x8275, 0x8276,
238 0x8277, 0x8278, 0x8279, 0x816d, 0x818f, 0x816e, 0x814f, 0x8151,
239 0x8165, 0x8281, 0x8282, 0x8283, 0x8284, 0x8285, 0x8286, 0x8287,
240 0x8288, 0x8289, 0x828a, 0x828b, 0x828c, 0x828d, 0x828e, 0x828f,
241 0x8290, 0x8291, 0x8292, 0x8293, 0x8294, 0x8295, 0x8296, 0x8297,
242 0x8298, 0x8299, 0x829a, 0x816f, 0x8162, 0x8170, 0x8150
243};
244static unsigned short han_to_zen_kana_table[0x40] = {
245 0x8140, 0x8142, 0x8175, 0x8176, 0x8141, 0x8145, 0x8392, 0x8340,
246 0x8342, 0x8344, 0x8346, 0x8348, 0x8383, 0x8385, 0x8387, 0x8362,
247 0x815b, 0x8341, 0x8343, 0x8345, 0x8347, 0x8349, 0x834a, 0x834c,
248 0x834e, 0x8350, 0x8352, 0x8354, 0x8356, 0x8358, 0x835a, 0x835c,
249 0x835e, 0x8360, 0x8363, 0x8365, 0x8367, 0x8369, 0x836a, 0x836b,
250 0x836c, 0x836d, 0x836e, 0x8371, 0x8374, 0x8377, 0x837a, 0x837d,
251 0x837e, 0x8380, 0x8381, 0x8382, 0x8384, 0x8386, 0x8388, 0x8389,
252 0x838a, 0x838b, 0x838c, 0x838d, 0x838f, 0x8393, 0x814a, 0x814b
253};
254static unsigned char zen_to_han_kana_table[0x8396-0x8340+1] = {
255 0xa7, 0xb1, 0xa8, 0xb2, 0xa9, 0xb3, 0xaa, 0xb4,
256 0xab, 0xb5, 0xb6, 0xb6, 0xb7, 0xb7, 0xb8, 0xb8,
257 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xbb, 0xbc, 0xbc,
258 0xbd, 0xbd, 0xbe, 0xbe, 0xbf, 0xbf, 0xc0, 0xc0,
259 0xc1, 0xc1, 0xaf, 0xc2, 0xc2, 0xc3, 0xc3, 0xc4,
260 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xca,
261 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc, 0xcd,
262 0xcd, 0xcd, 0xce, 0xce, 0xce, 0xcf, 0xd0, 0,
263 0xd1, 0xd2, 0xd3, 0xac, 0xd4, 0xad, 0xd5, 0xae,
264 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdc,
265 0xb2, 0xb4, 0xa6, 0xdd, 0xb3, 0xb6, 0xb9
266};
267#define ZTOH_SYMBOLS 9
268static unsigned short zen_to_han_symbol_table_1[ZTOH_SYMBOLS] = {
269 0x8142, 0x8175, 0x8176, 0x8141, 0x8145, 0x815b, 0x814a, 0x814b
270};
271static unsigned char zen_to_han_symbol_table_2[ZTOH_SYMBOLS] = {
272 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xb0, 0xde, 0xdf
273};
274#define ISKANA(c) ((c) >= 0xa1 && (c) <= 0xdf)
275#define JISHIRA(c) ((c) >= 0x829f && (c) <= 0x82f1)
276#define JISKANA(c) ((c) >= 0x8340 && (c) <= 0x8396 && (c) != 0x837f)
277#define JTOKANA(c) ((c) <= 0x82dd ? (c) + 0xa1 : (c) + 0xa2)
278
279char _jctype[257] = {
280/*-1*/ ___,
281/*0x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
282/*1x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
283/*2x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
284/*3x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
285/*4x*/ __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,
286/*5x*/ __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,
287/*6x*/ __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,
288/*7x*/ __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,___,
289/*8x*/ __2,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,
290/*9x*/ _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,
291/*Ax*/ __2,_P2,_P2,_P2,_P2,_P2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,
292/*Bx*/ _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,
293/*Cx*/ _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,
294/*Dx*/ _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,
295/*Ex*/ _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,
296/*Fx*/ _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,___,___,___
297};
298
299
300// syserr / sysnerr Defs
301char __syserr00[] = "No Error";
302char __syserr01[] = "Input to function out of range (EDOM)";
303char __syserr02[] = "Output of function out of range (ERANGE)";
304char __syserr03[] = "Argument list too long (E2BIG)";
305char __syserr04[] = "Permission denied (EACCES)";
306char __syserr05[] = "Resource temporarily unavailable (EAGAIN)";
307char __syserr06[] = "Bad file descriptor (EBADF)";
308char __syserr07[] = "Resource busy (EBUSY)";
309char __syserr08[] = "No child processes (ECHILD)";
310char __syserr09[] = "Resource deadlock avoided (EDEADLK)";
311char __syserr10[] = "File exists (EEXIST)";
312char __syserr11[] = "Bad address (EFAULT)";
313char __syserr12[] = "File too large (EFBIG)";
314char __syserr13[] = "Interrupted system call (EINTR)";
315char __syserr14[] = "Invalid argument (EINVAL)";
316char __syserr15[] = "Input or output error (EIO)";
317char __syserr16[] = "Is a directory (EISDIR)";
318char __syserr17[] = "Too many open files (EMFILE)";
319char __syserr18[] = "Too many links (EMLINK)";
320char __syserr19[] = "File name too long (ENAMETOOLONG)";
321char __syserr20[] = "Too many open files in system (ENFILE)";
322char __syserr21[] = "No such device (ENODEV)";
323char __syserr22[] = "No such file or directory (ENOENT)";
324char __syserr23[] = "Unable to execute file (ENOEXEC)";
325char __syserr24[] = "No locks available (ENOLCK)";
326char __syserr25[] = "Not enough memory (ENOMEM)";
327char __syserr26[] = "No space left on drive (ENOSPC)";
328char __syserr27[] = "Function not implemented (ENOSYS)";
329char __syserr28[] = "Not a directory (ENOTDIR)";
330char __syserr29[] = "Directory not empty (ENOTEMPTY)";
331char __syserr30[] = "Inappropriate I/O control operation (ENOTTY)";
332char __syserr31[] = "No such device or address (ENXIO)";
333char __syserr32[] = "Operation not permitted (EPERM)";
334char __syserr33[] = "Broken pipe (EPIPE)";
335char __syserr34[] = "Read-only file system (EROFS)";
336char __syserr35[] = "Invalid seek (ESPIPE)";
337char __syserr36[] = "No such process (ESRCH)";
338char __syserr37[] = "Improper link (EXDEV)";
339char __syserr38[] = "No more files (ENMFILE)";
340
341const char *CRTDLL_sys_errlist[] = {
342__syserr00, __syserr01, __syserr02, __syserr03, __syserr04,
343__syserr05, __syserr06, __syserr07, __syserr08, __syserr09,
344__syserr10, __syserr11, __syserr12, __syserr13, __syserr14,
345__syserr15, __syserr16, __syserr17, __syserr18, __syserr19,
346__syserr20, __syserr21, __syserr22, __syserr23, __syserr24,
347__syserr25, __syserr26, __syserr27, __syserr28, __syserr29,
348__syserr30, __syserr31, __syserr32, __syserr33, __syserr34,
349__syserr35, __syserr36, __syserr37, __syserr38
350};
351
352int __sys_nerr = sizeof(CRTDLL_sys_errlist) / sizeof(CRTDLL_sys_errlist[0]);
353
354int* CRTDLL_sys_nerr_dll = &__sys_nerr;
Note: See TracBrowser for help on using the repository browser.