Author: cwittich
Date: Sun Feb 3 00:32:11 2008
New Revision: 32096
URL:
http://svn.reactos.org/svn/reactos?rev=32096&view=rev
Log:
support for adding and deleting macros
doskey macroname=command
doskey macroname=
Modified:
trunk/reactos/base/applications/cmdutils/doskey/doskey.c
Modified: trunk/reactos/base/applications/cmdutils/doskey/doskey.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
==============================================================================
--- trunk/reactos/base/applications/cmdutils/doskey/doskey.c (original)
+++ trunk/reactos/base/applications/cmdutils/doskey/doskey.c Sun Feb 3 00:32:11 2008
@@ -1,6 +1,17 @@
#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)
@@ -34,6 +45,29 @@
HeapFree(GetProcessHeap(), 0 , ptr);
}
+INT SetMacro (LPTSTR param)
+{
+ LPTSTR ptr;
+
+ /* error if no '=' found */
+ if ((ptr = _tcschr (param, _T('='))) == 0)
+ {
+ return 1;
+ }
+
+ /* Split rest into name and substitute */
+ *ptr++ = _T('\0');
+
+ partstrlwr (param);
+
+ if (ptr[0] == _T('\0'))
+ AddConsoleAlias(param, NULL, _T("cmd.exe"));
+ else
+ AddConsoleAlias(param, ptr, _T("cmd.exe"));
+
+ return 0;
+}
+
int
main (int argc, char **argv)
{
@@ -48,7 +82,7 @@
}
else
{
- /* FIXME */
+ SetMacro(argv[1]);
}