newlib/winsup/mingw/main.c
Earnie Boyd 4d6c899474 * CONTRIBUTORS: New file.
* DISCLAIMER: Ditto.
	* CRT_noglob.c: Reword copyright and disclaimer.  Move Contributors
	section CONTRIBUTORS file.  Remove RCS tags.
	* CRTFmode.c: Ditto.
	* CRTglob.c: Ditto.
	* CRTinit.c: Ditto.
	* crt1.c: Ditto.
	* crtdll.dev: Ditto.
	* dllcrt1.c: Ditto.
	* dllmain.c: Ditto.
	* gccmain.c: Ditto.
	* init.c: Ditto.
	* isascii.c: Ditto.
	* iscsym.c: Ditto.
	* iscsymf.c: Ditto.
	* jamfile: Ditto.
	* main.c: Ditto.
	* msvcrt.def.in: Ditto.
	* strcasecmp.c: Ditto.
	* toascii.c: Ditto.
	* wcscmpi.c: Ditto.
	* include/assert.h: Ditto.
	* include/conio.h: Ditto.
	* include/ctype.h: Ditto.
	* include/direct.h: Ditto.
	* include/dirent.h: Ditto.
	* include/dos.h: Ditto.
	* include/errno.h: Ditto.
	* include/excpt.h: Ditto.
	* include/fcntl.h: Ditto.
	* include/float.h: Ditto.
	* include/io.h: Ditto.
	* include/locale.h: Ditto.
	* include/malloc.h: Ditto.
	* include/math.h: Ditto.
	* include/process.h: Ditto.
	* include/setjmp.h: Ditto.
	* include/share.h: Ditto.
	* include/signal.h: Ditto.
	* include/stdio.h: Ditto.
	* include/stdlib.h: Ditto.
	* include/string.h: Ditto.
	* include/tchar.h: Ditto.
	* include/time.h: Ditto.
	* include/wchar.h: Ditto.
	* include/sys/locking.h: Ditto.
	* include/sys/param.h: Ditto.
	* include/sys/stat.h: Ditto.
	* include/sys/timeb.h: Ditto.
	* include/sys/types.h: Ditto.
	* include/sys/utime.h: Ditto.
	* mingwex/dirent.c: Ditto.
2004-04-20 22:49:32 +00:00

80 lines
1.6 KiB
C

/*
* main.c
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Extra startup code for applications which do not have a main function
* of their own (but do have a WinMain). Generally these are GUI
* applications, but they don't *have* to be.
*
*/
#include <stdlib.h>
#include <process.h>
#include <windows.h>
#define ISSPACE(a) (a == ' ' || a == '\t')
extern int PASCAL WinMain (HINSTANCE hInst, HINSTANCE hPrevInst,
LPSTR szCmdLine, int nShow);
int
main (int argc, char *argv[], char *environ[])
{
char *szCmd;
STARTUPINFO startinfo;
int nRet;
/* Get the command line passed to the process. */
szCmd = GetCommandLineA ();
GetStartupInfoA (&startinfo);
/* Strip off the name of the application and any leading
* whitespace. */
if (szCmd)
{
while (ISSPACE (*szCmd))
{
szCmd++;
}
/* On my system I always get the app name enclosed
* in quotes... */
if (*szCmd == '\"')
{
do
{
szCmd++;
}
while (*szCmd != '\"' && *szCmd != '\0');
if (*szCmd == '\"')
{
szCmd++;
}
}
else
{
/* If no quotes then assume first token is program
* name. */
while (!ISSPACE (*szCmd) && *szCmd != '\0')
{
szCmd++;
}
}
while (ISSPACE (*szCmd))
{
szCmd++;
}
}
nRet = WinMain (GetModuleHandle (NULL), NULL, szCmd,
(startinfo.dwFlags & STARTF_USESHOWWINDOW) ?
startinfo.wShowWindow : SW_SHOWDEFAULT);
return nRet;
}