master
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#ifndef _UNICODE
11#include <mbctype.h>
12#endif
13
14#define SPACECHAR _T(' ')
15#define DQUOTECHAR _T('\"')
16
17extern IMAGE_DOS_HEADER __ImageBase;
18
19int _tmain (int, _TCHAR **, _TCHAR **);
20int _tmain (int __UNUSED_PARAM(argc),
21 _TCHAR ** __UNUSED_PARAM(argv),
22 _TCHAR ** __UNUSED_PARAM(envp))
23{
24 HINSTANCE hInstance;
25 _TCHAR *lpCmdLine;
26 DWORD nShowCmd;
27
28 hInstance = (HINSTANCE) &__ImageBase;
29
30#ifdef _UNICODE
31 lpCmdLine = _wcmdln;
32#else
33 lpCmdLine = _acmdln;
34#endif
35 if (lpCmdLine)
36 {
37 BOOL inDoubleQuote = FALSE;
38 while (*lpCmdLine > SPACECHAR || (*lpCmdLine && inDoubleQuote))
39 {
40 if (*lpCmdLine == DQUOTECHAR)
41 inDoubleQuote = !inDoubleQuote;
42#ifndef _UNICODE
43 if (_ismbblead (*lpCmdLine))
44 {
45 if (lpCmdLine[1])
46 ++lpCmdLine;
47 }
48#endif
49 ++lpCmdLine;
50 }
51 while (*lpCmdLine && (*lpCmdLine <= SPACECHAR))
52 lpCmdLine++;
53 }
54 else
55 lpCmdLine = _TEXT("");
56
57 {
58 STARTUPINFO StartupInfo;
59 GetStartupInfo (&StartupInfo);
60 if (StartupInfo.dwFlags & STARTF_USESHOWWINDOW)
61 nShowCmd = StartupInfo.wShowWindow;
62 else
63 nShowCmd = SW_SHOWDEFAULT;
64 }
65
66 return _tWinMain (hInstance, NULL, lpCmdLine, nShowCmd);
67}