2000-07-01 05:51:55 +02:00
|
|
|
/* libcmain.c
|
2000-02-17 20:38:31 +01:00
|
|
|
|
2013-01-21 05:38:31 +01:00
|
|
|
Copyright 1996, 1997, 1998, 2000, 2001, 2004, 2006, 2009 Red Hat, Inc.
|
2000-02-17 20:38:31 +01: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-09 22:28:32 +01:00
|
|
|
|
|
|
|
#define SP " \t\n"
|
2000-02-17 20:38:31 +01:00
|
|
|
|
2006-04-12 17:53:22 +02:00
|
|
|
/* Allow apps which don't have a main to work, as long as they define WinMain */
|
2000-07-01 05:51:55 +02:00
|
|
|
int
|
|
|
|
main ()
|
2000-02-17 20:38:31 +01:00
|
|
|
{
|
2004-12-09 22:28:32 +01:00
|
|
|
HMODULE x = GetModuleHandle (0);
|
|
|
|
char *s = GetCommandLine ();
|
2000-02-17 20:38:31 +01:00
|
|
|
STARTUPINFO si;
|
2004-12-09 22:28:32 +01: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-17 20:38:31 +01:00
|
|
|
|
2004-12-09 22:28:32 +01:00
|
|
|
if (!nexts)
|
|
|
|
nexts = strchr (s, '\0');
|
2013-07-19 21:04:13 +02:00
|
|
|
else if (*++nexts)
|
|
|
|
nexts += strspn (nexts, SP);
|
2000-02-17 20:38:31 +01:00
|
|
|
|
|
|
|
GetStartupInfo (&si);
|
|
|
|
|
2004-12-09 22:28:32 +01:00
|
|
|
return WinMain (x, 0, nexts,
|
2000-07-01 05:51:55 +02:00
|
|
|
((si.dwFlags & STARTF_USESHOWWINDOW) != 0
|
|
|
|
? si.wShowWindow
|
|
|
|
: SW_SHOWNORMAL));
|
2000-02-17 20:38:31 +01:00
|
|
|
}
|