Export the debugging API from libwine instead of ntdll.
[wine] / loader / main.c
1 /*
2  * Main initialization code
3  *
4  * Copyright 1998 Ulrich Weigand
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include <locale.h>
22 #include <stdlib.h>
23 #include <sys/types.h>
24 #include <sys/stat.h>
25 #include <fcntl.h>
26 #include <unistd.h>
27 #include <stdio.h>
28 #include <string.h>
29 #ifdef MALLOC_DEBUGGING
30 # include <malloc.h>
31 #endif
32 #include "windef.h"
33 #include "wine/winbase16.h"
34 #include "drive.h"
35 #include "file.h"
36 #include "options.h"
37 #include "module.h"
38 #include "wine/debug.h"
39 #include "wine/server.h"
40
41 WINE_DEFAULT_DEBUG_CHANNEL(server);
42
43 extern void SHELL_LoadRegistry(void);
44
45 /***********************************************************************
46  *           Main initialisation routine
47  */
48 BOOL MAIN_MainInit(void)
49 {
50 #ifdef MALLOC_DEBUGGING
51     char *trace;
52
53     mcheck(NULL);
54     if (!(trace = getenv("MALLOC_TRACE")))
55         MESSAGE( "MALLOC_TRACE not set. No trace generated\n" );
56     else
57     {
58         MESSAGE( "malloc trace goes to %s\n", trace );
59         mtrace();
60     }
61 #endif
62     setbuf(stdout,NULL);
63     setbuf(stderr,NULL);
64     setlocale(LC_CTYPE,"");
65
66     /* Load the configuration file */
67     if (!PROFILE_LoadWineIni()) return FALSE;
68
69     /* Initialise DOS drives */
70     if (!DRIVE_Init()) return FALSE;
71
72     /* Initialise DOS directories */
73     if (!DIR_Init()) return FALSE;
74
75     /* Registry initialisation */
76     SHELL_LoadRegistry();
77
78     /* Initialize module loadorder */
79     if (CLIENT_IsBootThread()) MODULE_InitLoadOrder();
80
81     /* Global boot finished, the rest is process-local */
82     CLIENT_BootDone( TRACE_ON(server) );
83
84     return TRUE;
85 }
86
87
88 /***********************************************************************
89  *           ExitKernel (KERNEL.2)
90  *
91  * Clean-up everything and exit the Wine process.
92  *
93  */
94 void WINAPI ExitKernel16( void )
95 {
96     /* Do the clean-up stuff */
97
98     WriteOutProfiles16();
99     TerminateProcess( GetCurrentProcess(), 0 );
100 }
101