Alexandre Julliard | 234bc24 | 1994-12-10 13:02:28 +0000 | [diff] [blame] | 1 | /* |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 2 | * Main initialization code |
| 3 | */ |
| 4 | |
Alexandre Julliard | 751625e | 2000-12-12 00:50:19 +0000 | [diff] [blame] | 5 | #include <locale.h> |
Alexandre Julliard | 490a27e | 1994-06-08 13:57:50 +0000 | [diff] [blame] | 6 | #include <stdlib.h> |
| 7 | #include <sys/types.h> |
| 8 | #include <sys/stat.h> |
| 9 | #include <fcntl.h> |
| 10 | #include <unistd.h> |
Alexandre Julliard | 751625e | 2000-12-12 00:50:19 +0000 | [diff] [blame] | 11 | #include <stdio.h> |
Alexandre Julliard | 490a27e | 1994-06-08 13:57:50 +0000 | [diff] [blame] | 12 | #include <string.h> |
Alexandre Julliard | 751625e | 2000-12-12 00:50:19 +0000 | [diff] [blame] | 13 | #ifdef MALLOC_DEBUGGING |
| 14 | # include <malloc.h> |
| 15 | #endif |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 16 | #include "windef.h" |
Marcus Meissner | 317af32 | 1999-02-17 13:51:06 +0000 | [diff] [blame] | 17 | #include "wine/winbase16.h" |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 18 | #include "drive.h" |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 19 | #include "file.h" |
Alexandre Julliard | 490a27e | 1994-06-08 13:57:50 +0000 | [diff] [blame] | 20 | #include "options.h" |
Alexandre Julliard | f899ef0 | 2001-07-23 00:04:00 +0000 | [diff] [blame] | 21 | #include "module.h" |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 22 | #include "debugtools.h" |
Alexandre Julliard | 37e9503 | 2001-07-19 00:39:09 +0000 | [diff] [blame] | 23 | #include "wine/server.h" |
Alexandre Julliard | af0bae5 | 1995-10-03 17:06:08 +0000 | [diff] [blame] | 24 | |
Alexandre Julliard | b445952 | 2000-04-15 21:00:55 +0000 | [diff] [blame] | 25 | DEFAULT_DEBUG_CHANNEL(server); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 26 | |
Alexandre Julliard | 751625e | 2000-12-12 00:50:19 +0000 | [diff] [blame] | 27 | extern void SHELL_LoadRegistry(void); |
| 28 | |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 29 | /*********************************************************************** |
Ulrich Weigand | c75d0e1 | 1998-11-01 17:59:35 +0000 | [diff] [blame] | 30 | * Main initialisation routine |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 31 | */ |
Alexandre Julliard | a3e0cfc | 2000-07-16 18:21:34 +0000 | [diff] [blame] | 32 | BOOL MAIN_MainInit(void) |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 33 | { |
Alexandre Julliard | 751625e | 2000-12-12 00:50:19 +0000 | [diff] [blame] | 34 | #ifdef MALLOC_DEBUGGING |
| 35 | char *trace; |
| 36 | |
| 37 | mcheck(NULL); |
| 38 | if (!(trace = getenv("MALLOC_TRACE"))) |
| 39 | MESSAGE( "MALLOC_TRACE not set. No trace generated\n" ); |
| 40 | else |
| 41 | { |
| 42 | MESSAGE( "malloc trace goes to %s\n", trace ); |
| 43 | mtrace(); |
| 44 | } |
| 45 | #endif |
| 46 | setbuf(stdout,NULL); |
| 47 | setbuf(stderr,NULL); |
| 48 | setlocale(LC_CTYPE,""); |
Ulrich Weigand | 8a64b83 | 1999-10-23 14:15:33 +0000 | [diff] [blame] | 49 | |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 50 | /* Load the configuration file */ |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 51 | if (!PROFILE_LoadWineIni()) return FALSE; |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 52 | |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 53 | /* Initialise DOS drives */ |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 54 | if (!DRIVE_Init()) return FALSE; |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 55 | |
| 56 | /* Initialise DOS directories */ |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 57 | if (!DIR_Init()) return FALSE; |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 58 | |
Alexandre Julliard | 2fe5777 | 2000-01-25 01:40:27 +0000 | [diff] [blame] | 59 | /* Registry initialisation */ |
| 60 | SHELL_LoadRegistry(); |
Alexandre Julliard | 2fe5777 | 2000-01-25 01:40:27 +0000 | [diff] [blame] | 61 | |
| 62 | /* Initialize module loadorder */ |
Alexandre Julliard | b9c9cdc | 2001-03-20 02:11:08 +0000 | [diff] [blame] | 63 | if (CLIENT_IsBootThread()) MODULE_InitLoadOrder(); |
| 64 | |
| 65 | /* Global boot finished, the rest is process-local */ |
| 66 | CLIENT_BootDone( TRACE_ON(server) ); |
Alexandre Julliard | 2fe5777 | 2000-01-25 01:40:27 +0000 | [diff] [blame] | 67 | |
Ulrich Weigand | c75d0e1 | 1998-11-01 17:59:35 +0000 | [diff] [blame] | 68 | return TRUE; |
| 69 | } |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 70 | |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 71 | |
| 72 | /*********************************************************************** |
Patrik Stridvall | 01d5e5b | 2001-07-02 19:59:40 +0000 | [diff] [blame] | 73 | * ExitKernel (KERNEL.2) |
Ulrich Weigand | c319c66 | 1999-05-22 16:18:36 +0000 | [diff] [blame] | 74 | * |
| 75 | * Clean-up everything and exit the Wine process. |
| 76 | * |
| 77 | */ |
| 78 | void WINAPI ExitKernel16( void ) |
| 79 | { |
| 80 | /* Do the clean-up stuff */ |
| 81 | |
| 82 | WriteOutProfiles16(); |
Ulrich Weigand | ad6657e | 1999-06-06 14:43:34 +0000 | [diff] [blame] | 83 | TerminateProcess( GetCurrentProcess(), 0 ); |
Ulrich Weigand | c319c66 | 1999-05-22 16:18:36 +0000 | [diff] [blame] | 84 | } |
| 85 | |