Release 960314
[wine.git] / loader / main.c
blob0aca285c38c7bd1739f6ca7ad251b0371fa400a7
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 "module.h"
15 #include "task.h"
16 #include "selectors.h"
17 #include "comm.h"
18 #include "user.h"
19 #include "menu.h"
20 #include "kernel32.h"
21 #include "atom.h"
22 #include "dialog.h"
23 #include "directory.h"
24 #include "drive.h"
25 #include "queue.h"
26 #include "syscolor.h"
27 #include "sysmetrics.h"
28 #include "gdi.h"
29 #include "debugger.h"
30 #include "dlls.h"
31 #include "miscemu.h"
32 #include "neexe.h"
33 #include "options.h"
34 #include "spy.h"
35 #include "task.h"
36 #include "dce.h"
37 #include "pe_image.h"
38 #include "stddebug.h"
39 #include "debug.h"
41 void init_wine_signals(void);
44 /***********************************************************************
45 * Main initialisation routine
47 int MAIN_Init(void)
49 extern BOOL RELAY_Init(void);
50 extern BOOL RELAY32_Init(void);
52 int queueSize;
54 /* Load the configuration file */
55 if (!PROFILE_LoadWineIni()) return 0;
57 /* Initialize message spying */
58 if (!SPY_Init()) return 0;
60 #ifndef WINELIB
61 /* Initialize relay code */
62 if (!RELAY_Init()) return 0;
64 /* Initialize Win32 relay code */
65 if (!RELAY32_Init()) return 0;
66 #endif
68 /* Create built-in modules */
69 if (!MODULE_Init()) return 0;
71 /* Initialise DOS drives */
72 if (!DRIVE_Init()) return 0;
74 /* Initialise DOS directories */
75 if (!DIR_Init()) return 0;
77 /* Initialize tasks */
78 if (!TASK_Init()) return 0;
80 /* Initialize communications */
81 COMM_Init();
83 #ifndef WINELIB
84 /* Initialize interrupt vectors */
85 if (!INT_Init()) return 0;
87 /* Initialize DOS memory */
88 if (!DOSMEM_Init()) return 0;
90 /* Initialize signal handling */
91 init_wine_signals();
93 /* Initialize the DOS memory */
94 if (!INT21_Init()) return 0;
96 /* Create USER heap */
97 if (!USER_HeapInit()) return 0;
98 #endif
100 /* Global atom table initialisation */
101 if (!ATOM_Init()) return 0;
103 /* GDI initialisation */
104 if (!GDI_Init()) return 0;
106 /* Initialize system colors and metrics*/
107 SYSMETRICS_Init();
108 SYSCOLOR_Init();
110 /* Create the DCEs */
111 DCE_Init();
113 /* Initialize dialog manager */
114 if (!DIALOG_Init()) return 0;
116 /* Initialize menus */
117 if (!MENU_Init()) return 0;
119 /* Initialize Win32 data structures */
120 if (!KERN32_Init()) return 0;
122 /* Create system message queue */
123 queueSize = GetProfileInt( "windows", "TypeAhead", 120 );
124 if (!QUEUE_CreateSysMsgQueue( queueSize )) return 0;
126 /* Set double click time */
127 SetDoubleClickTime( GetProfileInt( "windows", "DoubleClickSpeed", 452 ) );
129 return 1;
133 #ifndef WINELIB
134 /**********************************************************************
135 * main
137 int _WinMain(int argc, char **argv)
139 int i;
140 HANDLE handle;
142 if (!MAIN_Init()) return 0;
144 for (i = 1; i < argc; i++)
146 if ((handle = WinExec( argv[i], SW_SHOWNORMAL )) < 32)
148 fprintf(stderr, "wine: can't exec '%s': ", argv[i]);
149 switch (handle)
151 case 2: fprintf( stderr, "file not found\n" ); break;
152 case 11: fprintf( stderr, "invalid exe file\n" ); break;
153 case 21: fprintf( stderr, "win32 executable\n" ); break;
154 default: fprintf( stderr, "error=%d\n", handle ); break;
156 exit(1);
160 if (Options.debug) DEBUG_SetBreakpoints( TRUE ); /* Setup breakpoints */
162 Yield(); /* Start the first task */
163 fprintf( stderr, "WinMain: Should never happen: returned from Yield()\n" );
164 return 0;
167 #endif /* #ifndef WINELIB */