Release 950901
[wine/multimedia.git] / loader / main.c
blob9bb0185188efbd1f7cc01d999087d37ba3580a89
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 "atom.h"
21 #include "dialog.h"
22 #include "message.h"
23 #include "syscolor.h"
24 #include "sysmetrics.h"
25 #include "gdi.h"
26 #include "debugger.h"
27 #include "dos_fs.h"
28 #include "dlls.h"
29 #include "miscemu.h"
30 #include "neexe.h"
31 #include "options.h"
32 #include "task.h"
33 #include "dce.h"
34 #include "pe_image.h"
35 #include "stddebug.h"
36 #include "debug.h"
39 /***********************************************************************
40 * Main initialisation routine
42 int MAIN_Init(void)
44 extern BOOL RELAY_Init(void);
45 extern BOOL RELAY32_Init(void);
47 int queueSize;
49 SpyInit();
51 /* Initialize relay code */
52 if (!RELAY_Init()) return 0;
54 /* Initialize Win32 relay code */
55 if (!RELAY32_Init()) return 0;
57 /* Create built-in modules */
58 if (!MODULE_Init()) return 0;
60 /* Initialize the DOS file system */
61 DOS_InitFS();
63 /* Initialize tasks */
64 if (!TASK_Init()) return 0;
66 /* Initialize interrupt vectors */
67 if (!INT_Init()) return 0;
69 /* Initialize DOS memory */
70 if (!DOSMEM_Init()) return 0;
72 /* Initialize signal handling */
73 init_wine_signals();
75 /* Initialize communications */
76 COMM_Init();
78 #ifndef WINELIB
79 /* Initialize the DOS memory */
80 INT21_Init();
82 /* Create USER heap */
83 if (!USER_HeapInit()) return 0;
84 #endif
86 /* Global atom table initialisation */
87 if (!ATOM_Init()) return 0;
89 /* GDI initialisation */
90 if (!GDI_Init()) return 0;
92 /* Initialize system colors and metrics*/
93 SYSMETRICS_Init();
94 SYSCOLOR_Init();
96 /* Create the DCEs */
97 DCE_Init();
99 /* Initialize dialog manager */
100 if (!DIALOG_Init()) return 0;
102 /* Initialize menus */
103 if (!MENU_Init()) return 0;
105 /* Create system message queue */
106 queueSize = GetProfileInt( "windows", "TypeAhead", 120 );
107 if (!MSG_CreateSysMsgQueue( queueSize )) return 0;
109 return 1;
113 #ifndef WINELIB
114 /**********************************************************************
115 * main
117 int _WinMain(int argc, char **argv)
119 int i;
120 HANDLE handle;
122 if (!MAIN_Init()) return 0;
124 for (i = 1; i < argc; i++)
126 if ((handle = WinExec( argv[i], SW_SHOWNORMAL )) < 32)
128 fprintf(stderr, "wine: can't exec '%s': ", argv[i]);
129 switch (handle)
131 case 2: fprintf( stderr, "file not found\n" ); break;
132 case 11: fprintf( stderr, "invalid exe file\n" ); break;
133 case 21: fprintf( stderr, "win32 executable\n" ); break;
134 default: fprintf( stderr, "error=%d\n", handle ); break;
136 exit(1);
140 if (Options.debug) DEBUG_SetBreakpoints( TRUE ); /* Setup breakpoints */
142 Yield(); /* Start the first task */
143 fprintf( stderr, "WinMain: Should never happen: returned from Yield()\n" );
144 return 0;
147 #endif /* #ifndef WINELIB */