mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 17:22:59 +00:00
[CMD]
Fix whitespace (part 3/x) (convert tabs into 4-space indent). svn path=/trunk/; revision=59379
This commit is contained in:
parent
9b6dc5bd15
commit
6437619ff3
25 changed files with 3026 additions and 3010 deletions
|
@ -25,8 +25,8 @@
|
|||
* 24-Jan-1998 Eric Kohl
|
||||
* Redirection safe!
|
||||
*
|
||||
* 02-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 02-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*
|
||||
* 02-Feb-2008 (Christoph von Wittich) <christoph_vw@reactos.org>)
|
||||
* rewrote alias handling for doskey compat
|
||||
|
@ -42,168 +42,168 @@
|
|||
static VOID
|
||||
partstrlwr (LPTSTR str)
|
||||
{
|
||||
LPTSTR c = str;
|
||||
while (*c && !_istspace (*c) && *c != _T('='))
|
||||
{
|
||||
*c = _totlower (*c);
|
||||
c++;
|
||||
}
|
||||
LPTSTR c = str;
|
||||
while (*c && !_istspace (*c) && *c != _T('='))
|
||||
{
|
||||
*c = _totlower (*c);
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
static VOID
|
||||
PrintAlias (VOID)
|
||||
{
|
||||
LPTSTR Aliases;
|
||||
LPTSTR ptr;
|
||||
DWORD len;
|
||||
LPTSTR Aliases;
|
||||
LPTSTR ptr;
|
||||
DWORD len;
|
||||
|
||||
len = GetConsoleAliasesLength(_T("cmd.exe"));
|
||||
if (len <= 0)
|
||||
return;
|
||||
len = GetConsoleAliasesLength(_T("cmd.exe"));
|
||||
if (len <= 0)
|
||||
return;
|
||||
|
||||
/* allocate memory for an extra \0 char to make parsing easier */
|
||||
ptr = cmd_alloc(len + sizeof(TCHAR));
|
||||
if (!ptr)
|
||||
return;
|
||||
/* allocate memory for an extra \0 char to make parsing easier */
|
||||
ptr = cmd_alloc(len + sizeof(TCHAR));
|
||||
if (!ptr)
|
||||
return;
|
||||
|
||||
Aliases = ptr;
|
||||
Aliases = ptr;
|
||||
|
||||
ZeroMemory(Aliases, len + sizeof(TCHAR));
|
||||
ZeroMemory(Aliases, len + sizeof(TCHAR));
|
||||
|
||||
if (GetConsoleAliases(Aliases, len, _T("cmd.exe")) != 0)
|
||||
{
|
||||
while (*Aliases != '\0')
|
||||
{
|
||||
ConOutPrintf(_T("%s\n"), Aliases);
|
||||
Aliases = Aliases + lstrlen(Aliases);
|
||||
Aliases++;
|
||||
}
|
||||
}
|
||||
cmd_free(ptr);
|
||||
if (GetConsoleAliases(Aliases, len, _T("cmd.exe")) != 0)
|
||||
{
|
||||
while (*Aliases != '\0')
|
||||
{
|
||||
ConOutPrintf(_T("%s\n"), Aliases);
|
||||
Aliases = Aliases + lstrlen(Aliases);
|
||||
Aliases++;
|
||||
}
|
||||
}
|
||||
cmd_free(ptr);
|
||||
}
|
||||
|
||||
/* specified routines */
|
||||
VOID ExpandAlias (LPTSTR cmd, INT maxlen)
|
||||
{
|
||||
LPTSTR buffer;
|
||||
TCHAR *position, *in, *out;
|
||||
LPTSTR Token;
|
||||
LPTSTR tmp;
|
||||
LPTSTR buffer;
|
||||
TCHAR *position, *in, *out;
|
||||
LPTSTR Token;
|
||||
LPTSTR tmp;
|
||||
|
||||
tmp = cmd_dup(cmd);
|
||||
if (!tmp)
|
||||
return;
|
||||
tmp = cmd_dup(cmd);
|
||||
if (!tmp)
|
||||
return;
|
||||
|
||||
/* first part is the macro name */
|
||||
position = tmp + _tcscspn(tmp, _T(" \n"));
|
||||
if (position == tmp)
|
||||
{
|
||||
cmd_free(tmp);
|
||||
return;
|
||||
}
|
||||
*position++ = _T('\0');
|
||||
position += _tcsspn(position, _T(" "));
|
||||
/* first part is the macro name */
|
||||
position = tmp + _tcscspn(tmp, _T(" \n"));
|
||||
if (position == tmp)
|
||||
{
|
||||
cmd_free(tmp);
|
||||
return;
|
||||
}
|
||||
*position++ = _T('\0');
|
||||
position += _tcsspn(position, _T(" "));
|
||||
|
||||
buffer = cmd_alloc(maxlen);
|
||||
if (!buffer)
|
||||
{
|
||||
cmd_free(tmp);
|
||||
return;
|
||||
}
|
||||
buffer = cmd_alloc(maxlen);
|
||||
if (!buffer)
|
||||
{
|
||||
cmd_free(tmp);
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetConsoleAlias(tmp, buffer, maxlen, _T("cmd.exe")) == 0)
|
||||
{
|
||||
cmd_free(tmp);
|
||||
cmd_free(buffer);
|
||||
return;
|
||||
}
|
||||
if (GetConsoleAlias(tmp, buffer, maxlen, _T("cmd.exe")) == 0)
|
||||
{
|
||||
cmd_free(tmp);
|
||||
cmd_free(buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
in = buffer;
|
||||
out = cmd;
|
||||
while (*in)
|
||||
{
|
||||
if (*in == _T('$'))
|
||||
{
|
||||
Token = position;
|
||||
if (in[1] >= _T('1') && in[1] <= _T('9'))
|
||||
{
|
||||
/* Copy a single space-delimited token from the input line */
|
||||
INT num;
|
||||
for (num = in[1] - _T('1'); num > 0; num--)
|
||||
{
|
||||
Token += _tcscspn(Token, _T(" \n"));
|
||||
Token += _tcsspn(Token, _T(" "));
|
||||
}
|
||||
while (!_tcschr(_T(" \n"), *Token))
|
||||
{
|
||||
if (out >= &cmd[maxlen - 1])
|
||||
break;
|
||||
*out++ = *Token++;
|
||||
}
|
||||
in += 2;
|
||||
continue;
|
||||
}
|
||||
else if (in[1] == _T('*'))
|
||||
{
|
||||
/* Copy the entire remainder of the line */
|
||||
while (*Token && *Token != _T('\n'))
|
||||
{
|
||||
if (out >= &cmd[maxlen - 1])
|
||||
break;
|
||||
*out++ = *Token++;
|
||||
}
|
||||
in += 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (out >= &cmd[maxlen - 1])
|
||||
break;
|
||||
*out++ = *in++;
|
||||
}
|
||||
*out++ = _T('\n');
|
||||
*out = _T('\0');
|
||||
in = buffer;
|
||||
out = cmd;
|
||||
while (*in)
|
||||
{
|
||||
if (*in == _T('$'))
|
||||
{
|
||||
Token = position;
|
||||
if (in[1] >= _T('1') && in[1] <= _T('9'))
|
||||
{
|
||||
/* Copy a single space-delimited token from the input line */
|
||||
INT num;
|
||||
for (num = in[1] - _T('1'); num > 0; num--)
|
||||
{
|
||||
Token += _tcscspn(Token, _T(" \n"));
|
||||
Token += _tcsspn(Token, _T(" "));
|
||||
}
|
||||
while (!_tcschr(_T(" \n"), *Token))
|
||||
{
|
||||
if (out >= &cmd[maxlen - 1])
|
||||
break;
|
||||
*out++ = *Token++;
|
||||
}
|
||||
in += 2;
|
||||
continue;
|
||||
}
|
||||
else if (in[1] == _T('*'))
|
||||
{
|
||||
/* Copy the entire remainder of the line */
|
||||
while (*Token && *Token != _T('\n'))
|
||||
{
|
||||
if (out >= &cmd[maxlen - 1])
|
||||
break;
|
||||
*out++ = *Token++;
|
||||
}
|
||||
in += 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (out >= &cmd[maxlen - 1])
|
||||
break;
|
||||
*out++ = *in++;
|
||||
}
|
||||
*out++ = _T('\n');
|
||||
*out = _T('\0');
|
||||
|
||||
cmd_free(buffer);
|
||||
cmd_free(tmp);
|
||||
cmd_free(buffer);
|
||||
cmd_free(tmp);
|
||||
}
|
||||
|
||||
INT CommandAlias (LPTSTR param)
|
||||
{
|
||||
LPTSTR ptr;
|
||||
LPTSTR ptr;
|
||||
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_ALIAS_HELP);
|
||||
return 0;
|
||||
}
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_ALIAS_HELP);
|
||||
return 0;
|
||||
}
|
||||
|
||||
nErrorLevel = 0;
|
||||
nErrorLevel = 0;
|
||||
|
||||
if (param[0] == _T('\0'))
|
||||
{
|
||||
PrintAlias ();
|
||||
return 0;
|
||||
}
|
||||
if (param[0] == _T('\0'))
|
||||
{
|
||||
PrintAlias ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
nErrorLevel = 0;
|
||||
nErrorLevel = 0;
|
||||
|
||||
/* error if no '=' found */
|
||||
if ((ptr = _tcschr (param, _T('='))) == 0)
|
||||
{
|
||||
nErrorLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
/* error if no '=' found */
|
||||
if ((ptr = _tcschr (param, _T('='))) == 0)
|
||||
{
|
||||
nErrorLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Split rest into name and substitute */
|
||||
*ptr++ = _T('\0');
|
||||
/* Split rest into name and substitute */
|
||||
*ptr++ = _T('\0');
|
||||
|
||||
partstrlwr (param);
|
||||
partstrlwr (param);
|
||||
|
||||
if (ptr[0] == _T('\0'))
|
||||
AddConsoleAlias(param, NULL, _T("cmd.exe"));
|
||||
else
|
||||
AddConsoleAlias(param, ptr, _T("cmd.exe"));
|
||||
if (ptr[0] == _T('\0'))
|
||||
AddConsoleAlias(param, NULL, _T("cmd.exe"));
|
||||
else
|
||||
AddConsoleAlias(param, ptr, _T("cmd.exe"));
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -24,236 +24,235 @@
|
|||
static INT
|
||||
PrintAssociation(LPTSTR extension)
|
||||
{
|
||||
DWORD return_val;
|
||||
HKEY hKey = NULL, hInsideKey = NULL;
|
||||
DWORD return_val;
|
||||
HKEY hKey = NULL, hInsideKey = NULL;
|
||||
|
||||
DWORD fileTypeLength = 0;
|
||||
LPTSTR fileType = NULL;
|
||||
DWORD fileTypeLength = 0;
|
||||
LPTSTR fileType = NULL;
|
||||
|
||||
return_val = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Classes"), 0, KEY_READ, &hKey);
|
||||
return_val = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Classes"), 0, KEY_READ, &hKey);
|
||||
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return -1;
|
||||
}
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return_val = RegOpenKeyEx(hKey, extension, 0, KEY_READ, &hInsideKey);
|
||||
return_val = RegOpenKeyEx(hKey, extension, 0, KEY_READ, &hInsideKey);
|
||||
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
RegCloseKey(hInsideKey);
|
||||
return 0;
|
||||
}
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
RegCloseKey(hInsideKey);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* obtain string length */
|
||||
return_val = RegQueryValueEx(hInsideKey, NULL, NULL, NULL, NULL, &fileTypeLength);
|
||||
/* obtain string length */
|
||||
return_val = RegQueryValueEx(hInsideKey, NULL, NULL, NULL, NULL, &fileTypeLength);
|
||||
|
||||
if(return_val == ERROR_FILE_NOT_FOUND) /* no default value, don't display */
|
||||
{
|
||||
RegCloseKey(hInsideKey);
|
||||
RegCloseKey(hKey);
|
||||
return 0;
|
||||
}
|
||||
if(return_val == ERROR_FILE_NOT_FOUND) /* no default value, don't display */
|
||||
{
|
||||
RegCloseKey(hInsideKey);
|
||||
RegCloseKey(hKey);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hInsideKey);
|
||||
RegCloseKey(hKey);
|
||||
return -2;
|
||||
}
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hInsideKey);
|
||||
RegCloseKey(hKey);
|
||||
return -2;
|
||||
}
|
||||
|
||||
fileType = cmd_alloc(fileTypeLength * sizeof(TCHAR));
|
||||
fileType = cmd_alloc(fileTypeLength * sizeof(TCHAR));
|
||||
|
||||
/* obtain actual file type */
|
||||
return_val = RegQueryValueEx(hInsideKey, NULL, NULL, NULL, (LPBYTE) fileType, &fileTypeLength);
|
||||
/* obtain actual file type */
|
||||
return_val = RegQueryValueEx(hInsideKey, NULL, NULL, NULL, (LPBYTE) fileType, &fileTypeLength);
|
||||
|
||||
RegCloseKey(hInsideKey);
|
||||
RegCloseKey(hKey);
|
||||
RegCloseKey(hInsideKey);
|
||||
RegCloseKey(hKey);
|
||||
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
cmd_free(fileType);
|
||||
return -2;
|
||||
}
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
cmd_free(fileType);
|
||||
return -2;
|
||||
}
|
||||
|
||||
if(fileTypeLength != 0) /* if there is a default key, display relevant information */
|
||||
{
|
||||
ConOutPrintf(_T("%s=%s\r\n"), extension, fileType);
|
||||
}
|
||||
if(fileTypeLength != 0) /* if there is a default key, display relevant information */
|
||||
{
|
||||
ConOutPrintf(_T("%s=%s\r\n"), extension, fileType);
|
||||
}
|
||||
|
||||
if(fileTypeLength)
|
||||
cmd_free(fileType);
|
||||
if(fileTypeLength)
|
||||
cmd_free(fileType);
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static INT
|
||||
PrintAllAssociations()
|
||||
{
|
||||
DWORD return_val = 0;
|
||||
HKEY hKey = NULL;
|
||||
DWORD numKeys = 0;
|
||||
DWORD return_val = 0;
|
||||
HKEY hKey = NULL;
|
||||
DWORD numKeys = 0;
|
||||
|
||||
DWORD extLength = 0;
|
||||
LPTSTR extName = NULL;
|
||||
DWORD keyCtr = 0;
|
||||
DWORD extLength = 0;
|
||||
LPTSTR extName = NULL;
|
||||
DWORD keyCtr = 0;
|
||||
|
||||
return_val = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Classes"), 0, KEY_READ, &hKey);
|
||||
return_val = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Classes"), 0, KEY_READ, &hKey);
|
||||
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return -1;
|
||||
}
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return_val = RegQueryInfoKey(hKey, NULL, NULL, NULL, &numKeys, &extLength, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
return_val = RegQueryInfoKey(hKey, NULL, NULL, NULL, &numKeys, &extLength, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return -2;
|
||||
}
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return -2;
|
||||
}
|
||||
|
||||
extName = cmd_alloc(extLength * sizeof(TCHAR));
|
||||
extName = cmd_alloc(extLength * sizeof(TCHAR));
|
||||
|
||||
for(keyCtr = 0; keyCtr < numKeys; keyCtr++)
|
||||
{
|
||||
DWORD buffer_size = extLength;
|
||||
return_val = RegEnumKeyEx(hKey, keyCtr, extName, &buffer_size, NULL, NULL, NULL, NULL);
|
||||
for(keyCtr = 0; keyCtr < numKeys; keyCtr++)
|
||||
{
|
||||
DWORD buffer_size = extLength;
|
||||
return_val = RegEnumKeyEx(hKey, keyCtr, extName, &buffer_size, NULL, NULL, NULL, NULL);
|
||||
|
||||
if(return_val == ERROR_SUCCESS || return_val == ERROR_MORE_DATA)
|
||||
{
|
||||
if(*extName == _T('.'))
|
||||
PrintAssociation(extName);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd_free(extName);
|
||||
RegCloseKey(hKey);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if(return_val == ERROR_SUCCESS || return_val == ERROR_MORE_DATA)
|
||||
{
|
||||
if(*extName == _T('.'))
|
||||
PrintAssociation(extName);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd_free(extName);
|
||||
RegCloseKey(hKey);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
RegCloseKey(hKey);
|
||||
|
||||
if(extName)
|
||||
cmd_free(extName);
|
||||
if(extName)
|
||||
cmd_free(extName);
|
||||
|
||||
return numKeys;
|
||||
return numKeys;
|
||||
}
|
||||
|
||||
static INT
|
||||
AddAssociation(LPTSTR extension, LPTSTR type)
|
||||
{
|
||||
DWORD return_val;
|
||||
HKEY hKey = NULL, insideKey = NULL;
|
||||
DWORD return_val;
|
||||
HKEY hKey = NULL, insideKey = NULL;
|
||||
|
||||
return_val = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Classes"), 0, KEY_ALL_ACCESS, &hKey);
|
||||
return_val = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Classes"), 0, KEY_ALL_ACCESS, &hKey);
|
||||
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
return -1;
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
return -1;
|
||||
|
||||
return_val = RegCreateKeyEx(hKey, extension, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &insideKey, NULL);
|
||||
return_val = RegCreateKeyEx(hKey, extension, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &insideKey, NULL);
|
||||
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return -1;
|
||||
}
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return_val = RegSetValueEx(insideKey, NULL, 0, REG_SZ, (LPBYTE)type, (_tcslen(type) + 1) * sizeof(TCHAR));
|
||||
return_val = RegSetValueEx(insideKey, NULL, 0, REG_SZ, (LPBYTE)type, (_tcslen(type) + 1) * sizeof(TCHAR));
|
||||
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(insideKey);
|
||||
RegCloseKey(hKey);
|
||||
return -2;
|
||||
}
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(insideKey);
|
||||
RegCloseKey(hKey);
|
||||
return -2;
|
||||
}
|
||||
|
||||
RegCloseKey(insideKey);
|
||||
RegCloseKey(hKey);
|
||||
return 0;
|
||||
RegCloseKey(insideKey);
|
||||
RegCloseKey(hKey);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
RemoveAssociation(LPTSTR extension)
|
||||
{
|
||||
DWORD return_val;
|
||||
HKEY hKey;
|
||||
DWORD return_val;
|
||||
HKEY hKey;
|
||||
|
||||
return_val = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Classes"), 0, KEY_ALL_ACCESS, &hKey);
|
||||
return_val = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Classes"), 0, KEY_ALL_ACCESS, &hKey);
|
||||
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
return -1;
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
return -1;
|
||||
|
||||
return_val = RegDeleteKey(hKey, extension);
|
||||
return_val = RegDeleteKey(hKey, extension);
|
||||
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return -2;
|
||||
}
|
||||
if(return_val != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return -2;
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return 0;
|
||||
RegCloseKey(hKey);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
INT CommandAssoc (LPTSTR param)
|
||||
{
|
||||
/* print help */
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_ASSOC_HELP);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* print help */
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_ASSOC_HELP);
|
||||
return 0;
|
||||
}
|
||||
nErrorLevel = 0;
|
||||
|
||||
nErrorLevel = 0;
|
||||
if(_tcslen(param) == 0)
|
||||
PrintAllAssociations();
|
||||
else
|
||||
{
|
||||
LPTSTR lpEqualSign = _tcschr(param, _T('='));
|
||||
if(lpEqualSign != NULL)
|
||||
{
|
||||
LPTSTR fileType = lpEqualSign + 1;
|
||||
LPTSTR extension = cmd_alloc((lpEqualSign - param + 1) * sizeof(TCHAR));
|
||||
|
||||
if(_tcslen(param) == 0)
|
||||
PrintAllAssociations();
|
||||
else
|
||||
{
|
||||
LPTSTR lpEqualSign = _tcschr(param, _T('='));
|
||||
if(lpEqualSign != NULL)
|
||||
{
|
||||
LPTSTR fileType = lpEqualSign + 1;
|
||||
LPTSTR extension = cmd_alloc((lpEqualSign - param + 1) * sizeof(TCHAR));
|
||||
_tcsncpy(extension, param, lpEqualSign - param);
|
||||
extension[lpEqualSign - param] = (TCHAR)0;
|
||||
|
||||
_tcsncpy(extension, param, lpEqualSign - param);
|
||||
extension[lpEqualSign - param] = (TCHAR)0;
|
||||
if(_tcslen(fileType) == 0)
|
||||
/* if the equal sign is the last character
|
||||
in the string, then delete the key */
|
||||
{
|
||||
RemoveAssociation(extension);
|
||||
}
|
||||
else
|
||||
/* otherwise, add the key and print out the association*/
|
||||
{
|
||||
AddAssociation( extension, fileType);
|
||||
PrintAssociation(extension);
|
||||
}
|
||||
|
||||
if(_tcslen(fileType) == 0)
|
||||
/* if the equal sign is the last character
|
||||
in the string, then delete the key */
|
||||
{
|
||||
RemoveAssociation(extension);
|
||||
}
|
||||
else
|
||||
/* otherwise, add the key and print out the association*/
|
||||
{
|
||||
AddAssociation( extension, fileType);
|
||||
PrintAssociation(extension);
|
||||
}
|
||||
cmd_free(extension);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* no equal sign, print all associations */
|
||||
INT retval = PrintAssociation(param);
|
||||
|
||||
cmd_free(extension);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* no equal sign, print all associations */
|
||||
INT retval = PrintAssociation(param);
|
||||
if(retval == 0) /* if nothing printed out */
|
||||
ConOutResPrintf(STRING_ASSOC_ERROR, param);
|
||||
}
|
||||
}
|
||||
|
||||
if(retval == 0) /* if nothing printed out */
|
||||
ConOutResPrintf(STRING_ASSOC_ERROR, param);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* INCLUDE_CMD_ASSOC */
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
* 23-Jan-1999 Eric Kohl
|
||||
* Added handling of multiple filenames.
|
||||
*
|
||||
* 02-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 02-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
@ -39,306 +39,306 @@
|
|||
static VOID
|
||||
PrintAttribute (LPTSTR pszPath, LPTSTR pszFile, BOOL bRecurse)
|
||||
{
|
||||
WIN32_FIND_DATA findData;
|
||||
HANDLE hFind;
|
||||
TCHAR szFullName[MAX_PATH];
|
||||
LPTSTR pszFileName;
|
||||
WIN32_FIND_DATA findData;
|
||||
HANDLE hFind;
|
||||
TCHAR szFullName[MAX_PATH];
|
||||
LPTSTR pszFileName;
|
||||
|
||||
/* prepare full file name buffer */
|
||||
_tcscpy (szFullName, pszPath);
|
||||
pszFileName = szFullName + _tcslen (szFullName);
|
||||
/* prepare full file name buffer */
|
||||
_tcscpy (szFullName, pszPath);
|
||||
pszFileName = szFullName + _tcslen (szFullName);
|
||||
|
||||
/* display all subdirectories */
|
||||
if (bRecurse)
|
||||
{
|
||||
/* append file name */
|
||||
_tcscpy (pszFileName, pszFile);
|
||||
/* display all subdirectories */
|
||||
if (bRecurse)
|
||||
{
|
||||
/* append file name */
|
||||
_tcscpy (pszFileName, pszFile);
|
||||
|
||||
hFind = FindFirstFile (szFullName, &findData);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
ErrorMessage (GetLastError (), pszFile);
|
||||
return;
|
||||
}
|
||||
hFind = FindFirstFile (szFullName, &findData);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
ErrorMessage (GetLastError (), pszFile);
|
||||
return;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||
continue;
|
||||
do
|
||||
{
|
||||
if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||
continue;
|
||||
|
||||
if (!_tcscmp (findData.cFileName, _T(".")) ||
|
||||
!_tcscmp (findData.cFileName, _T("..")))
|
||||
continue;
|
||||
if (!_tcscmp (findData.cFileName, _T(".")) ||
|
||||
!_tcscmp (findData.cFileName, _T("..")))
|
||||
continue;
|
||||
|
||||
_tcscpy (pszFileName, findData.cFileName);
|
||||
_tcscat (pszFileName, _T("\\"));
|
||||
PrintAttribute (szFullName, pszFile, bRecurse);
|
||||
}
|
||||
while (FindNextFile (hFind, &findData));
|
||||
FindClose (hFind);
|
||||
}
|
||||
_tcscpy (pszFileName, findData.cFileName);
|
||||
_tcscat (pszFileName, _T("\\"));
|
||||
PrintAttribute (szFullName, pszFile, bRecurse);
|
||||
}
|
||||
while (FindNextFile (hFind, &findData));
|
||||
FindClose (hFind);
|
||||
}
|
||||
|
||||
/* append file name */
|
||||
_tcscpy (pszFileName, pszFile);
|
||||
/* append file name */
|
||||
_tcscpy (pszFileName, pszFile);
|
||||
|
||||
/* display current directory */
|
||||
hFind = FindFirstFile (szFullName, &findData);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
ErrorMessage (GetLastError (), pszFile);
|
||||
return;
|
||||
}
|
||||
/* display current directory */
|
||||
hFind = FindFirstFile (szFullName, &findData);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
ErrorMessage (GetLastError (), pszFile);
|
||||
return;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
continue;
|
||||
do
|
||||
{
|
||||
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
continue;
|
||||
|
||||
_tcscpy (pszFileName, findData.cFileName);
|
||||
_tcscpy (pszFileName, findData.cFileName);
|
||||
|
||||
ConOutPrintf (_T("%c %c%c%c %s\n"),
|
||||
(findData.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) ? _T('A') : _T(' '),
|
||||
(findData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) ? _T('S') : _T(' '),
|
||||
(findData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ? _T('H') : _T(' '),
|
||||
(findData.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? _T('R') : _T(' '),
|
||||
szFullName);
|
||||
}
|
||||
while (FindNextFile (hFind, &findData));
|
||||
FindClose (hFind);
|
||||
ConOutPrintf (_T("%c %c%c%c %s\n"),
|
||||
(findData.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) ? _T('A') : _T(' '),
|
||||
(findData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) ? _T('S') : _T(' '),
|
||||
(findData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ? _T('H') : _T(' '),
|
||||
(findData.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? _T('R') : _T(' '),
|
||||
szFullName);
|
||||
}
|
||||
while (FindNextFile (hFind, &findData));
|
||||
FindClose (hFind);
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
ChangeAttribute (LPTSTR pszPath, LPTSTR pszFile, DWORD dwMask,
|
||||
DWORD dwAttrib, BOOL bRecurse, BOOL bDirectories)
|
||||
ChangeAttribute(LPTSTR pszPath, LPTSTR pszFile, DWORD dwMask,
|
||||
DWORD dwAttrib, BOOL bRecurse, BOOL bDirectories)
|
||||
{
|
||||
WIN32_FIND_DATA findData;
|
||||
HANDLE hFind;
|
||||
DWORD dwAttribute;
|
||||
TCHAR szFullName[MAX_PATH];
|
||||
LPTSTR pszFileName;
|
||||
WIN32_FIND_DATA findData;
|
||||
HANDLE hFind;
|
||||
DWORD dwAttribute;
|
||||
TCHAR szFullName[MAX_PATH];
|
||||
LPTSTR pszFileName;
|
||||
|
||||
|
||||
/* prepare full file name buffer */
|
||||
_tcscpy (szFullName, pszPath);
|
||||
pszFileName = szFullName + _tcslen (szFullName);
|
||||
/* prepare full file name buffer */
|
||||
_tcscpy (szFullName, pszPath);
|
||||
pszFileName = szFullName + _tcslen (szFullName);
|
||||
|
||||
/* change all subdirectories */
|
||||
if (bRecurse)
|
||||
{
|
||||
/* append file name */
|
||||
_tcscpy (pszFileName, _T("*.*"));
|
||||
/* change all subdirectories */
|
||||
if (bRecurse)
|
||||
{
|
||||
/* append file name */
|
||||
_tcscpy (pszFileName, _T("*.*"));
|
||||
|
||||
hFind = FindFirstFile (szFullName, &findData);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
ErrorMessage (GetLastError (), pszFile);
|
||||
hFind = FindFirstFile (szFullName, &findData);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
ErrorMessage (GetLastError (), pszFile);
|
||||
nErrorLevel = 1;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
if (!_tcscmp (findData.cFileName, _T(".")) ||
|
||||
!_tcscmp (findData.cFileName, _T("..")))
|
||||
continue;
|
||||
do
|
||||
{
|
||||
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
if (!_tcscmp (findData.cFileName, _T(".")) ||
|
||||
!_tcscmp (findData.cFileName, _T("..")))
|
||||
continue;
|
||||
|
||||
_tcscpy (pszFileName, findData.cFileName);
|
||||
_tcscat (pszFileName, _T("\\"));
|
||||
_tcscpy (pszFileName, findData.cFileName);
|
||||
_tcscat (pszFileName, _T("\\"));
|
||||
|
||||
ChangeAttribute (szFullName, pszFile, dwMask,
|
||||
dwAttrib, bRecurse, bDirectories);
|
||||
}
|
||||
}
|
||||
while (FindNextFile (hFind, &findData));
|
||||
FindClose (hFind);
|
||||
}
|
||||
ChangeAttribute (szFullName, pszFile, dwMask,
|
||||
dwAttrib, bRecurse, bDirectories);
|
||||
}
|
||||
}
|
||||
while (FindNextFile (hFind, &findData));
|
||||
FindClose (hFind);
|
||||
}
|
||||
|
||||
/* append file name */
|
||||
_tcscpy (pszFileName, pszFile);
|
||||
/* append file name */
|
||||
_tcscpy (pszFileName, pszFile);
|
||||
|
||||
hFind = FindFirstFile (szFullName, &findData);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
ErrorMessage (GetLastError (), pszFile);
|
||||
hFind = FindFirstFile (szFullName, &findData);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
ErrorMessage (GetLastError (), pszFile);
|
||||
nErrorLevel = 1;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
continue;
|
||||
do
|
||||
{
|
||||
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
continue;
|
||||
|
||||
_tcscpy (pszFileName, findData.cFileName);
|
||||
_tcscpy (pszFileName, findData.cFileName);
|
||||
|
||||
dwAttribute = GetFileAttributes (szFullName);
|
||||
dwAttribute = GetFileAttributes (szFullName);
|
||||
|
||||
if (dwAttribute != 0xFFFFFFFF)
|
||||
{
|
||||
dwAttribute = (dwAttribute & ~dwMask) | dwAttrib;
|
||||
SetFileAttributes (szFullName, dwAttribute);
|
||||
}
|
||||
}
|
||||
while (FindNextFile (hFind, &findData));
|
||||
FindClose (hFind);
|
||||
if (dwAttribute != 0xFFFFFFFF)
|
||||
{
|
||||
dwAttribute = (dwAttribute & ~dwMask) | dwAttrib;
|
||||
SetFileAttributes (szFullName, dwAttribute);
|
||||
}
|
||||
}
|
||||
while (FindNextFile (hFind, &findData));
|
||||
FindClose (hFind);
|
||||
}
|
||||
|
||||
|
||||
INT CommandAttrib (LPTSTR param)
|
||||
{
|
||||
LPTSTR *arg;
|
||||
INT argc, i;
|
||||
TCHAR szPath[MAX_PATH];
|
||||
TCHAR szFileName [MAX_PATH];
|
||||
BOOL bRecurse = FALSE;
|
||||
BOOL bDirectories = FALSE;
|
||||
DWORD dwAttrib = 0;
|
||||
DWORD dwMask = 0;
|
||||
LPTSTR *arg;
|
||||
INT argc, i;
|
||||
TCHAR szPath[MAX_PATH];
|
||||
TCHAR szFileName [MAX_PATH];
|
||||
BOOL bRecurse = FALSE;
|
||||
BOOL bDirectories = FALSE;
|
||||
DWORD dwAttrib = 0;
|
||||
DWORD dwMask = 0;
|
||||
|
||||
/* initialize strings */
|
||||
szPath[0] = _T('\0');
|
||||
szFileName[0] = _T('\0');
|
||||
/* initialize strings */
|
||||
szPath[0] = _T('\0');
|
||||
szFileName[0] = _T('\0');
|
||||
|
||||
/* print help */
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_ATTRIB_HELP);
|
||||
return 0;
|
||||
}
|
||||
/* print help */
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_ATTRIB_HELP);
|
||||
return 0;
|
||||
}
|
||||
|
||||
nErrorLevel = 0;
|
||||
nErrorLevel = 0;
|
||||
|
||||
/* build parameter array */
|
||||
arg = split (param, &argc, FALSE, FALSE);
|
||||
/* build parameter array */
|
||||
arg = split (param, &argc, FALSE, FALSE);
|
||||
|
||||
/* check for options */
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
if (_tcsicmp (arg[i], _T("/s")) == 0)
|
||||
bRecurse = TRUE;
|
||||
else if (_tcsicmp (arg[i], _T("/d")) == 0)
|
||||
bDirectories = TRUE;
|
||||
}
|
||||
/* check for options */
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
if (_tcsicmp (arg[i], _T("/s")) == 0)
|
||||
bRecurse = TRUE;
|
||||
else if (_tcsicmp (arg[i], _T("/d")) == 0)
|
||||
bDirectories = TRUE;
|
||||
}
|
||||
|
||||
/* create attributes and mask */
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
if (*arg[i] == _T('+'))
|
||||
{
|
||||
if (_tcslen (arg[i]) != 2)
|
||||
{
|
||||
error_invalid_parameter_format (arg[i]);
|
||||
freep (arg);
|
||||
return -1;
|
||||
}
|
||||
/* create attributes and mask */
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
if (*arg[i] == _T('+'))
|
||||
{
|
||||
if (_tcslen (arg[i]) != 2)
|
||||
{
|
||||
error_invalid_parameter_format (arg[i]);
|
||||
freep (arg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch ((TCHAR)_totupper (arg[i][1]))
|
||||
{
|
||||
case _T('A'):
|
||||
dwMask |= FILE_ATTRIBUTE_ARCHIVE;
|
||||
dwAttrib |= FILE_ATTRIBUTE_ARCHIVE;
|
||||
break;
|
||||
switch ((TCHAR)_totupper (arg[i][1]))
|
||||
{
|
||||
case _T('A'):
|
||||
dwMask |= FILE_ATTRIBUTE_ARCHIVE;
|
||||
dwAttrib |= FILE_ATTRIBUTE_ARCHIVE;
|
||||
break;
|
||||
|
||||
case _T('H'):
|
||||
dwMask |= FILE_ATTRIBUTE_HIDDEN;
|
||||
dwAttrib |= FILE_ATTRIBUTE_HIDDEN;
|
||||
break;
|
||||
case _T('H'):
|
||||
dwMask |= FILE_ATTRIBUTE_HIDDEN;
|
||||
dwAttrib |= FILE_ATTRIBUTE_HIDDEN;
|
||||
break;
|
||||
|
||||
case _T('R'):
|
||||
dwMask |= FILE_ATTRIBUTE_READONLY;
|
||||
dwAttrib |= FILE_ATTRIBUTE_READONLY;
|
||||
break;
|
||||
case _T('R'):
|
||||
dwMask |= FILE_ATTRIBUTE_READONLY;
|
||||
dwAttrib |= FILE_ATTRIBUTE_READONLY;
|
||||
break;
|
||||
|
||||
case _T('S'):
|
||||
dwMask |= FILE_ATTRIBUTE_SYSTEM;
|
||||
dwAttrib |= FILE_ATTRIBUTE_SYSTEM;
|
||||
break;
|
||||
case _T('S'):
|
||||
dwMask |= FILE_ATTRIBUTE_SYSTEM;
|
||||
dwAttrib |= FILE_ATTRIBUTE_SYSTEM;
|
||||
break;
|
||||
|
||||
default:
|
||||
error_invalid_parameter_format (arg[i]);
|
||||
freep (arg);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (*arg[i] == _T('-'))
|
||||
{
|
||||
if (_tcslen (arg[i]) != 2)
|
||||
{
|
||||
error_invalid_parameter_format (arg[i]);
|
||||
freep (arg);
|
||||
return -1;
|
||||
}
|
||||
default:
|
||||
error_invalid_parameter_format (arg[i]);
|
||||
freep (arg);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (*arg[i] == _T('-'))
|
||||
{
|
||||
if (_tcslen (arg[i]) != 2)
|
||||
{
|
||||
error_invalid_parameter_format (arg[i]);
|
||||
freep (arg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch ((TCHAR)_totupper (arg[i][1]))
|
||||
{
|
||||
case _T('A'):
|
||||
dwMask |= FILE_ATTRIBUTE_ARCHIVE;
|
||||
dwAttrib &= ~FILE_ATTRIBUTE_ARCHIVE;
|
||||
break;
|
||||
switch ((TCHAR)_totupper (arg[i][1]))
|
||||
{
|
||||
case _T('A'):
|
||||
dwMask |= FILE_ATTRIBUTE_ARCHIVE;
|
||||
dwAttrib &= ~FILE_ATTRIBUTE_ARCHIVE;
|
||||
break;
|
||||
|
||||
case _T('H'):
|
||||
dwMask |= FILE_ATTRIBUTE_HIDDEN;
|
||||
dwAttrib &= ~FILE_ATTRIBUTE_HIDDEN;
|
||||
break;
|
||||
case _T('H'):
|
||||
dwMask |= FILE_ATTRIBUTE_HIDDEN;
|
||||
dwAttrib &= ~FILE_ATTRIBUTE_HIDDEN;
|
||||
break;
|
||||
|
||||
case _T('R'):
|
||||
dwMask |= FILE_ATTRIBUTE_READONLY;
|
||||
dwAttrib &= ~FILE_ATTRIBUTE_READONLY;
|
||||
break;
|
||||
case _T('R'):
|
||||
dwMask |= FILE_ATTRIBUTE_READONLY;
|
||||
dwAttrib &= ~FILE_ATTRIBUTE_READONLY;
|
||||
break;
|
||||
|
||||
case _T('S'):
|
||||
dwMask |= FILE_ATTRIBUTE_SYSTEM;
|
||||
dwAttrib &= ~FILE_ATTRIBUTE_SYSTEM;
|
||||
break;
|
||||
case _T('S'):
|
||||
dwMask |= FILE_ATTRIBUTE_SYSTEM;
|
||||
dwAttrib &= ~FILE_ATTRIBUTE_SYSTEM;
|
||||
break;
|
||||
|
||||
default:
|
||||
error_invalid_parameter_format (arg[i]);
|
||||
freep (arg);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
error_invalid_parameter_format (arg[i]);
|
||||
freep (arg);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
DWORD len;
|
||||
if (argc == 0)
|
||||
{
|
||||
DWORD len;
|
||||
|
||||
len = GetCurrentDirectory (MAX_PATH, szPath);
|
||||
if (szPath[len-1] != _T('\\'))
|
||||
{
|
||||
szPath[len] = _T('\\');
|
||||
szPath[len + 1] = 0;
|
||||
}
|
||||
_tcscpy (szFileName, _T("*.*"));
|
||||
PrintAttribute (szPath, szFileName, bRecurse);
|
||||
freep (arg);
|
||||
return 0;
|
||||
}
|
||||
len = GetCurrentDirectory (MAX_PATH, szPath);
|
||||
if (szPath[len-1] != _T('\\'))
|
||||
{
|
||||
szPath[len] = _T('\\');
|
||||
szPath[len + 1] = 0;
|
||||
}
|
||||
_tcscpy (szFileName, _T("*.*"));
|
||||
PrintAttribute (szPath, szFileName, bRecurse);
|
||||
freep (arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* get full file name */
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
if ((*arg[i] != _T('+')) && (*arg[i] != _T('-')) && (*arg[i] != _T('/')))
|
||||
{
|
||||
LPTSTR p;
|
||||
GetFullPathName (arg[i], MAX_PATH, szPath, NULL);
|
||||
p = _tcsrchr (szPath, _T('\\')) + 1;
|
||||
_tcscpy (szFileName, p);
|
||||
*p = _T('\0');
|
||||
/* get full file name */
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
if ((*arg[i] != _T('+')) && (*arg[i] != _T('-')) && (*arg[i] != _T('/')))
|
||||
{
|
||||
LPTSTR p;
|
||||
GetFullPathName (arg[i], MAX_PATH, szPath, NULL);
|
||||
p = _tcsrchr (szPath, _T('\\')) + 1;
|
||||
_tcscpy (szFileName, p);
|
||||
*p = _T('\0');
|
||||
|
||||
if (dwMask == 0)
|
||||
PrintAttribute (szPath, szFileName, bRecurse);
|
||||
else
|
||||
ChangeAttribute (szPath, szFileName, dwMask,
|
||||
dwAttrib, bRecurse, bDirectories);
|
||||
}
|
||||
}
|
||||
if (dwMask == 0)
|
||||
PrintAttribute (szPath, szFileName, bRecurse);
|
||||
else
|
||||
ChangeAttribute (szPath, szFileName, dwMask,
|
||||
dwAttrib, bRecurse, bDirectories);
|
||||
}
|
||||
}
|
||||
|
||||
freep (arg);
|
||||
return 0;
|
||||
freep (arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* INCLUDE_CMD_ATTRIB */
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
* 20-Jan-1999 (Eric Kohl)
|
||||
* Redirection ready!
|
||||
*
|
||||
* 02-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 02-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
@ -31,19 +31,19 @@
|
|||
|
||||
INT cmd_beep (LPTSTR param)
|
||||
{
|
||||
if (_tcsncmp (param, _T("/?"), 2) == 0)
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_BEEP_HELP);
|
||||
return 0;
|
||||
}
|
||||
if (_tcsncmp (param, _T("/?"), 2) == 0)
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_BEEP_HELP);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* check if run in batch mode */
|
||||
if (bc == NULL)
|
||||
return 1;
|
||||
/* check if run in batch mode */
|
||||
if (bc == NULL)
|
||||
return 1;
|
||||
#endif
|
||||
MessageBeep (-1);
|
||||
MessageBeep (-1);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
* 20-Jan-1999 (Eric Kohl)
|
||||
* Unicode and redirection safe!
|
||||
*
|
||||
* 02-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 02-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
@ -36,48 +36,48 @@
|
|||
|
||||
INT cmd_call (LPTSTR param)
|
||||
{
|
||||
TCHAR line[CMDLINE_LENGTH + 1];
|
||||
TCHAR *first;
|
||||
BOOL bInQuote = FALSE;
|
||||
TCHAR line[CMDLINE_LENGTH + 1];
|
||||
TCHAR *first;
|
||||
BOOL bInQuote = FALSE;
|
||||
|
||||
TRACE ("cmd_call: (\'%s\')\n", debugstr_aw(param));
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_CALL_HELP);
|
||||
return 0;
|
||||
}
|
||||
TRACE ("cmd_call: (\'%s\')\n", debugstr_aw(param));
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_CALL_HELP);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Do a second round of %-variable substitutions */
|
||||
if (!SubstituteVars(param, line, _T('%')))
|
||||
return nErrorLevel = 1;
|
||||
/* Do a second round of %-variable substitutions */
|
||||
if (!SubstituteVars(param, line, _T('%')))
|
||||
return nErrorLevel = 1;
|
||||
|
||||
/* Find start and end of first word */
|
||||
first = line;
|
||||
while (_istspace(*first))
|
||||
first++;
|
||||
/* Find start and end of first word */
|
||||
first = line;
|
||||
while (_istspace(*first))
|
||||
first++;
|
||||
|
||||
for (param = first; *param; param++)
|
||||
{
|
||||
if (!bInQuote && (_istspace(*param) || _tcschr(_T(",;="), *param)))
|
||||
break;
|
||||
bInQuote ^= (*param == _T('"'));
|
||||
}
|
||||
for (param = first; *param; param++)
|
||||
{
|
||||
if (!bInQuote && (_istspace(*param) || _tcschr(_T(",;="), *param)))
|
||||
break;
|
||||
bInQuote ^= (*param == _T('"'));
|
||||
}
|
||||
|
||||
/* Separate first word from rest of line */
|
||||
memmove(param + 1, param, (_tcslen(param) + 1) * sizeof(TCHAR));
|
||||
*param++ = _T('\0');
|
||||
/* Separate first word from rest of line */
|
||||
memmove(param + 1, param, (_tcslen(param) + 1) * sizeof(TCHAR));
|
||||
*param++ = _T('\0');
|
||||
|
||||
if (*first == _T(':') && (bc))
|
||||
{
|
||||
/* CALL :label - call a subroutine of the current batch file */
|
||||
while (*param == _T(' '))
|
||||
param++;
|
||||
nErrorLevel = Batch(bc->BatchFilePath, first, param, NULL);
|
||||
return nErrorLevel;
|
||||
}
|
||||
if (*first == _T(':') && (bc))
|
||||
{
|
||||
/* CALL :label - call a subroutine of the current batch file */
|
||||
while (*param == _T(' '))
|
||||
param++;
|
||||
nErrorLevel = Batch(bc->BatchFilePath, first, param, NULL);
|
||||
return nErrorLevel;
|
||||
}
|
||||
|
||||
nErrorLevel = DoCommand(first, param, NULL);
|
||||
return nErrorLevel;
|
||||
nErrorLevel = DoCommand(first, param, NULL);
|
||||
return nErrorLevel;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
* 23-Dec-1998 (Eric Kohl)
|
||||
* Started.
|
||||
*
|
||||
* 02-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 02-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
@ -17,64 +17,64 @@
|
|||
|
||||
INT CommandChcp (LPTSTR param)
|
||||
{
|
||||
LPTSTR *arg;
|
||||
INT args;
|
||||
UINT uNewCodePage;
|
||||
LPTSTR *arg;
|
||||
INT args;
|
||||
UINT uNewCodePage;
|
||||
|
||||
/* print help */
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_CHCP_HELP);
|
||||
return 0;
|
||||
}
|
||||
/* print help */
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_CHCP_HELP);
|
||||
return 0;
|
||||
}
|
||||
|
||||
nErrorLevel = 0;
|
||||
nErrorLevel = 0;
|
||||
|
||||
/* get parameters */
|
||||
arg = split (param, &args, FALSE, FALSE);
|
||||
/* get parameters */
|
||||
arg = split (param, &args, FALSE, FALSE);
|
||||
|
||||
if (args == 0)
|
||||
{
|
||||
/* display active code page number */
|
||||
ConErrResPrintf(STRING_CHCP_ERROR1, InputCodePage);
|
||||
freep (arg);
|
||||
return 0;
|
||||
}
|
||||
if (args == 0)
|
||||
{
|
||||
/* display active code page number */
|
||||
ConErrResPrintf(STRING_CHCP_ERROR1, InputCodePage);
|
||||
freep (arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (args >= 2)
|
||||
{
|
||||
/* too many parameters */
|
||||
ConErrResPrintf(STRING_ERROR_INVALID_PARAM_FORMAT, param);
|
||||
nErrorLevel = 1;
|
||||
freep (arg);
|
||||
return 1;
|
||||
}
|
||||
if (args >= 2)
|
||||
{
|
||||
/* too many parameters */
|
||||
ConErrResPrintf(STRING_ERROR_INVALID_PARAM_FORMAT, param);
|
||||
nErrorLevel = 1;
|
||||
freep (arg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uNewCodePage = (UINT)_ttoi(arg[0]);
|
||||
uNewCodePage = (UINT)_ttoi(arg[0]);
|
||||
|
||||
if (uNewCodePage == 0)
|
||||
{
|
||||
ConErrResPrintf(STRING_ERROR_INVALID_PARAM_FORMAT, arg[0]);
|
||||
freep (arg);
|
||||
nErrorLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
if (uNewCodePage == 0)
|
||||
{
|
||||
ConErrResPrintf(STRING_ERROR_INVALID_PARAM_FORMAT, arg[0]);
|
||||
freep (arg);
|
||||
nErrorLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!SetConsoleCP(uNewCodePage))
|
||||
{
|
||||
ConErrResPuts(STRING_CHCP_ERROR4);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!SetConsoleCP(uNewCodePage))
|
||||
{
|
||||
ConErrResPuts(STRING_CHCP_ERROR4);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
SetConsoleOutputCP (uNewCodePage);
|
||||
InitLocale ();
|
||||
InputCodePage= GetConsoleCP();
|
||||
}
|
||||
SetConsoleOutputCP (uNewCodePage);
|
||||
InitLocale ();
|
||||
InputCodePage= GetConsoleCP();
|
||||
}
|
||||
|
||||
freep (arg);
|
||||
freep (arg);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* INCLUDE_CMD_CHCP */
|
||||
|
|
|
@ -13,9 +13,8 @@
|
|||
* 26 Sep 1999 (Paolo Pantaleo)
|
||||
* Fixed timeout.
|
||||
*
|
||||
* 02 Apr 2005 (Magnus Olsen
|
||||
* Remove Hardcode string so
|
||||
* they can be translate
|
||||
* 02 Apr 2005 (Magnus Olsen)
|
||||
* Remove hardcoded strings so that they can be translated.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -24,9 +23,9 @@
|
|||
#ifdef INCLUDE_CMD_CHOICE
|
||||
|
||||
|
||||
#define GC_TIMEOUT -1
|
||||
#define GC_NOKEY 0 //an event occurred but it wasn't a key pressed
|
||||
#define GC_KEYREAD 1 //a key has been read
|
||||
#define GC_TIMEOUT -1
|
||||
#define GC_NOKEY 0 //an event occurred but it wasn't a key pressed
|
||||
#define GC_KEYREAD 1 //a key has been read
|
||||
|
||||
|
||||
static INT
|
||||
|
@ -37,275 +36,275 @@ GetCharacterTimeout (LPTCH ch, DWORD dwMilliseconds)
|
|||
// The function will wait a limited amount
|
||||
// of time, then the function returns GC_TIMEOUT.
|
||||
//
|
||||
// dwMilliseconds is the timeout value, that can
|
||||
// be set to INFINITE, so the function works like
|
||||
// stdio.h's getchar()
|
||||
// dwMilliseconds is the timeout value, that can
|
||||
// be set to INFINITE, so the function works like
|
||||
// stdio.h's getchar()
|
||||
|
||||
HANDLE hInput;
|
||||
DWORD dwRead;
|
||||
HANDLE hInput;
|
||||
DWORD dwRead;
|
||||
|
||||
INPUT_RECORD lpBuffer;
|
||||
INPUT_RECORD lpBuffer;
|
||||
|
||||
hInput = GetStdHandle (STD_INPUT_HANDLE);
|
||||
hInput = GetStdHandle (STD_INPUT_HANDLE);
|
||||
|
||||
//if the timeout experied return GC_TIMEOUT
|
||||
if (WaitForSingleObject (hInput, dwMilliseconds) == WAIT_TIMEOUT)
|
||||
return GC_TIMEOUT;
|
||||
//if the timeout experied return GC_TIMEOUT
|
||||
if (WaitForSingleObject (hInput, dwMilliseconds) == WAIT_TIMEOUT)
|
||||
return GC_TIMEOUT;
|
||||
|
||||
//otherwise get the event
|
||||
ReadConsoleInput (hInput, &lpBuffer, 1, &dwRead);
|
||||
//otherwise get the event
|
||||
ReadConsoleInput (hInput, &lpBuffer, 1, &dwRead);
|
||||
|
||||
//if the event is a key pressed
|
||||
if ((lpBuffer.EventType == KEY_EVENT) &&
|
||||
(lpBuffer.Event.KeyEvent.bKeyDown == TRUE))
|
||||
{
|
||||
//read the key
|
||||
//if the event is a key pressed
|
||||
if ((lpBuffer.EventType == KEY_EVENT) &&
|
||||
(lpBuffer.Event.KeyEvent.bKeyDown == TRUE))
|
||||
{
|
||||
//read the key
|
||||
#ifdef _UNICODE
|
||||
*ch = lpBuffer.Event.KeyEvent.uChar.UnicodeChar;
|
||||
*ch = lpBuffer.Event.KeyEvent.uChar.UnicodeChar;
|
||||
#else
|
||||
*ch = lpBuffer.Event.KeyEvent.uChar.AsciiChar;
|
||||
*ch = lpBuffer.Event.KeyEvent.uChar.AsciiChar;
|
||||
#endif
|
||||
return GC_KEYREAD;
|
||||
}
|
||||
return GC_KEYREAD;
|
||||
}
|
||||
|
||||
//else return no key
|
||||
return GC_NOKEY;
|
||||
//else return no key
|
||||
return GC_NOKEY;
|
||||
}
|
||||
|
||||
static INT
|
||||
IsKeyInString (LPTSTR lpString, TCHAR cKey, BOOL bCaseSensitive)
|
||||
{
|
||||
LPTCH p = lpString;
|
||||
INT val = 0;
|
||||
LPTCH p = lpString;
|
||||
INT val = 0;
|
||||
|
||||
while (*p)
|
||||
{
|
||||
if (bCaseSensitive)
|
||||
{
|
||||
if (*p == cKey)
|
||||
return val;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_totlower (*p) == _totlower (cKey))
|
||||
return val;
|
||||
}
|
||||
while (*p)
|
||||
{
|
||||
if (bCaseSensitive)
|
||||
{
|
||||
if (*p == cKey)
|
||||
return val;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_totlower (*p) == _totlower (cKey))
|
||||
return val;
|
||||
}
|
||||
|
||||
val++;
|
||||
p++;
|
||||
}
|
||||
val++;
|
||||
p++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
INT
|
||||
CommandChoice (LPTSTR param)
|
||||
{
|
||||
LPTSTR lpOptions;
|
||||
TCHAR Options[6];
|
||||
LPTSTR lpText = NULL;
|
||||
BOOL bNoPrompt = FALSE;
|
||||
BOOL bCaseSensitive = FALSE;
|
||||
BOOL bTimeout = FALSE;
|
||||
INT nTimeout = 0;
|
||||
TCHAR cDefault = _T('\0');
|
||||
INPUT_RECORD ir;
|
||||
LPTSTR p, np;
|
||||
LPTSTR *arg;
|
||||
INT argc;
|
||||
INT i;
|
||||
INT val;
|
||||
LPTSTR lpOptions;
|
||||
TCHAR Options[6];
|
||||
LPTSTR lpText = NULL;
|
||||
BOOL bNoPrompt = FALSE;
|
||||
BOOL bCaseSensitive = FALSE;
|
||||
BOOL bTimeout = FALSE;
|
||||
INT nTimeout = 0;
|
||||
TCHAR cDefault = _T('\0');
|
||||
INPUT_RECORD ir;
|
||||
LPTSTR p, np;
|
||||
LPTSTR *arg;
|
||||
INT argc;
|
||||
INT i;
|
||||
INT val;
|
||||
|
||||
INT GCret;
|
||||
TCHAR Ch;
|
||||
DWORD amount,clk;
|
||||
INT GCret;
|
||||
TCHAR Ch;
|
||||
DWORD amount,clk;
|
||||
|
||||
LoadString(CMD_ModuleHandle, STRING_CHOICE_OPTION, Options, 4);
|
||||
lpOptions = Options;
|
||||
LoadString(CMD_ModuleHandle, STRING_CHOICE_OPTION, Options, 4);
|
||||
lpOptions = Options;
|
||||
|
||||
if (_tcsncmp (param, _T("/?"), 2) == 0)
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_CHOICE_HELP);
|
||||
return 0;
|
||||
}
|
||||
if (_tcsncmp (param, _T("/?"), 2) == 0)
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_CHOICE_HELP);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* retrieve text */
|
||||
p = param;
|
||||
/* retrieve text */
|
||||
p = param;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
if (*p == _T('\0'))
|
||||
break;
|
||||
while (TRUE)
|
||||
{
|
||||
if (*p == _T('\0'))
|
||||
break;
|
||||
|
||||
if (*p != _T('/'))
|
||||
{
|
||||
lpText = p;
|
||||
break;
|
||||
}
|
||||
np = _tcschr (p, _T(' '));
|
||||
if (!np)
|
||||
break;
|
||||
p = np + 1;
|
||||
}
|
||||
if (*p != _T('/'))
|
||||
{
|
||||
lpText = p;
|
||||
break;
|
||||
}
|
||||
np = _tcschr (p, _T(' '));
|
||||
if (!np)
|
||||
break;
|
||||
p = np + 1;
|
||||
}
|
||||
|
||||
/* build parameter array */
|
||||
arg = split (param, &argc, FALSE, FALSE);
|
||||
/* build parameter array */
|
||||
arg = split (param, &argc, FALSE, FALSE);
|
||||
|
||||
/* evaluate arguments */
|
||||
if (argc > 0)
|
||||
{
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
if (_tcsnicmp (arg[i], _T("/c"), 2) == 0)
|
||||
{
|
||||
if (arg[i][2] == _T(':'))
|
||||
lpOptions = &arg[i][3];
|
||||
else
|
||||
lpOptions = &arg[i][2];
|
||||
/* evaluate arguments */
|
||||
if (argc > 0)
|
||||
{
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
if (_tcsnicmp (arg[i], _T("/c"), 2) == 0)
|
||||
{
|
||||
if (arg[i][2] == _T(':'))
|
||||
lpOptions = &arg[i][3];
|
||||
else
|
||||
lpOptions = &arg[i][2];
|
||||
|
||||
if (_tcslen (lpOptions) == 0)
|
||||
{
|
||||
ConErrResPuts(STRING_CHOICE_ERROR);
|
||||
freep (arg);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (_tcsnicmp (arg[i], _T("/n"), 2) == 0)
|
||||
{
|
||||
bNoPrompt = TRUE;
|
||||
}
|
||||
else if (_tcsnicmp (arg[i], _T("/s"), 2) == 0)
|
||||
{
|
||||
bCaseSensitive = TRUE;
|
||||
}
|
||||
else if (_tcsnicmp (arg[i], _T("/t"), 2) == 0)
|
||||
{
|
||||
LPTSTR s;
|
||||
if (_tcslen (lpOptions) == 0)
|
||||
{
|
||||
ConErrResPuts(STRING_CHOICE_ERROR);
|
||||
freep (arg);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (_tcsnicmp (arg[i], _T("/n"), 2) == 0)
|
||||
{
|
||||
bNoPrompt = TRUE;
|
||||
}
|
||||
else if (_tcsnicmp (arg[i], _T("/s"), 2) == 0)
|
||||
{
|
||||
bCaseSensitive = TRUE;
|
||||
}
|
||||
else if (_tcsnicmp (arg[i], _T("/t"), 2) == 0)
|
||||
{
|
||||
LPTSTR s;
|
||||
|
||||
if (arg[i][2] == _T(':'))
|
||||
{
|
||||
cDefault = arg[i][3];
|
||||
s = &arg[i][4];
|
||||
}
|
||||
else
|
||||
{
|
||||
cDefault = arg[i][2];
|
||||
s = &arg[i][3];
|
||||
}
|
||||
if (arg[i][2] == _T(':'))
|
||||
{
|
||||
cDefault = arg[i][3];
|
||||
s = &arg[i][4];
|
||||
}
|
||||
else
|
||||
{
|
||||
cDefault = arg[i][2];
|
||||
s = &arg[i][3];
|
||||
}
|
||||
|
||||
if (*s != _T(','))
|
||||
{
|
||||
ConErrResPuts(STRING_CHOICE_ERROR_TXT);
|
||||
freep (arg);
|
||||
return 1;
|
||||
}
|
||||
if (*s != _T(','))
|
||||
{
|
||||
ConErrResPuts(STRING_CHOICE_ERROR_TXT);
|
||||
freep (arg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
s++;
|
||||
nTimeout = _ttoi(s);
|
||||
bTimeout = TRUE;
|
||||
}
|
||||
else if (arg[i][0] == _T('/'))
|
||||
{
|
||||
ConErrResPrintf(STRING_CHOICE_ERROR_OPTION, arg[i]);
|
||||
freep (arg);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
s++;
|
||||
nTimeout = _ttoi(s);
|
||||
bTimeout = TRUE;
|
||||
}
|
||||
else if (arg[i][0] == _T('/'))
|
||||
{
|
||||
ConErrResPrintf(STRING_CHOICE_ERROR_OPTION, arg[i]);
|
||||
freep (arg);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* print text */
|
||||
if (lpText)
|
||||
ConOutPrintf (_T("%s"), lpText);
|
||||
/* print text */
|
||||
if (lpText)
|
||||
ConOutPrintf (_T("%s"), lpText);
|
||||
|
||||
/* print options */
|
||||
if (bNoPrompt == FALSE)
|
||||
{
|
||||
ConOutPrintf (_T("[%c"), lpOptions[0]);
|
||||
/* print options */
|
||||
if (bNoPrompt == FALSE)
|
||||
{
|
||||
ConOutPrintf (_T("[%c"), lpOptions[0]);
|
||||
|
||||
for (i = 1; (unsigned)i < _tcslen (lpOptions); i++)
|
||||
ConOutPrintf (_T(",%c"), lpOptions[i]);
|
||||
for (i = 1; (unsigned)i < _tcslen (lpOptions); i++)
|
||||
ConOutPrintf (_T(",%c"), lpOptions[i]);
|
||||
|
||||
ConOutPrintf (_T("]?"));
|
||||
}
|
||||
ConOutPrintf (_T("]?"));
|
||||
}
|
||||
|
||||
ConInFlush ();
|
||||
ConInFlush ();
|
||||
|
||||
if(!bTimeout)
|
||||
{
|
||||
while (TRUE)
|
||||
{
|
||||
ConInKey (&ir);
|
||||
if(!bTimeout)
|
||||
{
|
||||
while (TRUE)
|
||||
{
|
||||
ConInKey (&ir);
|
||||
|
||||
val = IsKeyInString (lpOptions,
|
||||
val = IsKeyInString (lpOptions,
|
||||
#ifdef _UNICODE
|
||||
ir.Event.KeyEvent.uChar.UnicodeChar,
|
||||
ir.Event.KeyEvent.uChar.UnicodeChar,
|
||||
#else
|
||||
ir.Event.KeyEvent.uChar.AsciiChar,
|
||||
ir.Event.KeyEvent.uChar.AsciiChar,
|
||||
#endif
|
||||
bCaseSensitive);
|
||||
bCaseSensitive);
|
||||
|
||||
if (val >= 0)
|
||||
{
|
||||
ConOutPrintf (_T("%c\n"), lpOptions[val]);
|
||||
if (val >= 0)
|
||||
{
|
||||
ConOutPrintf (_T("%c\n"), lpOptions[val]);
|
||||
|
||||
nErrorLevel = val + 1;
|
||||
nErrorLevel = val + 1;
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Beep (440, 50);
|
||||
}
|
||||
Beep (440, 50);
|
||||
}
|
||||
|
||||
freep (arg);
|
||||
TRACE ("ErrorLevel: %d\n", nErrorLevel);
|
||||
return 0;
|
||||
}
|
||||
freep (arg);
|
||||
TRACE ("ErrorLevel: %d\n", nErrorLevel);
|
||||
return 0;
|
||||
}
|
||||
|
||||
clk = GetTickCount ();
|
||||
amount = nTimeout*1000;
|
||||
clk = GetTickCount ();
|
||||
amount = nTimeout*1000;
|
||||
|
||||
loop:
|
||||
GCret = GetCharacterTimeout (&Ch, amount - (GetTickCount () - clk));
|
||||
GCret = GetCharacterTimeout (&Ch, amount - (GetTickCount () - clk));
|
||||
|
||||
switch (GCret)
|
||||
{
|
||||
case GC_TIMEOUT:
|
||||
TRACE ("GC_TIMEOUT\n");
|
||||
TRACE ("elapsed %d msecs\n", GetTickCount () - clk);
|
||||
break;
|
||||
switch (GCret)
|
||||
{
|
||||
case GC_TIMEOUT:
|
||||
TRACE ("GC_TIMEOUT\n");
|
||||
TRACE ("elapsed %d msecs\n", GetTickCount () - clk);
|
||||
break;
|
||||
|
||||
case GC_NOKEY:
|
||||
TRACE ("GC_NOKEY\n");
|
||||
TRACE ("elapsed %d msecs\n", GetTickCount () - clk);
|
||||
goto loop;
|
||||
case GC_NOKEY:
|
||||
TRACE ("GC_NOKEY\n");
|
||||
TRACE ("elapsed %d msecs\n", GetTickCount () - clk);
|
||||
goto loop;
|
||||
|
||||
case GC_KEYREAD:
|
||||
TRACE ("GC_KEYREAD\n");
|
||||
TRACE ("elapsed %d msecs\n", GetTickCount () - clk);
|
||||
TRACE ("read %c", Ch);
|
||||
if ((val=IsKeyInString(lpOptions,Ch,bCaseSensitive))==-1)
|
||||
{
|
||||
Beep (440, 50);
|
||||
goto loop;
|
||||
}
|
||||
cDefault=Ch;
|
||||
break;
|
||||
}
|
||||
case GC_KEYREAD:
|
||||
TRACE ("GC_KEYREAD\n");
|
||||
TRACE ("elapsed %d msecs\n", GetTickCount () - clk);
|
||||
TRACE ("read %c", Ch);
|
||||
if ((val=IsKeyInString(lpOptions,Ch,bCaseSensitive))==-1)
|
||||
{
|
||||
Beep (440, 50);
|
||||
goto loop;
|
||||
}
|
||||
cDefault=Ch;
|
||||
break;
|
||||
}
|
||||
|
||||
TRACE ("exiting wait loop after %d msecs\n",
|
||||
GetTickCount () - clk);
|
||||
TRACE ("exiting wait loop after %d msecs\n",
|
||||
GetTickCount () - clk);
|
||||
|
||||
val = IsKeyInString (lpOptions, cDefault, bCaseSensitive);
|
||||
ConOutPrintf (_T("%c\n"), lpOptions[val]);
|
||||
val = IsKeyInString (lpOptions, cDefault, bCaseSensitive);
|
||||
ConOutPrintf (_T("%c\n"), lpOptions[val]);
|
||||
|
||||
nErrorLevel = val + 1;
|
||||
nErrorLevel = val + 1;
|
||||
|
||||
freep (arg);
|
||||
freep (arg);
|
||||
|
||||
TRACE ("ErrorLevel: %d\n", nErrorLevel);
|
||||
TRACE ("ErrorLevel: %d\n", nErrorLevel);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
#endif /* INCLUDE_CMD_CHOICE */
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
* 20-Jan-1998 (Eric Kohl)
|
||||
* Redirection ready!
|
||||
*
|
||||
* 02-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 02-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
@ -32,34 +32,34 @@
|
|||
|
||||
INT cmd_cls (LPTSTR param)
|
||||
{
|
||||
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
COORD coPos;
|
||||
DWORD dwWritten;
|
||||
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
COORD coPos;
|
||||
DWORD dwWritten;
|
||||
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_CLS_HELP);
|
||||
return 0;
|
||||
}
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_CLS_HELP);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (GetConsoleScreenBufferInfo(hOutput, &csbi))
|
||||
{
|
||||
coPos.X = 0;
|
||||
coPos.Y = 0;
|
||||
FillConsoleOutputAttribute(hOutput, csbi.wAttributes,
|
||||
csbi.dwSize.X * csbi.dwSize.Y,
|
||||
coPos, &dwWritten);
|
||||
FillConsoleOutputCharacter(hOutput, _T(' '),
|
||||
csbi.dwSize.X * csbi.dwSize.Y,
|
||||
coPos, &dwWritten);
|
||||
SetConsoleCursorPosition(hOutput, coPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConOutChar(_T('\f'));
|
||||
}
|
||||
if (GetConsoleScreenBufferInfo(hOutput, &csbi))
|
||||
{
|
||||
coPos.X = 0;
|
||||
coPos.Y = 0;
|
||||
FillConsoleOutputAttribute(hOutput, csbi.wAttributes,
|
||||
csbi.dwSize.X * csbi.dwSize.Y,
|
||||
coPos, &dwWritten);
|
||||
FillConsoleOutputCharacter(hOutput, _T(' '),
|
||||
csbi.dwSize.X * csbi.dwSize.Y,
|
||||
coPos, &dwWritten);
|
||||
SetConsoleCursorPosition(hOutput, coPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConOutChar(_T('\f'));
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -19,263 +19,265 @@
|
|||
|
||||
#include "precomp.h"
|
||||
|
||||
/* a list of all the internal commands, associating their command names */
|
||||
/* to the functions to process them */
|
||||
/*
|
||||
* A list of all the internal commands, associating their command names
|
||||
* to the functions to process them.
|
||||
*/
|
||||
|
||||
|
||||
COMMAND cmds[] =
|
||||
{
|
||||
{_T("?"), 0, CommandShowCommands},
|
||||
{_T("?"), 0, CommandShowCommands},
|
||||
|
||||
|
||||
#ifdef INCLUDE_CMD_ACTIVATE
|
||||
{_T("activate"), 0, CommandActivate},
|
||||
{_T("activate"), 0, CommandActivate},
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_ALIASES
|
||||
{_T("alias"), 0, CommandAlias},
|
||||
{_T("alias"), 0, CommandAlias},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_ASSOC
|
||||
{_T("assoc"), 0, CommandAssoc},
|
||||
{_T("assoc"), 0, CommandAssoc},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_ATTRIB
|
||||
{_T("attrib"), 0, CommandAttrib},
|
||||
{_T("attrib"), 0, CommandAttrib},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_BEEP
|
||||
{_T("beep"), 0, cmd_beep},
|
||||
{_T("beep"), 0, cmd_beep},
|
||||
#endif
|
||||
|
||||
{_T("call"), CMD_BATCHONLY, cmd_call},
|
||||
{_T("call"), CMD_BATCHONLY, cmd_call},
|
||||
|
||||
#ifdef INCLUDE_CMD_CHDIR
|
||||
{_T("cd"), CMD_SPECIAL, cmd_chdir},
|
||||
{_T("chdir"), CMD_SPECIAL, cmd_chdir},
|
||||
{_T("cd"), CMD_SPECIAL, cmd_chdir},
|
||||
{_T("chdir"), CMD_SPECIAL, cmd_chdir},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_CHCP
|
||||
{_T("chcp"), 0, CommandChcp},
|
||||
{_T("chcp"), 0, CommandChcp},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_CHOICE
|
||||
{_T("choice"), 0, CommandChoice},
|
||||
{_T("choice"), 0, CommandChoice},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_CLS
|
||||
{_T("cls"), 0, cmd_cls},
|
||||
{_T("cls"), 0, cmd_cls},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_COLOR
|
||||
{_T("color"), 0, CommandColor},
|
||||
{_T("color"), 0, CommandColor},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_COPY
|
||||
{_T("copy"), 0, cmd_copy},
|
||||
{_T("copy"), 0, cmd_copy},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_DATE
|
||||
{_T("date"), 0, cmd_date},
|
||||
{_T("date"), 0, cmd_date},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_DEL
|
||||
{_T("del"), 0, CommandDelete},
|
||||
{_T("delete"), 0, CommandDelete},
|
||||
{_T("del"), 0, CommandDelete},
|
||||
{_T("delete"), 0, CommandDelete},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_DELAY
|
||||
{_T("delay"), 0, CommandDelay},
|
||||
{_T("delay"), 0, CommandDelay},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_DIR
|
||||
{_T("dir"), CMD_SPECIAL, CommandDir},
|
||||
{_T("dir"), CMD_SPECIAL, CommandDir},
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_DIRECTORY_STACK
|
||||
{_T("dirs"), 0, CommandDirs},
|
||||
{_T("dirs"), 0, CommandDirs},
|
||||
#endif
|
||||
|
||||
{_T("echo"), CMD_SPECIAL, CommandEcho},
|
||||
{_T("echos"), 0, CommandEchos},
|
||||
{_T("echoerr"), CMD_SPECIAL, CommandEchoerr},
|
||||
{_T("echoserr"), 0, CommandEchoserr},
|
||||
{_T("echo"), CMD_SPECIAL, CommandEcho},
|
||||
{_T("echos"), 0, CommandEchos},
|
||||
{_T("echoerr"), CMD_SPECIAL, CommandEchoerr},
|
||||
{_T("echoserr"), 0, CommandEchoserr},
|
||||
|
||||
{_T("endlocal"), 0, cmd_endlocal},
|
||||
{_T("endlocal"), 0, cmd_endlocal},
|
||||
|
||||
#ifdef INCLUDE_CMD_DEL
|
||||
{_T("erase"), 0, CommandDelete},
|
||||
{_T("erase"), 0, CommandDelete},
|
||||
#endif
|
||||
|
||||
{_T("exit"), 0, CommandExit},
|
||||
{_T("exit"), 0, CommandExit},
|
||||
|
||||
{_T("for"), 0, cmd_for},
|
||||
{_T("for"), 0, cmd_for},
|
||||
|
||||
#ifdef INCLUDE_CMD_FREE
|
||||
{_T("free"), 0, CommandFree},
|
||||
{_T("free"), 0, CommandFree},
|
||||
#endif
|
||||
|
||||
{_T("goto"), CMD_BATCHONLY, cmd_goto},
|
||||
{_T("goto"), CMD_BATCHONLY, cmd_goto},
|
||||
|
||||
{_T("help"), 0, CommandShowCommandsDetail},
|
||||
{_T("help"), 0, CommandShowCommandsDetail},
|
||||
|
||||
#ifdef FEATURE_HISTORY
|
||||
{_T("history"), 0, CommandHistory},
|
||||
{_T("history"), 0, CommandHistory},
|
||||
#endif
|
||||
|
||||
{_T("if"), 0, cmd_if},
|
||||
{_T("if"), 0, cmd_if},
|
||||
|
||||
#ifdef INCLUDE_CMD_LABEL
|
||||
{_T("label"), 0, cmd_label},
|
||||
{_T("label"), 0, cmd_label},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_MEMORY
|
||||
{_T("memory"), 0, CommandMemory},
|
||||
{_T("memory"), 0, CommandMemory},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_MKDIR
|
||||
{_T("md"), CMD_SPECIAL, cmd_mkdir},
|
||||
{_T("mkdir"), CMD_SPECIAL, cmd_mkdir},
|
||||
{_T("md"), CMD_SPECIAL, cmd_mkdir},
|
||||
{_T("mkdir"), CMD_SPECIAL, cmd_mkdir},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_MKLINK
|
||||
{_T("mklink"), 0, cmd_mklink},
|
||||
{_T("mklink"), 0, cmd_mklink},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_MOVE
|
||||
{_T("move"), 0, cmd_move},
|
||||
{_T("move"), 0, cmd_move},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_MSGBOX
|
||||
{_T("msgbox"), 0, CommandMsgbox},
|
||||
{_T("msgbox"), 0, CommandMsgbox},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_PATH
|
||||
{_T("path"), 0, cmd_path},
|
||||
{_T("path"), 0, cmd_path},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_PAUSE
|
||||
{_T("pause"), 0, cmd_pause},
|
||||
{_T("pause"), 0, cmd_pause},
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_DIRECTORY_STACK
|
||||
{_T("popd"), 0, CommandPopd},
|
||||
{_T("popd"), 0, CommandPopd},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_PROMPT
|
||||
{_T("prompt"), 0, cmd_prompt},
|
||||
{_T("prompt"), 0, cmd_prompt},
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_DIRECTORY_STACK
|
||||
{_T("pushd"), 0, CommandPushd},
|
||||
{_T("pushd"), 0, CommandPushd},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_RMDIR
|
||||
{_T("rd"), CMD_SPECIAL, cmd_rmdir},
|
||||
{_T("rd"), CMD_SPECIAL, cmd_rmdir},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_REM
|
||||
{_T("rem"), 0, CommandRem},
|
||||
{_T("rem"), 0, CommandRem},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_RENAME
|
||||
{_T("ren"), 0, cmd_rename},
|
||||
{_T("rename"), 0, cmd_rename},
|
||||
{_T("ren"), 0, cmd_rename},
|
||||
{_T("rename"), 0, cmd_rename},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_REPLACE
|
||||
{_T("replace"), 0, cmd_replace},
|
||||
{_T("replace"), 0, cmd_replace},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_RMDIR
|
||||
{_T("rmdir"), CMD_SPECIAL, cmd_rmdir},
|
||||
{_T("rmdir"), CMD_SPECIAL, cmd_rmdir},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_SCREEN
|
||||
{_T("screen"), 0, CommandScreen},
|
||||
{_T("screen"), 0, CommandScreen},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_SET
|
||||
{_T("set"), 0, cmd_set},
|
||||
{_T("set"), 0, cmd_set},
|
||||
#endif
|
||||
|
||||
{_T("setlocal"), 0, cmd_setlocal},
|
||||
{_T("setlocal"), 0, cmd_setlocal},
|
||||
|
||||
{_T("shift"), CMD_BATCHONLY, cmd_shift},
|
||||
{_T("shift"), CMD_BATCHONLY, cmd_shift},
|
||||
|
||||
#ifdef INCLUDE_CMD_START
|
||||
{_T("start"), 0, cmd_start},
|
||||
{_T("start"), 0, cmd_start},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_TIME
|
||||
{_T("time"), 0, cmd_time},
|
||||
{_T("time"), 0, cmd_time},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_TIMER
|
||||
{_T("timer"), 0, CommandTimer},
|
||||
{_T("timer"), 0, CommandTimer},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_TITLE
|
||||
{_T("title"), 0, cmd_title},
|
||||
{_T("title"), 0, cmd_title},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_TYPE
|
||||
{_T("type"), 0, cmd_type},
|
||||
{_T("type"), 0, cmd_type},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_VER
|
||||
{_T("ver"), 0, cmd_ver},
|
||||
{_T("ver"), 0, cmd_ver},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_VERIFY
|
||||
{_T("verify"), 0, cmd_verify},
|
||||
{_T("verify"), 0, cmd_verify},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_VOL
|
||||
{_T("vol"), 0, cmd_vol},
|
||||
{_T("vol"), 0, cmd_vol},
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_WINDOW
|
||||
{_T("window"), 0, CommandWindow},
|
||||
{_T("window"), 0, CommandWindow},
|
||||
#endif
|
||||
|
||||
{NULL, 0, NULL}
|
||||
{NULL, 0, NULL}
|
||||
};
|
||||
|
||||
|
||||
VOID PrintCommandList (VOID)
|
||||
{
|
||||
LPCOMMAND cmdptr;
|
||||
INT y;
|
||||
LPCOMMAND cmdptr;
|
||||
INT y;
|
||||
|
||||
y = 0;
|
||||
cmdptr = cmds;
|
||||
while (cmdptr->name)
|
||||
{
|
||||
if (!(cmdptr->flags & CMD_HIDE))
|
||||
{
|
||||
if (++y == 8)
|
||||
{
|
||||
ConOutPuts (cmdptr->name);
|
||||
y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ConOutPrintf (_T("%-10s"), cmdptr->name);
|
||||
}
|
||||
}
|
||||
y = 0;
|
||||
cmdptr = cmds;
|
||||
while (cmdptr->name)
|
||||
{
|
||||
if (!(cmdptr->flags & CMD_HIDE))
|
||||
{
|
||||
if (++y == 8)
|
||||
{
|
||||
ConOutPuts (cmdptr->name);
|
||||
y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ConOutPrintf (_T("%-10s"), cmdptr->name);
|
||||
}
|
||||
}
|
||||
|
||||
cmdptr++;
|
||||
}
|
||||
cmdptr++;
|
||||
}
|
||||
|
||||
if (y != 0)
|
||||
ConOutChar ('\n');
|
||||
if (y != 0)
|
||||
ConOutChar ('\n');
|
||||
}
|
||||
|
||||
VOID PrintCommandListDetail (VOID)
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_HELP1);
|
||||
ConOutResPaging(FALSE,STRING_HELP2);
|
||||
ConOutResPaging(TRUE,STRING_HELP1);
|
||||
ConOutResPaging(FALSE,STRING_HELP2);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* 14-Oct-1999 (Paolo Pantaleo <paolopan@freemail.it>)
|
||||
* 4nt's syntax implemented.
|
||||
*
|
||||
* 03-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Move all hardcoded strings to En.rc.
|
||||
* 03-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Move all hardcoded strings in En.rc.
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
@ -26,32 +26,32 @@
|
|||
|
||||
BOOL SetScreenColor(WORD wColor, BOOL bNoFill)
|
||||
{
|
||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
DWORD dwWritten;
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
COORD coPos;
|
||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
DWORD dwWritten;
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
COORD coPos;
|
||||
|
||||
/* Foreground and Background colors can't be the same */
|
||||
if ((wColor & 0x0F) == (wColor & 0xF0) >> 4)
|
||||
return FALSE;
|
||||
/* Foreground and Background colors can't be the same */
|
||||
if ((wColor & 0x0F) == (wColor & 0xF0) >> 4)
|
||||
return FALSE;
|
||||
|
||||
/* Fill the whole background if needed */
|
||||
if (bNoFill != TRUE)
|
||||
{
|
||||
GetConsoleScreenBufferInfo(hConsole, &csbi);
|
||||
/* Fill the whole background if needed */
|
||||
if (bNoFill != TRUE)
|
||||
{
|
||||
GetConsoleScreenBufferInfo(hConsole, &csbi);
|
||||
|
||||
coPos.X = 0;
|
||||
coPos.Y = 0;
|
||||
FillConsoleOutputAttribute(hConsole,
|
||||
wColor & 0x00FF,
|
||||
csbi.dwSize.X * csbi.dwSize.Y,
|
||||
coPos,
|
||||
&dwWritten);
|
||||
}
|
||||
coPos.X = 0;
|
||||
coPos.Y = 0;
|
||||
FillConsoleOutputAttribute(hConsole,
|
||||
wColor & 0x00FF,
|
||||
csbi.dwSize.X * csbi.dwSize.Y,
|
||||
coPos,
|
||||
&dwWritten);
|
||||
}
|
||||
|
||||
/* Set the text attribute */
|
||||
SetConsoleTextAttribute(hConsole, wColor & 0x00FF);
|
||||
return TRUE;
|
||||
/* Set the text attribute */
|
||||
SetConsoleTextAttribute(hConsole, wColor & 0x00FF);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -61,76 +61,76 @@ BOOL SetScreenColor(WORD wColor, BOOL bNoFill)
|
|||
*/
|
||||
INT CommandColor(LPTSTR rest)
|
||||
{
|
||||
WORD wColor = 0x00;
|
||||
WORD wColor = 0x00;
|
||||
|
||||
/* The user asked for help */
|
||||
if (_tcsncmp(rest, _T("/?"), 2) == 0)
|
||||
{
|
||||
ConOutResPaging(TRUE, STRING_COLOR_HELP1);
|
||||
return 0;
|
||||
}
|
||||
/* The user asked for help */
|
||||
if (_tcsncmp(rest, _T("/?"), 2) == 0)
|
||||
{
|
||||
ConOutResPaging(TRUE, STRING_COLOR_HELP1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Let's prepare %ERRORLEVEL% */
|
||||
nErrorLevel = 0;
|
||||
/* Let's prepare %ERRORLEVEL% */
|
||||
nErrorLevel = 0;
|
||||
|
||||
/* No parameter. Set the default colors */
|
||||
if (rest[0] == _T('\0'))
|
||||
{
|
||||
SetScreenColor(wDefColor, FALSE);
|
||||
return 0;
|
||||
}
|
||||
/* No parameter. Set the default colors */
|
||||
if (rest[0] == _T('\0'))
|
||||
{
|
||||
SetScreenColor(wDefColor, FALSE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The parameter is just one character: Set color text */
|
||||
if (_tcslen(rest) == 1)
|
||||
{
|
||||
if ((rest[0] >= _T('0')) && (rest[0] <= _T('9')))
|
||||
{
|
||||
wColor = (WORD)_ttoi(rest);
|
||||
}
|
||||
else if ((rest[0] >= _T('a')) && (rest[0] <= _T('f')))
|
||||
{
|
||||
wColor = (WORD)(rest[0] + 10 - _T('a'));
|
||||
}
|
||||
else if ((rest[0] >= _T('A')) && (rest[0] <= _T('F')))
|
||||
{
|
||||
wColor = (WORD)(rest[0] + 10 - _T('A'));
|
||||
}
|
||||
else /* Invalid character */
|
||||
{
|
||||
ConOutResPaging(TRUE, STRING_COLOR_HELP1);
|
||||
nErrorLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/* Color string: advanced choice: two-digits, "Color ON Color" , "Foreground ON Background" */
|
||||
else if (StringToColor(&wColor, &rest) == FALSE)
|
||||
{
|
||||
/* Invalid color string */
|
||||
ConOutResPaging(TRUE, STRING_COLOR_HELP1);
|
||||
nErrorLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
/* The parameter is just one character: Set color text */
|
||||
if (_tcslen(rest) == 1)
|
||||
{
|
||||
if ((rest[0] >= _T('0')) && (rest[0] <= _T('9')))
|
||||
{
|
||||
wColor = (WORD)_ttoi(rest);
|
||||
}
|
||||
else if ((rest[0] >= _T('a')) && (rest[0] <= _T('f')))
|
||||
{
|
||||
wColor = (WORD)(rest[0] + 10 - _T('a'));
|
||||
}
|
||||
else if ((rest[0] >= _T('A')) && (rest[0] <= _T('F')))
|
||||
{
|
||||
wColor = (WORD)(rest[0] + 10 - _T('A'));
|
||||
}
|
||||
else /* Invalid character */
|
||||
{
|
||||
ConOutResPaging(TRUE, STRING_COLOR_HELP1);
|
||||
nErrorLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/* Color string: advanced choice: two-digits, "Color ON Color" , "Foreground ON Background" */
|
||||
else if (StringToColor(&wColor, &rest) == FALSE)
|
||||
{
|
||||
/* Invalid color string */
|
||||
ConOutResPaging(TRUE, STRING_COLOR_HELP1);
|
||||
nErrorLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Print the chosen color if we are in echo mode (NOTE: Not Windows-compliant) */
|
||||
if ((bc && bc->bEcho) || !bc)
|
||||
{
|
||||
ConErrResPrintf(STRING_COLOR_ERROR3, wColor);
|
||||
}
|
||||
/* Print the chosen color if we are in echo mode (NOTE: Not Windows-compliant) */
|
||||
if ((bc && bc->bEcho) || !bc)
|
||||
{
|
||||
ConErrResPrintf(STRING_COLOR_ERROR3, wColor);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the chosen color. Use also the following advanced flag:
|
||||
* /-F to avoid changing already buffered foreground/background.
|
||||
*/
|
||||
if (SetScreenColor(wColor, (_tcsstr(rest, _T("/-F")) || _tcsstr(rest, _T("/-f")))) == FALSE)
|
||||
{
|
||||
/* Failed because foreground and background colors were the same */
|
||||
ConErrResPuts(STRING_COLOR_ERROR1);
|
||||
nErrorLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
* Set the chosen color. Use also the following advanced flag:
|
||||
* /-F to avoid changing already buffered foreground/background.
|
||||
*/
|
||||
if (SetScreenColor(wColor, (_tcsstr(rest, _T("/-F")) || _tcsstr(rest, _T("/-f")))) == FALSE)
|
||||
{
|
||||
/* Failed because foreground and background colors were the same */
|
||||
ConErrResPuts(STRING_COLOR_ERROR1);
|
||||
nErrorLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Return success */
|
||||
return 0;
|
||||
/* Return success */
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* INCLUDE_CMD_COLOR */
|
||||
|
|
|
@ -16,33 +16,33 @@
|
|||
|
||||
INT CommandDelay (LPTSTR param)
|
||||
{
|
||||
DWORD val;
|
||||
DWORD mul=1000;
|
||||
DWORD val;
|
||||
DWORD mul=1000;
|
||||
|
||||
if (_tcsncmp (param, _T("/?"), 2) == 0)
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_DELAY_HELP);
|
||||
return 0;
|
||||
}
|
||||
if (_tcsncmp (param, _T("/?"), 2) == 0)
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_DELAY_HELP);
|
||||
return 0;
|
||||
}
|
||||
|
||||
nErrorLevel = 0;
|
||||
nErrorLevel = 0;
|
||||
|
||||
if (*param==0)
|
||||
{
|
||||
error_req_param_missing ();
|
||||
return 1;
|
||||
}
|
||||
if (*param==0)
|
||||
{
|
||||
error_req_param_missing ();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (_tcsnicmp(param,_T("/m"),2) == 0)
|
||||
{
|
||||
mul = 1;
|
||||
param += 2;
|
||||
}
|
||||
if (_tcsnicmp(param,_T("/m"),2) == 0)
|
||||
{
|
||||
mul = 1;
|
||||
param += 2;
|
||||
}
|
||||
|
||||
val = _ttoi(param);
|
||||
Sleep(val * mul);
|
||||
val = _ttoi(param);
|
||||
Sleep(val * mul);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* INCLUDE_CMD_DELAY */
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
|
||||
typedef struct tagDIRENTRY
|
||||
{
|
||||
struct tagDIRENTRY *prev;
|
||||
struct tagDIRENTRY *next;
|
||||
TCHAR szPath[1];
|
||||
struct tagDIRENTRY *prev;
|
||||
struct tagDIRENTRY *next;
|
||||
TCHAR szPath[1];
|
||||
} DIRENTRY, *LPDIRENTRY;
|
||||
|
||||
|
||||
|
@ -34,42 +34,42 @@ static LPDIRENTRY lpStackBottom;
|
|||
static INT
|
||||
PushDirectory (LPTSTR pszPath)
|
||||
{
|
||||
LPDIRENTRY lpDir = cmd_alloc(FIELD_OFFSET(DIRENTRY, szPath[_tcslen(pszPath) + 1]));
|
||||
if (!lpDir)
|
||||
{
|
||||
error_out_of_memory ();
|
||||
return -1;
|
||||
}
|
||||
LPDIRENTRY lpDir = cmd_alloc(FIELD_OFFSET(DIRENTRY, szPath[_tcslen(pszPath) + 1]));
|
||||
if (!lpDir)
|
||||
{
|
||||
error_out_of_memory ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
lpDir->prev = NULL;
|
||||
lpDir->next = lpStackTop;
|
||||
if (lpStackTop == NULL)
|
||||
lpStackBottom = lpDir;
|
||||
else
|
||||
lpStackTop->prev = lpDir;
|
||||
lpStackTop = lpDir;
|
||||
lpDir->prev = NULL;
|
||||
lpDir->next = lpStackTop;
|
||||
if (lpStackTop == NULL)
|
||||
lpStackBottom = lpDir;
|
||||
else
|
||||
lpStackTop->prev = lpDir;
|
||||
lpStackTop = lpDir;
|
||||
|
||||
_tcscpy(lpDir->szPath, pszPath);
|
||||
_tcscpy(lpDir->szPath, pszPath);
|
||||
|
||||
nStackDepth++;
|
||||
nStackDepth++;
|
||||
|
||||
return nErrorLevel = 0;
|
||||
return nErrorLevel = 0;
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
PopDirectory (VOID)
|
||||
{
|
||||
LPDIRENTRY lpDir = lpStackTop;
|
||||
lpStackTop = lpDir->next;
|
||||
if (lpStackTop != NULL)
|
||||
lpStackTop->prev = NULL;
|
||||
else
|
||||
lpStackBottom = NULL;
|
||||
LPDIRENTRY lpDir = lpStackTop;
|
||||
lpStackTop = lpDir->next;
|
||||
if (lpStackTop != NULL)
|
||||
lpStackTop->prev = NULL;
|
||||
else
|
||||
lpStackBottom = NULL;
|
||||
|
||||
cmd_free (lpDir);
|
||||
cmd_free (lpDir);
|
||||
|
||||
nStackDepth--;
|
||||
nStackDepth--;
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,9 +78,9 @@ PopDirectory (VOID)
|
|||
*/
|
||||
VOID InitDirectoryStack (VOID)
|
||||
{
|
||||
nStackDepth = 0;
|
||||
lpStackTop = NULL;
|
||||
lpStackBottom = NULL;
|
||||
nStackDepth = 0;
|
||||
lpStackTop = NULL;
|
||||
lpStackBottom = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,14 +89,14 @@ VOID InitDirectoryStack (VOID)
|
|||
*/
|
||||
VOID DestroyDirectoryStack (VOID)
|
||||
{
|
||||
while (nStackDepth)
|
||||
PopDirectory ();
|
||||
while (nStackDepth)
|
||||
PopDirectory ();
|
||||
}
|
||||
|
||||
|
||||
INT GetDirectoryStackDepth (VOID)
|
||||
{
|
||||
return nStackDepth;
|
||||
return nStackDepth;
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,23 +105,23 @@ INT GetDirectoryStackDepth (VOID)
|
|||
*/
|
||||
INT CommandPushd (LPTSTR rest)
|
||||
{
|
||||
TCHAR curPath[MAX_PATH];
|
||||
TCHAR curPath[MAX_PATH];
|
||||
|
||||
if (!_tcsncmp (rest, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPuts(STRING_DIRSTACK_HELP1);
|
||||
return 0;
|
||||
}
|
||||
if (!_tcsncmp (rest, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPuts(STRING_DIRSTACK_HELP1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GetCurrentDirectory (MAX_PATH, curPath);
|
||||
GetCurrentDirectory (MAX_PATH, curPath);
|
||||
|
||||
if (rest[0] != _T('\0'))
|
||||
{
|
||||
if (!SetRootPath(NULL, rest))
|
||||
return 1;
|
||||
}
|
||||
if (rest[0] != _T('\0'))
|
||||
{
|
||||
if (!SetRootPath(NULL, rest))
|
||||
return 1;
|
||||
}
|
||||
|
||||
return PushDirectory(curPath);
|
||||
return PushDirectory(curPath);
|
||||
}
|
||||
|
||||
|
||||
|
@ -130,20 +130,20 @@ INT CommandPushd (LPTSTR rest)
|
|||
*/
|
||||
INT CommandPopd (LPTSTR rest)
|
||||
{
|
||||
INT ret = 0;
|
||||
if (!_tcsncmp(rest, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPuts(STRING_DIRSTACK_HELP2);
|
||||
return 0;
|
||||
}
|
||||
INT ret = 0;
|
||||
if (!_tcsncmp(rest, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPuts(STRING_DIRSTACK_HELP2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (nStackDepth == 0)
|
||||
return 1;
|
||||
if (nStackDepth == 0)
|
||||
return 1;
|
||||
|
||||
ret = _tchdir(lpStackTop->szPath) != 0;
|
||||
PopDirectory ();
|
||||
ret = _tchdir(lpStackTop->szPath) != 0;
|
||||
PopDirectory ();
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -152,31 +152,31 @@ INT CommandPopd (LPTSTR rest)
|
|||
*/
|
||||
INT CommandDirs (LPTSTR rest)
|
||||
{
|
||||
LPDIRENTRY lpDir;
|
||||
LPDIRENTRY lpDir;
|
||||
|
||||
if (!_tcsncmp(rest, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPuts(STRING_DIRSTACK_HELP3);
|
||||
return 0;
|
||||
}
|
||||
if (!_tcsncmp(rest, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPuts(STRING_DIRSTACK_HELP3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
nErrorLevel = 0;
|
||||
|
||||
lpDir = lpStackBottom;
|
||||
lpDir = lpStackBottom;
|
||||
|
||||
if (lpDir == NULL)
|
||||
{
|
||||
ConOutResPuts(STRING_DIRSTACK_HELP4);
|
||||
return 0;
|
||||
}
|
||||
if (lpDir == NULL)
|
||||
{
|
||||
ConOutResPuts(STRING_DIRSTACK_HELP4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (lpDir != NULL)
|
||||
{
|
||||
ConOutPuts(lpDir->szPath);
|
||||
lpDir = lpDir->prev;
|
||||
}
|
||||
while (lpDir != NULL)
|
||||
{
|
||||
ConOutPuts(lpDir->szPath);
|
||||
lpDir = lpDir->prev;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* FEATURE_DIRECTORY_STACK */
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
* 13-Jul-2000 (Eric Kohl)
|
||||
* Implemented 'echo.' and 'echoerr.'.
|
||||
*
|
||||
* 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
@ -31,105 +31,105 @@
|
|||
BOOL
|
||||
OnOffCommand(LPTSTR param, LPBOOL flag, INT message)
|
||||
{
|
||||
TCHAR *p2;
|
||||
if (_tcsnicmp(param, D_OFF, sizeof(D_OFF)/sizeof(TCHAR) - 1) == 0)
|
||||
{
|
||||
p2 = param + sizeof(D_OFF)/sizeof(TCHAR) - 1;
|
||||
while (_istspace(*p2))
|
||||
p2++;
|
||||
if (*p2 == _T('\0'))
|
||||
{
|
||||
*flag = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if (_tcsnicmp(param, D_ON, sizeof(D_ON)/sizeof(TCHAR) - 1) == 0)
|
||||
{
|
||||
p2 = param + sizeof(D_ON)/sizeof(TCHAR) - 1;
|
||||
while (_istspace(*p2))
|
||||
p2++;
|
||||
if (*p2 == _T('\0'))
|
||||
{
|
||||
*flag = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if (*param == _T('\0'))
|
||||
{
|
||||
ConOutResPrintf(message, *flag ? D_ON : D_OFF);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
TCHAR *p2;
|
||||
if (_tcsnicmp(param, D_OFF, sizeof(D_OFF)/sizeof(TCHAR) - 1) == 0)
|
||||
{
|
||||
p2 = param + sizeof(D_OFF)/sizeof(TCHAR) - 1;
|
||||
while (_istspace(*p2))
|
||||
p2++;
|
||||
if (*p2 == _T('\0'))
|
||||
{
|
||||
*flag = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if (_tcsnicmp(param, D_ON, sizeof(D_ON)/sizeof(TCHAR) - 1) == 0)
|
||||
{
|
||||
p2 = param + sizeof(D_ON)/sizeof(TCHAR) - 1;
|
||||
while (_istspace(*p2))
|
||||
p2++;
|
||||
if (*p2 == _T('\0'))
|
||||
{
|
||||
*flag = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if (*param == _T('\0'))
|
||||
{
|
||||
ConOutResPrintf(message, *flag ? D_ON : D_OFF);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
INT CommandEcho (LPTSTR param)
|
||||
{
|
||||
LPTSTR p1;
|
||||
LPTSTR p1;
|
||||
|
||||
TRACE ("CommandEcho: '%s'\n", debugstr_aw(param));
|
||||
TRACE ("CommandEcho: '%s'\n", debugstr_aw(param));
|
||||
|
||||
/* skip all spaces for the check of '/?', 'ON' and 'OFF' */
|
||||
p1 = param;
|
||||
while(_istspace(*p1))
|
||||
p1++;
|
||||
/* skip all spaces for the check of '/?', 'ON' and 'OFF' */
|
||||
p1 = param;
|
||||
while(_istspace(*p1))
|
||||
p1++;
|
||||
|
||||
if (!_tcsncmp (p1, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_ECHO_HELP4);
|
||||
return 0;
|
||||
}
|
||||
if (!_tcsncmp (p1, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_ECHO_HELP4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!OnOffCommand(p1, &bEcho, STRING_ECHO_HELP5))
|
||||
{
|
||||
/* skip the first character */
|
||||
ConOutPuts(param + 1);
|
||||
ConOutPuts(_T("\r\n"));
|
||||
}
|
||||
return 0;
|
||||
if (!OnOffCommand(p1, &bEcho, STRING_ECHO_HELP5))
|
||||
{
|
||||
/* skip the first character */
|
||||
ConOutPuts(param + 1);
|
||||
ConOutPuts(_T("\r\n"));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
INT CommandEchos (LPTSTR param)
|
||||
{
|
||||
TRACE ("CommandEchos: '%s'\n", debugstr_aw(param));
|
||||
TRACE ("CommandEchos: '%s'\n", debugstr_aw(param));
|
||||
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPuts(STRING_ECHO_HELP1);
|
||||
return 0;
|
||||
}
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPuts(STRING_ECHO_HELP1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ConOutPrintf (_T("%s"), param);
|
||||
return 0;
|
||||
ConOutPrintf (_T("%s"), param);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
INT CommandEchoerr (LPTSTR param)
|
||||
{
|
||||
TRACE ("CommandEchoerr: '%s'\n", debugstr_aw(param));
|
||||
TRACE ("CommandEchoerr: '%s'\n", debugstr_aw(param));
|
||||
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPuts(STRING_ECHO_HELP2);
|
||||
return 0;
|
||||
}
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPuts(STRING_ECHO_HELP2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ConErrPuts (param);
|
||||
return 0;
|
||||
ConErrPuts (param);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
INT CommandEchoserr (LPTSTR param)
|
||||
{
|
||||
TRACE ("CommandEchoserr: '%s'\n", debugstr_aw(param));
|
||||
TRACE ("CommandEchoserr: '%s'\n", debugstr_aw(param));
|
||||
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPuts(STRING_ECHO_HELP3);
|
||||
return 0;
|
||||
}
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPuts(STRING_ECHO_HELP3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ConErrPrintf (_T("%s"), param);
|
||||
return 0;
|
||||
ConErrPrintf (_T("%s"), param);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* 02-Feb-1999 (Eric Kohl)
|
||||
* Use FormatMessage() for error reports.
|
||||
*
|
||||
* 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
@ -25,145 +25,145 @@
|
|||
|
||||
VOID ErrorMessage (DWORD dwErrorCode, LPTSTR szFormat, ...)
|
||||
{
|
||||
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
||||
TCHAR szMessage[1024];
|
||||
LPTSTR szError;
|
||||
va_list arg_ptr;
|
||||
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
||||
TCHAR szMessage[1024];
|
||||
LPTSTR szError;
|
||||
va_list arg_ptr;
|
||||
|
||||
if (dwErrorCode == ERROR_SUCCESS)
|
||||
return;
|
||||
if (dwErrorCode == ERROR_SUCCESS)
|
||||
return;
|
||||
|
||||
nErrorLevel = 1;
|
||||
nErrorLevel = 1;
|
||||
|
||||
if (szFormat)
|
||||
{
|
||||
va_start (arg_ptr, szFormat);
|
||||
_vstprintf (szMessage, szFormat, arg_ptr);
|
||||
va_end (arg_ptr);
|
||||
}
|
||||
if (szFormat)
|
||||
{
|
||||
va_start (arg_ptr, szFormat);
|
||||
_vstprintf (szMessage, szFormat, arg_ptr);
|
||||
va_end (arg_ptr);
|
||||
}
|
||||
|
||||
if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||
NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR)&szError, 0, NULL))
|
||||
{
|
||||
ConErrPrintf (_T("%s %s\n"), szError, szMessage);
|
||||
if(szError)
|
||||
LocalFree (szError);
|
||||
return;
|
||||
}
|
||||
if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||
NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR)&szError, 0, NULL))
|
||||
{
|
||||
ConErrPrintf (_T("%s %s\n"), szError, szMessage);
|
||||
if(szError)
|
||||
LocalFree (szError);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Fall back just in case the error is not defined */
|
||||
if (szFormat)
|
||||
ConErrPrintf (_T("%s -- %s\n"), szMsg, szMessage);
|
||||
else
|
||||
ConErrPrintf (_T("%s\n"), szMsg);
|
||||
/* Fall back just in case the error is not defined */
|
||||
if (szFormat)
|
||||
ConErrPrintf (_T("%s -- %s\n"), szMsg, szMessage);
|
||||
else
|
||||
ConErrPrintf (_T("%s\n"), szMsg);
|
||||
}
|
||||
|
||||
VOID error_parameter_format(TCHAR ch)
|
||||
{
|
||||
ConErrResPrintf(STRING_ERROR_PARAMETERF_ERROR, ch);
|
||||
nErrorLevel = 1;
|
||||
ConErrResPrintf(STRING_ERROR_PARAMETERF_ERROR, ch);
|
||||
nErrorLevel = 1;
|
||||
}
|
||||
|
||||
|
||||
VOID error_invalid_switch (TCHAR ch)
|
||||
{
|
||||
ConErrResPrintf(STRING_ERROR_INVALID_SWITCH, ch);
|
||||
nErrorLevel = 1;
|
||||
ConErrResPrintf(STRING_ERROR_INVALID_SWITCH, ch);
|
||||
nErrorLevel = 1;
|
||||
}
|
||||
|
||||
|
||||
VOID error_too_many_parameters (LPTSTR s)
|
||||
{
|
||||
ConErrResPrintf(STRING_ERROR_TOO_MANY_PARAMETERS, s);
|
||||
nErrorLevel = 1;
|
||||
ConErrResPrintf(STRING_ERROR_TOO_MANY_PARAMETERS, s);
|
||||
nErrorLevel = 1;
|
||||
}
|
||||
|
||||
|
||||
VOID error_path_not_found (VOID)
|
||||
{
|
||||
ConErrResPuts(STRING_ERROR_PATH_NOT_FOUND);
|
||||
nErrorLevel = 1;
|
||||
ConErrResPuts(STRING_ERROR_PATH_NOT_FOUND);
|
||||
nErrorLevel = 1;
|
||||
}
|
||||
|
||||
|
||||
VOID error_file_not_found (VOID)
|
||||
{
|
||||
ConErrResPuts(STRING_ERROR_FILE_NOT_FOUND);
|
||||
nErrorLevel = 1;
|
||||
ConErrResPuts(STRING_ERROR_FILE_NOT_FOUND);
|
||||
nErrorLevel = 1;
|
||||
}
|
||||
|
||||
|
||||
VOID error_sfile_not_found (LPTSTR f)
|
||||
{
|
||||
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
||||
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
||||
|
||||
LoadString(CMD_ModuleHandle, STRING_ERROR_FILE_NOT_FOUND, szMsg, RC_STRING_MAX_SIZE);
|
||||
ConErrPrintf(_T("%s - %s\n"), szMsg, f);
|
||||
nErrorLevel = 1;
|
||||
LoadString(CMD_ModuleHandle, STRING_ERROR_FILE_NOT_FOUND, szMsg, RC_STRING_MAX_SIZE);
|
||||
ConErrPrintf(_T("%s - %s\n"), szMsg, f);
|
||||
nErrorLevel = 1;
|
||||
}
|
||||
|
||||
|
||||
VOID error_req_param_missing (VOID)
|
||||
{
|
||||
ConErrResPuts(STRING_ERROR_REQ_PARAM_MISSING);
|
||||
nErrorLevel = 1;
|
||||
ConErrResPuts(STRING_ERROR_REQ_PARAM_MISSING);
|
||||
nErrorLevel = 1;
|
||||
}
|
||||
|
||||
|
||||
VOID error_invalid_drive (VOID)
|
||||
{
|
||||
ConErrResPuts(STRING_ERROR_INVALID_DRIVE);
|
||||
nErrorLevel = 1;
|
||||
ConErrResPuts(STRING_ERROR_INVALID_DRIVE);
|
||||
nErrorLevel = 1;
|
||||
}
|
||||
|
||||
|
||||
VOID error_bad_command (LPTSTR s)
|
||||
{
|
||||
ConErrResPrintf(STRING_ERROR_BADCOMMAND, s);
|
||||
nErrorLevel = 9009;
|
||||
ConErrResPrintf(STRING_ERROR_BADCOMMAND, s);
|
||||
nErrorLevel = 9009;
|
||||
}
|
||||
|
||||
|
||||
VOID error_no_pipe (VOID)
|
||||
{
|
||||
ConErrResPuts(STRING_ERROR_CANNOTPIPE);
|
||||
nErrorLevel = 1;
|
||||
ConErrResPuts(STRING_ERROR_CANNOTPIPE);
|
||||
nErrorLevel = 1;
|
||||
}
|
||||
|
||||
|
||||
VOID error_out_of_memory (VOID)
|
||||
{
|
||||
ConErrResPuts(STRING_ERROR_OUT_OF_MEMORY);
|
||||
nErrorLevel = 1;
|
||||
ConErrResPuts(STRING_ERROR_OUT_OF_MEMORY);
|
||||
nErrorLevel = 1;
|
||||
}
|
||||
|
||||
|
||||
VOID error_invalid_parameter_format (LPTSTR s)
|
||||
{
|
||||
ConErrResPrintf(STRING_ERROR_INVALID_PARAM_FORMAT, s);
|
||||
nErrorLevel = 1;
|
||||
ConErrResPrintf(STRING_ERROR_INVALID_PARAM_FORMAT, s);
|
||||
nErrorLevel = 1;
|
||||
}
|
||||
|
||||
|
||||
VOID error_syntax (LPTSTR s)
|
||||
{
|
||||
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
||||
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
||||
|
||||
LoadString(CMD_ModuleHandle, STRING_ERROR_ERROR2, szMsg, RC_STRING_MAX_SIZE);
|
||||
LoadString(CMD_ModuleHandle, STRING_ERROR_ERROR2, szMsg, RC_STRING_MAX_SIZE);
|
||||
|
||||
if (s)
|
||||
ConErrPrintf(_T("%s - %s\n"), szMsg, s);
|
||||
else
|
||||
ConErrPrintf(_T("%s.\n"), szMsg);
|
||||
if (s)
|
||||
ConErrPrintf(_T("%s - %s\n"), szMsg, s);
|
||||
else
|
||||
ConErrPrintf(_T("%s.\n"), szMsg);
|
||||
|
||||
nErrorLevel = 1;
|
||||
nErrorLevel = 1;
|
||||
}
|
||||
|
||||
|
||||
VOID msg_pause (VOID)
|
||||
{
|
||||
ConOutResPuts(STRING_ERROR_D_PAUSEMSG);
|
||||
ConOutResPuts(STRING_ERROR_D_PAUSEMSG);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
* Implemented preservation of echo flag. Some other for related
|
||||
* code in other files fixed, too.
|
||||
*
|
||||
* 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
@ -36,16 +36,16 @@
|
|||
/* FOR is a special command, so this function is only used for showing help now */
|
||||
INT cmd_for (LPTSTR param)
|
||||
{
|
||||
TRACE ("cmd_for (\'%s\')\n", debugstr_aw(param));
|
||||
TRACE ("cmd_for (\'%s\')\n", debugstr_aw(param));
|
||||
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_FOR_HELP1);
|
||||
return 0;
|
||||
}
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_FOR_HELP1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
error_syntax(param);
|
||||
return 1;
|
||||
error_syntax(param);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* The stack of current FOR contexts.
|
||||
|
@ -55,322 +55,322 @@ LPFOR_CONTEXT fc = NULL;
|
|||
/* Get the next element of the FOR's list */
|
||||
static BOOL GetNextElement(TCHAR **pStart, TCHAR **pEnd)
|
||||
{
|
||||
TCHAR *p = *pEnd;
|
||||
BOOL InQuotes = FALSE;
|
||||
while (_istspace(*p))
|
||||
p++;
|
||||
if (!*p)
|
||||
return FALSE;
|
||||
*pStart = p;
|
||||
while (*p && (InQuotes || !_istspace(*p)))
|
||||
InQuotes ^= (*p++ == _T('"'));
|
||||
*pEnd = p;
|
||||
return TRUE;
|
||||
TCHAR *p = *pEnd;
|
||||
BOOL InQuotes = FALSE;
|
||||
while (_istspace(*p))
|
||||
p++;
|
||||
if (!*p)
|
||||
return FALSE;
|
||||
*pStart = p;
|
||||
while (*p && (InQuotes || !_istspace(*p)))
|
||||
InQuotes ^= (*p++ == _T('"'));
|
||||
*pEnd = p;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Execute a single instance of a FOR command */
|
||||
static INT RunInstance(PARSED_COMMAND *Cmd)
|
||||
{
|
||||
if (bEcho && !bDisableBatchEcho && Cmd->Subcommands->Type != C_QUIET)
|
||||
{
|
||||
if (!bIgnoreEcho)
|
||||
ConOutChar(_T('\n'));
|
||||
PrintPrompt();
|
||||
EchoCommand(Cmd->Subcommands);
|
||||
ConOutChar(_T('\n'));
|
||||
}
|
||||
/* Just run the command (variable expansion is done in DoDelayedExpansion) */
|
||||
return ExecuteCommand(Cmd->Subcommands);
|
||||
if (bEcho && !bDisableBatchEcho && Cmd->Subcommands->Type != C_QUIET)
|
||||
{
|
||||
if (!bIgnoreEcho)
|
||||
ConOutChar(_T('\n'));
|
||||
PrintPrompt();
|
||||
EchoCommand(Cmd->Subcommands);
|
||||
ConOutChar(_T('\n'));
|
||||
}
|
||||
/* Just run the command (variable expansion is done in DoDelayedExpansion) */
|
||||
return ExecuteCommand(Cmd->Subcommands);
|
||||
}
|
||||
|
||||
/* Check if this FOR should be terminated early */
|
||||
static BOOL Exiting(PARSED_COMMAND *Cmd)
|
||||
{
|
||||
/* Someone might have removed our context */
|
||||
return bCtrlBreak || fc != Cmd->For.Context;
|
||||
/* Someone might have removed our context */
|
||||
return bCtrlBreak || fc != Cmd->For.Context;
|
||||
}
|
||||
|
||||
/* Read the contents of a text file into memory,
|
||||
* dynamically allocating enough space to hold it all */
|
||||
static LPTSTR ReadFileContents(FILE *InputFile, TCHAR *Buffer)
|
||||
{
|
||||
SIZE_T Len = 0;
|
||||
SIZE_T AllocLen = 1000;
|
||||
LPTSTR Contents = cmd_alloc(AllocLen * sizeof(TCHAR));
|
||||
if (!Contents)
|
||||
return NULL;
|
||||
SIZE_T Len = 0;
|
||||
SIZE_T AllocLen = 1000;
|
||||
LPTSTR Contents = cmd_alloc(AllocLen * sizeof(TCHAR));
|
||||
if (!Contents)
|
||||
return NULL;
|
||||
|
||||
while (_fgetts(Buffer, CMDLINE_LENGTH, InputFile))
|
||||
{
|
||||
ULONG_PTR CharsRead = _tcslen(Buffer);
|
||||
while (Len + CharsRead >= AllocLen)
|
||||
{
|
||||
LPTSTR OldContents = Contents;
|
||||
Contents = cmd_realloc(Contents, (AllocLen *= 2) * sizeof(TCHAR));
|
||||
if (!Contents)
|
||||
{
|
||||
cmd_free(OldContents);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
_tcscpy(&Contents[Len], Buffer);
|
||||
Len += CharsRead;
|
||||
}
|
||||
while (_fgetts(Buffer, CMDLINE_LENGTH, InputFile))
|
||||
{
|
||||
ULONG_PTR CharsRead = _tcslen(Buffer);
|
||||
while (Len + CharsRead >= AllocLen)
|
||||
{
|
||||
LPTSTR OldContents = Contents;
|
||||
Contents = cmd_realloc(Contents, (AllocLen *= 2) * sizeof(TCHAR));
|
||||
if (!Contents)
|
||||
{
|
||||
cmd_free(OldContents);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
_tcscpy(&Contents[Len], Buffer);
|
||||
Len += CharsRead;
|
||||
}
|
||||
|
||||
Contents[Len] = _T('\0');
|
||||
return Contents;
|
||||
Contents[Len] = _T('\0');
|
||||
return Contents;
|
||||
}
|
||||
|
||||
static INT ForF(PARSED_COMMAND *Cmd, LPTSTR List, TCHAR *Buffer)
|
||||
{
|
||||
LPTSTR Delims = _T(" \t");
|
||||
TCHAR Eol = _T(';');
|
||||
INT SkipLines = 0;
|
||||
DWORD Tokens = (1 << 1);
|
||||
BOOL RemainderVar = FALSE;
|
||||
TCHAR StringQuote = _T('"');
|
||||
TCHAR CommandQuote = _T('\'');
|
||||
LPTSTR Variables[32];
|
||||
TCHAR *Start, *End;
|
||||
INT i;
|
||||
INT Ret = 0;
|
||||
LPTSTR Delims = _T(" \t");
|
||||
TCHAR Eol = _T(';');
|
||||
INT SkipLines = 0;
|
||||
DWORD Tokens = (1 << 1);
|
||||
BOOL RemainderVar = FALSE;
|
||||
TCHAR StringQuote = _T('"');
|
||||
TCHAR CommandQuote = _T('\'');
|
||||
LPTSTR Variables[32];
|
||||
TCHAR *Start, *End;
|
||||
INT i;
|
||||
INT Ret = 0;
|
||||
|
||||
if (Cmd->For.Params)
|
||||
{
|
||||
TCHAR Quote = 0;
|
||||
TCHAR *Param = Cmd->For.Params;
|
||||
if (*Param == _T('"') || *Param == _T('\''))
|
||||
Quote = *Param++;
|
||||
if (Cmd->For.Params)
|
||||
{
|
||||
TCHAR Quote = 0;
|
||||
TCHAR *Param = Cmd->For.Params;
|
||||
if (*Param == _T('"') || *Param == _T('\''))
|
||||
Quote = *Param++;
|
||||
|
||||
while (*Param && *Param != Quote)
|
||||
{
|
||||
if (*Param <= _T(' '))
|
||||
{
|
||||
Param++;
|
||||
}
|
||||
else if (_tcsnicmp(Param, _T("delims="), 7) == 0)
|
||||
{
|
||||
Param += 7;
|
||||
/* delims=xxx: Specifies the list of characters that separate tokens */
|
||||
Delims = Param;
|
||||
while (*Param && *Param != Quote)
|
||||
{
|
||||
if (*Param == _T(' '))
|
||||
{
|
||||
TCHAR *FirstSpace = Param;
|
||||
Param += _tcsspn(Param, _T(" "));
|
||||
/* Exclude trailing spaces if this is not the last parameter */
|
||||
if (*Param && *Param != Quote)
|
||||
*FirstSpace = _T('\0');
|
||||
break;
|
||||
}
|
||||
Param++;
|
||||
}
|
||||
if (*Param == Quote)
|
||||
*Param++ = _T('\0');
|
||||
}
|
||||
else if (_tcsnicmp(Param, _T("eol="), 4) == 0)
|
||||
{
|
||||
Param += 4;
|
||||
/* eol=c: Lines starting with this character (may be
|
||||
* preceded by delimiters) are skipped. */
|
||||
Eol = *Param;
|
||||
if (Eol != _T('\0'))
|
||||
Param++;
|
||||
}
|
||||
else if (_tcsnicmp(Param, _T("skip="), 5) == 0)
|
||||
{
|
||||
/* skip=n: Number of lines to skip at the beginning of each file */
|
||||
SkipLines = _tcstol(Param + 5, &Param, 0);
|
||||
if (SkipLines <= 0)
|
||||
goto error;
|
||||
}
|
||||
else if (_tcsnicmp(Param, _T("tokens="), 7) == 0)
|
||||
{
|
||||
Param += 7;
|
||||
/* tokens=x,y,m-n: List of token numbers (must be between
|
||||
* 1 and 31) that will be assigned into variables. */
|
||||
Tokens = 0;
|
||||
while (*Param && *Param != Quote && *Param != _T('*'))
|
||||
{
|
||||
INT First = _tcstol(Param, &Param, 0);
|
||||
INT Last = First;
|
||||
if (First < 1)
|
||||
goto error;
|
||||
if (*Param == _T('-'))
|
||||
{
|
||||
/* It's a range of tokens */
|
||||
Last = _tcstol(Param + 1, &Param, 0);
|
||||
if (Last < First || Last > 31)
|
||||
goto error;
|
||||
}
|
||||
Tokens |= (2 << Last) - (1 << First);
|
||||
while (*Param && *Param != Quote)
|
||||
{
|
||||
if (*Param <= _T(' '))
|
||||
{
|
||||
Param++;
|
||||
}
|
||||
else if (_tcsnicmp(Param, _T("delims="), 7) == 0)
|
||||
{
|
||||
Param += 7;
|
||||
/* delims=xxx: Specifies the list of characters that separate tokens */
|
||||
Delims = Param;
|
||||
while (*Param && *Param != Quote)
|
||||
{
|
||||
if (*Param == _T(' '))
|
||||
{
|
||||
TCHAR *FirstSpace = Param;
|
||||
Param += _tcsspn(Param, _T(" "));
|
||||
/* Exclude trailing spaces if this is not the last parameter */
|
||||
if (*Param && *Param != Quote)
|
||||
*FirstSpace = _T('\0');
|
||||
break;
|
||||
}
|
||||
Param++;
|
||||
}
|
||||
if (*Param == Quote)
|
||||
*Param++ = _T('\0');
|
||||
}
|
||||
else if (_tcsnicmp(Param, _T("eol="), 4) == 0)
|
||||
{
|
||||
Param += 4;
|
||||
/* eol=c: Lines starting with this character (may be
|
||||
* preceded by delimiters) are skipped. */
|
||||
Eol = *Param;
|
||||
if (Eol != _T('\0'))
|
||||
Param++;
|
||||
}
|
||||
else if (_tcsnicmp(Param, _T("skip="), 5) == 0)
|
||||
{
|
||||
/* skip=n: Number of lines to skip at the beginning of each file */
|
||||
SkipLines = _tcstol(Param + 5, &Param, 0);
|
||||
if (SkipLines <= 0)
|
||||
goto error;
|
||||
}
|
||||
else if (_tcsnicmp(Param, _T("tokens="), 7) == 0)
|
||||
{
|
||||
Param += 7;
|
||||
/* tokens=x,y,m-n: List of token numbers (must be between
|
||||
* 1 and 31) that will be assigned into variables. */
|
||||
Tokens = 0;
|
||||
while (*Param && *Param != Quote && *Param != _T('*'))
|
||||
{
|
||||
INT First = _tcstol(Param, &Param, 0);
|
||||
INT Last = First;
|
||||
if (First < 1)
|
||||
goto error;
|
||||
if (*Param == _T('-'))
|
||||
{
|
||||
/* It's a range of tokens */
|
||||
Last = _tcstol(Param + 1, &Param, 0);
|
||||
if (Last < First || Last > 31)
|
||||
goto error;
|
||||
}
|
||||
Tokens |= (2 << Last) - (1 << First);
|
||||
|
||||
if (*Param != _T(','))
|
||||
break;
|
||||
Param++;
|
||||
}
|
||||
/* With an asterisk at the end, an additional variable
|
||||
* will be created to hold the remainder of the line
|
||||
* (after the last token specified). */
|
||||
if (*Param == _T('*'))
|
||||
{
|
||||
RemainderVar = TRUE;
|
||||
Param++;
|
||||
}
|
||||
}
|
||||
else if (_tcsnicmp(Param, _T("useback"), 7) == 0)
|
||||
{
|
||||
Param += 7;
|
||||
/* usebackq: Use alternate quote characters */
|
||||
StringQuote = _T('\'');
|
||||
CommandQuote = _T('`');
|
||||
/* Can be written as either "useback" or "usebackq" */
|
||||
if (_totlower(*Param) == _T('q'))
|
||||
Param++;
|
||||
}
|
||||
else
|
||||
{
|
||||
error:
|
||||
error_syntax(Param);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (*Param != _T(','))
|
||||
break;
|
||||
Param++;
|
||||
}
|
||||
/* With an asterisk at the end, an additional variable
|
||||
* will be created to hold the remainder of the line
|
||||
* (after the last token specified). */
|
||||
if (*Param == _T('*'))
|
||||
{
|
||||
RemainderVar = TRUE;
|
||||
Param++;
|
||||
}
|
||||
}
|
||||
else if (_tcsnicmp(Param, _T("useback"), 7) == 0)
|
||||
{
|
||||
Param += 7;
|
||||
/* usebackq: Use alternate quote characters */
|
||||
StringQuote = _T('\'');
|
||||
CommandQuote = _T('`');
|
||||
/* Can be written as either "useback" or "usebackq" */
|
||||
if (_totlower(*Param) == _T('q'))
|
||||
Param++;
|
||||
}
|
||||
else
|
||||
{
|
||||
error:
|
||||
error_syntax(Param);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Count how many variables will be set: one for each token,
|
||||
* plus maybe one for the remainder */
|
||||
fc->varcount = RemainderVar;
|
||||
for (i = 1; i < 32; i++)
|
||||
fc->varcount += (Tokens >> i & 1);
|
||||
fc->values = Variables;
|
||||
/* Count how many variables will be set: one for each token,
|
||||
* plus maybe one for the remainder */
|
||||
fc->varcount = RemainderVar;
|
||||
for (i = 1; i < 32; i++)
|
||||
fc->varcount += (Tokens >> i & 1);
|
||||
fc->values = Variables;
|
||||
|
||||
if (*List == StringQuote || *List == CommandQuote)
|
||||
{
|
||||
/* Treat the entire "list" as one single element */
|
||||
Start = List;
|
||||
End = &List[_tcslen(List)];
|
||||
goto single_element;
|
||||
}
|
||||
if (*List == StringQuote || *List == CommandQuote)
|
||||
{
|
||||
/* Treat the entire "list" as one single element */
|
||||
Start = List;
|
||||
End = &List[_tcslen(List)];
|
||||
goto single_element;
|
||||
}
|
||||
|
||||
End = List;
|
||||
while (GetNextElement(&Start, &End))
|
||||
{
|
||||
FILE *InputFile;
|
||||
LPTSTR FullInput, In, NextLine;
|
||||
INT Skip;
|
||||
single_element:
|
||||
End = List;
|
||||
while (GetNextElement(&Start, &End))
|
||||
{
|
||||
FILE *InputFile;
|
||||
LPTSTR FullInput, In, NextLine;
|
||||
INT Skip;
|
||||
single_element:
|
||||
|
||||
if (*Start == StringQuote && End[-1] == StringQuote)
|
||||
{
|
||||
/* Input given directly as a string */
|
||||
End[-1] = _T('\0');
|
||||
FullInput = cmd_dup(Start + 1);
|
||||
}
|
||||
else if (*Start == CommandQuote && End[-1] == CommandQuote)
|
||||
{
|
||||
/* Read input from a command */
|
||||
End[-1] = _T('\0');
|
||||
InputFile = _tpopen(Start + 1, _T("r"));
|
||||
if (!InputFile)
|
||||
{
|
||||
error_bad_command(Start + 1);
|
||||
return 1;
|
||||
}
|
||||
FullInput = ReadFileContents(InputFile, Buffer);
|
||||
_pclose(InputFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Read input from a file */
|
||||
TCHAR Temp = *End;
|
||||
*End = _T('\0');
|
||||
StripQuotes(Start);
|
||||
InputFile = _tfopen(Start, _T("r"));
|
||||
*End = Temp;
|
||||
if (!InputFile)
|
||||
{
|
||||
error_sfile_not_found(Start);
|
||||
return 1;
|
||||
}
|
||||
FullInput = ReadFileContents(InputFile, Buffer);
|
||||
fclose(InputFile);
|
||||
}
|
||||
if (*Start == StringQuote && End[-1] == StringQuote)
|
||||
{
|
||||
/* Input given directly as a string */
|
||||
End[-1] = _T('\0');
|
||||
FullInput = cmd_dup(Start + 1);
|
||||
}
|
||||
else if (*Start == CommandQuote && End[-1] == CommandQuote)
|
||||
{
|
||||
/* Read input from a command */
|
||||
End[-1] = _T('\0');
|
||||
InputFile = _tpopen(Start + 1, _T("r"));
|
||||
if (!InputFile)
|
||||
{
|
||||
error_bad_command(Start + 1);
|
||||
return 1;
|
||||
}
|
||||
FullInput = ReadFileContents(InputFile, Buffer);
|
||||
_pclose(InputFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Read input from a file */
|
||||
TCHAR Temp = *End;
|
||||
*End = _T('\0');
|
||||
StripQuotes(Start);
|
||||
InputFile = _tfopen(Start, _T("r"));
|
||||
*End = Temp;
|
||||
if (!InputFile)
|
||||
{
|
||||
error_sfile_not_found(Start);
|
||||
return 1;
|
||||
}
|
||||
FullInput = ReadFileContents(InputFile, Buffer);
|
||||
fclose(InputFile);
|
||||
}
|
||||
|
||||
if (!FullInput)
|
||||
{
|
||||
error_out_of_memory();
|
||||
return 1;
|
||||
}
|
||||
if (!FullInput)
|
||||
{
|
||||
error_out_of_memory();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Loop over the input line by line */
|
||||
In = FullInput;
|
||||
Skip = SkipLines;
|
||||
do
|
||||
{
|
||||
DWORD RemainingTokens = Tokens;
|
||||
LPTSTR *CurVar = Variables;
|
||||
/* Loop over the input line by line */
|
||||
In = FullInput;
|
||||
Skip = SkipLines;
|
||||
do
|
||||
{
|
||||
DWORD RemainingTokens = Tokens;
|
||||
LPTSTR *CurVar = Variables;
|
||||
|
||||
NextLine = _tcschr(In, _T('\n'));
|
||||
if (NextLine)
|
||||
*NextLine++ = _T('\0');
|
||||
NextLine = _tcschr(In, _T('\n'));
|
||||
if (NextLine)
|
||||
*NextLine++ = _T('\0');
|
||||
|
||||
if (--Skip >= 0)
|
||||
continue;
|
||||
if (--Skip >= 0)
|
||||
continue;
|
||||
|
||||
/* Ignore lines where the first token starts with the eol character */
|
||||
In += _tcsspn(In, Delims);
|
||||
if (*In == Eol)
|
||||
continue;
|
||||
/* Ignore lines where the first token starts with the eol character */
|
||||
In += _tcsspn(In, Delims);
|
||||
if (*In == Eol)
|
||||
continue;
|
||||
|
||||
while ((RemainingTokens >>= 1) != 0)
|
||||
{
|
||||
/* Save pointer to this token in a variable if requested */
|
||||
if (RemainingTokens & 1)
|
||||
*CurVar++ = In;
|
||||
/* Find end of token */
|
||||
In += _tcscspn(In, Delims);
|
||||
/* Nul-terminate it and advance to next token */
|
||||
if (*In)
|
||||
{
|
||||
*In++ = _T('\0');
|
||||
In += _tcsspn(In, Delims);
|
||||
}
|
||||
}
|
||||
/* Save pointer to remainder of line */
|
||||
*CurVar = In;
|
||||
while ((RemainingTokens >>= 1) != 0)
|
||||
{
|
||||
/* Save pointer to this token in a variable if requested */
|
||||
if (RemainingTokens & 1)
|
||||
*CurVar++ = In;
|
||||
/* Find end of token */
|
||||
In += _tcscspn(In, Delims);
|
||||
/* Nul-terminate it and advance to next token */
|
||||
if (*In)
|
||||
{
|
||||
*In++ = _T('\0');
|
||||
In += _tcsspn(In, Delims);
|
||||
}
|
||||
}
|
||||
/* Save pointer to remainder of line */
|
||||
*CurVar = In;
|
||||
|
||||
/* Don't run unless the line had enough tokens to fill at least one variable */
|
||||
if (*Variables[0])
|
||||
Ret = RunInstance(Cmd);
|
||||
} while (!Exiting(Cmd) && (In = NextLine) != NULL);
|
||||
cmd_free(FullInput);
|
||||
}
|
||||
/* Don't run unless the line had enough tokens to fill at least one variable */
|
||||
if (*Variables[0])
|
||||
Ret = RunInstance(Cmd);
|
||||
} while (!Exiting(Cmd) && (In = NextLine) != NULL);
|
||||
cmd_free(FullInput);
|
||||
}
|
||||
|
||||
return Ret;
|
||||
return Ret;
|
||||
}
|
||||
|
||||
/* FOR /L: Do a numeric loop */
|
||||
static INT ForLoop(PARSED_COMMAND *Cmd, LPTSTR List, TCHAR *Buffer)
|
||||
{
|
||||
enum { START, STEP, END };
|
||||
INT params[3] = { 0, 0, 0 };
|
||||
INT i;
|
||||
INT Ret = 0;
|
||||
enum { START, STEP, END };
|
||||
INT params[3] = { 0, 0, 0 };
|
||||
INT i;
|
||||
INT Ret = 0;
|
||||
|
||||
TCHAR *Start, *End = List;
|
||||
for (i = 0; i < 3 && GetNextElement(&Start, &End); i++)
|
||||
params[i] = _tcstol(Start, NULL, 0);
|
||||
TCHAR *Start, *End = List;
|
||||
for (i = 0; i < 3 && GetNextElement(&Start, &End); i++)
|
||||
params[i] = _tcstol(Start, NULL, 0);
|
||||
|
||||
i = params[START];
|
||||
while (!Exiting(Cmd) &&
|
||||
(params[STEP] >= 0 ? (i <= params[END]) : (i >= params[END])))
|
||||
{
|
||||
_itot(i, Buffer, 10);
|
||||
Ret = RunInstance(Cmd);
|
||||
i += params[STEP];
|
||||
}
|
||||
return Ret;
|
||||
i = params[START];
|
||||
while (!Exiting(Cmd) &&
|
||||
(params[STEP] >= 0 ? (i <= params[END]) : (i >= params[END])))
|
||||
{
|
||||
_itot(i, Buffer, 10);
|
||||
Ret = RunInstance(Cmd);
|
||||
i += params[STEP];
|
||||
}
|
||||
return Ret;
|
||||
}
|
||||
|
||||
/* Process a FOR in one directory. Stored in Buffer (up to BufPos) is a
|
||||
|
@ -378,135 +378,135 @@ static INT ForLoop(PARSED_COMMAND *Cmd, LPTSTR List, TCHAR *Buffer)
|
|||
* it will be empty, but in FOR /R it will be the directory name. */
|
||||
static INT ForDir(PARSED_COMMAND *Cmd, LPTSTR List, TCHAR *Buffer, TCHAR *BufPos)
|
||||
{
|
||||
TCHAR *Start, *End = List;
|
||||
INT Ret = 0;
|
||||
while (!Exiting(Cmd) && GetNextElement(&Start, &End))
|
||||
{
|
||||
if (BufPos + (End - Start) > &Buffer[CMDLINE_LENGTH])
|
||||
continue;
|
||||
memcpy(BufPos, Start, (End - Start) * sizeof(TCHAR));
|
||||
BufPos[End - Start] = _T('\0');
|
||||
TCHAR *Start, *End = List;
|
||||
INT Ret = 0;
|
||||
while (!Exiting(Cmd) && GetNextElement(&Start, &End))
|
||||
{
|
||||
if (BufPos + (End - Start) > &Buffer[CMDLINE_LENGTH])
|
||||
continue;
|
||||
memcpy(BufPos, Start, (End - Start) * sizeof(TCHAR));
|
||||
BufPos[End - Start] = _T('\0');
|
||||
|
||||
if (_tcschr(BufPos, _T('?')) || _tcschr(BufPos, _T('*')))
|
||||
{
|
||||
WIN32_FIND_DATA w32fd;
|
||||
HANDLE hFind;
|
||||
TCHAR *FilePart;
|
||||
if (_tcschr(BufPos, _T('?')) || _tcschr(BufPos, _T('*')))
|
||||
{
|
||||
WIN32_FIND_DATA w32fd;
|
||||
HANDLE hFind;
|
||||
TCHAR *FilePart;
|
||||
|
||||
StripQuotes(BufPos);
|
||||
hFind = FindFirstFile(Buffer, &w32fd);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
continue;
|
||||
FilePart = _tcsrchr(BufPos, _T('\\'));
|
||||
FilePart = FilePart ? FilePart + 1 : BufPos;
|
||||
do
|
||||
{
|
||||
if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
|
||||
continue;
|
||||
if (!(w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
!= !(Cmd->For.Switches & FOR_DIRS))
|
||||
continue;
|
||||
if (_tcscmp(w32fd.cFileName, _T(".")) == 0 ||
|
||||
_tcscmp(w32fd.cFileName, _T("..")) == 0)
|
||||
continue;
|
||||
_tcscpy(FilePart, w32fd.cFileName);
|
||||
Ret = RunInstance(Cmd);
|
||||
} while (!Exiting(Cmd) && FindNextFile(hFind, &w32fd));
|
||||
FindClose(hFind);
|
||||
}
|
||||
else
|
||||
{
|
||||
Ret = RunInstance(Cmd);
|
||||
}
|
||||
}
|
||||
return Ret;
|
||||
StripQuotes(BufPos);
|
||||
hFind = FindFirstFile(Buffer, &w32fd);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
continue;
|
||||
FilePart = _tcsrchr(BufPos, _T('\\'));
|
||||
FilePart = FilePart ? FilePart + 1 : BufPos;
|
||||
do
|
||||
{
|
||||
if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
|
||||
continue;
|
||||
if (!(w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
!= !(Cmd->For.Switches & FOR_DIRS))
|
||||
continue;
|
||||
if (_tcscmp(w32fd.cFileName, _T(".")) == 0 ||
|
||||
_tcscmp(w32fd.cFileName, _T("..")) == 0)
|
||||
continue;
|
||||
_tcscpy(FilePart, w32fd.cFileName);
|
||||
Ret = RunInstance(Cmd);
|
||||
} while (!Exiting(Cmd) && FindNextFile(hFind, &w32fd));
|
||||
FindClose(hFind);
|
||||
}
|
||||
else
|
||||
{
|
||||
Ret = RunInstance(Cmd);
|
||||
}
|
||||
}
|
||||
return Ret;
|
||||
}
|
||||
|
||||
/* FOR /R: Process a FOR in each directory of a tree, recursively. */
|
||||
static INT ForRecursive(PARSED_COMMAND *Cmd, LPTSTR List, TCHAR *Buffer, TCHAR *BufPos)
|
||||
{
|
||||
HANDLE hFind;
|
||||
WIN32_FIND_DATA w32fd;
|
||||
INT Ret = 0;
|
||||
HANDLE hFind;
|
||||
WIN32_FIND_DATA w32fd;
|
||||
INT Ret = 0;
|
||||
|
||||
if (BufPos[-1] != _T('\\'))
|
||||
{
|
||||
*BufPos++ = _T('\\');
|
||||
*BufPos = _T('\0');
|
||||
}
|
||||
if (BufPos[-1] != _T('\\'))
|
||||
{
|
||||
*BufPos++ = _T('\\');
|
||||
*BufPos = _T('\0');
|
||||
}
|
||||
|
||||
Ret = ForDir(Cmd, List, Buffer, BufPos);
|
||||
Ret = ForDir(Cmd, List, Buffer, BufPos);
|
||||
|
||||
_tcscpy(BufPos, _T("*"));
|
||||
hFind = FindFirstFile(Buffer, &w32fd);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
return Ret;
|
||||
do
|
||||
{
|
||||
if (!(w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||
continue;
|
||||
if (_tcscmp(w32fd.cFileName, _T(".")) == 0 ||
|
||||
_tcscmp(w32fd.cFileName, _T("..")) == 0)
|
||||
continue;
|
||||
Ret = ForRecursive(Cmd, List, Buffer, _stpcpy(BufPos, w32fd.cFileName));
|
||||
} while (!Exiting(Cmd) && FindNextFile(hFind, &w32fd));
|
||||
FindClose(hFind);
|
||||
return Ret;
|
||||
_tcscpy(BufPos, _T("*"));
|
||||
hFind = FindFirstFile(Buffer, &w32fd);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
return Ret;
|
||||
do
|
||||
{
|
||||
if (!(w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||
continue;
|
||||
if (_tcscmp(w32fd.cFileName, _T(".")) == 0 ||
|
||||
_tcscmp(w32fd.cFileName, _T("..")) == 0)
|
||||
continue;
|
||||
Ret = ForRecursive(Cmd, List, Buffer, _stpcpy(BufPos, w32fd.cFileName));
|
||||
} while (!Exiting(Cmd) && FindNextFile(hFind, &w32fd));
|
||||
FindClose(hFind);
|
||||
return Ret;
|
||||
}
|
||||
|
||||
BOOL
|
||||
ExecuteFor(PARSED_COMMAND *Cmd)
|
||||
{
|
||||
TCHAR Buffer[CMDLINE_LENGTH]; /* Buffer to hold the variable value */
|
||||
LPTSTR BufferPtr = Buffer;
|
||||
LPFOR_CONTEXT lpNew;
|
||||
INT Ret;
|
||||
LPTSTR List = DoDelayedExpansion(Cmd->For.List);
|
||||
TCHAR Buffer[CMDLINE_LENGTH]; /* Buffer to hold the variable value */
|
||||
LPTSTR BufferPtr = Buffer;
|
||||
LPFOR_CONTEXT lpNew;
|
||||
INT Ret;
|
||||
LPTSTR List = DoDelayedExpansion(Cmd->For.List);
|
||||
|
||||
if (!List)
|
||||
return 1;
|
||||
if (!List)
|
||||
return 1;
|
||||
|
||||
/* Create our FOR context */
|
||||
lpNew = cmd_alloc(sizeof(FOR_CONTEXT));
|
||||
if (!lpNew)
|
||||
{
|
||||
cmd_free(List);
|
||||
return 1;
|
||||
}
|
||||
lpNew->prev = fc;
|
||||
lpNew->firstvar = Cmd->For.Variable;
|
||||
lpNew->varcount = 1;
|
||||
lpNew->values = &BufferPtr;
|
||||
/* Create our FOR context */
|
||||
lpNew = cmd_alloc(sizeof(FOR_CONTEXT));
|
||||
if (!lpNew)
|
||||
{
|
||||
cmd_free(List);
|
||||
return 1;
|
||||
}
|
||||
lpNew->prev = fc;
|
||||
lpNew->firstvar = Cmd->For.Variable;
|
||||
lpNew->varcount = 1;
|
||||
lpNew->values = &BufferPtr;
|
||||
|
||||
Cmd->For.Context = lpNew;
|
||||
fc = lpNew;
|
||||
Cmd->For.Context = lpNew;
|
||||
fc = lpNew;
|
||||
|
||||
if (Cmd->For.Switches & FOR_F)
|
||||
{
|
||||
Ret = ForF(Cmd, List, Buffer);
|
||||
}
|
||||
else if (Cmd->For.Switches & FOR_LOOP)
|
||||
{
|
||||
Ret = ForLoop(Cmd, List, Buffer);
|
||||
}
|
||||
else if (Cmd->For.Switches & FOR_RECURSIVE)
|
||||
{
|
||||
DWORD Len = GetFullPathName(Cmd->For.Params ? Cmd->For.Params : _T("."),
|
||||
MAX_PATH, Buffer, NULL);
|
||||
Ret = ForRecursive(Cmd, List, Buffer, &Buffer[Len]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Ret = ForDir(Cmd, List, Buffer, Buffer);
|
||||
}
|
||||
if (Cmd->For.Switches & FOR_F)
|
||||
{
|
||||
Ret = ForF(Cmd, List, Buffer);
|
||||
}
|
||||
else if (Cmd->For.Switches & FOR_LOOP)
|
||||
{
|
||||
Ret = ForLoop(Cmd, List, Buffer);
|
||||
}
|
||||
else if (Cmd->For.Switches & FOR_RECURSIVE)
|
||||
{
|
||||
DWORD Len = GetFullPathName(Cmd->For.Params ? Cmd->For.Params : _T("."),
|
||||
MAX_PATH, Buffer, NULL);
|
||||
Ret = ForRecursive(Cmd, List, Buffer, &Buffer[Len]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Ret = ForDir(Cmd, List, Buffer, Buffer);
|
||||
}
|
||||
|
||||
/* Remove our context, unless someone already did that */
|
||||
if (fc == lpNew)
|
||||
fc = lpNew->prev;
|
||||
/* Remove our context, unless someone already did that */
|
||||
if (fc == lpNew)
|
||||
fc = lpNew->prev;
|
||||
|
||||
cmd_free(lpNew);
|
||||
cmd_free(List);
|
||||
return Ret;
|
||||
cmd_free(lpNew);
|
||||
cmd_free(List);
|
||||
return Ret;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
* 01-Sep-1999 (Eric Kohl)
|
||||
* Started.
|
||||
*
|
||||
* 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
@ -18,102 +18,101 @@
|
|||
static VOID
|
||||
PrintDiskInfo (LPTSTR szDisk)
|
||||
{
|
||||
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
||||
TCHAR szRootPath[4] = _T("A:\\");
|
||||
TCHAR szDrive[2] = _T("A");
|
||||
TCHAR szVolume[64];
|
||||
TCHAR szSerial[10];
|
||||
TCHAR szTotal[40];
|
||||
TCHAR szUsed[40];
|
||||
TCHAR szFree[40];
|
||||
DWORD dwSerial;
|
||||
ULONGLONG uliSize;
|
||||
DWORD dwSecPerCl;
|
||||
DWORD dwBytPerSec;
|
||||
DWORD dwFreeCl;
|
||||
DWORD dwTotCl;
|
||||
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
||||
TCHAR szRootPath[4] = _T("A:\\");
|
||||
TCHAR szDrive[2] = _T("A");
|
||||
TCHAR szVolume[64];
|
||||
TCHAR szSerial[10];
|
||||
TCHAR szTotal[40];
|
||||
TCHAR szUsed[40];
|
||||
TCHAR szFree[40];
|
||||
DWORD dwSerial;
|
||||
ULONGLONG uliSize;
|
||||
DWORD dwSecPerCl;
|
||||
DWORD dwBytPerSec;
|
||||
DWORD dwFreeCl;
|
||||
DWORD dwTotCl;
|
||||
|
||||
if (_tcslen (szDisk) < 2 || szDisk[1] != _T(':'))
|
||||
{
|
||||
ConErrResPrintf(STRING_FREE_ERROR1);
|
||||
return;
|
||||
}
|
||||
if (_tcslen (szDisk) < 2 || szDisk[1] != _T(':'))
|
||||
{
|
||||
ConErrResPrintf(STRING_FREE_ERROR1);
|
||||
return;
|
||||
}
|
||||
|
||||
szRootPath[0] = szDisk[0];
|
||||
szDrive[0] = _totupper (szRootPath[0]);
|
||||
szRootPath[0] = szDisk[0];
|
||||
szDrive[0] = _totupper (szRootPath[0]);
|
||||
|
||||
if (!GetVolumeInformation (szRootPath, szVolume, 64, &dwSerial,
|
||||
NULL, NULL, NULL, 0))
|
||||
{
|
||||
LoadString(CMD_ModuleHandle, STRING_FREE_ERROR1, szMsg, RC_STRING_MAX_SIZE);
|
||||
ConErrPrintf(_T("%s %s:\n"), szMsg, szDrive);
|
||||
return;
|
||||
}
|
||||
if (!GetVolumeInformation (szRootPath, szVolume, 64, &dwSerial,
|
||||
NULL, NULL, NULL, 0))
|
||||
{
|
||||
LoadString(CMD_ModuleHandle, STRING_FREE_ERROR1, szMsg, RC_STRING_MAX_SIZE);
|
||||
ConErrPrintf(_T("%s %s:\n"), szMsg, szDrive);
|
||||
return;
|
||||
}
|
||||
|
||||
if (szVolume[0] == _T('\0'))
|
||||
{
|
||||
if (szVolume[0] == _T('\0'))
|
||||
{
|
||||
|
||||
LoadString(CMD_ModuleHandle, STRING_FREE_ERROR2, szMsg, RC_STRING_MAX_SIZE);
|
||||
_tcscpy (szVolume, szMsg);
|
||||
}
|
||||
LoadString(CMD_ModuleHandle, STRING_FREE_ERROR2, szMsg, RC_STRING_MAX_SIZE);
|
||||
_tcscpy (szVolume, szMsg);
|
||||
}
|
||||
|
||||
_stprintf (szSerial,
|
||||
_T("%04X-%04X"),
|
||||
HIWORD(dwSerial),
|
||||
LOWORD(dwSerial));
|
||||
_stprintf (szSerial,
|
||||
_T("%04X-%04X"),
|
||||
HIWORD(dwSerial),
|
||||
LOWORD(dwSerial));
|
||||
|
||||
if (!GetDiskFreeSpace (szRootPath, &dwSecPerCl,
|
||||
&dwBytPerSec, &dwFreeCl, &dwTotCl))
|
||||
{
|
||||
LoadString(CMD_ModuleHandle, STRING_FREE_ERROR1, szMsg, RC_STRING_MAX_SIZE);
|
||||
ConErrPrintf (_T("%s %s:\n"), szMsg, szDrive);
|
||||
return;
|
||||
}
|
||||
if (!GetDiskFreeSpace (szRootPath, &dwSecPerCl,
|
||||
&dwBytPerSec, &dwFreeCl, &dwTotCl))
|
||||
{
|
||||
LoadString(CMD_ModuleHandle, STRING_FREE_ERROR1, szMsg, RC_STRING_MAX_SIZE);
|
||||
ConErrPrintf (_T("%s %s:\n"), szMsg, szDrive);
|
||||
return;
|
||||
}
|
||||
|
||||
uliSize = dwSecPerCl * dwBytPerSec * (ULONGLONG)dwTotCl;
|
||||
ConvertULargeInteger(uliSize, szTotal, 40, TRUE);
|
||||
uliSize = dwSecPerCl * dwBytPerSec * (ULONGLONG)dwTotCl;
|
||||
ConvertULargeInteger(uliSize, szTotal, 40, TRUE);
|
||||
|
||||
uliSize = dwSecPerCl * dwBytPerSec * (ULONGLONG)(dwTotCl - dwFreeCl);
|
||||
ConvertULargeInteger(uliSize, szUsed, 40, TRUE);
|
||||
uliSize = dwSecPerCl * dwBytPerSec * (ULONGLONG)(dwTotCl - dwFreeCl);
|
||||
ConvertULargeInteger(uliSize, szUsed, 40, TRUE);
|
||||
|
||||
uliSize = dwSecPerCl * dwBytPerSec * (ULONGLONG)dwFreeCl;
|
||||
ConvertULargeInteger(uliSize, szFree, 40, TRUE);
|
||||
uliSize = dwSecPerCl * dwBytPerSec * (ULONGLONG)dwFreeCl;
|
||||
ConvertULargeInteger(uliSize, szFree, 40, TRUE);
|
||||
|
||||
|
||||
ConOutResPrintf(STRING_FREE_HELP1, szDrive, szVolume, szSerial, szTotal, szUsed, szFree);
|
||||
ConOutResPrintf(STRING_FREE_HELP1, szDrive, szVolume, szSerial, szTotal, szUsed, szFree);
|
||||
}
|
||||
|
||||
|
||||
INT CommandFree (LPTSTR param)
|
||||
{
|
||||
LPTSTR szParam;
|
||||
TCHAR szDefPath[MAX_PATH];
|
||||
INT argc, i;
|
||||
LPTSTR *arg;
|
||||
LPTSTR szParam;
|
||||
TCHAR szDefPath[MAX_PATH];
|
||||
INT argc, i;
|
||||
LPTSTR *arg;
|
||||
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_FREE_HELP2);
|
||||
return 0;
|
||||
}
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_FREE_HELP2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!param || *param == _T('\0'))
|
||||
{
|
||||
GetCurrentDirectory (MAX_PATH, szDefPath);
|
||||
szDefPath[2] = _T('\0');
|
||||
szParam = szDefPath;
|
||||
}
|
||||
else
|
||||
szParam = param;
|
||||
if (!param || *param == _T('\0'))
|
||||
{
|
||||
GetCurrentDirectory (MAX_PATH, szDefPath);
|
||||
szDefPath[2] = _T('\0');
|
||||
szParam = szDefPath;
|
||||
}
|
||||
else
|
||||
szParam = param;
|
||||
|
||||
arg = split (szParam, &argc, FALSE, FALSE);
|
||||
arg = split (szParam, &argc, FALSE, FALSE);
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
PrintDiskInfo (arg[i]);
|
||||
for (i = 0; i < argc; i++)
|
||||
PrintDiskInfo (arg[i]);
|
||||
|
||||
freep (arg);
|
||||
freep (arg);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* INCLUDE_CMD_FREE */
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
* 27-Jan-1999 (Eric Kohl)
|
||||
* Added help text ("/?").
|
||||
*
|
||||
* 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
@ -38,82 +38,82 @@
|
|||
|
||||
INT cmd_goto (LPTSTR param)
|
||||
{
|
||||
LPTSTR tmp, tmp2;
|
||||
LPTSTR tmp, tmp2;
|
||||
|
||||
TRACE ("cmd_goto (\'%s\')\n", debugstr_aw(param));
|
||||
TRACE ("cmd_goto (\'%s\')\n", debugstr_aw(param));
|
||||
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_GOTO_HELP1);
|
||||
return 0;
|
||||
}
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_GOTO_HELP1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* if not in batch -- error!! */
|
||||
if (bc == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
/* if not in batch -- error!! */
|
||||
if (bc == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (*param == _T('\0'))
|
||||
{
|
||||
ConErrResPrintf(STRING_GOTO_ERROR1);
|
||||
ExitBatch();
|
||||
return 1;
|
||||
}
|
||||
if (*param == _T('\0'))
|
||||
{
|
||||
ConErrResPrintf(STRING_GOTO_ERROR1);
|
||||
ExitBatch();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* terminate label at first space char */
|
||||
tmp = param+1;
|
||||
while (!_istcntrl (*tmp) && !_istspace (*tmp) && (*tmp != _T(':')))
|
||||
tmp++;
|
||||
*(tmp) = _T('\0');
|
||||
/* terminate label at first space char */
|
||||
tmp = param+1;
|
||||
while (!_istcntrl (*tmp) && !_istspace (*tmp) && (*tmp != _T(':')))
|
||||
tmp++;
|
||||
*(tmp) = _T('\0');
|
||||
|
||||
/* jump to end of the file */
|
||||
if ( _tcsicmp( param, _T(":eof"))==0)
|
||||
{
|
||||
bc->mempos=bc->memsize; /* position at the end of the batchfile */
|
||||
return 0;
|
||||
}
|
||||
/* jump to end of the file */
|
||||
if ( _tcsicmp( param, _T(":eof"))==0)
|
||||
{
|
||||
bc->mempos=bc->memsize; /* position at the end of the batchfile */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* jump to begin of the file */
|
||||
bc->mempos=0;
|
||||
/* jump to begin of the file */
|
||||
bc->mempos=0;
|
||||
|
||||
while (BatchGetString (textline, sizeof(textline) / sizeof(textline[0])))
|
||||
{
|
||||
int pos;
|
||||
INT_PTR size;
|
||||
while (BatchGetString (textline, sizeof(textline) / sizeof(textline[0])))
|
||||
{
|
||||
int pos;
|
||||
INT_PTR size;
|
||||
|
||||
/* Strip out any trailing spaces or control chars */
|
||||
tmp = textline + _tcslen (textline) - 1;
|
||||
/* Strip out any trailing spaces or control chars */
|
||||
tmp = textline + _tcslen (textline) - 1;
|
||||
|
||||
while (_istcntrl (*tmp) || _istspace (*tmp) || (*tmp == _T(':')))
|
||||
tmp--;
|
||||
*(tmp + 1) = _T('\0');
|
||||
while (_istcntrl (*tmp) || _istspace (*tmp) || (*tmp == _T(':')))
|
||||
tmp--;
|
||||
*(tmp + 1) = _T('\0');
|
||||
|
||||
/* Then leading spaces... */
|
||||
tmp = textline;
|
||||
while (_istspace (*tmp))
|
||||
tmp++;
|
||||
/* Then leading spaces... */
|
||||
tmp = textline;
|
||||
while (_istspace (*tmp))
|
||||
tmp++;
|
||||
|
||||
/* All space after leading space terminate the string */
|
||||
size = _tcslen(tmp) -1;
|
||||
pos=0;
|
||||
while (tmp+pos < tmp+size)
|
||||
{
|
||||
if (_istspace(tmp[pos]))
|
||||
tmp[pos]=_T('\0');
|
||||
pos++;
|
||||
}
|
||||
/* All space after leading space terminate the string */
|
||||
size = _tcslen(tmp) -1;
|
||||
pos=0;
|
||||
while (tmp+pos < tmp+size)
|
||||
{
|
||||
if (_istspace(tmp[pos]))
|
||||
tmp[pos]=_T('\0');
|
||||
pos++;
|
||||
}
|
||||
|
||||
tmp2 = param;
|
||||
/* use whole label name */
|
||||
if ((*tmp == _T(':')) && ((_tcsicmp (++tmp, param) == 0) || (_tcsicmp (tmp, ++tmp2) == 0)))
|
||||
return 0;
|
||||
tmp2 = param;
|
||||
/* use whole label name */
|
||||
if ((*tmp == _T(':')) && ((_tcsicmp (++tmp, param) == 0) || (_tcsicmp (tmp, ++tmp2) == 0)))
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ConErrResPrintf(STRING_GOTO_ERROR2, param);
|
||||
ExitBatch();
|
||||
return 1;
|
||||
ConErrResPrintf(STRING_GOTO_ERROR2, param);
|
||||
ExitBatch();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
* 17-Feb-2001 (ea)
|
||||
* IF DEFINED variable command
|
||||
*
|
||||
* 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -35,144 +35,144 @@
|
|||
static INT GenericCmp(INT (*StringCmp)(LPCTSTR, LPCTSTR),
|
||||
LPCTSTR Left, LPCTSTR Right)
|
||||
{
|
||||
TCHAR *end;
|
||||
INT nLeft = _tcstol(Left, &end, 0);
|
||||
if (*end == _T('\0'))
|
||||
{
|
||||
INT nRight = _tcstol(Right, &end, 0);
|
||||
if (*end == _T('\0'))
|
||||
{
|
||||
/* both arguments are numeric */
|
||||
return (nLeft < nRight) ? -1 : (nLeft > nRight);
|
||||
}
|
||||
}
|
||||
return StringCmp(Left, Right);
|
||||
TCHAR *end;
|
||||
INT nLeft = _tcstol(Left, &end, 0);
|
||||
if (*end == _T('\0'))
|
||||
{
|
||||
INT nRight = _tcstol(Right, &end, 0);
|
||||
if (*end == _T('\0'))
|
||||
{
|
||||
/* both arguments are numeric */
|
||||
return (nLeft < nRight) ? -1 : (nLeft > nRight);
|
||||
}
|
||||
}
|
||||
return StringCmp(Left, Right);
|
||||
}
|
||||
|
||||
INT cmd_if (LPTSTR param)
|
||||
{
|
||||
TRACE ("cmd_if: (\'%s\')\n", debugstr_aw(param));
|
||||
TRACE ("cmd_if: (\'%s\')\n", debugstr_aw(param));
|
||||
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_IF_HELP1);
|
||||
return 0;
|
||||
}
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_IF_HELP1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
error_syntax(param);
|
||||
return 1;
|
||||
error_syntax(param);
|
||||
return 1;
|
||||
}
|
||||
|
||||
INT ExecuteIf(PARSED_COMMAND *Cmd)
|
||||
{
|
||||
INT result = FALSE; /* when set cause 'then' clause to be executed */
|
||||
LPTSTR param;
|
||||
LPTSTR Left = NULL, Right;
|
||||
INT result = FALSE; /* when set cause 'then' clause to be executed */
|
||||
LPTSTR param;
|
||||
LPTSTR Left = NULL, Right;
|
||||
|
||||
if (Cmd->If.LeftArg)
|
||||
{
|
||||
Left = DoDelayedExpansion(Cmd->If.LeftArg);
|
||||
if (!Left)
|
||||
return 1;
|
||||
}
|
||||
Right = DoDelayedExpansion(Cmd->If.RightArg);
|
||||
if (!Right)
|
||||
{
|
||||
cmd_free(Left);
|
||||
return 1;
|
||||
}
|
||||
if (Cmd->If.LeftArg)
|
||||
{
|
||||
Left = DoDelayedExpansion(Cmd->If.LeftArg);
|
||||
if (!Left)
|
||||
return 1;
|
||||
}
|
||||
Right = DoDelayedExpansion(Cmd->If.RightArg);
|
||||
if (!Right)
|
||||
{
|
||||
cmd_free(Left);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (Cmd->If.Operator == IF_CMDEXTVERSION)
|
||||
{
|
||||
/* IF CMDEXTVERSION n: check if Command Extensions version
|
||||
* is greater or equal to n */
|
||||
DWORD n = _tcstoul(Right, ¶m, 10);
|
||||
if (*param != _T('\0'))
|
||||
{
|
||||
error_syntax(Right);
|
||||
cmd_free(Right);
|
||||
return 1;
|
||||
}
|
||||
result = (2 >= n);
|
||||
}
|
||||
else if (Cmd->If.Operator == IF_DEFINED)
|
||||
{
|
||||
/* IF DEFINED var: check if environment variable exists */
|
||||
result = (GetEnvVarOrSpecial(Right) != NULL);
|
||||
}
|
||||
else if (Cmd->If.Operator == IF_ERRORLEVEL)
|
||||
{
|
||||
/* IF ERRORLEVEL n: check if last exit code is greater or equal to n */
|
||||
INT n = _tcstol(Right, ¶m, 10);
|
||||
if (*param != _T('\0'))
|
||||
{
|
||||
error_syntax(Right);
|
||||
cmd_free(Right);
|
||||
return 1;
|
||||
}
|
||||
result = (nErrorLevel >= n);
|
||||
}
|
||||
else if (Cmd->If.Operator == IF_EXIST)
|
||||
{
|
||||
/* IF EXIST filename: check if file exists (wildcards allowed) */
|
||||
StripQuotes(Right);
|
||||
if (Cmd->If.Operator == IF_CMDEXTVERSION)
|
||||
{
|
||||
/* IF CMDEXTVERSION n: check if Command Extensions version
|
||||
* is greater or equal to n */
|
||||
DWORD n = _tcstoul(Right, ¶m, 10);
|
||||
if (*param != _T('\0'))
|
||||
{
|
||||
error_syntax(Right);
|
||||
cmd_free(Right);
|
||||
return 1;
|
||||
}
|
||||
result = (2 >= n);
|
||||
}
|
||||
else if (Cmd->If.Operator == IF_DEFINED)
|
||||
{
|
||||
/* IF DEFINED var: check if environment variable exists */
|
||||
result = (GetEnvVarOrSpecial(Right) != NULL);
|
||||
}
|
||||
else if (Cmd->If.Operator == IF_ERRORLEVEL)
|
||||
{
|
||||
/* IF ERRORLEVEL n: check if last exit code is greater or equal to n */
|
||||
INT n = _tcstol(Right, ¶m, 10);
|
||||
if (*param != _T('\0'))
|
||||
{
|
||||
error_syntax(Right);
|
||||
cmd_free(Right);
|
||||
return 1;
|
||||
}
|
||||
result = (nErrorLevel >= n);
|
||||
}
|
||||
else if (Cmd->If.Operator == IF_EXIST)
|
||||
{
|
||||
/* IF EXIST filename: check if file exists (wildcards allowed) */
|
||||
StripQuotes(Right);
|
||||
|
||||
if (_tcschr(Right, _T('*')) || _tcschr(Right, _T('?')))
|
||||
{
|
||||
WIN32_FIND_DATA f;
|
||||
HANDLE hFind = FindFirstFile(Right, &f);
|
||||
if (hFind != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
result = TRUE;
|
||||
FindClose(hFind);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = (GetFileAttributes(Right) != INVALID_FILE_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Do case-insensitive string comparisons if /I specified */
|
||||
INT (*StringCmp)(LPCTSTR, LPCTSTR) =
|
||||
(Cmd->If.Flags & IFFLAG_IGNORECASE) ? _tcsicmp : _tcscmp;
|
||||
if (_tcschr(Right, _T('*')) || _tcschr(Right, _T('?')))
|
||||
{
|
||||
WIN32_FIND_DATA f;
|
||||
HANDLE hFind = FindFirstFile(Right, &f);
|
||||
if (hFind != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
result = TRUE;
|
||||
FindClose(hFind);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = (GetFileAttributes(Right) != INVALID_FILE_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Do case-insensitive string comparisons if /I specified */
|
||||
INT (*StringCmp)(LPCTSTR, LPCTSTR) =
|
||||
(Cmd->If.Flags & IFFLAG_IGNORECASE) ? _tcsicmp : _tcscmp;
|
||||
|
||||
if (Cmd->If.Operator == IF_STRINGEQ)
|
||||
{
|
||||
/* IF str1 == str2 */
|
||||
result = StringCmp(Left, Right) == 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = GenericCmp(StringCmp, Left, Right);
|
||||
switch (Cmd->If.Operator)
|
||||
{
|
||||
case IF_EQU: result = (result == 0); break;
|
||||
case IF_NEQ: result = (result != 0); break;
|
||||
case IF_LSS: result = (result < 0); break;
|
||||
case IF_LEQ: result = (result <= 0); break;
|
||||
case IF_GTR: result = (result > 0); break;
|
||||
case IF_GEQ: result = (result >= 0); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Cmd->If.Operator == IF_STRINGEQ)
|
||||
{
|
||||
/* IF str1 == str2 */
|
||||
result = StringCmp(Left, Right) == 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = GenericCmp(StringCmp, Left, Right);
|
||||
switch (Cmd->If.Operator)
|
||||
{
|
||||
case IF_EQU: result = (result == 0); break;
|
||||
case IF_NEQ: result = (result != 0); break;
|
||||
case IF_LSS: result = (result < 0); break;
|
||||
case IF_LEQ: result = (result <= 0); break;
|
||||
case IF_GTR: result = (result > 0); break;
|
||||
case IF_GEQ: result = (result >= 0); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cmd_free(Left);
|
||||
cmd_free(Right);
|
||||
cmd_free(Left);
|
||||
cmd_free(Right);
|
||||
|
||||
if (result ^ ((Cmd->If.Flags & IFFLAG_NEGATE) != 0))
|
||||
{
|
||||
/* full condition was true, do the command */
|
||||
return ExecuteCommand(Cmd->Subcommands);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* full condition was false, do the "else" command if there is one */
|
||||
if (Cmd->Subcommands->Next)
|
||||
return ExecuteCommand(Cmd->Subcommands->Next);
|
||||
return 0;
|
||||
}
|
||||
if (result ^ ((Cmd->If.Flags & IFFLAG_NEGATE) != 0))
|
||||
{
|
||||
/* full condition was true, do the command */
|
||||
return ExecuteCommand(Cmd->Subcommands);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* full condition was false, do the "else" command if there is one */
|
||||
if (Cmd->Subcommands->Next)
|
||||
return ExecuteCommand(Cmd->Subcommands->Next);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* 19-Jan-1998 (Eric Kohl)
|
||||
* Unicode ready!
|
||||
*
|
||||
* 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
@ -24,80 +24,80 @@
|
|||
|
||||
INT cmd_label (LPTSTR param)
|
||||
{
|
||||
TCHAR szRootPath[] = _T("A:\\");
|
||||
TCHAR szLabel[80];
|
||||
TCHAR szOldLabel[80];
|
||||
DWORD dwSerialNr;
|
||||
TCHAR szRootPath[] = _T("A:\\");
|
||||
TCHAR szLabel[80];
|
||||
TCHAR szOldLabel[80];
|
||||
DWORD dwSerialNr;
|
||||
|
||||
/* set empty label string */
|
||||
szLabel[0] = _T('\0');
|
||||
/* set empty label string */
|
||||
szLabel[0] = _T('\0');
|
||||
|
||||
nErrorLevel = 0;
|
||||
nErrorLevel = 0;
|
||||
|
||||
/* print help */
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_LABEL_HELP1);
|
||||
return 0;
|
||||
}
|
||||
/* print help */
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_LABEL_HELP1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* get parameters */
|
||||
if (param[0] != _T('\0') && param[1] == _T(':'))
|
||||
{
|
||||
szRootPath[0] = toupper(*param);
|
||||
param += 2;
|
||||
while (_istspace(*param))
|
||||
param++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* get label of current drive */
|
||||
TCHAR szCurPath[MAX_PATH];
|
||||
GetCurrentDirectory (MAX_PATH, szCurPath);
|
||||
szRootPath[0] = szCurPath[0];
|
||||
}
|
||||
/* get parameters */
|
||||
if (param[0] != _T('\0') && param[1] == _T(':'))
|
||||
{
|
||||
szRootPath[0] = toupper(*param);
|
||||
param += 2;
|
||||
while (_istspace(*param))
|
||||
param++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* get label of current drive */
|
||||
TCHAR szCurPath[MAX_PATH];
|
||||
GetCurrentDirectory (MAX_PATH, szCurPath);
|
||||
szRootPath[0] = szCurPath[0];
|
||||
}
|
||||
|
||||
_tcsncat(szLabel, param, 79);
|
||||
_tcsncat(szLabel, param, 79);
|
||||
|
||||
/* check root path */
|
||||
if (!IsValidPathName (szRootPath))
|
||||
{
|
||||
error_invalid_drive ();
|
||||
nErrorLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
/* check root path */
|
||||
if (!IsValidPathName (szRootPath))
|
||||
{
|
||||
error_invalid_drive ();
|
||||
nErrorLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (szLabel[0] == _T('\0'))
|
||||
{
|
||||
GetVolumeInformation(szRootPath, szOldLabel, 80, &dwSerialNr,
|
||||
NULL, NULL, NULL, 0);
|
||||
if (szLabel[0] == _T('\0'))
|
||||
{
|
||||
GetVolumeInformation(szRootPath, szOldLabel, 80, &dwSerialNr,
|
||||
NULL, NULL, NULL, 0);
|
||||
|
||||
/* print drive info */
|
||||
if (szOldLabel[0] != _T('\0'))
|
||||
{
|
||||
ConOutResPrintf(STRING_LABEL_HELP2, _totupper(szRootPath[0]), szOldLabel);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConOutResPrintf(STRING_LABEL_HELP3, _totupper(szRootPath[0]));
|
||||
}
|
||||
/* print drive info */
|
||||
if (szOldLabel[0] != _T('\0'))
|
||||
{
|
||||
ConOutResPrintf(STRING_LABEL_HELP2, _totupper(szRootPath[0]), szOldLabel);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConOutResPrintf(STRING_LABEL_HELP3, _totupper(szRootPath[0]));
|
||||
}
|
||||
|
||||
/* print the volume serial number */
|
||||
ConOutResPrintf(STRING_LABEL_HELP4, HIWORD(dwSerialNr), LOWORD(dwSerialNr));
|
||||
/* print the volume serial number */
|
||||
ConOutResPrintf(STRING_LABEL_HELP4, HIWORD(dwSerialNr), LOWORD(dwSerialNr));
|
||||
|
||||
ConOutResPuts(STRING_LABEL_HELP5);
|
||||
ConOutResPuts(STRING_LABEL_HELP5);
|
||||
|
||||
ConInString(szLabel, 80);
|
||||
}
|
||||
ConInString(szLabel, 80);
|
||||
}
|
||||
|
||||
if (!SetVolumeLabel(szRootPath, szLabel))
|
||||
{
|
||||
ConOutFormatMessage(GetLastError());
|
||||
nErrorLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
if (!SetVolumeLabel(szRootPath, szLabel))
|
||||
{
|
||||
ConOutFormatMessage(GetLastError());
|
||||
nErrorLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* INCLUDE_CMD_LABEL */
|
||||
|
|
|
@ -24,32 +24,32 @@ INT nNumberGroups;
|
|||
|
||||
VOID InitLocale (VOID)
|
||||
{
|
||||
TCHAR szBuffer[256];
|
||||
TCHAR szBuffer[256];
|
||||
|
||||
/* date settings */
|
||||
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SDATE, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
|
||||
cDateSeparator = szBuffer[0];
|
||||
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_IDATE | LOCALE_RETURN_NUMBER, (LPTSTR)&nDateFormat, sizeof(nDateFormat) / sizeof(TCHAR));
|
||||
/* date settings */
|
||||
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SDATE, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
|
||||
cDateSeparator = szBuffer[0];
|
||||
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_IDATE | LOCALE_RETURN_NUMBER, (LPTSTR)&nDateFormat, sizeof(nDateFormat) / sizeof(TCHAR));
|
||||
|
||||
/* time settings */
|
||||
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_STIME, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
|
||||
cTimeSeparator = szBuffer[0];
|
||||
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_ITIME | LOCALE_RETURN_NUMBER, (LPTSTR)&nTimeFormat, sizeof(nTimeFormat) / sizeof(TCHAR));
|
||||
/* time settings */
|
||||
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_STIME, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
|
||||
cTimeSeparator = szBuffer[0];
|
||||
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_ITIME | LOCALE_RETURN_NUMBER, (LPTSTR)&nTimeFormat, sizeof(nTimeFormat) / sizeof(TCHAR));
|
||||
|
||||
/* number settings */
|
||||
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
|
||||
cThousandSeparator = szBuffer[0];
|
||||
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
|
||||
cDecimalSeparator = szBuffer[0];
|
||||
/* number settings */
|
||||
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
|
||||
cThousandSeparator = szBuffer[0];
|
||||
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
|
||||
cDecimalSeparator = szBuffer[0];
|
||||
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SGROUPING, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
|
||||
nNumberGroups = _ttoi(szBuffer);
|
||||
#if 0
|
||||
/* days of week */
|
||||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1 + i, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
|
||||
_tcscpy (aszDayNames[(i+1)%7], szBuffer); /* little hack */
|
||||
}
|
||||
/* days of week */
|
||||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1 + i, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
|
||||
_tcscpy (aszDayNames[(i+1)%7], szBuffer); /* little hack */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -57,26 +57,26 @@ VOID InitLocale (VOID)
|
|||
LPTSTR
|
||||
GetDateString(VOID)
|
||||
{
|
||||
static TCHAR szDate[32];
|
||||
SYSTEMTIME t;
|
||||
INT len;
|
||||
GetLocalTime(&t);
|
||||
static TCHAR szDate[32];
|
||||
SYSTEMTIME t;
|
||||
INT len;
|
||||
GetLocalTime(&t);
|
||||
|
||||
len = GetDateFormat(LOCALE_USER_DEFAULT, 0, &t, _T("ddd"), szDate, sizeof szDate);
|
||||
szDate[len - 1] = _T(' ');
|
||||
FormatDate(&szDate[len], &t, TRUE);
|
||||
return szDate;
|
||||
len = GetDateFormat(LOCALE_USER_DEFAULT, 0, &t, _T("ddd"), szDate, sizeof szDate);
|
||||
szDate[len - 1] = _T(' ');
|
||||
FormatDate(&szDate[len], &t, TRUE);
|
||||
return szDate;
|
||||
}
|
||||
|
||||
/* Return time in hh:mm:ss.xx format. Used for $T in prompt and %TIME% */
|
||||
LPTSTR
|
||||
GetTimeString(VOID)
|
||||
{
|
||||
static TCHAR szTime[12];
|
||||
SYSTEMTIME t;
|
||||
GetLocalTime(&t);
|
||||
_stprintf(szTime, _T("%2d%c%02d%c%02d%c%02d"),
|
||||
t.wHour, cTimeSeparator, t.wMinute, cTimeSeparator,
|
||||
t.wSecond, cDecimalSeparator, t.wMilliseconds / 10);
|
||||
return szTime;
|
||||
static TCHAR szTime[12];
|
||||
SYSTEMTIME t;
|
||||
GetLocalTime(&t);
|
||||
_stprintf(szTime, _T("%2d%c%02d%c%02d%c%02d"),
|
||||
t.wHour, cTimeSeparator, t.wMinute, cTimeSeparator,
|
||||
t.wSecond, cDecimalSeparator, t.wMilliseconds / 10);
|
||||
return szTime;
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
* 01-Sep-1999 (Eric Kohl)
|
||||
* Started.
|
||||
*
|
||||
* 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
@ -17,56 +17,56 @@
|
|||
|
||||
INT CommandMemory (LPTSTR param)
|
||||
{
|
||||
MEMORYSTATUSEX msex;
|
||||
TCHAR szMemoryLoad[20];
|
||||
TCHAR szTotalPhys[40];
|
||||
TCHAR szAvailPhys[40];
|
||||
TCHAR szTotalPageFile[40];
|
||||
TCHAR szAvailPageFile[40];
|
||||
TCHAR szTotalVirtual[40];
|
||||
TCHAR szAvailVirtual[40];
|
||||
BOOL (WINAPI *GlobalMemoryStatusEx)(LPMEMORYSTATUSEX);
|
||||
MEMORYSTATUSEX msex;
|
||||
TCHAR szMemoryLoad[20];
|
||||
TCHAR szTotalPhys[40];
|
||||
TCHAR szAvailPhys[40];
|
||||
TCHAR szTotalPageFile[40];
|
||||
TCHAR szAvailPageFile[40];
|
||||
TCHAR szTotalVirtual[40];
|
||||
TCHAR szAvailVirtual[40];
|
||||
BOOL (WINAPI *GlobalMemoryStatusEx)(LPMEMORYSTATUSEX);
|
||||
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_MEMMORY_HELP1);
|
||||
return 0;
|
||||
}
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_MEMMORY_HELP1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GlobalMemoryStatusEx
|
||||
= (BOOL (WINAPI *)(LPMEMORYSTATUSEX))GetProcAddress(GetModuleHandle(_T("KERNEL32")), "GlobalMemoryStatusEx");
|
||||
if (GlobalMemoryStatusEx)
|
||||
{
|
||||
msex.dwLength = sizeof(MEMORYSTATUSEX);
|
||||
GlobalMemoryStatusEx(&msex);
|
||||
}
|
||||
else
|
||||
{
|
||||
MEMORYSTATUS ms;
|
||||
ms.dwLength = sizeof(MEMORYSTATUS);
|
||||
GlobalMemoryStatus(&ms);
|
||||
msex.dwMemoryLoad = ms.dwMemoryLoad;
|
||||
msex.ullTotalPhys = ms.dwTotalPhys;
|
||||
msex.ullAvailPhys = ms.dwAvailPhys;
|
||||
msex.ullTotalPageFile = ms.dwTotalPageFile;
|
||||
msex.ullAvailPageFile = ms.dwAvailPageFile;
|
||||
msex.ullTotalVirtual = ms.dwTotalVirtual;
|
||||
msex.ullAvailVirtual = ms.dwAvailVirtual;
|
||||
}
|
||||
GlobalMemoryStatusEx
|
||||
= (BOOL (WINAPI *)(LPMEMORYSTATUSEX))GetProcAddress(GetModuleHandle(_T("KERNEL32")), "GlobalMemoryStatusEx");
|
||||
if (GlobalMemoryStatusEx)
|
||||
{
|
||||
msex.dwLength = sizeof(MEMORYSTATUSEX);
|
||||
GlobalMemoryStatusEx(&msex);
|
||||
}
|
||||
else
|
||||
{
|
||||
MEMORYSTATUS ms;
|
||||
ms.dwLength = sizeof(MEMORYSTATUS);
|
||||
GlobalMemoryStatus(&ms);
|
||||
msex.dwMemoryLoad = ms.dwMemoryLoad;
|
||||
msex.ullTotalPhys = ms.dwTotalPhys;
|
||||
msex.ullAvailPhys = ms.dwAvailPhys;
|
||||
msex.ullTotalPageFile = ms.dwTotalPageFile;
|
||||
msex.ullAvailPageFile = ms.dwAvailPageFile;
|
||||
msex.ullTotalVirtual = ms.dwTotalVirtual;
|
||||
msex.ullAvailVirtual = ms.dwAvailVirtual;
|
||||
}
|
||||
|
||||
ConvertULargeInteger(msex.dwMemoryLoad, szMemoryLoad, 20, FALSE);
|
||||
ConvertULargeInteger(msex.ullTotalPhys, szTotalPhys, 40, TRUE);
|
||||
ConvertULargeInteger(msex.ullAvailPhys, szAvailPhys, 40, TRUE);
|
||||
ConvertULargeInteger(msex.ullTotalPageFile, szTotalPageFile, 40, TRUE);
|
||||
ConvertULargeInteger(msex.ullAvailPageFile, szAvailPageFile, 40, TRUE);
|
||||
ConvertULargeInteger(msex.ullTotalVirtual, szTotalVirtual, 40, TRUE);
|
||||
ConvertULargeInteger(msex.ullAvailVirtual, szAvailVirtual, 40, TRUE);
|
||||
ConvertULargeInteger(msex.dwMemoryLoad, szMemoryLoad, 20, FALSE);
|
||||
ConvertULargeInteger(msex.ullTotalPhys, szTotalPhys, 40, TRUE);
|
||||
ConvertULargeInteger(msex.ullAvailPhys, szAvailPhys, 40, TRUE);
|
||||
ConvertULargeInteger(msex.ullTotalPageFile, szTotalPageFile, 40, TRUE);
|
||||
ConvertULargeInteger(msex.ullAvailPageFile, szAvailPageFile, 40, TRUE);
|
||||
ConvertULargeInteger(msex.ullTotalVirtual, szTotalVirtual, 40, TRUE);
|
||||
ConvertULargeInteger(msex.ullAvailVirtual, szAvailVirtual, 40, TRUE);
|
||||
|
||||
ConOutResPrintf(STRING_MEMMORY_HELP2,
|
||||
szMemoryLoad, szTotalPhys, szAvailPhys, szTotalPageFile,
|
||||
szAvailPageFile, szTotalVirtual, szAvailVirtual);
|
||||
ConOutResPrintf(STRING_MEMMORY_HELP2,
|
||||
szMemoryLoad, szTotalPhys, szAvailPhys, szTotalPageFile,
|
||||
szAvailPageFile, szTotalVirtual, szAvailVirtual);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* INCLUDE_CMD_MEMORY */
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* 25 Aug 1999
|
||||
* started - Paolo Pantaleo <paolopan@freemail.it>
|
||||
*
|
||||
* 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
@ -24,130 +24,128 @@
|
|||
|
||||
INT CommandMsgbox (LPTSTR param)
|
||||
{
|
||||
//used to parse command line
|
||||
LPTSTR tmp;
|
||||
|
||||
//used to parse command line
|
||||
LPTSTR tmp;
|
||||
//used to find window title (used as messagebox title)
|
||||
//and to find window handle to pass to MessageBox
|
||||
HWND hWnd;
|
||||
TCHAR buff[128];
|
||||
|
||||
//used to find window title (used as messagebox title)
|
||||
//and to find window handle to pass to MessageBox
|
||||
HWND hWnd;
|
||||
TCHAR buff[128];
|
||||
//these are MessabeBox() parameters
|
||||
LPTSTR title, prompt = "";
|
||||
UINT uType = U_TYPE_INIT;
|
||||
|
||||
//these are MessabeBox() parameters
|
||||
LPTSTR title, prompt = "";
|
||||
UINT uType = U_TYPE_INIT;
|
||||
/* set default title to window title */
|
||||
GetConsoleTitle(buff, 128);
|
||||
title = buff;
|
||||
|
||||
/* set default title to window title */
|
||||
GetConsoleTitle(buff, 128);
|
||||
title = buff;
|
||||
if (_tcsncmp (param, _T("/?"), 2) == 0)
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_MSGBOX_HELP);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (_tcsncmp (param, _T("/?"), 2) == 0)
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_MSGBOX_HELP);
|
||||
return 0;
|
||||
}
|
||||
//yes here things are quite massed up :)
|
||||
|
||||
//yes here things are quite massed up :)
|
||||
//skip spaces
|
||||
while(_istspace(*param))
|
||||
param++;
|
||||
|
||||
//skip spaces
|
||||
while(_istspace(*param))
|
||||
param++;
|
||||
|
||||
//search for type of messagebox (ok, okcancel, ...)
|
||||
if (_tcsnicmp(param, _T("ok "), 3) == 0)
|
||||
{
|
||||
uType |= MB_ICONEXCLAMATION | MB_OK;
|
||||
param += 3;
|
||||
}
|
||||
else if (_tcsnicmp(param, _T("okcancel "), 9) == 0)
|
||||
{
|
||||
uType |= MB_ICONQUESTION | MB_OKCANCEL;
|
||||
param += 9;
|
||||
}
|
||||
else if (_tcsnicmp(param, _T("yesno "), 6) == 0)
|
||||
{
|
||||
uType |= MB_ICONQUESTION | MB_YESNO;
|
||||
param += 6;
|
||||
}
|
||||
else if (_tcsnicmp(param, _T("yesnocancel "), 12) == 0)
|
||||
{
|
||||
uType |= MB_ICONQUESTION | MB_YESNOCANCEL;
|
||||
param += 12;
|
||||
}
|
||||
else
|
||||
{
|
||||
//search for type of messagebox (ok, okcancel, ...)
|
||||
if (_tcsnicmp(param, _T("ok "), 3) == 0)
|
||||
{
|
||||
uType |= MB_ICONEXCLAMATION | MB_OK;
|
||||
param += 3;
|
||||
}
|
||||
else if (_tcsnicmp(param, _T("okcancel "), 9) == 0)
|
||||
{
|
||||
uType |= MB_ICONQUESTION | MB_OKCANCEL;
|
||||
param += 9;
|
||||
}
|
||||
else if (_tcsnicmp(param, _T("yesno "), 6) == 0)
|
||||
{
|
||||
uType |= MB_ICONQUESTION | MB_YESNO;
|
||||
param += 6;
|
||||
}
|
||||
else if (_tcsnicmp(param, _T("yesnocancel "), 12) == 0)
|
||||
{
|
||||
uType |= MB_ICONQUESTION | MB_YESNOCANCEL;
|
||||
param += 12;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef _SYNTAX_CHECK
|
||||
error_req_param_missing ();
|
||||
return 1;
|
||||
error_req_param_missing ();
|
||||
return 1;
|
||||
#else
|
||||
uType |= MB_ICONEXCLAMATION | MB_OK;
|
||||
uType |= MB_ICONEXCLAMATION | MB_OK;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//skip spaces
|
||||
while(_istspace(*param))
|
||||
param++;
|
||||
//skip spaces
|
||||
while(_istspace(*param))
|
||||
param++;
|
||||
|
||||
#ifdef _SYNTAX_CHECK
|
||||
//if reached end of string
|
||||
//it is an error becuase we do not yet have prompt
|
||||
if (*param == 0)
|
||||
{
|
||||
error_req_param_missing ();
|
||||
return 1;
|
||||
}
|
||||
//if reached end of string
|
||||
//it is an error becuase we do not yet have prompt
|
||||
if (*param == 0)
|
||||
{
|
||||
error_req_param_missing ();
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
//search for "title"
|
||||
tmp = param;
|
||||
//search for "title"
|
||||
tmp = param;
|
||||
|
||||
if (*param == '"')
|
||||
{
|
||||
tmp = _tcschr(param + 1, '"');
|
||||
if (tmp)
|
||||
{
|
||||
*tmp = 0;
|
||||
title = param + 1;
|
||||
tmp++;
|
||||
param = tmp;
|
||||
}
|
||||
}
|
||||
if (*param == '"')
|
||||
{
|
||||
tmp = _tcschr(param + 1, '"');
|
||||
if (tmp)
|
||||
{
|
||||
*tmp = 0;
|
||||
title = param + 1;
|
||||
tmp++;
|
||||
param = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
//skip spaces
|
||||
while(_istspace(*param))
|
||||
param++;
|
||||
//skip spaces
|
||||
while(_istspace(*param))
|
||||
param++;
|
||||
|
||||
#ifdef _SYNTAX_CHECK
|
||||
//get prompt
|
||||
if (*param == 0)
|
||||
{
|
||||
error_req_param_missing ();
|
||||
return 1;
|
||||
}
|
||||
//get prompt
|
||||
if (*param == 0)
|
||||
{
|
||||
error_req_param_missing ();
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
prompt = param;
|
||||
prompt = param;
|
||||
|
||||
hWnd=GetConsoleWindow ();
|
||||
hWnd=GetConsoleWindow ();
|
||||
|
||||
switch (MessageBox(hWnd, prompt, title, uType))
|
||||
{
|
||||
case IDYES:
|
||||
case IDOK:
|
||||
nErrorLevel = 10;
|
||||
break;
|
||||
switch (MessageBox(hWnd, prompt, title, uType))
|
||||
{
|
||||
case IDYES:
|
||||
case IDOK:
|
||||
nErrorLevel = 10;
|
||||
break;
|
||||
|
||||
case IDNO:
|
||||
nErrorLevel = 11;
|
||||
break;
|
||||
case IDNO:
|
||||
nErrorLevel = 11;
|
||||
break;
|
||||
|
||||
case IDCANCEL:
|
||||
nErrorLevel = 12;
|
||||
break;
|
||||
}
|
||||
case IDCANCEL:
|
||||
nErrorLevel = 12;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* INCLUDE_CMD_MSGBOX */
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -22,8 +22,8 @@
|
|||
* 24-Jan-1999 (Eric Kohl)
|
||||
* Fixed Win32 environment handling.
|
||||
*
|
||||
* 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*/
|
||||
#include "precomp.h"
|
||||
|
||||
|
@ -35,53 +35,52 @@
|
|||
|
||||
INT cmd_path (LPTSTR param)
|
||||
{
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_PATH_HELP1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_PATH_HELP1);
|
||||
return 0;
|
||||
}
|
||||
nErrorLevel = 0;
|
||||
|
||||
nErrorLevel = 0;
|
||||
/* if param is empty, display the PATH environment variable */
|
||||
if (!param || !*param)
|
||||
{
|
||||
DWORD dwBuffer;
|
||||
LPTSTR pszBuffer;
|
||||
|
||||
/* if param is empty, display the PATH environment variable */
|
||||
if (!param || !*param)
|
||||
{
|
||||
DWORD dwBuffer;
|
||||
LPTSTR pszBuffer;
|
||||
pszBuffer = (LPTSTR)cmd_alloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
|
||||
dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE);
|
||||
if (dwBuffer == 0)
|
||||
{
|
||||
cmd_free(pszBuffer);
|
||||
ConOutResPrintf(STRING_VOL_HELP2, _T("PATH"));
|
||||
return 0;
|
||||
}
|
||||
else if (dwBuffer > ENV_BUFFER_SIZE)
|
||||
{
|
||||
pszBuffer = (LPTSTR)cmd_realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
|
||||
GetEnvironmentVariable (_T("PATH"), pszBuffer, dwBuffer);
|
||||
}
|
||||
|
||||
pszBuffer = (LPTSTR)cmd_alloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
|
||||
dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE);
|
||||
if (dwBuffer == 0)
|
||||
{
|
||||
cmd_free(pszBuffer);
|
||||
ConOutResPrintf(STRING_VOL_HELP2, _T("PATH"));
|
||||
return 0;
|
||||
}
|
||||
else if (dwBuffer > ENV_BUFFER_SIZE)
|
||||
{
|
||||
pszBuffer = (LPTSTR)cmd_realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
|
||||
GetEnvironmentVariable (_T("PATH"), pszBuffer, dwBuffer);
|
||||
}
|
||||
ConOutPrintf (_T("PATH=%s\n"), pszBuffer);
|
||||
cmd_free (pszBuffer);
|
||||
|
||||
ConOutPrintf (_T("PATH=%s\n"), pszBuffer);
|
||||
cmd_free (pszBuffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* skip leading '=' */
|
||||
if (*param == _T('='))
|
||||
param++;
|
||||
|
||||
/* skip leading '=' */
|
||||
if (*param == _T('='))
|
||||
param++;
|
||||
/* set PATH environment variable */
|
||||
if (!SetEnvironmentVariable (_T("PATH"), param))
|
||||
{
|
||||
nErrorLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* set PATH environment variable */
|
||||
if (!SetEnvironmentVariable (_T("PATH"), param))
|
||||
{
|
||||
nErrorLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,29 +30,28 @@
|
|||
* ?? Extend to include functionality of CHOICE if switch chars
|
||||
* specified.
|
||||
*
|
||||
* 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*/
|
||||
|
||||
INT cmd_pause (LPTSTR param)
|
||||
{
|
||||
TRACE ("cmd_pause: \'%s\')\n", debugstr_aw(param));
|
||||
|
||||
TRACE ("cmd_pause: \'%s\')\n", debugstr_aw(param));
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_PAUSE_HELP1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_PAUSE_HELP1);
|
||||
return 0;
|
||||
}
|
||||
if (*param)
|
||||
ConOutPrintf (param);
|
||||
else
|
||||
msg_pause ();
|
||||
|
||||
if (*param)
|
||||
ConOutPrintf (param);
|
||||
else
|
||||
msg_pause ();
|
||||
cgetchar ();
|
||||
|
||||
cgetchar ();
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue