1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#include <windows.h>
7#include <tchar.h>
8#include <corecrt_startup.h>
9
10#define SPACECHAR _T(' ')
11#define DQUOTECHAR _T('\"')
12
13extern IMAGE_DOS_HEADER __ImageBase;
14
15int _tmain (int, _TCHAR **, _TCHAR **);
16int _tmain (int __UNUSED_PARAM(argc),
17 _TCHAR ** __UNUSED_PARAM(argv),
18 _TCHAR ** __UNUSED_PARAM(envp))
19{
20 HINSTANCE hInstance;
21 _TCHAR *lpCmdLine;
22 DWORD nShowCmd;
23
24 hInstance = (HINSTANCE) &__ImageBase;
25
26#ifdef _UNICODE
27 lpCmdLine = _wcmdln;
28#else
29 lpCmdLine = _acmdln;
30#endif
31 if (lpCmdLine)
32 {
33 BOOL inDoubleQuote = FALSE;
34 while (*lpCmdLine > SPACECHAR || (*lpCmdLine && inDoubleQuote))
35 {
36 if (*lpCmdLine == DQUOTECHAR)
37 inDoubleQuote = !inDoubleQuote;
38#ifndef _UNICODE
39 if (IsDBCSLeadByte (*lpCmdLine))
40 {
41 if (lpCmdLine[1])
42 ++lpCmdLine;
43 }
44#endif
45 ++lpCmdLine;
46 }
47 while (*lpCmdLine && (*lpCmdLine <= SPACECHAR))
48 lpCmdLine++;
49 }
50 else
51 lpCmdLine = _TEXT("");
52
53 {
54 STARTUPINFO StartupInfo;
55 GetStartupInfo (&StartupInfo);
56 if (StartupInfo.dwFlags & STARTF_USESHOWWINDOW)
57 nShowCmd = StartupInfo.wShowWindow;
58 else
59 nShowCmd = SW_SHOWDEFAULT;
60 }
61
62 return _tWinMain (hInstance, NULL, lpCmdLine, nShowCmd);
63}