Release 960114
[wine/gsoc-2012-control.git] / loader / main.c
blob8ee5a4e145a67bf006bd82d6b3439bffe3a94181
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 "message.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 SpyInit();
56 #ifndef WINELIB
57 /* Initialize relay code */
58 if (!RELAY_Init()) return 0;
60 /* Initialize Win32 relay code */
61 if (!RELAY32_Init()) return 0;
62 #endif
64 /* Create built-in modules */
65 if (!MODULE_Init()) return 0;
67 /* Initialise DOS drives */
68 if (!DRIVE_Init()) return 0;
70 /* Initialise DOS directories */
71 if (!DIR_Init()) return 0;
73 /* Initialize tasks */
74 if (!TASK_Init()) return 0;
76 #ifndef WINELIB
77 /* Initialize interrupt vectors */
78 if (!INT_Init()) return 0;
80 /* Initialize DOS memory */
81 if (!DOSMEM_Init()) return 0;
83 /* Initialize signal handling */
84 init_wine_signals();
85 #endif
87 /* Initialize communications */
88 COMM_Init();
90 #ifndef WINELIB
91 /* Initialize the DOS memory */
92 INT21_Init();
94 /* Create USER heap */
95 if (!USER_HeapInit()) return 0;
96 #endif
98 /* Global atom table initialisation */
99 if (!ATOM_Init()) return 0;
101 /* GDI initialisation */
102 if (!GDI_Init()) return 0;
104 /* Initialize system colors and metrics*/
105 SYSMETRICS_Init();
106 SYSCOLOR_Init();
108 /* Create the DCEs */
109 DCE_Init();
111 /* Initialize dialog manager */
112 if (!DIALOG_Init()) return 0;
114 /* Initialize menus */
115 if (!MENU_Init()) return 0;
117 /* Initialize Win32 data structures */
118 if (!KERN32_Init()) return 0;
120 /* Create system message queue */
121 queueSize = GetProfileInt( "windows", "TypeAhead", 120 );
122 if (!MSG_CreateSysMsgQueue( queueSize )) return 0;
124 return 1;
128 #ifndef WINELIB
129 /**********************************************************************
130 * main
132 int _WinMain(int argc, char **argv)
134 int i;
135 HANDLE handle;
137 if (!MAIN_Init()) return 0;
139 for (i = 1; i < argc; i++)
141 if ((handle = WinExec( argv[i], SW_SHOWNORMAL )) < 32)
143 fprintf(stderr, "wine: can't exec '%s': ", argv[i]);
144 switch (handle)
146 case 2: fprintf( stderr, "file not found\n" ); break;
147 case 11: fprintf( stderr, "invalid exe file\n" ); break;
148 case 21: fprintf( stderr, "win32 executable\n" ); break;
149 default: fprintf( stderr, "error=%d\n", handle ); break;
151 exit(1);
155 if (Options.debug) DEBUG_SetBreakpoints( TRUE ); /* Setup breakpoints */
157 Yield(); /* Start the first task */
158 fprintf( stderr, "WinMain: Should never happen: returned from Yield()\n" );
159 return 0;
162 #endif /* #ifndef WINELIB */