2000-07-01 11:51:55 +08:00
|
|
|
/* libcmain.c
|
2000-02-18 03:38:31 +08:00
|
|
|
|
2013-01-21 12:38:31 +08:00
|
|
|
Copyright 1996, 1997, 1998, 2000, 2001, 2004, 2006, 2009 Red Hat, Inc.
|
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');
|
|
|
|
else
|
|
|
|
nexts += strspn (nexts + 1, 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
|
|
|
}
|