Subversion Repositories Kolibri OS

Rev

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