2000-07-01 11:51:55 +08:00
|
|
|
/* libcmain.c
|
2000-02-18 03:38:31 +08:00
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
|
|
|
#include <windows.h>
|
2004-12-10 05:28:32 +08:00
|
|
|
|
|
|
|
#define SP " \t\n"
|
2000-02-18 03:38:31 +08:00
|
|
|
|
2006-04-12 23:53:22 +08:00
|
|
|
/* Allow apps which don't have a main to work, as long as they define WinMain */
|
2000-07-01 11:51:55 +08:00
|
|
|
int
|
|
|
|
main ()
|
2000-02-18 03:38:31 +08:00
|
|
|
{
|
2004-12-10 05:28:32 +08:00
|
|
|
HMODULE x = GetModuleHandle (0);
|
|
|
|
char *s = GetCommandLine ();
|
2000-02-18 03:38:31 +08:00
|
|
|
STARTUPINFO si;
|
2004-12-10 05:28:32 +08:00
|
|
|
char *nexts;
|
|
|
|
|
|
|
|
s += strspn (s, SP);
|
|
|
|
|
|
|
|
if (*s != '"')
|
|
|
|
nexts = strpbrk (s, SP);
|
|
|
|
else
|
|
|
|
while ((nexts = strchr (s + 1, '"')) != NULL && nexts[-1] == '\\')
|
|
|
|
s = nexts;
|
2000-02-18 03:38:31 +08:00
|
|
|
|
2004-12-10 05:28:32 +08:00
|
|
|
if (!nexts)
|
|
|
|
nexts = strchr (s, '\0');
|
2013-07-20 03:04:13 +08:00
|
|
|
else if (*++nexts)
|
|
|
|
nexts += strspn (nexts, SP);
|
2000-02-18 03:38:31 +08:00
|
|
|
|
|
|
|
GetStartupInfo (&si);
|
|
|
|
|
2004-12-10 05:28:32 +08:00
|
|
|
return WinMain (x, 0, nexts,
|
2000-07-01 11:51:55 +08:00
|
|
|
((si.dwFlags & STARTF_USESHOWWINDOW) != 0
|
|
|
|
? si.wShowWindow
|
|
|
|
: SW_SHOWNORMAL));
|
2000-02-18 03:38:31 +08:00
|
|
|
}
|