Release 951003
[wine/hacks.git] / loader / main.c
blobde7df1efb326507f31b7963c67f38a174a1f6c8d
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 "message.h"
24 #include "syscolor.h"
25 #include "sysmetrics.h"
26 #include "gdi.h"
27 #include "debugger.h"
28 #include "dos_fs.h"
29 #include "dlls.h"
30 #include "miscemu.h"
31 #include "neexe.h"
32 #include "options.h"
33 #include "spy.h"
34 #include "task.h"
35 #include "dce.h"
36 #include "pe_image.h"
37 #include "stddebug.h"
38 #include "debug.h"
40 void init_wine_signals(void);
43 /***********************************************************************
44 * Main initialisation routine
46 int MAIN_Init(void)
48 extern BOOL RELAY_Init(void);
49 extern BOOL RELAY32_Init(void);
51 int queueSize;
53 SpyInit();
55 #ifndef WINELIB
56 /* Initialize relay code */
57 if (!RELAY_Init()) return 0;
59 /* Initialize Win32 relay code */
60 if (!RELAY32_Init()) return 0;
61 #endif
63 /* Create built-in modules */
64 if (!MODULE_Init()) return 0;
66 /* Initialize the DOS file system */
67 DOS_InitFS();
69 /* Initialize tasks */
70 if (!TASK_Init()) return 0;
72 #ifndef WINELIB
73 /* Initialize interrupt vectors */
74 if (!INT_Init()) return 0;
76 /* Initialize DOS memory */
77 if (!DOSMEM_Init()) return 0;
79 /* Initialize signal handling */
80 init_wine_signals();
81 #endif
83 /* Initialize communications */
84 COMM_Init();
86 #ifndef WINELIB
87 /* Initialize the DOS memory */
88 INT21_Init();
90 /* Create USER heap */
91 if (!USER_HeapInit()) return 0;
92 #endif
94 /* Global atom table initialisation */
95 if (!ATOM_Init()) return 0;
97 /* GDI initialisation */
98 if (!GDI_Init()) return 0;
100 /* Initialize system colors and metrics*/
101 SYSMETRICS_Init();
102 SYSCOLOR_Init();
104 /* Create the DCEs */
105 DCE_Init();
107 /* Initialize dialog manager */
108 if (!DIALOG_Init()) return 0;
110 /* Initialize menus */
111 if (!MENU_Init()) return 0;
113 /* Initialize Win32 data structures */
114 if (!KERN32_Init()) return 0;
116 /* Create system message queue */
117 queueSize = GetProfileInt( "windows", "TypeAhead", 120 );
118 if (!MSG_CreateSysMsgQueue( queueSize )) return 0;
120 return 1;
124 #ifndef WINELIB
125 /**********************************************************************
126 * main
128 int _WinMain(int argc, char **argv)
130 int i;
131 HANDLE handle;
133 if (!MAIN_Init()) return 0;
135 for (i = 1; i < argc; i++)
137 if ((handle = WinExec( argv[i], SW_SHOWNORMAL )) < 32)
139 fprintf(stderr, "wine: can't exec '%s': ", argv[i]);
140 switch (handle)
142 case 2: fprintf( stderr, "file not found\n" ); break;
143 case 11: fprintf( stderr, "invalid exe file\n" ); break;
144 case 21: fprintf( stderr, "win32 executable\n" ); break;
145 default: fprintf( stderr, "error=%d\n", handle ); break;
147 exit(1);
151 if (Options.debug) DEBUG_SetBreakpoints( TRUE ); /* Setup breakpoints */
153 Yield(); /* Start the first task */
154 fprintf( stderr, "WinMain: Should never happen: returned from Yield()\n" );
155 return 0;
158 #endif /* #ifndef WINELIB */