Release 980809
[wine] / loader / main.c
1 /*
2  * Main initialization code
3  */
4
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 "syslevel.h"
39 #include "debug.h"
40
41
42 int __winelib = 1;  /* Winelib run-time flag */
43
44 /***********************************************************************
45  *           Kernel initialisation routine
46  */
47 BOOL32 MAIN_KernelInit(void)
48 {
49     /* Initialize syslevel handling */
50     SYSLEVEL_Init();
51
52     /* Initialize signal handling */
53     if (!SIGNAL_Init()) return FALSE;
54
55     /* Load the configuration file */
56     if (!PROFILE_LoadWineIni()) return FALSE;
57
58       /* Initialize DOS memory */
59     if (!DOSMEM_Init(0)) return FALSE;
60
61     /* Initialise DOS drives */
62     if (!DRIVE_Init()) return FALSE;
63
64     /* Initialise DOS directories */
65     if (!DIR_Init()) return FALSE;
66
67       /* Initialize event handling */
68     if (!EVENT_Init()) return FALSE;
69
70     /* Initialize communications */
71     COMM_Init();
72
73     /* Initialize IO-port permissions */
74     IO_port_init();
75
76     return TRUE;
77 }
78
79
80 /***********************************************************************
81  *           USER (and GDI) initialisation routine
82  */
83 BOOL32 MAIN_UserInit(void)
84 {
85     int queueSize;
86
87     /* Create USER and GDI heap */
88     if (!USER_HeapSel)
89     {
90         USER_HeapSel = GlobalAlloc16( GMEM_FIXED, 0x10000 );
91         LocalInit( USER_HeapSel, 0, 0xffff );
92     }
93     if (!GDI_HeapSel)
94     {
95         GDI_HeapSel  = GlobalAlloc16( GMEM_FIXED, GDI_HEAP_SIZE );
96         LocalInit( GDI_HeapSel, 0, GDI_HEAP_SIZE-1 );
97     }
98
99     /* Initialize Wine tweaks */
100     if (!TWEAK_Init()) return FALSE;
101
102     /* Initialize OEM Bitmaps */
103     if (!OBM_Init()) return FALSE;
104
105     /* registry initialisation */
106     SHELL_LoadRegistry();
107     
108     /* Global atom table initialisation */
109     if (!ATOM_Init()) return FALSE;
110
111     /* GDI initialisation */
112     if (!GDI_Init()) return FALSE;
113
114     /* Initialize system colors and metrics*/
115     SYSMETRICS_Init();
116     SYSCOLOR_Init();
117
118     /* Create the DCEs */
119     DCE_Init();
120
121     /* Initialize keyboard */
122     if (!KEYBOARD_Init()) return FALSE;
123
124     /* Initialize window procedures */
125     if (!WINPROC_Init()) return FALSE;
126
127     /* Initialize built-in window classes */
128     if (!WIDGETS_Init()) return FALSE;
129
130     /* Initialize dialog manager */
131     if (!DIALOG_Init()) return FALSE;
132
133     /* Initialize menus */
134     if (!MENU_Init()) return FALSE;
135
136     /* Initialize multimedia */
137     if (!MULTIMEDIA_Init()) return FALSE;
138
139     /* Create desktop window */
140     if (!WIN_CreateDesktopWindow()) return FALSE;
141
142     /* Initialize message spying */
143     if (!SPY_Init()) return FALSE;
144
145     /* Check wine.conf for old/bad entries */
146     if (!TWEAK_CheckConfiguration()) return FALSE;
147
148     /* Create system message queue */
149     queueSize = GetProfileInt32A( "windows", "TypeAhead", 120 );
150     if (!QUEUE_CreateSysMsgQueue( queueSize )) return FALSE;
151
152     /* Set double click time */
153     SetDoubleClickTime32( GetProfileInt32A("windows","DoubleClickSpeed",452) );
154
155     return TRUE;
156 }
157
158
159 /***********************************************************************
160  *           Winelib initialisation routine
161  */
162 BOOL32 MAIN_WinelibInit( int *argc, char *argv[] )
163 {
164     /* Create the initial process */
165     if (!PROCESS_Init()) return FALSE;
166
167     /* Parse command line arguments */
168     MAIN_WineInit( argc, argv );
169
170     /* Initialize the kernel */
171     if (!MAIN_KernelInit()) return FALSE;
172
173     /* Initialize all the USER stuff */
174     if (!MAIN_UserInit()) return FALSE;
175
176     return TRUE;
177 }