Release 980601
[wine.git] / loader / main.c
blob5f592a69f2049d579e5ce7b1d583954bd656114f
1 /*
2 * Main initialization code
3 */
5 #include <stdlib.h>
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <fcntl.h>
9 #include <unistd.h>
10 #include <string.h>
11 #include <errno.h>
12 #include "windows.h"
13 #include "bitmap.h"
14 #include "comm.h"
15 #include "win.h"
16 #include "main.h"
17 #include "menu.h"
18 #include "message.h"
19 #include "multimedia.h"
20 #include "atom.h"
21 #include "dialog.h"
22 #include "drive.h"
23 #include "queue.h"
24 #include "sysmetrics.h"
25 #include "file.h"
26 #include "gdi.h"
27 #include "heap.h"
28 #include "keyboard.h"
29 #include "miscemu.h"
30 #include "options.h"
31 #include "process.h"
32 #include "spy.h"
33 #include "tweak.h"
34 #include "user.h"
35 #include "dce.h"
36 #include "shell.h"
37 #include "winproc.h"
38 #include "debug.h"
41 int __winelib = 1; /* Winelib run-time flag */
43 /***********************************************************************
44 * Kernel initialisation routine
46 BOOL32 MAIN_KernelInit(void)
48 /* Initialize signal handling */
49 if (!SIGNAL_Init()) return FALSE;
51 /* Load the configuration file */
52 if (!PROFILE_LoadWineIni()) return FALSE;
54 /* Initialize DOS memory */
55 if (!DOSMEM_Init()) return FALSE;
57 /* Initialise DOS drives */
58 if (!DRIVE_Init()) return FALSE;
60 /* Initialise DOS directories */
61 if (!DIR_Init()) return FALSE;
63 /* Initialize event handling */
64 if (!EVENT_Init()) return FALSE;
66 /* Initialize communications */
67 COMM_Init();
69 /* Initialize IO-port permissions */
70 IO_port_init();
72 return TRUE;
76 /***********************************************************************
77 * USER (and GDI) initialisation routine
79 BOOL32 MAIN_UserInit(void)
81 int queueSize;
83 /* Create USER and GDI heap */
84 if (!USER_HeapSel)
86 USER_HeapSel = GlobalAlloc16( GMEM_FIXED, 0x10000 );
87 LocalInit( USER_HeapSel, 0, 0xffff );
89 if (!GDI_HeapSel)
91 GDI_HeapSel = GlobalAlloc16( GMEM_FIXED, GDI_HEAP_SIZE );
92 LocalInit( GDI_HeapSel, 0, GDI_HEAP_SIZE-1 );
95 /* Initialize Wine tweaks */
96 if (!TWEAK_Init()) return FALSE;
98 /* Initialize OEM Bitmaps */
99 if (!OBM_Init()) return FALSE;
101 /* registry initialisation */
102 SHELL_LoadRegistry();
104 /* Global atom table initialisation */
105 if (!ATOM_Init()) return FALSE;
107 /* GDI initialisation */
108 if (!GDI_Init()) return FALSE;
110 /* Initialize system colors and metrics*/
111 SYSMETRICS_Init();
112 SYSCOLOR_Init();
114 /* Create the DCEs */
115 DCE_Init();
117 /* Initialize keyboard */
118 if (!KEYBOARD_Init()) return FALSE;
120 /* Initialize window procedures */
121 if (!WINPROC_Init()) return FALSE;
123 /* Initialize built-in window classes */
124 if (!WIDGETS_Init()) return FALSE;
126 /* Initialize dialog manager */
127 if (!DIALOG_Init()) return FALSE;
129 /* Initialize menus */
130 if (!MENU_Init()) return FALSE;
132 /* Initialize multimedia */
133 if (!MULTIMEDIA_Init()) return FALSE;
135 /* Create desktop window */
136 if (!WIN_CreateDesktopWindow()) return FALSE;
138 /* Initialize message spying */
139 if (!SPY_Init()) return FALSE;
141 /* Check wine.conf for old/bad entries */
142 if (!TWEAK_CheckConfiguration()) return FALSE;
144 /* Create system message queue */
145 queueSize = GetProfileInt32A( "windows", "TypeAhead", 120 );
146 if (!QUEUE_CreateSysMsgQueue( queueSize )) return FALSE;
148 /* Set double click time */
149 SetDoubleClickTime32( GetProfileInt32A("windows","DoubleClickSpeed",452) );
151 return TRUE;
155 /***********************************************************************
156 * Winelib initialisation routine
158 BOOL32 MAIN_WinelibInit( int *argc, char *argv[] )
160 /* Create the initial process */
161 if (!PROCESS_Init()) return FALSE;
163 /* Parse command line arguments */
164 MAIN_WineInit( argc, argv );
166 /* Initialize the kernel */
167 if (!MAIN_KernelInit()) return FALSE;
169 /* Initialize all the USER stuff */
170 if (!MAIN_UserInit()) return FALSE;
172 return TRUE;