struct tagALIAS *next;
LPTSTR lpName;
LPTSTR lpSubst;
- WORD wUsed;
+ DWORD dwUsed;
} ALIAS, *LPALIAS;
static LPALIAS lpFirst = NULL;
static LPALIAS lpLast = NULL;
-static WORD wUsed = 0;
+static DWORD dwUsed = 0;
/* module internal functions */
/* it's necessary for recursive substitution */
partstrlwr (ptr->lpSubst);
- ptr->wUsed = 0;
+ ptr->dwUsed = 0;
/* Alias table must be sorted!
* Here a little example:
}
+VOID InitializeAlias (VOID)
+{
+ lpFirst = NULL;
+ lpLast = NULL;
+ dwUsed = 0;
+}
+
+VOID DestroyAlias (VOID)
+{
+ while (lpFirst->next != NULL)
+ {
+ lpLast = lpFirst;
+ lpFirst = lpLast->next;
+
+ free (lpLast->lpName);
+ free (lpLast->lpSubst);
+ free (lpLast);
+ }
+
+ free (lpFirst->lpName);
+ free (lpFirst->lpSubst);
+ free (lpFirst);
+
+ lpFirst = NULL;
+ lpLast = NULL;
+ dwUsed = 0;
+}
+
/* specified routines */
VOID ExpandAlias (LPTSTR cmd, INT maxlen)
{
short d = 1;
LPALIAS ptr = lpFirst;
- wUsed++;
- if (wUsed == 0)
+ dwUsed++;
+ if (dwUsed == 0)
{
while (ptr)
- ptr->wUsed = 0;
+ ptr->dwUsed = 0;
ptr = lpFirst;
- wUsed = 1;
+ dwUsed = 1;
}
/* skipping white spaces */
partstrlwr (&cmd[n]);
if (!_tcsncmp (&cmd[n], _T("NOALIAS"), 7) &&
- (_istspace (cmd[n + 7]) || cmd[n + 7] == _T('\0')))
+ (_istspace (cmd[n + 7]) || cmd[n + 7] == _T('\0')))
{
memmove (cmd, &cmd[n + 7], (_tcslen (&cmd[n + 7]) + 1) * sizeof (TCHAR));
return;
{
len = _tcslen (ptr->lpName);
if (!_tcsncmp (&cmd[n], ptr->lpName, len) &&
- (_istspace (cmd[n + len]) || cmd[n + len] == _T('\0')) &&
- ptr->wUsed != wUsed)
+ (_istspace (cmd[n + len]) || cmd[n + len] == _T('\0')) &&
+ ptr->dwUsed != dwUsed)
{
m = _tcslen (ptr->lpSubst);
if ((int)(_tcslen (cmd) - len + m - n) > maxlen)
memmove (&cmd[m], &cmd[n + len], (_tcslen(&cmd[n + len]) + 1) * sizeof (TCHAR));
for (i = 0; i < m; i++)
cmd[i] = ptr->lpSubst[i];
- ptr->wUsed = wUsed;
+ ptr->dwUsed = dwUsed;
/* whitespaces are removed! */
n = 0;
d = 1;
}
-VOID CommandAlias (LPTSTR cmd, LPTSTR param)
+INT CommandAlias (LPTSTR cmd, LPTSTR param)
{
LPTSTR ptr;
" ALIAS da="
// "Type ALIAS without a parameter to display the alias list.\n"
));
- return;
+ return 0;
}
if (param[0] == _T('\0'))
{
PrintAlias ();
- return;
+ return 0;
}
/* error if no '=' found */
if ((ptr = _tcschr (param, _T('='))) == 0)
- return;
+ return 1;
/* Split rest into name and substitute */
*ptr++ = _T('\0');
else
AddAlias (param, ptr);
- return;
+ return 0;
}
#endif
_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);
+ (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);
}
-INT cmd_attrib (LPTSTR cmd, LPTSTR param)
+INT CommandAttrib (LPTSTR cmd, LPTSTR param)
{
LPTSTR *arg;
INT argc, i;
if (argc == 0)
{
- DWORD len;
-
- len = GetCurrentDirectory (MAX_PATH, szPath);
- if (szPath[len-1] != _T('\\'))
- {
- szPath[len] = _T('\\');
- szPath[len + 1] = 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;
}
- else
+
+ /* get full file name */
+ for (i = 0; i < argc; i++)
{
- /* get full file name */
- for (i = 0; i < argc; i++)
+ if ((*arg[i] != _T('+')) && (*arg[i] != _T('-')) && (*arg[i] != _T('/')))
{
- 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);
- }
+ 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);
}
}
freep (arg);
-
return 0;
}
-/*
+/* $Id: batch.c,v 1.3 1999/10/03 22:20:32 ekohl Exp $
+ *
* BATCH.C - batch file processor for CMD.EXE.
*
*
}
-/* HBP_002 { FOR command support */
/*
* Batch_params builds a parameter list in newlay allocated memory.
* The parameters consist of null terminated strings with a final
return dp;
}
-/* HBP_002 } */
-
/*
* If a batch file is current, exits it, freeing the context block and
DebugPrintf ("ExitBatch: (\'%s\')\n", msg);
#endif
- if (bc)
+ if (bc != NULL)
{
LPBATCH_CONTEXT t = bc;
if (bc->params)
free(bc->params);
-/* HBP_002 { FOR command support */
-
if (bc->forproto)
free(bc->forproto);
if (bc->ffind)
free(bc->ffind);
-/* HBP_002 } */
-
-/* HBP_003 { fix echo restore */
/* Preserve echo state across batch calls */
bEcho = bc->bEcho;
-/* HBP_003 fix echo restore } */
-
bc = bc->prev;
free(t);
}
-/* HBP_001 } */
-
if (msg && *msg)
ConOutPrintf ("%s\n", msg);
}
return FALSE;
}
-/* HBP_002 { FOR command support */
-
/* Kill any and all FOR contexts */
while (bc && bc->forvar)
ExitBatch (NULL);
-/* HBP_002 } */
-
if (bc == NULL)
{
/* No curent batch file, create a new context */
if (n == NULL)
{
- /* JPP 20-Jul-1998 added error checking */
error_out_of_memory ();
return FALSE;
}
}
bc->hBatchFile = hFile;
- bc->bEcho = bEcho; /* Preserve echo across batch calls [HBP_001] */
+ bc->bEcho = bEcho; /* Preserve echo across batch calls */
bc->shiftlevel = 0;
- /* HBP_002 { FOR command support */
bc->ffind = NULL;
bc->forvar = _T('\0');
bc->forproto = NULL;
bc->params = BatchParams (firstword, param);
- /* HBP_002 } */
+
+#ifdef _DEBUG
+ DebugPrintf ("Batch: returns TRUE\n");
+#endif
return TRUE;
}
return NULL;
}
- /* HBP_002 { FOR command support */
/* No batch */
if (bc == NULL)
return NULL;
/* For first find, allocate a find first block */
if ((bc->ffind = (LPWIN32_FIND_DATA)malloc (sizeof (WIN32_FIND_DATA))) == NULL)
{
- error_out_of_memory(); /* JPP 20-Jul-1998 added error checking */
+ error_out_of_memory();
return NULL;
}
return textline;
}
- /* HBP_002 } */
-
if (!FileGetString (bc->hBatchFile, textline, sizeof (textline)))
{
#ifdef _DEBUG
return first;
}
+
+/* EOF */
-/*
+/* $Id: call.c,v 1.3 1999/10/03 22:20:33 ekohl Exp $
+ *
* CALL.C - call internal batch command.
*
*
return 0;
}
+
+/* EOF */
#include "cmd.h"
-VOID CommandChcp (LPTSTR cmd, LPTSTR param)
+INT CommandChcp (LPTSTR cmd, LPTSTR param)
{
LPTSTR *arg;
INT args;
+ UINT uOldCodePage;
+ UINT uNewCodePage;
/* print help */
if (!_tcsncmp (param, _T("/?"), 2))
"CHCP [nnn]\n\n"
" nnn Specifies the active code page number.\n\n"
"Type CHCP without a parameter to display the active code page number."));
- return;
+ return 0;
}
- /* get parameters */
- arg = split (param, &args);
-
if (args == 0)
{
/* display active code page number */
ConOutPrintf ("Active code page: %u\n", GetConsoleCP ());
+ return 0;
}
- else if (args >= 2)
+
+ if (args >= 2)
{
/* too many parameters */
ConErrPrintf ("Invalid parameter format - %s\n", param);
+ return 1;
+ }
+
+ /* get parameters */
+ arg = split (param, &args);
+
+ /* save old code page */
+ uOldCodePage = GetConsoleCP ();
+
+ uNewCodePage = (UINT)_ttoi (arg[0]);
+
+ if (uNewCodePage == 0)
+ {
+ ConErrPrintf ("Parameter format incorrect - %s\n", arg[0]);
+ freep (arg);
+ return 1;
+ }
+
+ if (!SetConsoleCP (uNewCodePage))
+ {
+ ConErrPrintf ("Invalid code page\n");
}
else
{
- /* set active code page number */
-
- UINT uOldCodePage;
- UINT uNewCodePage;
-
- /* save old code page */
- uOldCodePage = GetConsoleCP ();
-
- uNewCodePage = (UINT)_ttoi (arg[0]);
-
- if (uNewCodePage == 0)
- {
- ConErrPrintf ("Parameter format incorrect - %s\n", arg[0]);
-
- }
- else
- {
- if (!SetConsoleCP (uNewCodePage))
- {
- ConErrPrintf ("Invalid code page\n");
- }
- else
- {
- SetConsoleOutputCP (uNewCodePage);
- InitLocale ();
- }
- }
+ SetConsoleOutputCP (uNewCodePage);
+ InitLocale ();
}
freep (arg);
- return;
+ return 0;
}
#endif /* INCLUDE_CMD_CHCP */
\ No newline at end of file
hInput = GetStdHandle (STD_INPUT_HANDLE);
-#ifdef _DEBUG
- if (hInput == INVALID_HANDLE_VALUE)
- DebugPrintf ("Invalid input handle!!!\n");
-#endif
- //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);
-
- //if the event is a key pressed
- if ((lpBuffer.EventType == KEY_EVENT) &&
- (lpBuffer.Event.KeyEvent.bKeyDown == TRUE))
- {
- //read the key
+ //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);
+
+ //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
switch (GCret)
{
case GC_TIMEOUT:
-#ifdef DEBUG
+#ifdef _DEBUG
DebugPrintf (_T("GC_TIMEOUT\n"));
DebugPrintf (_T("elapsed %d msecs\n"), GetTickCount () - clk);
-#endif /* DEBUG */
+#endif /* _DEBUG */
break;
case GC_NOKEY:
-#ifdef DEBUG
+#ifdef _DEBUG
DebugPrintf(_T("GC_NOKEY\n"));
DebugPrintf(_T("elapsed %d msecs\n"), GetTickCount () - clk);
-#endif /* DEBUG */
+#endif /* _DEBUG */
goto loop;
case GC_KEYREAD:
-#ifdef DEBUG
+#ifdef _DEBUG
DebugPrintf(_T("GC_KEYREAD\n"));
DebugPrintf(_T("elapsed %d msecs\n"), GetTickCount () - clk);
DebugPrintf(_T("read %c"), Ch);
-#endif /* DEBUG */
+#endif /* _DEBUG */
if ((val=IsKeyInString(lpOptions,Ch,bCaseSensitive))==-1)
{
Beep (440, 50);
break;
}
-#ifdef DEBUG
- DebugPrintf(_T("exiting waiting loop after %d msecs\n"),
+#ifdef _DEBUG
+ DebugPrintf(_T("exiting wait loop after %d msecs\n"),
GetTickCount () - clk);
-#endif /* DEBUG */
+#endif /* _DEBUG */
val = IsKeyInString (lpOptions, cDefault, bCaseSensitive);
ConOutPrintf (_T("%c\n"), lpOptions[val]);
freep (arg);
-#ifdef DEBUG
+#ifdef _DEBUG
DebugPrintf (_T("ErrorLevel: %d\n"), nErrorLevel);
-#endif /* DEBUG */
+#endif /* _DEBUG */
return 0;
}
stui.dwFlags = STARTF_USESHOWWINDOW;
stui.wShowWindow = SW_SHOWDEFAULT;
-#ifndef __REACTOS__
+#ifndef __REACTOS__
if (CreateProcess (NULL, szFullCmdLine, NULL, NULL, FALSE,
0, NULL, NULL, &stui, &prci))
#else
* full input/output redirection and piping are supported
*/
-VOID ParseCommandLine (LPTSTR s)
+VOID ParseCommandLine (LPTSTR cmd)
{
+ TCHAR cmdline[CMDLINE_LENGTH];
+ LPTSTR s;
#ifdef FEATURE_REDIRECTION
TCHAR in[CMDLINE_LENGTH] = "";
TCHAR out[CMDLINE_LENGTH] = "";
HANDLE hOldConErr;
#endif /* FEATURE_REDIRECTION */
+ _tcscpy (cmdline, cmd);
+ s = &cmdline[0];
+
#ifdef _DEBUG
DebugPrintf ("ParseCommandLine: (\'%s\')]\n", s);
-#endif /* _DEBUG */
+#endif /* DEBUG */
#ifdef FEATURE_ALIASES
/* expand all aliases */
LPTSTR tp;
LPTSTR ip;
LPTSTR cp;
-
- /* JPP 19980807 - changed name so not to conflict with echo global */
BOOL bEchoThisLine;
do
* argv - command-line parameters
*
*/
-static VOID Initialize (int argc, char *argv[])
+static VOID
+Initialize (int argc, char *argv[])
{
+ TCHAR commandline[CMDLINE_LENGTH];
INT i;
/* Added by Rob Lake 06/16/98. This enables the command.com
hOut = GetStdHandle (STD_OUTPUT_HANDLE);
hIn = GetStdHandle (STD_INPUT_HANDLE);
+ if (argc >= 2 && !_tcsncmp (argv[1], _T("/?"), 2))
+ {
+ ConOutPuts (_T("Starts a new instance of the ReactOS command line interpreter\n\n"
+ "CMD [/P][/C]...\n\n"
+ " /P ...\n"
+ " /C ..."));
+ ExitProcess (0);
+ }
+
+ ShortVersion ();
+ ShowCommands ();
+
#ifdef INCLUDE_CMD_CHDIR
InitLastPath ();
#endif
+#ifdef FATURE_ALIASES
+ InitializeAlias ();
+#endif
+
if (argc >= 2)
{
- if (!_tcsncmp (argv[1], _T("/?"), 2))
- {
- ConOutPuts (_T("Starts a new instance of the ReactOS command line interpreter\n\n"
- "CMD [/P][/C]...\n\n"
- " /P ...\n"
- " /C ..."));
- ExitProcess (0);
- }
- else
+ for (i = 1; i < argc; i++)
{
- for (i = 1; i < argc; i++)
+ if (!_tcsicmp (argv[i], _T("/p")))
{
- if (!_tcsicmp (argv[i], _T("/p")))
+ if (!IsValidFileName (_T("\\autoexec.bat")))
{
- if (!IsValidFileName (_T("\\autoexec.bat")))
- {
#ifdef INCLUDE_CMD_DATE
- cmd_date ("", "");
+ cmd_date ("", "");
#endif
#ifdef INCLUDE_CMD_TIME
- cmd_time ("", "");
+ cmd_time ("", "");
#endif
- }
- else
- ParseCommandLine ("\\autoexec.bat");
- bCanExit = FALSE;
}
- else if (!_tcsicmp (argv[i], _T("/c")))
+ else
{
- /* This just runs a program and exits, RL: 06/16,21/98 */
- char commandline[CMDLINE_LENGTH];
- ++i;
- strcpy(commandline, argv[i]);
- while (argv[++i])
- {
- strcat(commandline, " ");
- strcat(commandline, argv[i]);
- }
-
- ParseCommandLine(commandline);
-
- /* HBP_003 { Fix return value when /C used }*/
- ExitProcess (ProcessInput (TRUE));
+ ParseCommandLine (_T("\\autoexec.bat"));
}
-
-#ifdef INCLUDE_CMD_COLOR
- else if (!_tcsnicmp (argv[i], _T("/t:"), 3))
+ bCanExit = FALSE;
+ }
+ else if (!_tcsicmp (argv[i], _T("/c")))
+ {
+ /* This just runs a program and exits, RL: 06/16,21/98 */
+ ++i;
+ _tcscpy (commandline, argv[i]);
+ while (argv[++i])
{
- /* process /t (color) argument */
- wDefColor = (WORD)strtoul (&argv[i][3], NULL, 16);
- wColor = wDefColor;
+ _tcscat (commandline, " ");
+ _tcscat (commandline, argv[i]);
}
-#endif
+
+ ParseCommandLine(commandline);
+ ExitProcess (ProcessInput (TRUE));
}
+
+#ifdef INCLUDE_CMD_COLOR
+ else if (!_tcsnicmp (argv[i], _T("/t:"), 3))
+ {
+ /* process /t (color) argument */
+ wDefColor = (WORD)strtoul (&argv[i][3], NULL, 16);
+ wColor = wDefColor;
+ SetScreenColor (wColor);
+ }
+#endif
+ }
+ }
+
+ /* run cmdstart.bat */
+ if (IsValidFileName (_T("cmdstart.bat")))
+ {
+ ParseCommandLine (_T("cmdstart.bat"));
+ }
+ else if (IsValidFileName (_T("\\cmdstart.bat")))
+ {
+ ParseCommandLine (_T("\\cmdstart.bat"));
+ }
+ else
+ {
+ /* try to run cmdstart.bat from install dir */
+ LPTSTR p;
+
+ _tcscpy (commandline, argv[0]);
+ p = _tcsrchr (commandline, _T('\\')) + 1;
+ _tcscpy (p, _T("cmdstart.bat"));
+
+ if (IsValidFileName (_T("commandline")))
+ {
+ ConErrPrintf ("Running %s...\n", commandline);
+ ParseCommandLine (commandline);
}
}
InitDirectoryStack ();
#endif
-#ifdef INCLUDE_CMD_COLOR
- /* set default colors */
- SetScreenColor (wColor);
-#endif
-
- ShortVersion ();
- ShowCommands ();
-
/* Set COMSPEC environment variable */
#ifndef __REACTOS__
if (argv)
}
-static VOID Cleanup (VOID)
+static VOID Cleanup (int argc, char *argv[])
{
+ /* run cmdexit.bat */
+ if (IsValidFileName (_T("cmdexit.bat")))
+ {
+ ConErrPrintf ("Running cmdexit.bat...\n");
+ ParseCommandLine (_T("cmdexit.bat"));
+ }
+ else if (IsValidFileName (_T("\\cmdexit.bat")))
+ {
+ ConErrPrintf ("Running \\cmdexit.bat...\n");
+ ParseCommandLine (_T("\\cmdexit.bat"));
+ }
+ else
+ {
+ /* try to run cmdexit.bat from install dir */
+ TCHAR commandline[CMDLINE_LENGTH];
+ LPTSTR p;
+
+ _tcscpy (commandline, argv[0]);
+ p = _tcsrchr (commandline, _T('\\')) + 1;
+ _tcscpy (p, _T("cmdexit.bat"));
+
+ if (IsValidFileName (_T("commandline")))
+ {
+ ConErrPrintf ("Running %s...\n", commandline);
+ ParseCommandLine (commandline);
+ }
+ }
+
+#ifdef FEATURE_ALIASES
+ DestroyAlias ();
+#endif
#ifdef FEATURE_DIECTORY_STACK
/* destroy directory stack */
nExitCode = ProcessInput (FALSE);
/* do the cleanup */
- Cleanup ();
+ Cleanup (argc, argv);
FreeConsole ();
return nExitCode;
extern SHORT maxy;
extern OSVERSIONINFO osvi;
-
void command(char *);
VOID ParseCommandLine (LPTSTR);
int c_brk(void);
-
-
/* Prototypes for ALIAS.C */
+VOID InitializeAlias (VOID);
+VOID DestroyAlias (VOID);
VOID ExpandAlias (LPTSTR, INT);
-VOID CommandAlias (LPTSTR, LPTSTR);
+INT CommandAlias (LPTSTR, LPTSTR);
/* Prototypes for ATTRIB.C */
-INT cmd_attrib (LPTSTR, LPTSTR);
+INT CommandAttrib (LPTSTR, LPTSTR);
/* Prototypes for BEEP.C */
/* Prototypes for CHCP.C */
-VOID CommandChcp (LPTSTR, LPTSTR);
+INT CommandChcp (LPTSTR, LPTSTR);
/* Prototypes for CHOICE.C */
VOID InitDirectoryStack (VOID);
VOID DestroyDirectoryStack (VOID);
INT GetDirectoryStackDepth (VOID);
-VOID CommandPushd (LPTSTR, LPTSTR);
-INT cmd_popd (LPTSTR, LPTSTR);
+INT CommandPushd (LPTSTR, LPTSTR);
+INT CommandPopd (LPTSTR, LPTSTR);
/* Prototypes for ECHO.C */
-INT cmd_echo (LPTSTR, LPTSTR);
+INT CommandEcho (LPTSTR, LPTSTR);
+INT CommandEchos (LPTSTR, LPTSTR);
+INT CommandEchoerr (LPTSTR, LPTSTR);
+INT CommandEchoserr (LPTSTR, LPTSTR);
/* Prototypes for ERROR.C */
INT cmd_chdir (LPTSTR, LPTSTR);
INT cmd_mkdir (LPTSTR, LPTSTR);
INT cmd_rmdir (LPTSTR, LPTSTR);
-INT internal_exit (LPTSTR, LPTSTR);
-VOID CommandRem (LPTSTR, LPTSTR);
-VOID CommandShowCommands (LPTSTR, LPTSTR);
+INT CommandExit (LPTSTR, LPTSTR);
+INT CommandRem (LPTSTR, LPTSTR);
+INT CommandShowCommands (LPTSTR, LPTSTR);
/* Prototypes for LABEL.C */
BOOL SearchForExecutable (LPCTSTR, LPTSTR);
/* Prototypes for WINDOW.C */
+INT CommandActivate (LPTSTR, LPTSTR);
INT CommandWindow (LPTSTR, LPTSTR);
SetCursorXY (orgx, orgy);
for (count = 0; count < (INT)_tcslen (str); count++)
ConOutChar (_T(' '));
-#ifndef __REACTOS__
_tcsnset (str, _T('\0'), maxlen);
-#else
- memset (str, 0, maxlen * sizeof(TCHAR));
-#endif
SetCursorXY (orgx, orgy);
}
{
{_T("?"), 0, CommandShowCommands},
+#ifdef INCLUDE_CMD_ACTIVATE
+ {_T("activate"), 0, CommandActivate},
+#endif
+
#ifdef FEATURE_ALIASES
{_T("alias"), 0, CommandAlias},
#endif
#ifdef INCLUDE_CMD_ATTRIB
- {_T("attrib"), 0, cmd_attrib},
+ {_T("attrib"), 0, CommandAttrib},
#endif
#ifdef INCLUDE_CMD_BEEP
{_T("dir"), CMD_SPECIAL, cmd_dir},
#endif
- {_T("echo"), 0, cmd_echo},
+ {_T("echo"), 0, CommandEcho},
+ {_T("echos"), 0, CommandEchos},
+ {_T("echoerr"), 0, CommandEchoerr},
+ {_T("echoserr"), 0, CommandEchoserr},
#ifdef INCLUDE_CMD_DEL
{_T("erase"), 0, cmd_del},
#endif
- {_T("exit"), 0, internal_exit},
+ {_T("exit"), 0, CommandExit},
{_T("for"), 0, cmd_for},
#endif
#ifdef FEATURE_DIRECTORY_STACK
- {_T("popd"), 0, cmd_popd},
+ {_T("popd"), 0, CommandPopd},
#endif
#ifdef INCLUDE_CMD_PROMPT
#endif
#ifdef INCLUDE_CMD_WINDOW
- {_T("window"), 0, CommandWindow},
+ {_T("window"), 0, CommandWindow},
#endif
{NULL, 0, NULL}
#endif /* __REACTOS__ */
-/* JPP 20 Jul 1998 - define DEBUG to add debugging code */
-/*#define DEBUG */
+/* JPP 20 Jul 1998 - define _DEBUG to add debugging code */
+/* #define _DEBUG */
/* Define to enable the alias command, and aliases.*/
/* #define LOCALE_DEFAULT */ /* United States locale */
#endif
+#ifndef __REACTOS__
+#define INCLUDE_CMD_ACTIVATE
+#endif
#define INCLUDE_CMD_ATTRIB
/*#define INCLUDE_CMD_BREAK*/
#define INCLUDE_CMD_CHCP
-/*
+/* $Id: console.c,v 1.10 1999/10/03 22:20:33 ekohl Exp $
+ *
* CONSOLE.C - console input/output functions.
*
*
_vstprintf (szOut, szFormat, arg_ptr);
va_end (arg_ptr);
- WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szOut, _tcslen(szOut), &dwWritten, NULL);
+ WriteFile (GetStdHandle (STD_OUTPUT_HANDLE),
+ szOut,
+ _tcslen(szOut) * sizeof(TCHAR),
+ &dwWritten,
+ NULL);
#if 0
OutputDebugString (szOut);
#endif
#ifdef _DEBUG
if (hInput == INVALID_HANDLE_VALUE)
DebugPrintf ("Invalid input handle!!!\n");
-#endif
+#endif /* _DEBUG */
ReadConsoleInput (hInput, &dummy, 1, &dwRead);
}
#ifdef _DEBUG
if (hInput == INVALID_HANDLE_VALUE)
DebugPrintf ("Invalid input handle!!!\n");
-#endif
+#endif /* _DEBUG */
do
{
{
DWORD dwWritten;
- WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), &c, 1, &dwWritten, NULL);
+ WriteFile (GetStdHandle (STD_OUTPUT_HANDLE),
+ &c,
+ sizeof(TCHAR),
+ &dwWritten,
+ NULL);
}
{
DWORD dwWritten;
- WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szText, _tcslen(szText), &dwWritten, NULL);
-#if 0
- WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL);
-#endif
- WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\n", 1, &dwWritten, NULL);
+ WriteFile (GetStdHandle (STD_OUTPUT_HANDLE),
+ szText,
+ _tcslen(szText) * sizeof(TCHAR),
+ &dwWritten,
+ NULL);
+ WriteFile (GetStdHandle (STD_OUTPUT_HANDLE),
+ _T("\n"),
+ sizeof(TCHAR),
+ &dwWritten,
+ NULL);
}
VOID ConOutPrintf (LPTSTR szFormat, ...)
{
+ TCHAR szOut[OUTPUT_BUFFER_SIZE];
DWORD dwWritten;
- TCHAR szOut[OUTPUT_BUFFER_SIZE];
va_list arg_ptr;
va_start (arg_ptr, szFormat);
_vstprintf (szOut, szFormat, arg_ptr);
va_end (arg_ptr);
- WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szOut, _tcslen(szOut), &dwWritten, NULL);
+ WriteFile (GetStdHandle (STD_OUTPUT_HANDLE),
+ szOut,
+ _tcslen(szOut) * sizeof(TCHAR),
+ &dwWritten,
+ NULL);
}
{
DWORD dwWritten;
- WriteFile (GetStdHandle (STD_ERROR_HANDLE), &c, 1, &dwWritten, NULL);
+ WriteFile (GetStdHandle (STD_ERROR_HANDLE),
+ &c,
+ sizeof(TCHAR),
+ &dwWritten,
+ NULL);
}
{
DWORD dwWritten;
- WriteFile (GetStdHandle (STD_ERROR_HANDLE), szText, _tcslen(szText), &dwWritten, NULL);
-#if 0
- WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL);
-#endif
- WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\n", 1, &dwWritten, NULL);
+ WriteFile (GetStdHandle (STD_ERROR_HANDLE),
+ szText,
+ _tcslen(szText) * sizeof(TCHAR),
+ &dwWritten,
+ NULL);
+ WriteFile (GetStdHandle (STD_ERROR_HANDLE),
+ _T ("\n"),
+ sizeof(TCHAR),
+ &dwWritten,
+ NULL);
}
VOID ConErrPrintf (LPTSTR szFormat, ...)
{
+ TCHAR szOut[OUTPUT_BUFFER_SIZE];
DWORD dwWritten;
- TCHAR szOut[OUTPUT_BUFFER_SIZE];
va_list arg_ptr;
va_start (arg_ptr, szFormat);
_vstprintf (szOut, szFormat, arg_ptr);
va_end (arg_ptr);
- WriteFile (GetStdHandle (STD_ERROR_HANDLE), szOut, _tcslen(szOut), &dwWritten, NULL);
+ WriteFile (GetStdHandle (STD_ERROR_HANDLE),
+ szOut,
+ _tcslen(szOut) * sizeof(TCHAR),
+ &dwWritten,
+ NULL);
}
SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci);
}
+
+/* EOF */
\ No newline at end of file
* clone from 4nt delay command
*
* 30 Aug 1999
- * started - Dr.F <dfaustus@freemail.it>
+ * started - Paolo Pantaleo <paolopan@freemail.it>
*
*
*/
/*
* pushd command
*/
-VOID CommandPushd (LPTSTR first, LPTSTR rest)
+INT CommandPushd (LPTSTR first, LPTSTR rest)
{
TCHAR curPath[MAX_PATH];
TCHAR newPath[MAX_PATH];
if (!_tcsncmp (rest, _T("/?"), 2))
{
ConOutPuts (_T("Stores the current directory for use by the POPD command, then\n"
- "changes to the specified directory.\n\n"
- "PUSHD [path | ..]\n\n"
- " path Specifies the directory to make the current directory"));
- return;
+ "changes to the specified directory.\n\n"
+ "PUSHD [path | ..]\n\n"
+ " path Specifies the directory to make the current directory"));
+ return 0;
}
if (rest[0] != _T('\0'))
GetCurrentDirectory (MAX_PATH, curPath);
if (PushDirectory (curPath))
- return;
+ return 0;
if (bChangePath)
SetCurrentDirectory (newPath);
- return;
+ return 0;
}
/*
* popd command
*/
-INT cmd_popd (LPTSTR first, LPTSTR rest)
+INT CommandPopd (LPTSTR first, LPTSTR rest)
{
TCHAR szPath[MAX_PATH];
if (!_tcsncmp(rest, _T("/?"), 2))
{
ConOutPuts (_T("Changes to the directory stored by the PUSHD command.\n\n"
- "POPD"));
+ "POPD"));
return 0;
}
* set the exitflag to true
*
*/
-INT internal_exit (LPTSTR cmd, LPTSTR param)
+INT CommandExit (LPTSTR cmd, LPTSTR param)
{
if (!_tcsncmp (param, _T("/?"), 2))
{
ConOutPuts (_T("Exits the command line interpreter.\n\nEXIT"));
- }
- else
- {
- bExit = TRUE;
+ return 0;
}
+ bExit = TRUE;
return 0;
}
* does nothing
*
*/
-VOID CommandRem (LPTSTR cmd, LPTSTR param)
+INT CommandRem (LPTSTR cmd, LPTSTR param)
{
if (!_tcsncmp (param, _T("/?"), 2))
{
"REM [Comment]"));
}
- return;
+ return 0;
}
#endif /* INCLUDE_CMD_REM */
-VOID CommandShowCommands (LPTSTR cmd, LPTSTR param)
+INT CommandShowCommands (LPTSTR cmd, LPTSTR param)
{
LPCOMMAND cmdptr;
INT y;
if (y != 0)
ConOutChar (_T('\n'));
- return;
+ return 0;
}
/* EOF */
\ No newline at end of file
endif
include ../rules.mak
+
+# EOF
while ((--nBufferLength > 0) &&
ReadFile(hFile, &ch, 1, &dwRead, NULL) && dwRead)
{
- *lpString++ = ch;
if (ch == _T('\r'))
{
/* overread '\n' */
ReadFile (hFile, &ch, 1, &dwRead, NULL);
break;
}
+ *lpString++ = ch;
}
if (!dwRead && lpString == lpBuffer)
* clone from 4nt msgbox command
*
* 25 Aug 1999
- * started - Dr.F <dfaustus@freemail.it>
+ * started - Paolo Pantaleo <paolopan@freemail.it>
*/
#include "config.h"
* clone from 4nt msgbox command
*
* 30 Aug 1999
- * started - Dr.F <dfaustus@freemail.it>
+ * started - Paolo Pantaleo <paolopan@freemail.it>
*
*
*/
* clone from 4nt timer command
*
* 20 Aug 1999
- * started - Dr.F <dfaustus@freemail.it>
+ * started - Paolo Pantaleo <paolopan@freemail.it>
*/
#include "config.h"