Release 980503
[wine/hacks.git] / miscemu / main.c
blobe7c6e9f1b1694733da3243ec066cde65261000c2
1 /*
2 * Emulator initialisation code
4 */
6 #include <stdio.h>
7 #include "windows.h"
8 #include "callback.h"
9 #include "debugger.h"
10 #include "miscemu.h"
11 #include "module.h"
12 #include "options.h"
13 #include "debug.h"
16 /***********************************************************************
17 * Emulator initialisation
19 BOOL32 MAIN_EmulatorInit(void)
21 extern BOOL32 MAIN_KernelInit(void);
22 extern BOOL32 MAIN_UserInit(void);
23 extern BOOL32 WIN16DRV_Init(void);
24 extern BOOL32 RELAY_Init(void);
26 /* Initialize the kernel */
27 if (!MAIN_KernelInit()) return FALSE;
29 /* Initialize relay code */
30 if (!RELAY_Init()) return FALSE;
32 /* Initialize signal handling */
33 if (!SIGNAL_InitEmulator()) return FALSE;
35 /* Create the Win16 printer driver */
36 if (!WIN16DRV_Init()) return FALSE;
38 /* Initialize all the USER stuff */
39 return MAIN_UserInit();
43 /**********************************************************************
44 * main
46 int main( int argc, char *argv[] )
48 extern BOOL32 PROCESS_Init(void);
49 extern BOOL32 MAIN_WineInit( int *argc, char *argv[] );
50 extern void *CALL32_Init(void);
51 extern char * DEBUG_argv0;
53 int i,loaded;
54 HINSTANCE32 handle;
56 __winelib = 0; /* First of all, clear the Winelib flag */
59 * Save this so that the internal debugger can get a hold of it if
60 * it needs to.
62 DEBUG_argv0 = argv[0];
64 /* Create the initial process */
65 if (!PROCESS_Init()) return FALSE;
67 /* Parse command-line */
68 if (!MAIN_WineInit( &argc, argv )) return 1;
70 /* Handle -dll option (hack) */
72 if (Options.dllFlags)
74 if (!BUILTIN_ParseDLLOptions( Options.dllFlags ))
76 MSG("%s: Syntax: -dll +xxx,... or -dll -xxx,...\n",
77 argv[0] );
78 BUILTIN_PrintDLLs();
79 exit(1);
83 /* Initialize everything */
85 if (!MAIN_EmulatorInit()) return 1;
87 /* Initialize CALL32 routines */
88 /* This needs to be done just before task-switching starts */
89 IF1632_CallLargeStack = (int (*)(int (*func)(), void *arg))CALL32_Init();
91 loaded=0;
92 for (i = 1; i < argc; i++)
94 if ((handle = WinExec32( argv[i], SW_SHOWNORMAL )) < 32)
96 MSG("wine: can't exec '%s': ", argv[i]);
97 switch (handle)
99 case 2: MSG("file not found\n" ); break;
100 case 11: MSG("invalid exe file\n" ); break;
101 case 21: MSG("win32 executable\n" ); break; /* FIXME: Obsolete? */
102 default: MSG("error=%d\n", handle ); break;
104 return 1;
106 loaded++;
109 if (!loaded) { /* nothing loaded */
110 extern void MAIN_Usage(char*);
111 MAIN_Usage(argv[0]);
112 return 1;
115 if (!GetNumTasks())
117 MSG("wine: no executable file found.\n" );
118 return 0;
121 if (Options.debug) DEBUG_AddModuleBreakpoints();
123 Yield16(); /* Start the first task */
124 MSG("WinMain: Should never happen: returned from Yield16()\n" );
125 return 0;