blob: b54271ff1e32ece06db5edad267c88de12b41aeb [file] [log] [blame]
Alexandre Julliard234bc241994-12-10 13:02:28 +00001/*
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00002 * Main initialization code
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00003 *
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
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000019 */
20
Alexandre Julliard751625e2000-12-12 00:50:19 +000021#include <locale.h>
Alexandre Julliard490a27e1994-06-08 13:57:50 +000022#include <stdlib.h>
23#include <sys/types.h>
24#include <sys/stat.h>
25#include <fcntl.h>
26#include <unistd.h>
Alexandre Julliard751625e2000-12-12 00:50:19 +000027#include <stdio.h>
Alexandre Julliard490a27e1994-06-08 13:57:50 +000028#include <string.h>
Alexandre Julliard751625e2000-12-12 00:50:19 +000029#ifdef MALLOC_DEBUGGING
30# include <malloc.h>
31#endif
Jeremy Whited3e22d92000-02-10 19:03:02 +000032#include "windef.h"
Marcus Meissner317af321999-02-17 13:51:06 +000033#include "wine/winbase16.h"
Alexandre Julliard4f8c37b1996-01-14 18:12:01 +000034#include "drive.h"
Alexandre Julliard9ea19e51997-01-01 17:29:55 +000035#include "file.h"
Alexandre Julliard490a27e1994-06-08 13:57:50 +000036#include "options.h"
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000037#include "wine/debug.h"
Alexandre Julliard37e95032001-07-19 00:39:09 +000038#include "wine/server.h"
Alexandre Julliardaf0bae51995-10-03 17:06:08 +000039
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000040WINE_DEFAULT_DEBUG_CHANNEL(server);
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000041
Alexandre Julliard751625e2000-12-12 00:50:19 +000042extern void SHELL_LoadRegistry(void);
43
Alexandre Julliard594997c1995-04-30 10:05:20 +000044/***********************************************************************
Ulrich Weigandc75d0e11998-11-01 17:59:35 +000045 * Main initialisation routine
Alexandre Julliard594997c1995-04-30 10:05:20 +000046 */
Alexandre Julliarda3e0cfc2000-07-16 18:21:34 +000047BOOL MAIN_MainInit(void)
Alexandre Julliard594997c1995-04-30 10:05:20 +000048{
Alexandre Julliard751625e2000-12-12 00:50:19 +000049#ifdef MALLOC_DEBUGGING
50 char *trace;
51
52 mcheck(NULL);
53 if (!(trace = getenv("MALLOC_TRACE")))
54 MESSAGE( "MALLOC_TRACE not set. No trace generated\n" );
55 else
56 {
57 MESSAGE( "malloc trace goes to %s\n", trace );
58 mtrace();
59 }
60#endif
61 setbuf(stdout,NULL);
62 setbuf(stderr,NULL);
63 setlocale(LC_CTYPE,"");
Ulrich Weigand8a64b831999-10-23 14:15:33 +000064
Alexandre Julliard7e56f681996-01-31 19:02:28 +000065 /* Load the configuration file */
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000066 if (!PROFILE_LoadWineIni()) return FALSE;
Alexandre Julliard7e56f681996-01-31 19:02:28 +000067
Alexandre Julliard4f8c37b1996-01-14 18:12:01 +000068 /* Initialise DOS drives */
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000069 if (!DRIVE_Init()) return FALSE;
Alexandre Julliard4f8c37b1996-01-14 18:12:01 +000070
71 /* Initialise DOS directories */
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000072 if (!DIR_Init()) return FALSE;
Alexandre Julliard808cb041995-08-17 17:11:36 +000073
Alexandre Julliard2fe57772000-01-25 01:40:27 +000074 /* Registry initialisation */
75 SHELL_LoadRegistry();
Alexandre Julliard2fe57772000-01-25 01:40:27 +000076
Alexandre Julliardb9c9cdc2001-03-20 02:11:08 +000077 /* Global boot finished, the rest is process-local */
78 CLIENT_BootDone( TRACE_ON(server) );
Alexandre Julliard2fe57772000-01-25 01:40:27 +000079
Ulrich Weigandc75d0e11998-11-01 17:59:35 +000080 return TRUE;
81}
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000082
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000083
84/***********************************************************************
Patrik Stridvall01d5e5b2001-07-02 19:59:40 +000085 * ExitKernel (KERNEL.2)
Ulrich Weigandc319c661999-05-22 16:18:36 +000086 *
87 * Clean-up everything and exit the Wine process.
88 *
89 */
90void WINAPI ExitKernel16( void )
91{
92 /* Do the clean-up stuff */
93
94 WriteOutProfiles16();
Ulrich Weigandad6657e1999-06-06 14:43:34 +000095 TerminateProcess( GetCurrentProcess(), 0 );
Ulrich Weigandc319c661999-05-22 16:18:36 +000096}
97