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 |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 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 |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 19 | */ |
| 20 | |
Alexandre Julliard | 751625e | 2000-12-12 00:50:19 +0000 | [diff] [blame] | 21 | #include <locale.h> |
Alexandre Julliard | 490a27e | 1994-06-08 13:57:50 +0000 | [diff] [blame] | 22 | #include <stdlib.h> |
| 23 | #include <sys/types.h> |
| 24 | #include <sys/stat.h> |
| 25 | #include <fcntl.h> |
| 26 | #include <unistd.h> |
Alexandre Julliard | 751625e | 2000-12-12 00:50:19 +0000 | [diff] [blame] | 27 | #include <stdio.h> |
Alexandre Julliard | 490a27e | 1994-06-08 13:57:50 +0000 | [diff] [blame] | 28 | #include <string.h> |
Alexandre Julliard | 751625e | 2000-12-12 00:50:19 +0000 | [diff] [blame] | 29 | #ifdef MALLOC_DEBUGGING |
| 30 | # include <malloc.h> |
| 31 | #endif |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 32 | #include "windef.h" |
Marcus Meissner | 317af32 | 1999-02-17 13:51:06 +0000 | [diff] [blame] | 33 | #include "wine/winbase16.h" |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 34 | #include "drive.h" |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 35 | #include "file.h" |
Alexandre Julliard | 490a27e | 1994-06-08 13:57:50 +0000 | [diff] [blame] | 36 | #include "options.h" |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 37 | #include "wine/debug.h" |
Alexandre Julliard | 37e9503 | 2001-07-19 00:39:09 +0000 | [diff] [blame] | 38 | #include "wine/server.h" |
Alexandre Julliard | af0bae5 | 1995-10-03 17:06:08 +0000 | [diff] [blame] | 39 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 40 | WINE_DEFAULT_DEBUG_CHANNEL(server); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 41 | |
Alexandre Julliard | 751625e | 2000-12-12 00:50:19 +0000 | [diff] [blame] | 42 | extern void SHELL_LoadRegistry(void); |
| 43 | |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 44 | /*********************************************************************** |
Ulrich Weigand | c75d0e1 | 1998-11-01 17:59:35 +0000 | [diff] [blame] | 45 | * Main initialisation routine |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 46 | */ |
Alexandre Julliard | a3e0cfc | 2000-07-16 18:21:34 +0000 | [diff] [blame] | 47 | BOOL MAIN_MainInit(void) |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 48 | { |
Alexandre Julliard | 751625e | 2000-12-12 00:50:19 +0000 | [diff] [blame] | 49 | #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 Weigand | 8a64b83 | 1999-10-23 14:15:33 +0000 | [diff] [blame] | 64 | |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 65 | /* Load the configuration file */ |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 66 | if (!PROFILE_LoadWineIni()) return FALSE; |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 67 | |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 68 | /* Initialise DOS drives */ |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 69 | if (!DRIVE_Init()) return FALSE; |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 70 | |
| 71 | /* Initialise DOS directories */ |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 72 | if (!DIR_Init()) return FALSE; |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 73 | |
Alexandre Julliard | 2fe5777 | 2000-01-25 01:40:27 +0000 | [diff] [blame] | 74 | /* Registry initialisation */ |
| 75 | SHELL_LoadRegistry(); |
Alexandre Julliard | 2fe5777 | 2000-01-25 01:40:27 +0000 | [diff] [blame] | 76 | |
Alexandre Julliard | b9c9cdc | 2001-03-20 02:11:08 +0000 | [diff] [blame] | 77 | /* Global boot finished, the rest is process-local */ |
| 78 | CLIENT_BootDone( TRACE_ON(server) ); |
Alexandre Julliard | 2fe5777 | 2000-01-25 01:40:27 +0000 | [diff] [blame] | 79 | |
Ulrich Weigand | c75d0e1 | 1998-11-01 17:59:35 +0000 | [diff] [blame] | 80 | return TRUE; |
| 81 | } |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 82 | |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 83 | |
| 84 | /*********************************************************************** |
Patrik Stridvall | 01d5e5b | 2001-07-02 19:59:40 +0000 | [diff] [blame] | 85 | * ExitKernel (KERNEL.2) |
Ulrich Weigand | c319c66 | 1999-05-22 16:18:36 +0000 | [diff] [blame] | 86 | * |
| 87 | * Clean-up everything and exit the Wine process. |
| 88 | * |
| 89 | */ |
| 90 | void WINAPI ExitKernel16( void ) |
| 91 | { |
| 92 | /* Do the clean-up stuff */ |
| 93 | |
| 94 | WriteOutProfiles16(); |
Ulrich Weigand | ad6657e | 1999-06-06 14:43:34 +0000 | [diff] [blame] | 95 | TerminateProcess( GetCurrentProcess(), 0 ); |
Ulrich Weigand | c319c66 | 1999-05-22 16:18:36 +0000 | [diff] [blame] | 96 | } |
| 97 | |