Rev 704 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
548 | serge | 1 | /**************************************************************************** |
2 | * |
||
3 | * Open Watcom Project |
||
4 | * |
||
5 | * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. |
||
6 | * |
||
7 | * ======================================================================== |
||
8 | * |
||
9 | * This file contains Original Code and/or Modifications of Original |
||
10 | * Code as defined in and that are subject to the Sybase Open Watcom |
||
11 | * Public License version 1.0 (the 'License'). You may not use this file |
||
12 | * except in compliance with the License. BY USING THIS FILE YOU AGREE TO |
||
13 | * ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is |
||
14 | * provided with the Original Code and Modifications, and is also |
||
15 | * available at www.sybase.com/developer/opensource. |
||
16 | * |
||
17 | * The Original Code and all software distributed under the License are |
||
18 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER |
||
19 | * EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM |
||
20 | * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF |
||
21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR |
||
22 | * NON-INFRINGEMENT. Please see the License for the specific language |
||
23 | * governing rights and limitations under the License. |
||
24 | * |
||
25 | * ======================================================================== |
||
26 | * |
||
27 | * Description: Implementation of __NTMain(). |
||
28 | * |
||
29 | ****************************************************************************/ |
||
30 | |||
31 | |||
32 | #include "variety.h" |
||
33 | #include "widechar.h" |
||
34 | #include |
||
35 | #include |
||
36 | #include |
||
37 | #include |
||
38 | #include |
||
39 | //#include "ntex.h" |
||
40 | //#include "sigtab.h" |
||
41 | #include "initfini.h" |
||
42 | #include "initarg.h" |
||
43 | |||
44 | void _cdecl mf_init(); |
||
45 | void _stdcall InitHeap(int heap_size); |
||
46 | int __appcwdlen; |
||
47 | char* __appcwd; |
||
48 | |||
49 | _WCRTLINK void (*__process_fini)(unsigned,unsigned) = 0; |
||
50 | |||
51 | extern void __CommonInit( void ); |
||
52 | extern int wmain( int, wchar_t ** ); |
||
53 | extern int main( int, char ** ); |
||
54 | extern char *LpCmdLine; |
||
55 | extern char *LpPgmName; |
||
56 | |||
57 | void __F_NAME(__NTMain,__wNTMain)( void ) |
||
58 | /***************************************/ |
||
59 | { |
||
60 | |||
61 | InitHeap(32*1024*1024); |
||
62 | //mf_init(); |
||
63 | |||
64 | |||
65 | __process_fini = &__FiniRtns; |
||
66 | __InitRtns( 255 ); |
||
67 | __CommonInit(); |
||
68 | |||
69 | __appcwdlen = strrchr(_LpPgmName, '/') - _LpPgmName + 1; |
||
70 | __appcwdlen = __appcwdlen > 512 ? 512 : __appcwdlen; |
||
71 | __appcwd= (char*)malloc(__appcwdlen); |
||
72 | strncpy(__appcwd, _LpPgmName, __appcwdlen); |
||
73 | __appcwd[__appcwdlen] = 0; |
||
74 | ___Argc = 2; |
||
75 | ___Argv[0] = _LpPgmName; |
||
76 | ___Argv[1] = _LpCmdLine; |
||
77 | |||
78 | #ifdef __WIDECHAR__ |
||
79 | exit( wmain( ___wArgc, ___wArgv ) ); |
||
80 | #else |
||
81 | exit( main( ___Argc, ___Argv ) ); |
||
82 | #endif |
||
83 | } |
||
84 | |||
85 | #ifdef __WIDECHAR__ |
||
86 | #if defined(_M_IX86) |
||
87 | #pragma aux __wNTMain "*" |
||
88 | #endif |
||
89 | #else |
||
90 | #if defined(_M_IX86) |
||
91 | #pragma aux __NTMain "*" |
||
92 | #endif |
||
93 | #endif |
||
94 | |||
95 | _WCRTLINK void __exit( unsigned ret_code ) |
||
96 | { |
||
97 | __FiniRtns( 0, FINI_PRIORITY_EXIT-1 ); |
||
98 | _asm |
||
99 | { |
||
100 | mov eax, -1 |
||
101 | int 0x40 |
||
102 | } |
||
103 | } |
||
104 |