Added include protection for unistd.h and sys/time.h.
[wine/hacks.git] / loader / main.c
blob88b2171761a5b3e195457d09d54aeb96578545eb
1 /*
2 * Main initialization code
4 * Copyright 1998 Ulrich Weigand
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.
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.
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
21 #include "config.h"
23 #include <locale.h>
24 #include <stdlib.h>
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <fcntl.h>
28 #ifdef HAVE_UNISTD_H
29 # include <unistd.h>
30 #endif
31 #include <stdio.h>
32 #include <string.h>
33 #ifdef MALLOC_DEBUGGING
34 # include <malloc.h>
35 #endif
36 #include "windef.h"
37 #include "wine/winbase16.h"
38 #include "drive.h"
39 #include "file.h"
40 #include "options.h"
41 #include "wine/debug.h"
42 #include "wine/server.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(server);
46 extern void SHELL_LoadRegistry(void);
48 /***********************************************************************
49 * Main initialisation routine
51 BOOL MAIN_MainInit(void)
53 #ifdef MALLOC_DEBUGGING
54 char *trace;
56 mcheck(NULL);
57 if (!(trace = getenv("MALLOC_TRACE")))
58 MESSAGE( "MALLOC_TRACE not set. No trace generated\n" );
59 else
61 MESSAGE( "malloc trace goes to %s\n", trace );
62 mtrace();
64 #endif
65 setbuf(stdout,NULL);
66 setbuf(stderr,NULL);
67 setlocale(LC_CTYPE,"");
69 /* Load the configuration file */
70 if (!PROFILE_LoadWineIni()) return FALSE;
72 /* Initialise DOS drives */
73 if (!DRIVE_Init()) return FALSE;
75 /* Initialise DOS directories */
76 if (!DIR_Init()) return FALSE;
78 /* Registry initialisation */
79 SHELL_LoadRegistry();
81 /* Global boot finished, the rest is process-local */
82 CLIENT_BootDone( TRACE_ON(server) );
84 return TRUE;
88 /***********************************************************************
89 * ExitKernel (KERNEL.2)
91 * Clean-up everything and exit the Wine process.
94 void WINAPI ExitKernel16( void )
96 /* Do the clean-up stuff */
98 WriteOutProfiles16();
99 TerminateProcess( GetCurrentProcess(), 0 );