Release 980301
[wine.git] / miscemu / main.c
blob6110790a4dc0b851a307f0ffce74751e975daccc
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"
15 /***********************************************************************
16 * Emulator initialisation
18 BOOL32 MAIN_EmulatorInit(void)
20 extern BOOL32 MAIN_KernelInit(void);
21 extern BOOL32 MAIN_UserInit(void);
22 extern BOOL32 WIN16DRV_Init(void);
23 extern BOOL32 RELAY_Init(void);
25 /* Initialize the kernel */
26 if (!MAIN_KernelInit()) return FALSE;
28 /* Initialize relay code */
29 if (!RELAY_Init()) return FALSE;
31 /* Initialize signal handling */
32 if (!SIGNAL_InitEmulator()) return FALSE;
34 /* Create the Win16 printer driver */
35 if (!WIN16DRV_Init()) return FALSE;
37 /* Initialize all the USER stuff */
38 return MAIN_UserInit();
42 /**********************************************************************
43 * main
45 int main( int argc, char *argv[] )
47 extern BOOL32 PROCESS_Init(void);
48 extern BOOL32 MAIN_WineInit( int *argc, char *argv[] );
49 extern void *CALL32_Init(void);
50 extern char * DEBUG_argv0;
52 int i,loaded;
53 HINSTANCE32 handle;
55 __winelib = 0; /* First of all, clear the Winelib flag */
58 * Save this so that the internal debugger can get a hold of it if
59 * it needs to.
61 DEBUG_argv0 = argv[0];
63 /* Create the initial process */
64 if (!PROCESS_Init()) return FALSE;
66 /* Parse command-line */
67 if (!MAIN_WineInit( &argc, argv )) return 1;
69 /* Handle -dll option (hack) */
71 if (Options.dllFlags)
73 if (!BUILTIN_ParseDLLOptions( Options.dllFlags ))
75 fprintf( stderr, "%s: Syntax: -dll +xxx,... or -dll -xxx,...\n",
76 argv[0] );
77 BUILTIN_PrintDLLs();
78 exit(1);
82 /* Initialize everything */
84 if (!MAIN_EmulatorInit()) return 1;
86 /* Initialize CALL32 routines */
87 /* This needs to be done just before task-switching starts */
88 IF1632_CallLargeStack = (int (*)(int (*func)(), void *arg))CALL32_Init();
90 loaded=0;
91 for (i = 1; i < argc; i++)
93 if ((handle = WinExec32( argv[i], SW_SHOWNORMAL )) < 32)
95 fprintf(stderr, "wine: can't exec '%s': ", argv[i]);
96 switch (handle)
98 case 2: fprintf( stderr, "file not found\n" ); break;
99 case 11: fprintf( stderr, "invalid exe file\n" ); break;
100 case 21: fprintf( stderr, "win32 executable\n" ); break;
101 default: fprintf( stderr, "error=%d\n", handle ); break;
103 return 1;
105 loaded++;
108 if (!loaded) { /* nothing loaded */
109 extern void MAIN_Usage(char*);
110 MAIN_Usage(argv[0]);
111 return 1;
114 if (!GetNumTasks())
116 fprintf( stderr, "wine: no executable file found.\n" );
117 return 0;
120 if (Options.debug) DEBUG_AddModuleBreakpoints();
122 Yield16(); /* Start the first task */
123 fprintf( stderr, "WinMain: Should never happen: returned from Yield()\n" );
124 return 0;