mirror of
https://github.com/reactos/reactos.git
synced 2025-08-07 05:43:08 +00:00
Create a branch for network fixes.
svn path=/branches/aicom-network-fixes/; revision=34994
This commit is contained in:
parent
0e213bbc00
commit
c501d8112c
18148 changed files with 0 additions and 860488 deletions
139
base/applications/cmdutils/doskey/doskey.c
Normal file
139
base/applications/cmdutils/doskey/doskey.c
Normal file
|
@ -0,0 +1,139 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
|
||||
static VOID
|
||||
partstrlwr (LPTSTR str)
|
||||
{
|
||||
LPTSTR c = str;
|
||||
while (*c && !_istspace (*c) && *c != _T('='))
|
||||
{
|
||||
*c = _totlower (*c);
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
static VOID
|
||||
PrintAlias (VOID)
|
||||
{
|
||||
LPTSTR Aliases;
|
||||
LPTSTR ptr;
|
||||
DWORD len;
|
||||
|
||||
len = GetConsoleAliasesLength(_T("cmd.exe"));
|
||||
if (len <= 0)
|
||||
return;
|
||||
|
||||
/* allocate memory for an extra \0 char to make parsing easier */
|
||||
ptr = HeapAlloc(GetProcessHeap(), 0, (len + sizeof(TCHAR)));
|
||||
if (!ptr)
|
||||
return;
|
||||
|
||||
Aliases = ptr;
|
||||
|
||||
ZeroMemory(Aliases, len + sizeof(TCHAR));
|
||||
|
||||
if (GetConsoleAliases(Aliases, len, _T("cmd.exe")) != 0)
|
||||
{
|
||||
while (*Aliases != '\0')
|
||||
{
|
||||
_tprintf(_T("%s\n"), Aliases);
|
||||
Aliases = Aliases + lstrlen(Aliases);
|
||||
Aliases++;
|
||||
}
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0 , ptr);
|
||||
}
|
||||
|
||||
INT SetMacro (LPTSTR param)
|
||||
{
|
||||
LPTSTR ptr;
|
||||
|
||||
while (*param == _T(' '))
|
||||
param++;
|
||||
|
||||
/* error if no '=' found */
|
||||
if ((ptr = _tcschr (param, _T('='))) == 0)
|
||||
return 1;
|
||||
|
||||
while (*param == _T(' '))
|
||||
param++;
|
||||
|
||||
while (*ptr == _T(' '))
|
||||
ptr--;
|
||||
|
||||
/* Split rest into name and substitute */
|
||||
*ptr++ = _T('\0');
|
||||
|
||||
partstrlwr (param);
|
||||
|
||||
_tprintf(_T("%s, %s\n"), ptr, param);
|
||||
|
||||
if (ptr[0] == _T('\0'))
|
||||
AddConsoleAlias(param, NULL, _T("cmd.exe"));
|
||||
else
|
||||
AddConsoleAlias(param, ptr, _T("cmd.exe"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static VOID ReadFromFile(LPTSTR param)
|
||||
{
|
||||
FILE* fp;
|
||||
TCHAR line[MAX_PATH];
|
||||
|
||||
/* Skip the "/macrofile=" prefix */
|
||||
param += 11;
|
||||
|
||||
fp = _tfopen(param, _T("r"));
|
||||
|
||||
while ( _fgetts(line, MAX_PATH, fp) != NULL)
|
||||
SetMacro(line);
|
||||
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
_tmain (int argc, LPTSTR argv[])
|
||||
{
|
||||
if (argc < 2)
|
||||
return 0;
|
||||
|
||||
if (argv[1][0] == '/')
|
||||
{
|
||||
if (_tcsnicmp(argv[1], _T("/macrofile"), 10) == 0)
|
||||
ReadFromFile(argv[1]);
|
||||
if (_tcscmp(argv[1], _T("/macros")) == 0)
|
||||
PrintAlias();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get the full command line using GetCommandLine().
|
||||
We can't just pass argv[1] here, because then a parameter like "gotoroot=cd \" wouldn't be passed completely. */
|
||||
TCHAR* szCommandLine = GetCommandLine();
|
||||
|
||||
/* Skip the application name */
|
||||
if(*szCommandLine == '\"')
|
||||
{
|
||||
do
|
||||
{
|
||||
szCommandLine++;
|
||||
}
|
||||
while(*szCommandLine != '\"');
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
szCommandLine++;
|
||||
}
|
||||
while(*szCommandLine != ' ');
|
||||
}
|
||||
|
||||
/* Skip the trailing quotation mark/whitespace and pass the command line to SetMacro */
|
||||
SetMacro(++szCommandLine);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
9
base/applications/cmdutils/doskey/doskey.rbuild
Normal file
9
base/applications/cmdutils/doskey/doskey.rbuild
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
|
||||
<module name="doskey" type="win32cui" installbase="system32" installname="doskey.exe" unicode="yes">
|
||||
<define name="_WIN32_IE">0x0501</define>
|
||||
<define name="_WIN32_WINNT">0x0501</define>
|
||||
<library>kernel32</library>
|
||||
<file>doskey.c</file>
|
||||
<file>doskey.rc</file>
|
||||
</module>
|
7
base/applications/cmdutils/doskey/doskey.rc
Normal file
7
base/applications/cmdutils/doskey/doskey.rc
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id: find.rc 28350 2007-08-15 14:46:36Z fireball $ */
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "W32 doskey command\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "doskey\0"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "doskey.exe\0"
|
||||
#include <reactos/version.rc>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue