Release 950216
[wine.git] / loader / main.c
blob01136c8e4b34d677cf65c8f19880a7cc662fd024
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 "task.h"
21 #include "prototypes.h"
22 #include "options.h"
23 #include "if1632.h"
24 #include "ne_image.h"
25 #include "pe_image.h"
26 #include "stddebug.h"
27 #include "debug.h"
29 char **Argv;
30 int Argc;
31 HINSTANCE hSysRes, hInstMain;
32 unsigned short WIN_StackSize;
33 unsigned short WIN_HeapSize;
35 /**********************************************************************
36 * myerror
38 void
39 myerror(const char *s)
41 if (s == NULL)
42 perror("wine");
43 else
44 fprintf(stderr, "wine: %s\n", s);
46 exit(1);
49 #ifndef WINELIB
50 /**********************************************************************
51 * main
53 int _WinMain(int argc, char **argv)
55 char *p, filename[256];
56 HANDLE hTaskMain;
58 struct w_files *wpnt;
59 #ifdef WINESTAT
60 char * cp;
61 #endif
63 Argc = argc - 1;
64 Argv = argv + 1;
66 if (strchr(Argv[0], '\\') || strchr(Argv[0],'/')) {
67 for (p = Argv[0] + strlen(Argv[0]); *p != '\\' && *p !='/'; p--)
68 /* NOTHING */;
70 strncpy(filename, Argv[0], p - Argv[0]);
71 filename[p - Argv[0]] = '\0';
72 strcat(WindowsPath, ";");
73 if (strchr(filename, '/'))
74 strcat(WindowsPath, DOS_GetDosFileName(filename));
75 else
76 strcat(WindowsPath, filename);
79 if ((hInstMain = LoadImage(Argv[0], EXE, 1)) < 32) {
80 fprintf(stderr, "wine: can't load %s!.\n", Argv[0]);
81 exit(1);
83 hTaskMain = CreateNewTask(hInstMain, 0);
84 dprintf_dll(stddeb,"_WinMain // hTaskMain=%04X hInstMain=%04X !\n",
85 hTaskMain, hInstMain);
87 GetPrivateProfileString("wine", "SystemResources", "sysres.dll",
88 filename, sizeof(filename), WINE_INI);
90 hSysRes = LoadImage(filename, DLL, 0);
91 if (hSysRes < 32) {
92 fprintf(stderr, "wine: can't load %s!.\n", filename);
93 exit(1);
94 } else
95 dprintf_dll(stddeb,"System Resources Loaded // hSysRes='%04X'\n",
96 hSysRes);
99 #ifdef WINESTAT
100 cp = strrchr(argv[0], '/');
101 if(!cp) cp = argv[0];
102 else cp++;
103 if(strcmp(cp,"winestat") == 0) {
104 winestat();
105 exit(0);
107 #endif
110 * Initialize signal handling.
112 init_wine_signals();
114 wpnt = GetFileInfo(hInstMain);
115 if (Options.debug)
116 wine_debug(0, NULL);
118 if (wpnt->ne)
119 return(NE_StartProgram(wpnt));
120 else
121 return(PE_StartProgram(wpnt));
124 #endif /* #ifndef WINELIB */