6 partstrlwr (LPTSTR str
)
9 while (*c
&& !_istspace (*c
) && *c
!= _T('='))
23 len
= GetConsoleAliasesLength(_T("cmd.exe"));
27 /* allocate memory for an extra \0 char to make parsing easier */
28 ptr
= HeapAlloc(GetProcessHeap(), 0, (len
+ sizeof(TCHAR
)));
34 ZeroMemory(Aliases
, len
+ sizeof(TCHAR
));
36 if (GetConsoleAliases(Aliases
, len
, _T("cmd.exe")) != 0)
38 while (*Aliases
!= '\0')
40 _tprintf(_T("%s\n"), Aliases
);
41 Aliases
= Aliases
+ lstrlen(Aliases
);
45 HeapFree(GetProcessHeap(), 0 , ptr
);
48 INT
SetMacro (LPTSTR param
)
52 while (*param
== _T(' '))
55 /* error if no '=' found */
56 if ((ptr
= _tcschr (param
, _T('='))) == 0)
59 while (*param
== _T(' '))
62 while (*ptr
== _T(' '))
65 /* Split rest into name and substitute */
70 _tprintf(_T("%s, %s\n"), ptr
, param
);
72 if (ptr
[0] == _T('\0'))
73 AddConsoleAlias(param
, NULL
, _T("cmd.exe"));
75 AddConsoleAlias(param
, ptr
, _T("cmd.exe"));
80 static VOID
ReadFromFile(LPTSTR param
)
85 /* Skip the "/macrofile=" prefix */
88 fp
= _tfopen(param
, _T("r"));
90 while ( _fgetts(line
, MAX_PATH
, fp
) != NULL
)
98 _tmain (int argc
, LPTSTR argv
[])
103 if (argv
[1][0] == '/')
105 if (_tcsnicmp(argv
[1], _T("/macrofile"), 10) == 0)
106 ReadFromFile(argv
[1]);
107 if (_tcscmp(argv
[1], _T("/macros")) == 0)
112 /* Get the full command line using GetCommandLine().
113 We can't just pass argv[1] here, because then a parameter like "gotoroot=cd \" wouldn't be passed completely. */
114 TCHAR
* szCommandLine
= GetCommandLine();
116 /* Skip the application name */
117 if(*szCommandLine
== '\"')
123 while(*szCommandLine
!= '\"');
131 while(*szCommandLine
!= ' ');
134 /* Skip the trailing quotation mark/whitespace and pass the command line to SetMacro */
135 SetMacro(++szCommandLine
);