Release 941030
[wine/multimedia.git] / loader / main.c
blob5721a52e169f3ba0f53eafc020d1a15e89d50b0d
1 static char RCSId[] = "$Id: wine.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
2 static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <fcntl.h>
9 #include <unistd.h>
10 #include <string.h>
11 #include <errno.h>
12 #include "neexe.h"
13 #include "segmem.h"
14 #include "prototypes.h"
15 #include "dlls.h"
16 #include "wine.h"
17 #include "windows.h"
18 #include "wineopts.h"
19 #include "arch.h"
20 #include "task.h"
21 #include "options.h"
22 #include "stddebug.h"
23 /* #define DEBUG_DLL */
24 /* #undef DEBUG_DLL */
25 #include "debug.h"
28 char *GetDosFileName(char *unixfilename);
29 extern char WindowsPath[256];
31 char **Argv;
32 int Argc;
33 HINSTANCE hSysRes;
34 unsigned short WIN_StackSize;
35 unsigned short WIN_HeapSize;
37 /**********************************************************************
38 * myerror
40 void
41 myerror(const char *s)
43 if (s == NULL)
44 perror("wine");
45 else
46 fprintf(stderr, "wine: %s\n", s);
48 exit(1);
51 #ifndef WINELIB
52 /**********************************************************************
53 * main
55 int _WinMain(int argc, char **argv)
57 char *p, filename[256];
58 HANDLE hTaskMain;
59 HINSTANCE hInstMain;
60 struct w_files *wpnt;
61 #ifdef WINESTAT
62 char * cp;
63 #endif
65 Argc = argc - 1;
66 Argv = argv + 1;
68 if (strchr(Argv[0], '\\') || strchr(Argv[0],'/')) {
69 for (p = Argv[0] + strlen(Argv[0]); *p != '\\' && *p !='/'; p--)
70 /* NOTHING */;
72 strncpy(filename, Argv[0], p - Argv[0]);
73 filename[p - Argv[0]] = '\0';
74 strcat(WindowsPath, ";");
75 if (strchr(filename, '/'))
76 strcat(WindowsPath, GetDosFileName(filename));
77 else
78 strcat(WindowsPath, filename);
81 if ((hInstMain = LoadImage(Argv[0], EXE, 1)) < 32) {
82 fprintf(stderr, "wine: can't load %s!.\n", Argv[0]);
83 exit(1);
85 hTaskMain = CreateNewTask(hInstMain, 0);
86 dprintf_dll(stddeb,"_WinMain // hTaskMain=%04X hInstMain=%04X !\n",
87 hTaskMain, hInstMain);
89 GetPrivateProfileString("wine", "SystemResources", "sysres.dll",
90 filename, sizeof(filename), WINE_INI);
92 hSysRes = LoadImage(filename, DLL, 0);
93 if (hSysRes < 32) {
94 fprintf(stderr, "wine: can't load %s!.\n", filename);
95 exit(1);
96 } else
97 dprintf_dll(stddeb,"System Resources Loaded // hSysRes='%04X'\n",
98 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 StartNEprogram(wpnt);
121 else
122 StartPEprogram(wpnt);
125 #endif /* #ifndef WINELIB */