Minor fixes.

svn path=/trunk/; revision=685
This commit is contained in:
Eric Kohl 1999-10-03 22:20:33 +00:00
parent 49f51f37f3
commit c2829c9869
20 changed files with 372 additions and 264 deletions

View file

@ -45,13 +45,13 @@ typedef struct tagALIAS
struct tagALIAS *next; struct tagALIAS *next;
LPTSTR lpName; LPTSTR lpName;
LPTSTR lpSubst; LPTSTR lpSubst;
WORD wUsed; DWORD dwUsed;
} ALIAS, *LPALIAS; } ALIAS, *LPALIAS;
static LPALIAS lpFirst = NULL; static LPALIAS lpFirst = NULL;
static LPALIAS lpLast = NULL; static LPALIAS lpLast = NULL;
static WORD wUsed = 0; static DWORD dwUsed = 0;
/* module internal functions */ /* module internal functions */
@ -159,7 +159,7 @@ AddAlias (LPTSTR name, LPTSTR subst)
/* it's necessary for recursive substitution */ /* it's necessary for recursive substitution */
partstrlwr (ptr->lpSubst); partstrlwr (ptr->lpSubst);
ptr->wUsed = 0; ptr->dwUsed = 0;
/* Alias table must be sorted! /* Alias table must be sorted!
* Here a little example: * Here a little example:
@ -208,6 +208,34 @@ AddAlias (LPTSTR name, LPTSTR subst)
} }
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 */ /* specified routines */
VOID ExpandAlias (LPTSTR cmd, INT maxlen) VOID ExpandAlias (LPTSTR cmd, INT maxlen)
{ {
@ -218,13 +246,13 @@ VOID ExpandAlias (LPTSTR cmd, INT maxlen)
short d = 1; short d = 1;
LPALIAS ptr = lpFirst; LPALIAS ptr = lpFirst;
wUsed++; dwUsed++;
if (wUsed == 0) if (dwUsed == 0)
{ {
while (ptr) while (ptr)
ptr->wUsed = 0; ptr->dwUsed = 0;
ptr = lpFirst; ptr = lpFirst;
wUsed = 1; dwUsed = 1;
} }
/* skipping white spaces */ /* skipping white spaces */
@ -234,7 +262,7 @@ VOID ExpandAlias (LPTSTR cmd, INT maxlen)
partstrlwr (&cmd[n]); partstrlwr (&cmd[n]);
if (!_tcsncmp (&cmd[n], _T("NOALIAS"), 7) && 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)); memmove (cmd, &cmd[n + 7], (_tcslen (&cmd[n + 7]) + 1) * sizeof (TCHAR));
return; return;
@ -248,8 +276,8 @@ VOID ExpandAlias (LPTSTR cmd, INT maxlen)
{ {
len = _tcslen (ptr->lpName); len = _tcslen (ptr->lpName);
if (!_tcsncmp (&cmd[n], ptr->lpName, len) && if (!_tcsncmp (&cmd[n], ptr->lpName, len) &&
(_istspace (cmd[n + len]) || cmd[n + len] == _T('\0')) && (_istspace (cmd[n + len]) || cmd[n + len] == _T('\0')) &&
ptr->wUsed != wUsed) ptr->dwUsed != dwUsed)
{ {
m = _tcslen (ptr->lpSubst); m = _tcslen (ptr->lpSubst);
if ((int)(_tcslen (cmd) - len + m - n) > maxlen) if ((int)(_tcslen (cmd) - len + m - n) > maxlen)
@ -263,7 +291,7 @@ VOID ExpandAlias (LPTSTR cmd, INT maxlen)
memmove (&cmd[m], &cmd[n + len], (_tcslen(&cmd[n + len]) + 1) * sizeof (TCHAR)); memmove (&cmd[m], &cmd[n + len], (_tcslen(&cmd[n + len]) + 1) * sizeof (TCHAR));
for (i = 0; i < m; i++) for (i = 0; i < m; i++)
cmd[i] = ptr->lpSubst[i]; cmd[i] = ptr->lpSubst[i];
ptr->wUsed = wUsed; ptr->dwUsed = dwUsed;
/* whitespaces are removed! */ /* whitespaces are removed! */
n = 0; n = 0;
d = 1; d = 1;
@ -275,7 +303,7 @@ VOID ExpandAlias (LPTSTR cmd, INT maxlen)
} }
VOID CommandAlias (LPTSTR cmd, LPTSTR param) INT CommandAlias (LPTSTR cmd, LPTSTR param)
{ {
LPTSTR ptr; LPTSTR ptr;
@ -297,18 +325,18 @@ VOID CommandAlias (LPTSTR cmd, LPTSTR param)
" ALIAS da=" " ALIAS da="
// "Type ALIAS without a parameter to display the alias list.\n" // "Type ALIAS without a parameter to display the alias list.\n"
)); ));
return; return 0;
} }
if (param[0] == _T('\0')) if (param[0] == _T('\0'))
{ {
PrintAlias (); PrintAlias ();
return; return 0;
} }
/* error if no '=' found */ /* error if no '=' found */
if ((ptr = _tcschr (param, _T('='))) == 0) if ((ptr = _tcschr (param, _T('='))) == 0)
return; return 1;
/* Split rest into name and substitute */ /* Split rest into name and substitute */
*ptr++ = _T('\0'); *ptr++ = _T('\0');
@ -320,6 +348,6 @@ VOID CommandAlias (LPTSTR cmd, LPTSTR param)
else else
AddAlias (param, ptr); AddAlias (param, ptr);
return; return 0;
} }
#endif #endif

View file

@ -102,11 +102,11 @@ PrintAttribute (LPTSTR pszPath, LPTSTR pszFile, BOOL bRecurse)
_tcscpy (pszFileName, findData.cFileName); _tcscpy (pszFileName, findData.cFileName);
ConOutPrintf (_T("%c %c%c%c %s\n"), ConOutPrintf (_T("%c %c%c%c %s\n"),
(findData.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) ? _T('A') : _T(' '), (findData.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) ? _T('A') : _T(' '),
(findData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) ? _T('S') : _T(' '), (findData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) ? _T('S') : _T(' '),
(findData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ? _T('H') : _T(' '), (findData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ? _T('H') : _T(' '),
(findData.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? _T('R') : _T(' '), (findData.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? _T('R') : _T(' '),
szFullName); szFullName);
} }
while (FindNextFile (hFind, &findData)); while (FindNextFile (hFind, &findData));
FindClose (hFind); FindClose (hFind);
@ -189,7 +189,7 @@ ChangeAttribute (LPTSTR pszPath, LPTSTR pszFile, DWORD dwMask,
} }
INT cmd_attrib (LPTSTR cmd, LPTSTR param) INT CommandAttrib (LPTSTR cmd, LPTSTR param)
{ {
LPTSTR *arg; LPTSTR *arg;
INT argc, i; INT argc, i;
@ -316,41 +316,40 @@ INT cmd_attrib (LPTSTR cmd, LPTSTR param)
if (argc == 0) if (argc == 0)
{ {
DWORD len; DWORD len;
len = GetCurrentDirectory (MAX_PATH, szPath); len = GetCurrentDirectory (MAX_PATH, szPath);
if (szPath[len-1] != _T('\\')) if (szPath[len-1] != _T('\\'))
{ {
szPath[len] = _T('\\'); szPath[len] = _T('\\');
szPath[len + 1] = 0; szPath[len + 1] = 0;
} }
_tcscpy (szFileName, _T("*.*")); _tcscpy (szFileName, _T("*.*"));
PrintAttribute (szPath, szFileName, bRecurse); PrintAttribute (szPath, szFileName, bRecurse);
freep (arg);
return 0;
} }
else
{
/* 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) /* get full file name */
PrintAttribute (szPath, szFileName, bRecurse); for (i = 0; i < argc; i++)
else {
ChangeAttribute (szPath, szFileName, dwMask, if ((*arg[i] != _T('+')) && (*arg[i] != _T('-')) && (*arg[i] != _T('/')))
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); freep (arg);
return 0; return 0;
} }

View file

@ -1,4 +1,5 @@
/* /* $Id: batch.c,v 1.3 1999/10/03 22:20:32 ekohl Exp $
*
* BATCH.C - batch file processor for CMD.EXE. * BATCH.C - batch file processor for CMD.EXE.
* *
* *
@ -107,7 +108,6 @@ LPTSTR FindArg (INT n)
} }
/* HBP_002 { FOR command support */
/* /*
* Batch_params builds a parameter list in newlay allocated memory. * Batch_params builds a parameter list in newlay allocated memory.
* The parameters consist of null terminated strings with a final * The parameters consist of null terminated strings with a final
@ -163,8 +163,6 @@ LPTSTR BatchParams (LPTSTR s1, LPTSTR s2)
return dp; return dp;
} }
/* HBP_002 } */
/* /*
* If a batch file is current, exits it, freeing the context block and * If a batch file is current, exits it, freeing the context block and
@ -182,7 +180,7 @@ VOID ExitBatch (LPTSTR msg)
DebugPrintf ("ExitBatch: (\'%s\')\n", msg); DebugPrintf ("ExitBatch: (\'%s\')\n", msg);
#endif #endif
if (bc) if (bc != NULL)
{ {
LPBATCH_CONTEXT t = bc; LPBATCH_CONTEXT t = bc;
@ -195,28 +193,19 @@ VOID ExitBatch (LPTSTR msg)
if (bc->params) if (bc->params)
free(bc->params); free(bc->params);
/* HBP_002 { FOR command support */
if (bc->forproto) if (bc->forproto)
free(bc->forproto); free(bc->forproto);
if (bc->ffind) if (bc->ffind)
free(bc->ffind); free(bc->ffind);
/* HBP_002 } */
/* HBP_003 { fix echo restore */
/* Preserve echo state across batch calls */ /* Preserve echo state across batch calls */
bEcho = bc->bEcho; bEcho = bc->bEcho;
/* HBP_003 fix echo restore } */
bc = bc->prev; bc = bc->prev;
free(t); free(t);
} }
/* HBP_001 } */
if (msg && *msg) if (msg && *msg)
ConOutPrintf ("%s\n", msg); ConOutPrintf ("%s\n", msg);
} }
@ -248,14 +237,10 @@ BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param)
return FALSE; return FALSE;
} }
/* HBP_002 { FOR command support */
/* Kill any and all FOR contexts */ /* Kill any and all FOR contexts */
while (bc && bc->forvar) while (bc && bc->forvar)
ExitBatch (NULL); ExitBatch (NULL);
/* HBP_002 } */
if (bc == NULL) if (bc == NULL)
{ {
/* No curent batch file, create a new context */ /* No curent batch file, create a new context */
@ -263,7 +248,6 @@ BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param)
if (n == NULL) if (n == NULL)
{ {
/* JPP 20-Jul-1998 added error checking */
error_out_of_memory (); error_out_of_memory ();
return FALSE; return FALSE;
} }
@ -280,15 +264,17 @@ BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param)
} }
bc->hBatchFile = hFile; bc->hBatchFile = hFile;
bc->bEcho = bEcho; /* Preserve echo across batch calls [HBP_001] */ bc->bEcho = bEcho; /* Preserve echo across batch calls */
bc->shiftlevel = 0; bc->shiftlevel = 0;
/* HBP_002 { FOR command support */
bc->ffind = NULL; bc->ffind = NULL;
bc->forvar = _T('\0'); bc->forvar = _T('\0');
bc->forproto = NULL; bc->forproto = NULL;
bc->params = BatchParams (firstword, param); bc->params = BatchParams (firstword, param);
/* HBP_002 } */
#ifdef _DEBUG
DebugPrintf ("Batch: returns TRUE\n");
#endif
return TRUE; return TRUE;
} }
@ -330,7 +316,6 @@ LPTSTR ReadBatchLine (LPBOOL bLocalEcho)
return NULL; return NULL;
} }
/* HBP_002 { FOR command support */
/* No batch */ /* No batch */
if (bc == NULL) if (bc == NULL)
return NULL; return NULL;
@ -368,7 +353,7 @@ LPTSTR ReadBatchLine (LPBOOL bLocalEcho)
/* For first find, allocate a find first block */ /* For first find, allocate a find first block */
if ((bc->ffind = (LPWIN32_FIND_DATA)malloc (sizeof (WIN32_FIND_DATA))) == NULL) 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 NULL;
} }
@ -409,8 +394,6 @@ LPTSTR ReadBatchLine (LPBOOL bLocalEcho)
return textline; return textline;
} }
/* HBP_002 } */
if (!FileGetString (bc->hBatchFile, textline, sizeof (textline))) if (!FileGetString (bc->hBatchFile, textline, sizeof (textline)))
{ {
#ifdef _DEBUG #ifdef _DEBUG
@ -459,3 +442,5 @@ LPTSTR ReadBatchLine (LPBOOL bLocalEcho)
return first; return first;
} }
/* EOF */

View file

@ -1,4 +1,5 @@
/* /* $Id: call.c,v 1.3 1999/10/03 22:20:33 ekohl Exp $
*
* CALL.C - call internal batch command. * CALL.C - call internal batch command.
* *
* *
@ -90,3 +91,5 @@ INT cmd_call (LPTSTR cmd, LPTSTR param)
return 0; return 0;
} }
/* EOF */

View file

@ -21,10 +21,12 @@
#include "cmd.h" #include "cmd.h"
VOID CommandChcp (LPTSTR cmd, LPTSTR param) INT CommandChcp (LPTSTR cmd, LPTSTR param)
{ {
LPTSTR *arg; LPTSTR *arg;
INT args; INT args;
UINT uOldCodePage;
UINT uNewCodePage;
/* print help */ /* print help */
if (!_tcsncmp (param, _T("/?"), 2)) if (!_tcsncmp (param, _T("/?"), 2))
@ -33,56 +35,51 @@ VOID CommandChcp (LPTSTR cmd, LPTSTR param)
"CHCP [nnn]\n\n" "CHCP [nnn]\n\n"
" nnn Specifies the active code page number.\n\n" " nnn Specifies the active code page number.\n\n"
"Type CHCP without a parameter to display the active code page number.")); "Type CHCP without a parameter to display the active code page number."));
return; return 0;
} }
/* get parameters */
arg = split (param, &args);
if (args == 0) if (args == 0)
{ {
/* display active code page number */ /* display active code page number */
ConOutPrintf ("Active code page: %u\n", GetConsoleCP ()); ConOutPrintf ("Active code page: %u\n", GetConsoleCP ());
return 0;
} }
else if (args >= 2)
if (args >= 2)
{ {
/* too many parameters */ /* too many parameters */
ConErrPrintf ("Invalid parameter format - %s\n", param); 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 else
{ {
/* set active code page number */ SetConsoleOutputCP (uNewCodePage);
InitLocale ();
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 ();
}
}
} }
freep (arg); freep (arg);
return; return 0;
} }
#endif /* INCLUDE_CMD_CHCP */ #endif /* INCLUDE_CMD_CHCP */

View file

@ -52,32 +52,28 @@ GetCharacterTimeout (LPTCH ch, DWORD dwMilliseconds)
hInput = GetStdHandle (STD_INPUT_HANDLE); hInput = GetStdHandle (STD_INPUT_HANDLE);
#ifdef _DEBUG //if the timeout experied return GC_TIMEOUT
if (hInput == INVALID_HANDLE_VALUE) if (WaitForSingleObject (hInput, dwMilliseconds) == WAIT_TIMEOUT)
DebugPrintf ("Invalid input handle!!!\n"); return GC_TIMEOUT;
#endif
//if the timeout experied return GC_TIMEOUT
if (WaitForSingleObject (hInput, dwMilliseconds) == WAIT_TIMEOUT)
return GC_TIMEOUT;
//otherwise get the event //otherwise get the event
ReadConsoleInput (hInput, &lpBuffer, 1, &dwRead); ReadConsoleInput (hInput, &lpBuffer, 1, &dwRead);
//if the event is a key pressed //if the event is a key pressed
if ((lpBuffer.EventType == KEY_EVENT) && if ((lpBuffer.EventType == KEY_EVENT) &&
(lpBuffer.Event.KeyEvent.bKeyDown == TRUE)) (lpBuffer.Event.KeyEvent.bKeyDown == TRUE))
{ {
//read the key //read the key
#ifdef _UNICODE #ifdef _UNICODE
*ch = lpBuffer.Event.KeyEvent.uChar.UnicodeChar; *ch = lpBuffer.Event.KeyEvent.uChar.UnicodeChar;
#else #else
*ch = lpBuffer.Event.KeyEvent.uChar.AsciiChar; *ch = lpBuffer.Event.KeyEvent.uChar.AsciiChar;
#endif #endif
return GC_KEYREAD; return GC_KEYREAD;
} }
//else return no key //else return no key
return GC_NOKEY; return GC_NOKEY;
} }
static INT static INT
@ -284,25 +280,25 @@ loop:
switch (GCret) switch (GCret)
{ {
case GC_TIMEOUT: case GC_TIMEOUT:
#ifdef DEBUG #ifdef _DEBUG
DebugPrintf (_T("GC_TIMEOUT\n")); DebugPrintf (_T("GC_TIMEOUT\n"));
DebugPrintf (_T("elapsed %d msecs\n"), GetTickCount () - clk); DebugPrintf (_T("elapsed %d msecs\n"), GetTickCount () - clk);
#endif /* DEBUG */ #endif /* _DEBUG */
break; break;
case GC_NOKEY: case GC_NOKEY:
#ifdef DEBUG #ifdef _DEBUG
DebugPrintf(_T("GC_NOKEY\n")); DebugPrintf(_T("GC_NOKEY\n"));
DebugPrintf(_T("elapsed %d msecs\n"), GetTickCount () - clk); DebugPrintf(_T("elapsed %d msecs\n"), GetTickCount () - clk);
#endif /* DEBUG */ #endif /* _DEBUG */
goto loop; goto loop;
case GC_KEYREAD: case GC_KEYREAD:
#ifdef DEBUG #ifdef _DEBUG
DebugPrintf(_T("GC_KEYREAD\n")); DebugPrintf(_T("GC_KEYREAD\n"));
DebugPrintf(_T("elapsed %d msecs\n"), GetTickCount () - clk); DebugPrintf(_T("elapsed %d msecs\n"), GetTickCount () - clk);
DebugPrintf(_T("read %c"), Ch); DebugPrintf(_T("read %c"), Ch);
#endif /* DEBUG */ #endif /* _DEBUG */
if ((val=IsKeyInString(lpOptions,Ch,bCaseSensitive))==-1) if ((val=IsKeyInString(lpOptions,Ch,bCaseSensitive))==-1)
{ {
Beep (440, 50); Beep (440, 50);
@ -312,10 +308,10 @@ loop:
break; break;
} }
#ifdef DEBUG #ifdef _DEBUG
DebugPrintf(_T("exiting waiting loop after %d msecs\n"), DebugPrintf(_T("exiting wait loop after %d msecs\n"),
GetTickCount () - clk); GetTickCount () - clk);
#endif /* DEBUG */ #endif /* _DEBUG */
val = IsKeyInString (lpOptions, cDefault, bCaseSensitive); val = IsKeyInString (lpOptions, cDefault, bCaseSensitive);
ConOutPrintf (_T("%c\n"), lpOptions[val]); ConOutPrintf (_T("%c\n"), lpOptions[val]);
@ -324,9 +320,9 @@ loop:
freep (arg); freep (arg);
#ifdef DEBUG #ifdef _DEBUG
DebugPrintf (_T("ErrorLevel: %d\n"), nErrorLevel); DebugPrintf (_T("ErrorLevel: %d\n"), nErrorLevel);
#endif /* DEBUG */ #endif /* _DEBUG */
return 0; return 0;
} }

View file

@ -219,7 +219,7 @@ Execute (LPTSTR first, LPTSTR rest)
stui.dwFlags = STARTF_USESHOWWINDOW; stui.dwFlags = STARTF_USESHOWWINDOW;
stui.wShowWindow = SW_SHOWDEFAULT; stui.wShowWindow = SW_SHOWDEFAULT;
#ifndef __REACTOS__ #ifndef __REACTOS__
if (CreateProcess (NULL, szFullCmdLine, NULL, NULL, FALSE, if (CreateProcess (NULL, szFullCmdLine, NULL, NULL, FALSE,
0, NULL, NULL, &stui, &prci)) 0, NULL, NULL, &stui, &prci))
#else #else
@ -332,8 +332,10 @@ DoCommand (LPTSTR line)
* full input/output redirection and piping are supported * 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 #ifdef FEATURE_REDIRECTION
TCHAR in[CMDLINE_LENGTH] = ""; TCHAR in[CMDLINE_LENGTH] = "";
TCHAR out[CMDLINE_LENGTH] = ""; TCHAR out[CMDLINE_LENGTH] = "";
@ -350,9 +352,12 @@ VOID ParseCommandLine (LPTSTR s)
HANDLE hOldConErr; HANDLE hOldConErr;
#endif /* FEATURE_REDIRECTION */ #endif /* FEATURE_REDIRECTION */
_tcscpy (cmdline, cmd);
s = &cmdline[0];
#ifdef _DEBUG #ifdef _DEBUG
DebugPrintf ("ParseCommandLine: (\'%s\')]\n", s); DebugPrintf ("ParseCommandLine: (\'%s\')]\n", s);
#endif /* _DEBUG */ #endif /* DEBUG */
#ifdef FEATURE_ALIASES #ifdef FEATURE_ALIASES
/* expand all aliases */ /* expand all aliases */
@ -658,8 +663,6 @@ ProcessInput (BOOL bFlag)
LPTSTR tp; LPTSTR tp;
LPTSTR ip; LPTSTR ip;
LPTSTR cp; LPTSTR cp;
/* JPP 19980807 - changed name so not to conflict with echo global */
BOOL bEchoThisLine; BOOL bEchoThisLine;
do do
@ -835,8 +838,10 @@ ShowCommands (VOID)
* argv - command-line parameters * argv - command-line parameters
* *
*/ */
static VOID Initialize (int argc, char *argv[]) static VOID
Initialize (int argc, char *argv[])
{ {
TCHAR commandline[CMDLINE_LENGTH];
INT i; INT i;
/* Added by Rob Lake 06/16/98. This enables the command.com /* Added by Rob Lake 06/16/98. This enables the command.com
@ -863,66 +868,96 @@ static VOID Initialize (int argc, char *argv[])
hOut = GetStdHandle (STD_OUTPUT_HANDLE); hOut = GetStdHandle (STD_OUTPUT_HANDLE);
hIn = GetStdHandle (STD_INPUT_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 #ifdef INCLUDE_CMD_CHDIR
InitLastPath (); InitLastPath ();
#endif #endif
#ifdef FATURE_ALIASES
InitializeAlias ();
#endif
if (argc >= 2) if (argc >= 2)
{ {
if (!_tcsncmp (argv[1], _T("/?"), 2)) for (i = 1; i < argc; i++)
{ {
ConOutPuts (_T("Starts a new instance of the ReactOS command line interpreter\n\n" if (!_tcsicmp (argv[i], _T("/p")))
"CMD [/P][/C]...\n\n"
" /P ...\n"
" /C ..."));
ExitProcess (0);
}
else
{
for (i = 1; i < argc; i++)
{ {
if (!_tcsicmp (argv[i], _T("/p"))) if (!IsValidFileName (_T("\\autoexec.bat")))
{ {
if (!IsValidFileName (_T("\\autoexec.bat")))
{
#ifdef INCLUDE_CMD_DATE #ifdef INCLUDE_CMD_DATE
cmd_date ("", ""); cmd_date ("", "");
#endif #endif
#ifdef INCLUDE_CMD_TIME #ifdef INCLUDE_CMD_TIME
cmd_time ("", ""); cmd_time ("", "");
#endif #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 */ ParseCommandLine (_T("\\autoexec.bat"));
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));
} }
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])
{
_tcscat (commandline, " ");
_tcscat (commandline, argv[i]);
}
ParseCommandLine(commandline);
ExitProcess (ProcessInput (TRUE));
}
#ifdef INCLUDE_CMD_COLOR #ifdef INCLUDE_CMD_COLOR
else if (!_tcsnicmp (argv[i], _T("/t:"), 3)) else if (!_tcsnicmp (argv[i], _T("/t:"), 3))
{ {
/* process /t (color) argument */ /* process /t (color) argument */
wDefColor = (WORD)strtoul (&argv[i][3], NULL, 16); wDefColor = (WORD)strtoul (&argv[i][3], NULL, 16);
wColor = wDefColor; wColor = wDefColor;
} SetScreenColor (wColor);
#endif
} }
#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);
} }
} }
@ -931,14 +966,6 @@ static VOID Initialize (int argc, char *argv[])
InitDirectoryStack (); InitDirectoryStack ();
#endif #endif
#ifdef INCLUDE_CMD_COLOR
/* set default colors */
SetScreenColor (wColor);
#endif
ShortVersion ();
ShowCommands ();
/* Set COMSPEC environment variable */ /* Set COMSPEC environment variable */
#ifndef __REACTOS__ #ifndef __REACTOS__
if (argv) if (argv)
@ -952,8 +979,39 @@ static VOID Initialize (int argc, char *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 #ifdef FEATURE_DIECTORY_STACK
/* destroy directory stack */ /* destroy directory stack */
@ -994,7 +1052,7 @@ int main (int argc, char *argv[])
nExitCode = ProcessInput (FALSE); nExitCode = ProcessInput (FALSE);
/* do the cleanup */ /* do the cleanup */
Cleanup (); Cleanup (argc, argv);
FreeConsole (); FreeConsole ();
return nExitCode; return nExitCode;

View file

@ -78,21 +78,20 @@ extern SHORT maxx;
extern SHORT maxy; extern SHORT maxy;
extern OSVERSIONINFO osvi; extern OSVERSIONINFO osvi;
void command(char *); void command(char *);
VOID ParseCommandLine (LPTSTR); VOID ParseCommandLine (LPTSTR);
int c_brk(void); int c_brk(void);
/* Prototypes for ALIAS.C */ /* Prototypes for ALIAS.C */
VOID InitializeAlias (VOID);
VOID DestroyAlias (VOID);
VOID ExpandAlias (LPTSTR, INT); VOID ExpandAlias (LPTSTR, INT);
VOID CommandAlias (LPTSTR, LPTSTR); INT CommandAlias (LPTSTR, LPTSTR);
/* Prototypes for ATTRIB.C */ /* Prototypes for ATTRIB.C */
INT cmd_attrib (LPTSTR, LPTSTR); INT CommandAttrib (LPTSTR, LPTSTR);
/* Prototypes for BEEP.C */ /* Prototypes for BEEP.C */
@ -104,7 +103,7 @@ INT cmd_call (LPTSTR, LPTSTR);
/* Prototypes for CHCP.C */ /* Prototypes for CHCP.C */
VOID CommandChcp (LPTSTR, LPTSTR); INT CommandChcp (LPTSTR, LPTSTR);
/* Prototypes for CHOICE.C */ /* Prototypes for CHOICE.C */
@ -189,12 +188,15 @@ INT cmd_dir (LPTSTR, LPTSTR);
VOID InitDirectoryStack (VOID); VOID InitDirectoryStack (VOID);
VOID DestroyDirectoryStack (VOID); VOID DestroyDirectoryStack (VOID);
INT GetDirectoryStackDepth (VOID); INT GetDirectoryStackDepth (VOID);
VOID CommandPushd (LPTSTR, LPTSTR); INT CommandPushd (LPTSTR, LPTSTR);
INT cmd_popd (LPTSTR, LPTSTR); INT CommandPopd (LPTSTR, LPTSTR);
/* Prototypes for ECHO.C */ /* 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 */ /* Prototypes for ERROR.C */
@ -249,9 +251,9 @@ VOID FreeLastPath (VOID);
INT cmd_chdir (LPTSTR, LPTSTR); INT cmd_chdir (LPTSTR, LPTSTR);
INT cmd_mkdir (LPTSTR, LPTSTR); INT cmd_mkdir (LPTSTR, LPTSTR);
INT cmd_rmdir (LPTSTR, LPTSTR); INT cmd_rmdir (LPTSTR, LPTSTR);
INT internal_exit (LPTSTR, LPTSTR); INT CommandExit (LPTSTR, LPTSTR);
VOID CommandRem (LPTSTR, LPTSTR); INT CommandRem (LPTSTR, LPTSTR);
VOID CommandShowCommands (LPTSTR, LPTSTR); INT CommandShowCommands (LPTSTR, LPTSTR);
/* Prototypes for LABEL.C */ /* Prototypes for LABEL.C */
@ -367,6 +369,7 @@ INT cmd_vol (LPTSTR, LPTSTR);
BOOL SearchForExecutable (LPCTSTR, LPTSTR); BOOL SearchForExecutable (LPCTSTR, LPTSTR);
/* Prototypes for WINDOW.C */ /* Prototypes for WINDOW.C */
INT CommandActivate (LPTSTR, LPTSTR);
INT CommandWindow (LPTSTR, LPTSTR); INT CommandWindow (LPTSTR, LPTSTR);

View file

@ -122,11 +122,7 @@ ClearCommandLine (LPTSTR str, INT maxlen, SHORT orgx, SHORT orgy)
SetCursorXY (orgx, orgy); SetCursorXY (orgx, orgy);
for (count = 0; count < (INT)_tcslen (str); count++) for (count = 0; count < (INT)_tcslen (str); count++)
ConOutChar (_T(' ')); ConOutChar (_T(' '));
#ifndef __REACTOS__
_tcsnset (str, _T('\0'), maxlen); _tcsnset (str, _T('\0'), maxlen);
#else
memset (str, 0, maxlen * sizeof(TCHAR));
#endif
SetCursorXY (orgx, orgy); SetCursorXY (orgx, orgy);
} }

View file

@ -32,12 +32,16 @@ COMMAND cmds[] =
{ {
{_T("?"), 0, CommandShowCommands}, {_T("?"), 0, CommandShowCommands},
#ifdef INCLUDE_CMD_ACTIVATE
{_T("activate"), 0, CommandActivate},
#endif
#ifdef FEATURE_ALIASES #ifdef FEATURE_ALIASES
{_T("alias"), 0, CommandAlias}, {_T("alias"), 0, CommandAlias},
#endif #endif
#ifdef INCLUDE_CMD_ATTRIB #ifdef INCLUDE_CMD_ATTRIB
{_T("attrib"), 0, cmd_attrib}, {_T("attrib"), 0, CommandAttrib},
#endif #endif
#ifdef INCLUDE_CMD_BEEP #ifdef INCLUDE_CMD_BEEP
@ -99,13 +103,16 @@ COMMAND cmds[] =
{_T("dir"), CMD_SPECIAL, cmd_dir}, {_T("dir"), CMD_SPECIAL, cmd_dir},
#endif #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 #ifdef INCLUDE_CMD_DEL
{_T("erase"), 0, cmd_del}, {_T("erase"), 0, cmd_del},
#endif #endif
{_T("exit"), 0, internal_exit}, {_T("exit"), 0, CommandExit},
{_T("for"), 0, cmd_for}, {_T("for"), 0, cmd_for},
@ -147,7 +154,7 @@ COMMAND cmds[] =
#endif #endif
#ifdef FEATURE_DIRECTORY_STACK #ifdef FEATURE_DIRECTORY_STACK
{_T("popd"), 0, cmd_popd}, {_T("popd"), 0, CommandPopd},
#endif #endif
#ifdef INCLUDE_CMD_PROMPT #ifdef INCLUDE_CMD_PROMPT
@ -218,7 +225,7 @@ COMMAND cmds[] =
#endif #endif
#ifdef INCLUDE_CMD_WINDOW #ifdef INCLUDE_CMD_WINDOW
{_T("window"), 0, CommandWindow}, {_T("window"), 0, CommandWindow},
#endif #endif
{NULL, 0, NULL} {NULL, 0, NULL}

View file

@ -21,8 +21,8 @@
#endif /* __REACTOS__ */ #endif /* __REACTOS__ */
/* JPP 20 Jul 1998 - define DEBUG to add debugging code */ /* JPP 20 Jul 1998 - define _DEBUG to add debugging code */
/*#define DEBUG */ /* #define _DEBUG */
/* Define to enable the alias command, and aliases.*/ /* Define to enable the alias command, and aliases.*/
@ -57,6 +57,9 @@
/* #define LOCALE_DEFAULT */ /* United States locale */ /* #define LOCALE_DEFAULT */ /* United States locale */
#endif #endif
#ifndef __REACTOS__
#define INCLUDE_CMD_ACTIVATE
#endif
#define INCLUDE_CMD_ATTRIB #define INCLUDE_CMD_ATTRIB
/*#define INCLUDE_CMD_BREAK*/ /*#define INCLUDE_CMD_BREAK*/
#define INCLUDE_CMD_CHCP #define INCLUDE_CMD_CHCP

View file

@ -1,4 +1,5 @@
/* /* $Id: console.c,v 1.10 1999/10/03 22:20:33 ekohl Exp $
*
* CONSOLE.C - console input/output functions. * CONSOLE.C - console input/output functions.
* *
* *
@ -33,7 +34,11 @@ VOID DebugPrintf (LPTSTR szFormat, ...)
_vstprintf (szOut, szFormat, arg_ptr); _vstprintf (szOut, szFormat, arg_ptr);
va_end (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 #if 0
OutputDebugString (szOut); OutputDebugString (szOut);
#endif #endif
@ -50,7 +55,7 @@ VOID ConInDummy (VOID)
#ifdef _DEBUG #ifdef _DEBUG
if (hInput == INVALID_HANDLE_VALUE) if (hInput == INVALID_HANDLE_VALUE)
DebugPrintf ("Invalid input handle!!!\n"); DebugPrintf ("Invalid input handle!!!\n");
#endif #endif /* _DEBUG */
ReadConsoleInput (hInput, &dummy, 1, &dwRead); ReadConsoleInput (hInput, &dummy, 1, &dwRead);
} }
@ -69,7 +74,7 @@ VOID ConInKey (PINPUT_RECORD lpBuffer)
#ifdef _DEBUG #ifdef _DEBUG
if (hInput == INVALID_HANDLE_VALUE) if (hInput == INVALID_HANDLE_VALUE)
DebugPrintf ("Invalid input handle!!!\n"); DebugPrintf ("Invalid input handle!!!\n");
#endif #endif /* _DEBUG */
do do
{ {
@ -118,7 +123,11 @@ VOID ConOutChar (TCHAR c)
{ {
DWORD dwWritten; DWORD dwWritten;
WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), &c, 1, &dwWritten, NULL); WriteFile (GetStdHandle (STD_OUTPUT_HANDLE),
&c,
sizeof(TCHAR),
&dwWritten,
NULL);
} }
@ -126,25 +135,34 @@ VOID ConOutPuts (LPTSTR szText)
{ {
DWORD dwWritten; DWORD dwWritten;
WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szText, _tcslen(szText), &dwWritten, NULL); WriteFile (GetStdHandle (STD_OUTPUT_HANDLE),
#if 0 szText,
WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); _tcslen(szText) * sizeof(TCHAR),
#endif &dwWritten,
WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\n", 1, &dwWritten, NULL); NULL);
WriteFile (GetStdHandle (STD_OUTPUT_HANDLE),
_T("\n"),
sizeof(TCHAR),
&dwWritten,
NULL);
} }
VOID ConOutPrintf (LPTSTR szFormat, ...) VOID ConOutPrintf (LPTSTR szFormat, ...)
{ {
TCHAR szOut[OUTPUT_BUFFER_SIZE];
DWORD dwWritten; DWORD dwWritten;
TCHAR szOut[OUTPUT_BUFFER_SIZE];
va_list arg_ptr; va_list arg_ptr;
va_start (arg_ptr, szFormat); va_start (arg_ptr, szFormat);
_vstprintf (szOut, szFormat, arg_ptr); _vstprintf (szOut, szFormat, arg_ptr);
va_end (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);
} }
@ -152,7 +170,11 @@ VOID ConErrChar (TCHAR c)
{ {
DWORD dwWritten; DWORD dwWritten;
WriteFile (GetStdHandle (STD_ERROR_HANDLE), &c, 1, &dwWritten, NULL); WriteFile (GetStdHandle (STD_ERROR_HANDLE),
&c,
sizeof(TCHAR),
&dwWritten,
NULL);
} }
@ -160,25 +182,34 @@ VOID ConErrPuts (LPTSTR szText)
{ {
DWORD dwWritten; DWORD dwWritten;
WriteFile (GetStdHandle (STD_ERROR_HANDLE), szText, _tcslen(szText), &dwWritten, NULL); WriteFile (GetStdHandle (STD_ERROR_HANDLE),
#if 0 szText,
WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); _tcslen(szText) * sizeof(TCHAR),
#endif &dwWritten,
WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\n", 1, &dwWritten, NULL); NULL);
WriteFile (GetStdHandle (STD_ERROR_HANDLE),
_T ("\n"),
sizeof(TCHAR),
&dwWritten,
NULL);
} }
VOID ConErrPrintf (LPTSTR szFormat, ...) VOID ConErrPrintf (LPTSTR szFormat, ...)
{ {
TCHAR szOut[OUTPUT_BUFFER_SIZE];
DWORD dwWritten; DWORD dwWritten;
TCHAR szOut[OUTPUT_BUFFER_SIZE];
va_list arg_ptr; va_list arg_ptr;
va_start (arg_ptr, szFormat); va_start (arg_ptr, szFormat);
_vstprintf (szOut, szFormat, arg_ptr); _vstprintf (szOut, szFormat, arg_ptr);
va_end (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);
} }
@ -245,3 +276,5 @@ VOID SetCursorType (BOOL bInsert, BOOL bVisible)
SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci); SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci);
} }
/* EOF */

View file

@ -4,7 +4,7 @@
* clone from 4nt delay command * clone from 4nt delay command
* *
* 30 Aug 1999 * 30 Aug 1999
* started - Dr.F <dfaustus@freemail.it> * started - Paolo Pantaleo <paolopan@freemail.it>
* *
* *
*/ */

View file

@ -121,7 +121,7 @@ INT GetDirectoryStackDepth (VOID)
/* /*
* pushd command * pushd command
*/ */
VOID CommandPushd (LPTSTR first, LPTSTR rest) INT CommandPushd (LPTSTR first, LPTSTR rest)
{ {
TCHAR curPath[MAX_PATH]; TCHAR curPath[MAX_PATH];
TCHAR newPath[MAX_PATH]; TCHAR newPath[MAX_PATH];
@ -130,10 +130,10 @@ VOID CommandPushd (LPTSTR first, LPTSTR rest)
if (!_tcsncmp (rest, _T("/?"), 2)) if (!_tcsncmp (rest, _T("/?"), 2))
{ {
ConOutPuts (_T("Stores the current directory for use by the POPD command, then\n" ConOutPuts (_T("Stores the current directory for use by the POPD command, then\n"
"changes to the specified directory.\n\n" "changes to the specified directory.\n\n"
"PUSHD [path | ..]\n\n" "PUSHD [path | ..]\n\n"
" path Specifies the directory to make the current directory")); " path Specifies the directory to make the current directory"));
return; return 0;
} }
if (rest[0] != _T('\0')) if (rest[0] != _T('\0'))
@ -144,26 +144,26 @@ VOID CommandPushd (LPTSTR first, LPTSTR rest)
GetCurrentDirectory (MAX_PATH, curPath); GetCurrentDirectory (MAX_PATH, curPath);
if (PushDirectory (curPath)) if (PushDirectory (curPath))
return; return 0;
if (bChangePath) if (bChangePath)
SetCurrentDirectory (newPath); SetCurrentDirectory (newPath);
return; return 0;
} }
/* /*
* popd command * popd command
*/ */
INT cmd_popd (LPTSTR first, LPTSTR rest) INT CommandPopd (LPTSTR first, LPTSTR rest)
{ {
TCHAR szPath[MAX_PATH]; TCHAR szPath[MAX_PATH];
if (!_tcsncmp(rest, _T("/?"), 2)) if (!_tcsncmp(rest, _T("/?"), 2))
{ {
ConOutPuts (_T("Changes to the directory stored by the PUSHD command.\n\n" ConOutPuts (_T("Changes to the directory stored by the PUSHD command.\n\n"
"POPD")); "POPD"));
return 0; return 0;
} }

View file

@ -440,17 +440,15 @@ INT cmd_rmdir (LPTSTR cmd, LPTSTR param)
* set the exitflag to true * set the exitflag to true
* *
*/ */
INT internal_exit (LPTSTR cmd, LPTSTR param) INT CommandExit (LPTSTR cmd, LPTSTR param)
{ {
if (!_tcsncmp (param, _T("/?"), 2)) if (!_tcsncmp (param, _T("/?"), 2))
{ {
ConOutPuts (_T("Exits the command line interpreter.\n\nEXIT")); ConOutPuts (_T("Exits the command line interpreter.\n\nEXIT"));
} return 0;
else
{
bExit = TRUE;
} }
bExit = TRUE;
return 0; return 0;
} }
@ -460,7 +458,7 @@ INT internal_exit (LPTSTR cmd, LPTSTR param)
* does nothing * does nothing
* *
*/ */
VOID CommandRem (LPTSTR cmd, LPTSTR param) INT CommandRem (LPTSTR cmd, LPTSTR param)
{ {
if (!_tcsncmp (param, _T("/?"), 2)) if (!_tcsncmp (param, _T("/?"), 2))
{ {
@ -468,12 +466,12 @@ VOID CommandRem (LPTSTR cmd, LPTSTR param)
"REM [Comment]")); "REM [Comment]"));
} }
return; return 0;
} }
#endif /* INCLUDE_CMD_REM */ #endif /* INCLUDE_CMD_REM */
VOID CommandShowCommands (LPTSTR cmd, LPTSTR param) INT CommandShowCommands (LPTSTR cmd, LPTSTR param)
{ {
LPCOMMAND cmdptr; LPCOMMAND cmdptr;
INT y; INT y;
@ -496,7 +494,7 @@ VOID CommandShowCommands (LPTSTR cmd, LPTSTR param)
if (y != 0) if (y != 0)
ConOutChar (_T('\n')); ConOutChar (_T('\n'));
return; return 0;
} }
/* EOF */ /* EOF */

View file

@ -50,3 +50,5 @@ else
endif endif
include ../rules.mak include ../rules.mak
# EOF

View file

@ -279,13 +279,13 @@ BOOL FileGetString (HANDLE hFile, LPTSTR lpBuffer, INT nBufferLength)
while ((--nBufferLength > 0) && while ((--nBufferLength > 0) &&
ReadFile(hFile, &ch, 1, &dwRead, NULL) && dwRead) ReadFile(hFile, &ch, 1, &dwRead, NULL) && dwRead)
{ {
*lpString++ = ch;
if (ch == _T('\r')) if (ch == _T('\r'))
{ {
/* overread '\n' */ /* overread '\n' */
ReadFile (hFile, &ch, 1, &dwRead, NULL); ReadFile (hFile, &ch, 1, &dwRead, NULL);
break; break;
} }
*lpString++ = ch;
} }
if (!dwRead && lpString == lpBuffer) if (!dwRead && lpString == lpBuffer)

View file

@ -4,7 +4,7 @@
* clone from 4nt msgbox command * clone from 4nt msgbox command
* *
* 25 Aug 1999 * 25 Aug 1999
* started - Dr.F <dfaustus@freemail.it> * started - Paolo Pantaleo <paolopan@freemail.it>
*/ */
#include "config.h" #include "config.h"

View file

@ -4,7 +4,7 @@
* clone from 4nt msgbox command * clone from 4nt msgbox command
* *
* 30 Aug 1999 * 30 Aug 1999
* started - Dr.F <dfaustus@freemail.it> * started - Paolo Pantaleo <paolopan@freemail.it>
* *
* *
*/ */

View file

@ -4,7 +4,7 @@
* clone from 4nt timer command * clone from 4nt timer command
* *
* 20 Aug 1999 * 20 Aug 1999
* started - Dr.F <dfaustus@freemail.it> * started - Paolo Pantaleo <paolopan@freemail.it>
*/ */
#include "config.h" #include "config.h"