- Cleanup the /lib directory, by putting more 3rd-party libs in /3rdparty, and by...
[reactos.git] / reactos / lib / 3rdparty / mingw / main.c
1 /*
2 * main.c
3 * This file has no copyright assigned and is placed in the Public Domain.
4 * This file is a part of the mingw-runtime package.
5 * No warranty is given; refer to the file DISCLAIMER within the package.
6 *
7 * Extra startup code for applications which do not have a main function
8 * of their own (but do have a WinMain). Generally these are GUI
9 * applications, but they don't *have* to be.
10 *
11 */
12
13 #include <stdlib.h>
14 #include <process.h>
15 #include <windows.h>
16
17 #define ISSPACE(a) (a == ' ' || a == '\t')
18
19 extern int PASCAL WinMain (HINSTANCE hInst, HINSTANCE hPrevInst,
20 LPSTR szCmdLine, int nShow);
21
22 int
23 main (int argc, const char *argv[], const char *environ[])
24 {
25 char *szCmd;
26 STARTUPINFO startinfo;
27 int nRet;
28
29 /* Get the command line passed to the process. */
30 szCmd = GetCommandLineA ();
31 GetStartupInfoA (&startinfo);
32
33 /* Strip off the name of the application and any leading
34 * whitespace. */
35 if (szCmd)
36 {
37 while (ISSPACE (*szCmd))
38 {
39 szCmd++;
40 }
41
42 /* On my system I always get the app name enclosed
43 * in quotes... */
44 if (*szCmd == '\"')
45 {
46 do
47 {
48 szCmd++;
49 }
50 while (*szCmd != '\"' && *szCmd != '\0');
51
52 if (*szCmd == '\"')
53 {
54 szCmd++;
55 }
56 }
57 else
58 {
59 /* If no quotes then assume first token is program
60 * name. */
61 while (!ISSPACE (*szCmd) && *szCmd != '\0')
62 {
63 szCmd++;
64 }
65 }
66
67 while (ISSPACE (*szCmd))
68 {
69 szCmd++;
70 }
71 }
72
73 nRet = WinMain (GetModuleHandle (NULL), NULL, szCmd,
74 (startinfo.dwFlags & STARTF_USESHOWWINDOW) ?
75 startinfo.wShowWindow : SW_SHOWDEFAULT);
76
77 return nRet;
78 }
79