Release 960506
[wine/multimedia.git] / loader / main.c
blob0a2d76464d86ca0ec466a09ee3b9fab0b3956561
1 /*
2 static char RCSId[] = "$Id: wine.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
3 static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
4 */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <sys/types.h>
8 #include <sys/stat.h>
9 #include <fcntl.h>
10 #include <unistd.h>
11 #include <string.h>
12 #include <errno.h>
13 #include "windows.h"
14 #include "alias.h"
15 #include "module.h"
16 #include "task.h"
17 #include "selectors.h"
18 #include "comm.h"
19 #include "win.h"
20 #include "menu.h"
21 #include "kernel32.h"
22 #include "atom.h"
23 #include "dialog.h"
24 #include "directory.h"
25 #include "drive.h"
26 #include "queue.h"
27 #include "syscolor.h"
28 #include "sysmetrics.h"
29 #include "gdi.h"
30 #include "heap.h"
31 #include "debugger.h"
32 #include "miscemu.h"
33 #include "neexe.h"
34 #include "options.h"
35 #include "spy.h"
36 #include "task.h"
37 #include "user.h"
38 #include "dce.h"
39 #include "pe_image.h"
40 #include "stddebug.h"
41 #include "debug.h"
43 void init_wine_signals(void);
45 HANDLE32 SystemHeap = 0;
47 /***********************************************************************
48 * Main initialisation routine
50 int MAIN_Init(void)
52 extern BOOL RELAY_Init(void);
54 int queueSize;
56 /* Create the system heap */
57 if (!(SystemHeap = HeapCreate( HEAP_GROWABLE, 0x10000, 0 ))) return 0;
59 /* Load the configuration file */
60 if (!PROFILE_LoadWineIni()) return 0;
62 /* Initialize message spying */
63 if (!SPY_Init()) return 0;
65 #ifdef WINELIB
66 /* Create USER and GDI heap */
67 USER_HeapSel = GlobalAlloc16( GMEM_FIXED, 0x10000 );
68 LocalInit( USER_HeapSel, 0, 0xffff );
69 GDI_HeapSel = GlobalAlloc16( GMEM_FIXED, GDI_HEAP_SIZE );
70 LocalInit( GDI_HeapSel, 0, GDI_HEAP_SIZE-1 );
71 #else
72 /* Initialize relay code */
73 if (!RELAY_Init()) return 0;
75 /* Create built-in modules */
76 if (!BUILTIN_Init()) return 0;
77 #endif
79 /* Initialise DOS drives */
80 if (!DRIVE_Init()) return 0;
82 /* Initialise DOS directories */
83 if (!DIR_Init()) return 0;
85 /* Initialize tasks */
86 if (!TASK_Init()) return 0;
88 /* Initialize communications */
89 COMM_Init();
91 #ifndef WINELIB
92 /* Initialize interrupt vectors */
93 if (!INT_Init()) return 0;
95 /* Initialize DOS memory */
96 if (!DOSMEM_Init()) return 0;
98 /* Initialize signal handling */
99 init_wine_signals();
101 /* Initialize the DOS memory */
102 if (!INT21_Init()) return 0;
103 #endif
105 /* Global atom table initialisation */
106 if (!ATOM_Init()) return 0;
108 /* GDI initialisation */
109 if (!GDI_Init()) return 0;
111 /* Initialise window procedures aliases */
112 if (!ALIAS_Init()) return 0;
114 /* Initialize system colors and metrics*/
115 SYSMETRICS_Init();
116 SYSCOLOR_Init();
118 /* Create the DCEs */
119 DCE_Init();
121 /* Initialize dialog manager */
122 if (!DIALOG_Init()) return 0;
124 /* Initialize menus */
125 if (!MENU_Init()) return 0;
127 /* Initialize Win32 data structures */
128 if (!KERN32_Init()) return 0;
130 /* Create system message queue */
131 queueSize = GetProfileInt( "windows", "TypeAhead", 120 );
132 if (!QUEUE_CreateSysMsgQueue( queueSize )) return 0;
134 /* Set double click time */
135 SetDoubleClickTime( GetProfileInt( "windows", "DoubleClickSpeed", 452 ) );
137 return 1;
141 #ifndef WINELIB
142 /**********************************************************************
143 * main
145 int _WinMain(int argc, char **argv)
147 int i;
148 HANDLE handle;
150 if (!MAIN_Init()) return 0;
152 for (i = 1; i < argc; i++)
154 if ((handle = WinExec( argv[i], SW_SHOWNORMAL )) < 32)
156 fprintf(stderr, "wine: can't exec '%s': ", argv[i]);
157 switch (handle)
159 case 2: fprintf( stderr, "file not found\n" ); break;
160 case 11: fprintf( stderr, "invalid exe file\n" ); break;
161 case 21: fprintf( stderr, "win32 executable\n" ); break;
162 default: fprintf( stderr, "error=%d\n", handle ); break;
164 exit(1);
168 if (Options.debug) DEBUG_SetBreakpoints( TRUE ); /* Setup breakpoints */
170 Yield(); /* Start the first task */
171 fprintf( stderr, "WinMain: Should never happen: returned from Yield()\n" );
172 return 0;
175 #endif /* #ifndef WINELIB */