Subversion Repositories Kolibri OS

Rev

Rev 548 | Rev 704 | Go to most recent revision | Details | Compare with Previous | 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 _stdcall InitHeap(int heap_size);
45
int  __appcwdlen;
46
char* __appcwd;
47
extern char *LpCmdLine;
48
extern char *LpPgmName;
49
 
702 serge 50
_WCRTLINK void (*__process_fini)(unsigned,unsigned) = 0;
51
 
52
#ifdef __SW_BR
53
    _WCRTLINK extern    void    (*__process_fini)( unsigned, unsigned );
54
    extern      void    __CommonInit( void );
55
    extern      int     wmain( int, wchar_t ** );
56
    extern      int     main( int, char ** );
57
#else
58
    extern      void            __NTMainInit( void *, void * );
59
    #ifdef __WIDECHAR__
60
        extern  void            __wCMain( void );
61
        #if defined(_M_IX86)
62
            #pragma aux __wCMain  "*"
63
        #endif
64
    #else
65
        extern  void            __CMain( void );
66
        #if defined(_M_IX86)
67
            #pragma aux __CMain  "*"
68
        #endif
69
    #endif
70
    extern      unsigned        __ThreadDataSize;
71
#endif
72
 
548 serge 73
void __F_NAME(__NTMain,__wNTMain)( void )
74
/***************************************/
75
{
76
 
702 serge 77
   InitHeap(0);
78
 
79
    __process_fini = &__FiniRtns;
548 serge 80
   __InitRtns( 255 );
81
   __CommonInit();
82
 
83
   __appcwdlen = strrchr(_LpPgmName, '/') - _LpPgmName + 1;
702 serge 84
   __appcwdlen = __appcwdlen > 512 ? 512 : __appcwdlen;
85
   __appcwd= (char*)malloc(__appcwdlen);
548 serge 86
   strncpy(__appcwd, _LpPgmName, __appcwdlen);
87
   __appcwd[__appcwdlen] = 0;
88
   ___Argc = 2;
89
   ___Argv[0] = _LpPgmName;
90
   ___Argv[1] = _LpCmdLine;
91
 
92
   #ifdef __WIDECHAR__
93
      exit( wmain( ___wArgc, ___wArgv ) );
94
   #else
95
      exit( main( ___Argc, ___Argv ) );
96
   #endif
97
}
98
 
99
#ifdef __WIDECHAR__
100
    #if defined(_M_IX86)
101
        #pragma aux __wNTMain "*"
102
    #endif
103
#else
104
    #if defined(_M_IX86)
105
        #pragma aux __NTMain "*"
106
    #endif
107
#endif
108
 
109
_WCRTLINK void __exit( unsigned ret_code )
110
{
111
  __FiniRtns( 0, FINI_PRIORITY_EXIT-1 );
112
  _asm
113
  {
114
    mov eax, -1
115
    int 0x40
116
  }
702 serge 117
}
548 serge 118