Release 950109
[wine/multimedia.git] / loader / main.c
blob10dd8836ee4d044b4a90acfe6bbcd728daad48db
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 "neexe.h"
14 #include "segmem.h"
15 #include "dos_fs.h"
16 #include "dlls.h"
17 #include "library.h"
18 #include "windows.h"
19 #include "wineopts.h"
20 #include "dos_fs.h"
21 #include "task.h"
22 #include "prototypes.h"
23 #include "options.h"
24 #include "if1632.h"
25 #include "ne_image.h"
26 #include "pe_image.h"
27 #include "stddebug.h"
28 #include "debug.h"
30 char **Argv;
31 int Argc;
32 HINSTANCE hSysRes, hInstMain;
33 unsigned short WIN_StackSize;
34 unsigned short WIN_HeapSize;
36 /**********************************************************************
37 * myerror
39 void
40 myerror(const char *s)
42 if (s == NULL)
43 perror("wine");
44 else
45 fprintf(stderr, "wine: %s\n", s);
47 exit(1);
50 #ifndef WINELIB
51 /**********************************************************************
52 * main
54 int _WinMain(int argc, char **argv)
56 char *p, filename[256];
57 HANDLE hTaskMain;
59 struct w_files *wpnt;
60 #ifdef WINESTAT
61 char * cp;
62 #endif
64 Argc = argc - 1;
65 Argv = argv + 1;
67 if (strchr(Argv[0], '\\') || strchr(Argv[0],'/')) {
68 for (p = Argv[0] + strlen(Argv[0]); *p != '\\' && *p !='/'; p--)
69 /* NOTHING */;
71 strncpy(filename, Argv[0], p - Argv[0]);
72 filename[p - Argv[0]] = '\0';
73 strcat(WindowsPath, ";");
74 if (strchr(filename, '/'))
75 strcat(WindowsPath, DOS_GetDosFileName(filename));
76 else
77 strcat(WindowsPath, filename);
80 if ((hInstMain = LoadImage(Argv[0], EXE, 1)) < 32) {
81 fprintf(stderr, "wine: can't load %s!.\n", Argv[0]);
82 exit(1);
84 hTaskMain = CreateNewTask(hInstMain, 0);
85 dprintf_dll(stddeb,"_WinMain // hTaskMain=%04X hInstMain=%04X !\n",
86 hTaskMain, hInstMain);
88 GetPrivateProfileString("wine", "SystemResources", "sysres.dll",
89 filename, sizeof(filename), WINE_INI);
91 hSysRes = LoadImage(filename, DLL, 0);
92 if (hSysRes < 32) {
93 fprintf(stderr, "wine: can't load %s!.\n", filename);
94 exit(1);
95 } else
96 dprintf_dll(stddeb,"System Resources Loaded // hSysRes='%04X'\n",
97 hSysRes);
100 #ifdef WINESTAT
101 cp = strrchr(argv[0], '/');
102 if(!cp) cp = argv[0];
103 else cp++;
104 if(strcmp(cp,"winestat") == 0) {
105 winestat();
106 exit(0);
108 #endif
111 * Initialize signal handling.
113 init_wine_signals();
115 wpnt = GetFileInfo(hInstMain);
116 if (Options.debug)
117 wine_debug(0, NULL);
119 if (wpnt->ne)
120 return(NE_StartProgram(wpnt));
121 else
122 return(PE_StartProgram(wpnt));
125 #endif /* #ifndef WINELIB */