mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 23:03:00 +00:00
Fixed current directory handling
Added new prompt functions Fixed dangling pointer bug in copy command svn path=/trunk/; revision=874
This commit is contained in:
parent
43d5d0b2f0
commit
8bbcdc3d4a
9 changed files with 350 additions and 159 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: cmd.c,v 1.16 1999/12/07 18:17:17 paolopan Exp $
|
/* $Id: cmd.c,v 1.17 1999/12/15 00:50:41 ekohl Exp $
|
||||||
*
|
*
|
||||||
* CMD.C - command-line interface.
|
* CMD.C - command-line interface.
|
||||||
*
|
*
|
||||||
|
@ -107,6 +107,9 @@
|
||||||
*
|
*
|
||||||
* 22-Oct-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 22-Oct-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* Added break handler.
|
* Added break handler.
|
||||||
|
*
|
||||||
|
* 15-Dec-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
|
* Fixed current directory
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -166,13 +169,44 @@ Execute (LPTSTR first, LPTSTR rest)
|
||||||
TCHAR szFullName[MAX_PATH];
|
TCHAR szFullName[MAX_PATH];
|
||||||
DWORD dwExitCode = 0;
|
DWORD dwExitCode = 0;
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
DebugPrintf ("Execute: \'%s\' \'%s\'\n", first, rest);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* check for a drive change */
|
/* check for a drive change */
|
||||||
if (!_tcscmp (first + 1, _T(":")) && _istalpha (*first))
|
if ((_istalpha (first[0])) && (!_tcscmp (first + 1, _T(":"))))
|
||||||
{
|
{
|
||||||
TCHAR szPath[MAX_PATH];
|
TCHAR szPath[MAX_PATH];
|
||||||
|
TCHAR szVar[5];
|
||||||
|
|
||||||
_tcscpy (szPath, _T("A:"));
|
#ifdef _DEBUG
|
||||||
|
DebugPrintf ("Drive change to drive %s\n", first);
|
||||||
|
#endif
|
||||||
|
/* save curent directory in environment variable */
|
||||||
|
GetCurrentDirectory (MAX_PATH, szPath);
|
||||||
|
|
||||||
|
_tcscpy (szVar, _T("=A:"));
|
||||||
|
szVar[1] = _totupper (szPath[0]);
|
||||||
|
|
||||||
|
SetEnvironmentVariable (szVar, szPath);
|
||||||
|
|
||||||
|
|
||||||
|
/* check for current directory of new drive */
|
||||||
|
_tcscpy (szVar, _T("=A:"));
|
||||||
|
szVar[1] = _totupper (*first);
|
||||||
|
|
||||||
|
if (GetEnvironmentVariable (szVar, szPath, MAX_PATH) == 0)
|
||||||
|
{
|
||||||
|
/* no environment variable found */
|
||||||
|
_tcscpy (szPath, _T("A:\\"));
|
||||||
szPath[0] = _totupper (*first);
|
szPath[0] = _totupper (*first);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
DebugPrintf ("Drive change to drive %s\n", szPath);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* set new current directory */
|
||||||
SetCurrentDirectory (szPath);
|
SetCurrentDirectory (szPath);
|
||||||
GetCurrentDirectory (MAX_PATH, szPath);
|
GetCurrentDirectory (MAX_PATH, szPath);
|
||||||
if (szPath[0] != (TCHAR)_totupper (*first))
|
if (szPath[0] != (TCHAR)_totupper (*first))
|
||||||
|
@ -289,6 +323,10 @@ DoCommand (LPTSTR line)
|
||||||
INT cl;
|
INT cl;
|
||||||
LPCOMMAND cmdptr;
|
LPCOMMAND cmdptr;
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
DebugPrintf ("DoCommand: (\'%s\')\n", line);
|
||||||
|
#endif /* DEBUG */
|
||||||
|
|
||||||
/* Skip over initial white space */
|
/* Skip over initial white space */
|
||||||
while (isspace (*rest))
|
while (isspace (*rest))
|
||||||
rest++;
|
rest++;
|
||||||
|
@ -383,7 +421,7 @@ VOID ParseCommandLine (LPTSTR cmd)
|
||||||
s = &cmdline[0];
|
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
|
||||||
|
@ -822,6 +860,23 @@ BOOL BreakHandler (DWORD dwCtrlType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID AddBreakHandler (VOID)
|
||||||
|
{
|
||||||
|
#ifndef __REACTOS__
|
||||||
|
SetConsoleCtrlHandler ((PHANDLER_ROUTINE)&BreakHandler,
|
||||||
|
TRUE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID RemoveBreakHandler (VOID)
|
||||||
|
{
|
||||||
|
#ifndef __REACTOS__
|
||||||
|
SetConsoleCtrlHandler (NULL, FALSE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* show commands and options that are available.
|
* show commands and options that are available.
|
||||||
*
|
*
|
||||||
|
@ -1036,10 +1091,7 @@ Initialize (int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* add ctrl break handler */
|
/* add ctrl break handler */
|
||||||
#ifndef __REACTOS__
|
AddBreakHandler ();
|
||||||
SetConsoleCtrlHandler ((PHANDLER_ROUTINE)&BreakHandler,
|
|
||||||
TRUE);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1092,9 +1144,7 @@ static VOID Cleanup (int argc, char *argv[])
|
||||||
|
|
||||||
|
|
||||||
/* remove ctrl break handler */
|
/* remove ctrl break handler */
|
||||||
#ifndef __REACTOS__
|
RemoveBreakHandler ();
|
||||||
SetConsoleCtrlHandler (NULL, FALSE);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1126,3 +1176,5 @@ int main (int argc, char *argv[])
|
||||||
|
|
||||||
return nExitCode;
|
return nExitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* $Id: cmd.h,v 1.17 1999/12/15 00:50:41 ekohl Exp $
|
||||||
|
*
|
||||||
* CMD.H - header file for the modules in CMD.EXE
|
* CMD.H - header file for the modules in CMD.EXE
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
@ -57,7 +58,7 @@
|
||||||
#define ERROR_E2BIG "ERROR: Argument list too long"
|
#define ERROR_E2BIG "ERROR: Argument list too long"
|
||||||
#define ERROR_EINVAL "ERROR: Invalid argument"
|
#define ERROR_EINVAL "ERROR: Invalid argument"
|
||||||
|
|
||||||
#define SHELLINFO "ReactOS Command Line Interface"
|
#define SHELLINFO "ReactOS Command Line Interpreter"
|
||||||
|
|
||||||
|
|
||||||
#define D_ON "on"
|
#define D_ON "on"
|
||||||
|
@ -65,7 +66,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes for CMD.C */
|
/* global variables */
|
||||||
extern HANDLE hOut;
|
extern HANDLE hOut;
|
||||||
extern HANDLE hIn;
|
extern HANDLE hIn;
|
||||||
extern WORD wColor;
|
extern WORD wColor;
|
||||||
|
@ -78,9 +79,6 @@ extern SHORT maxx;
|
||||||
extern SHORT maxy;
|
extern SHORT maxy;
|
||||||
extern OSVERSIONINFO osvi;
|
extern OSVERSIONINFO osvi;
|
||||||
|
|
||||||
void command(char *);
|
|
||||||
VOID ParseCommandLine (LPTSTR);
|
|
||||||
int c_brk(void);
|
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes for ALIAS.C */
|
/* Prototypes for ALIAS.C */
|
||||||
|
@ -114,6 +112,13 @@ INT CommandChoice (LPTSTR, LPTSTR);
|
||||||
INT cmd_cls (LPTSTR, LPTSTR);
|
INT cmd_cls (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
/* Prototypes for CMD.C */
|
||||||
|
//void command(char *);
|
||||||
|
VOID ParseCommandLine (LPTSTR);
|
||||||
|
VOID AddBreakHandler (VOID);
|
||||||
|
VOID RemoveBreakHandler (VOID);
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes for CMDINPUT.C */
|
/* Prototypes for CMDINPUT.C */
|
||||||
VOID ReadCommand (LPTSTR, INT);
|
VOID ReadCommand (LPTSTR, INT);
|
||||||
|
|
||||||
|
@ -144,6 +149,8 @@ VOID DebugPrintf (LPTSTR, ...);
|
||||||
#endif /* _DEBUG */
|
#endif /* _DEBUG */
|
||||||
|
|
||||||
VOID ConInDummy (VOID);
|
VOID ConInDummy (VOID);
|
||||||
|
VOID ConInDisable (VOID);
|
||||||
|
VOID ConInEnable (VOID);
|
||||||
VOID ConInFlush (VOID);
|
VOID ConInFlush (VOID);
|
||||||
VOID ConInKey (PINPUT_RECORD);
|
VOID ConInKey (PINPUT_RECORD);
|
||||||
|
|
||||||
|
@ -183,8 +190,7 @@ INT CommandDelay (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes for DIR.C */
|
/* Prototypes for DIR.C */
|
||||||
//int incline(int *line, unsigned flags);
|
INT CommandDir (LPTSTR, LPTSTR);
|
||||||
INT cmd_dir (LPTSTR, LPTSTR);
|
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes for DIRSTACK.C */
|
/* Prototypes for DIRSTACK.C */
|
||||||
|
@ -301,6 +307,15 @@ BOOL FileGetString (HANDLE, LPTSTR, INT);
|
||||||
HWND GetConsoleWindow(VOID);
|
HWND GetConsoleWindow(VOID);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define PROMPT_NO 0
|
||||||
|
#define PROMPT_YES 1
|
||||||
|
#define PROMPT_ALL 2
|
||||||
|
#define PROMPT_BREAK 3
|
||||||
|
|
||||||
|
INT PagePrompt (VOID);
|
||||||
|
INT FilePromptYN (LPTSTR, ...);
|
||||||
|
INT FilePromptYNA (LPTSTR, ...);
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes for MOVE.C */
|
/* Prototypes for MOVE.C */
|
||||||
INT cmd_move (LPTSTR, LPTSTR);
|
INT cmd_move (LPTSTR, LPTSTR);
|
||||||
|
|
|
@ -89,7 +89,7 @@ COMMAND cmds[] =
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_DIR
|
#ifdef INCLUDE_CMD_DIR
|
||||||
{_T("dir"), CMD_SPECIAL, cmd_dir},
|
{_T("dir"), CMD_SPECIAL, CommandDir},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FEATURE_DIRECTORY_STACK
|
#ifdef FEATURE_DIRECTORY_STACK
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: console.c,v 1.12 1999/10/23 18:17:37 ekohl Exp $
|
/* $Id: console.c,v 1.13 1999/12/15 00:50:41 ekohl Exp $
|
||||||
*
|
*
|
||||||
* CONSOLE.C - console input/output functions.
|
* CONSOLE.C - console input/output functions.
|
||||||
*
|
*
|
||||||
|
@ -46,6 +46,28 @@ VOID DebugPrintf (LPTSTR szFormat, ...)
|
||||||
#endif /* _DEBUG */
|
#endif /* _DEBUG */
|
||||||
|
|
||||||
|
|
||||||
|
VOID ConInDisable (VOID)
|
||||||
|
{
|
||||||
|
HANDLE hInput = GetStdHandle (STD_INPUT_HANDLE);
|
||||||
|
DWORD dwMode;
|
||||||
|
|
||||||
|
GetConsoleMode (hInput, &dwMode);
|
||||||
|
dwMode &= ~ENABLE_PROCESSED_INPUT;
|
||||||
|
SetConsoleMode (hInput, dwMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID ConInEnable (VOID)
|
||||||
|
{
|
||||||
|
HANDLE hInput = GetStdHandle (STD_INPUT_HANDLE);
|
||||||
|
DWORD dwMode;
|
||||||
|
|
||||||
|
GetConsoleMode (hInput, &dwMode);
|
||||||
|
dwMode |= ENABLE_PROCESSED_INPUT;
|
||||||
|
SetConsoleMode (hInput, dwMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID ConInDummy (VOID)
|
VOID ConInDummy (VOID)
|
||||||
{
|
{
|
||||||
HANDLE hInput = GetStdHandle (STD_INPUT_HANDLE);
|
HANDLE hInput = GetStdHandle (STD_INPUT_HANDLE);
|
||||||
|
|
|
@ -611,9 +611,9 @@ INT cmd_copy (LPTSTR first, LPTSTR rest)
|
||||||
int files;
|
int files;
|
||||||
int copied;
|
int copied;
|
||||||
|
|
||||||
LPFILES sources;
|
LPFILES sources = NULL;
|
||||||
|
LPFILES start = NULL;
|
||||||
FILES dest;
|
FILES dest;
|
||||||
LPFILES start;
|
|
||||||
BOOL bMultiple;
|
BOOL bMultiple;
|
||||||
BOOL bWildcards;
|
BOOL bWildcards;
|
||||||
BOOL bDestFound;
|
BOOL bDestFound;
|
||||||
|
@ -738,7 +738,8 @@ INT cmd_copy (LPTSTR first, LPTSTR rest)
|
||||||
copied = setup_copy (sources->next, p, bMultiple, drive_d, dir_d, file_d, ext_d, &append, &dwFlags) + 1;
|
copied = setup_copy (sources->next, p, bMultiple, drive_d, dir_d, file_d, ext_d, &append, &dwFlags) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteFileList (start);
|
// DeleteFileList (start);
|
||||||
|
DeleteFileList (sources);
|
||||||
freep (p);
|
freep (p);
|
||||||
ConOutPrintf (_T(" %d file(s) copied\n"), copied);
|
ConOutPrintf (_T(" %d file(s) copied\n"), copied);
|
||||||
|
|
||||||
|
|
|
@ -45,12 +45,6 @@
|
||||||
#include "batch.h"
|
#include "batch.h"
|
||||||
|
|
||||||
|
|
||||||
#define PROMPT_NO 0
|
|
||||||
#define PROMPT_YES 1
|
|
||||||
#define PROMPT_ALL 2
|
|
||||||
#define PROMPT_BREAK 3
|
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
DEL_ATTRIBUTES = 0x001, /* /A : not implemented */
|
DEL_ATTRIBUTES = 0x001, /* /A : not implemented */
|
||||||
|
@ -68,64 +62,6 @@ enum
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static BOOL ConfirmDeleteAll (VOID)
|
|
||||||
{
|
|
||||||
TCHAR inp[10];
|
|
||||||
LPTSTR p;
|
|
||||||
|
|
||||||
ConOutPrintf (_T("All files in directory will be deleted!\n"
|
|
||||||
"Are you sure (Y/N)? "));
|
|
||||||
ConInString (inp, 10);
|
|
||||||
|
|
||||||
_tcsupr (inp);
|
|
||||||
for (p = inp; _istspace (*p); p++)
|
|
||||||
;
|
|
||||||
|
|
||||||
if (*p == _T('Y'))
|
|
||||||
return PROMPT_YES;
|
|
||||||
else if (*p == _T('N'))
|
|
||||||
return PROMPT_NO;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (*p == _T('A'))
|
|
||||||
return PROMPT_ALL;
|
|
||||||
else if (*p == _T('\03'))
|
|
||||||
return PROMPT_BREAK;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return PROMPT_NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static INT Prompt (LPTSTR str)
|
|
||||||
{
|
|
||||||
TCHAR inp[10];
|
|
||||||
LPTSTR p;
|
|
||||||
|
|
||||||
ConOutPrintf (_T("Delete %s (Yes/No)? "), str);
|
|
||||||
ConInString (inp, 10);
|
|
||||||
|
|
||||||
_tcsupr (inp);
|
|
||||||
for (p = inp; _istspace (*p); p++)
|
|
||||||
;
|
|
||||||
|
|
||||||
if (*p == _T('Y'))
|
|
||||||
return PROMPT_YES;
|
|
||||||
else if (*p == _T('N'))
|
|
||||||
return PROMPT_NO;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (*p == _T('A'))
|
|
||||||
return PROMPT_ALL;
|
|
||||||
else if (*p == _T('\03'))
|
|
||||||
return PROMPT_BREAK;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return PROMPT_NO;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
RemoveFile (LPTSTR lpFileName, DWORD dwFlags)
|
RemoveFile (LPTSTR lpFileName, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
|
@ -241,9 +177,13 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
|
||||||
if (!_tcscmp (arg[i], _T("*")) ||
|
if (!_tcscmp (arg[i], _T("*")) ||
|
||||||
!_tcscmp (arg[i], _T("*.*")))
|
!_tcscmp (arg[i], _T("*.*")))
|
||||||
{
|
{
|
||||||
if (!ConfirmDeleteAll ())
|
INT res;
|
||||||
break;
|
|
||||||
|
|
||||||
|
res = FilePromptYN (_T("All files in directory will be deleted!\n"
|
||||||
|
"Are you sure (Y/N)?"));
|
||||||
|
if ((res == PROMPT_NO) ||
|
||||||
|
(res == PROMPT_BREAK))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*arg[i] != _T('/'))
|
if (*arg[i] != _T('/'))
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* $Id: dir.c,v 1.9 1999/12/15 00:50:41 ekohl Exp $
|
||||||
|
*
|
||||||
* DIR.C - dir internal command.
|
* DIR.C - dir internal command.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
@ -462,40 +463,26 @@ DirParsePathspec (LPTSTR szPathspec, LPTSTR szPath, LPTSTR szFilespec)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* pause
|
|
||||||
*
|
|
||||||
* pause until a key is pressed
|
|
||||||
*/
|
|
||||||
static INT
|
|
||||||
Pause (VOID)
|
|
||||||
{
|
|
||||||
cmd_pause ("", "");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* incline
|
* incline
|
||||||
*
|
*
|
||||||
* increment our line if paginating, display message at end of screen
|
* increment our line if paginating, display message at end of screen
|
||||||
*/
|
*/
|
||||||
static INT
|
static BOOL
|
||||||
IncLine (LPINT pLine, DWORD dwFlags)
|
IncLine (LPINT pLine, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
if (!(dwFlags & DIR_PAGE))
|
if (!(dwFlags & DIR_PAGE))
|
||||||
return 0;
|
return FALSE;
|
||||||
|
|
||||||
(*pLine)++;
|
(*pLine)++;
|
||||||
|
|
||||||
if (*pLine >= (int)maxy - 2)
|
if (*pLine >= (int)maxy - 2)
|
||||||
{
|
{
|
||||||
*pLine = 0;
|
*pLine = 0;
|
||||||
return Pause ();
|
return (PagePrompt () == PROMPT_BREAK);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -536,7 +523,8 @@ PrintDirectoryHeader (LPTSTR szPath, LPINT pLine, DWORD dwFlags)
|
||||||
|
|
||||||
/* print the volume serial number if the return was successful */
|
/* print the volume serial number if the return was successful */
|
||||||
ConOutPrintf (_T(" Volume Serial Number is %04X-%04X\n"),
|
ConOutPrintf (_T(" Volume Serial Number is %04X-%04X\n"),
|
||||||
HIWORD(dwSerialNr), LOWORD(dwSerialNr));
|
HIWORD(dwSerialNr),
|
||||||
|
LOWORD(dwSerialNr));
|
||||||
if (IncLine (pLine, dwFlags))
|
if (IncLine (pLine, dwFlags))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -745,9 +733,10 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
|
||||||
*/
|
*/
|
||||||
if ((dwFlags & DIR_RECURSE) == 0)
|
if ((dwFlags & DIR_RECURSE) == 0)
|
||||||
{
|
{
|
||||||
error_file_not_found ();
|
|
||||||
IncLine (pLine, dwFlags);
|
|
||||||
FindClose (hFile);
|
FindClose (hFile);
|
||||||
|
error_file_not_found ();
|
||||||
|
if (IncLine (pLine, dwFlags))
|
||||||
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
FindClose (hFile);
|
FindClose (hFile);
|
||||||
|
@ -1085,7 +1074,7 @@ DirRecurse (LPTSTR szPath, LPTSTR szSpec, LPINT pLine, DWORD dwFlags)
|
||||||
*
|
*
|
||||||
* internal dir command
|
* internal dir command
|
||||||
*/
|
*/
|
||||||
INT cmd_dir (LPTSTR first, LPTSTR rest)
|
INT CommandDir (LPTSTR first, LPTSTR rest)
|
||||||
{
|
{
|
||||||
DWORD dwFlags = DIR_NEW | DIR_FOUR;
|
DWORD dwFlags = DIR_NEW | DIR_FOUR;
|
||||||
TCHAR dircmd[256];
|
TCHAR dircmd[256];
|
||||||
|
@ -1120,7 +1109,8 @@ INT cmd_dir (LPTSTR first, LPTSTR rest)
|
||||||
|
|
||||||
if (dwFlags & DIR_RECURSE)
|
if (dwFlags & DIR_RECURSE)
|
||||||
{
|
{
|
||||||
IncLine (&nLine, dwFlags);
|
if (IncLine (&nLine, dwFlags))
|
||||||
|
return 0;
|
||||||
if (DirRecurse (szPath, szFilespec, &nLine, dwFlags))
|
if (DirRecurse (szPath, szFilespec, &nLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1137,3 +1127,5 @@ INT cmd_dir (LPTSTR first, LPTSTR rest)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* EOF */
|
|
@ -24,15 +24,20 @@
|
||||||
*
|
*
|
||||||
* 28-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 28-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* FileGetString() seems to be working now.
|
* FileGetString() seems to be working now.
|
||||||
|
*
|
||||||
|
* 06-Nov-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
|
* Added PagePrompt() and FilePrompt().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
//#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
@ -329,4 +334,169 @@ HWND GetConsoleWindow (VOID)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
INT PagePrompt (VOID)
|
||||||
|
{
|
||||||
|
INPUT_RECORD ir;
|
||||||
|
|
||||||
|
ConOutPrintf ("Press a key to continue...\n");
|
||||||
|
|
||||||
|
RemoveBreakHandler ();
|
||||||
|
ConInDisable ();
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
ConInKey (&ir);
|
||||||
|
}
|
||||||
|
while ((ir.Event.KeyEvent.wVirtualKeyCode == VK_SHIFT) ||
|
||||||
|
(ir.Event.KeyEvent.wVirtualKeyCode == VK_MENU) ||
|
||||||
|
(ir.Event.KeyEvent.wVirtualKeyCode == VK_CONTROL));
|
||||||
|
|
||||||
|
AddBreakHandler ();
|
||||||
|
ConInEnable ();
|
||||||
|
|
||||||
|
if ((ir.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE) ||
|
||||||
|
((ir.Event.KeyEvent.wVirtualKeyCode == 'C') &&
|
||||||
|
(ir.Event.KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))))
|
||||||
|
return PROMPT_BREAK;
|
||||||
|
|
||||||
|
return PROMPT_YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
INT FilePromptYN (LPTSTR szFormat, ...)
|
||||||
|
{
|
||||||
|
TCHAR szOut[512];
|
||||||
|
va_list arg_ptr;
|
||||||
|
// TCHAR cKey = 0;
|
||||||
|
// LPTSTR szKeys = _T("yna");
|
||||||
|
|
||||||
|
TCHAR szIn[10];
|
||||||
|
LPTSTR p;
|
||||||
|
|
||||||
|
va_start (arg_ptr, szFormat);
|
||||||
|
_vstprintf (szOut, szFormat, arg_ptr);
|
||||||
|
va_end (arg_ptr);
|
||||||
|
|
||||||
|
ConOutPrintf (szFormat);
|
||||||
|
|
||||||
|
/* preliminary fix */
|
||||||
|
ConInString (szIn, 10);
|
||||||
|
ConOutPrintf (_T("\n"));
|
||||||
|
|
||||||
|
_tcsupr (szIn);
|
||||||
|
for (p = szIn; _istspace (*p); p++)
|
||||||
|
;
|
||||||
|
|
||||||
|
if (*p == _T('Y'))
|
||||||
|
return PROMPT_YES;
|
||||||
|
else if (*p == _T('N'))
|
||||||
|
return PROMPT_NO;
|
||||||
|
#if 0
|
||||||
|
else if (*p == _T('\03'))
|
||||||
|
return PROMPT_BREAK;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return PROMPT_NO;
|
||||||
|
|
||||||
|
|
||||||
|
/* unfinished sollution */
|
||||||
|
#if 0
|
||||||
|
RemoveBreakHandler ();
|
||||||
|
ConInDisable ();
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
ConInKey (&ir);
|
||||||
|
cKey = _totlower (ir.Event.KeyEvent.uChar.AsciiChar);
|
||||||
|
if (_tcschr (szKeys, cKey[0]) == NULL)
|
||||||
|
cKey = 0;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
while ((ir.Event.KeyEvent.wVirtualKeyCode == VK_SHIFT) ||
|
||||||
|
(ir.Event.KeyEvent.wVirtualKeyCode == VK_MENU) ||
|
||||||
|
(ir.Event.KeyEvent.wVirtualKeyCode == VK_CONTROL));
|
||||||
|
|
||||||
|
AddBreakHandler ();
|
||||||
|
ConInEnable ();
|
||||||
|
|
||||||
|
if ((ir.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE) ||
|
||||||
|
((ir.Event.KeyEvent.wVirtualKeyCode == 'C') &&
|
||||||
|
(ir.Event.KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))))
|
||||||
|
return PROMPT_BREAK;
|
||||||
|
|
||||||
|
return PROMPT_YES;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
INT FilePromptYNA (LPTSTR szFormat, ...)
|
||||||
|
{
|
||||||
|
TCHAR szOut[512];
|
||||||
|
va_list arg_ptr;
|
||||||
|
// TCHAR cKey = 0;
|
||||||
|
// LPTSTR szKeys = _T("yna");
|
||||||
|
|
||||||
|
TCHAR szIn[10];
|
||||||
|
LPTSTR p;
|
||||||
|
|
||||||
|
va_start (arg_ptr, szFormat);
|
||||||
|
_vstprintf (szOut, szFormat, arg_ptr);
|
||||||
|
va_end (arg_ptr);
|
||||||
|
|
||||||
|
ConOutPrintf (szFormat);
|
||||||
|
|
||||||
|
/* preliminary fix */
|
||||||
|
ConInString (szIn, 10);
|
||||||
|
ConOutPrintf (_T("\n"));
|
||||||
|
|
||||||
|
_tcsupr (szIn);
|
||||||
|
for (p = szIn; _istspace (*p); p++)
|
||||||
|
;
|
||||||
|
|
||||||
|
if (*p == _T('Y'))
|
||||||
|
return PROMPT_YES;
|
||||||
|
else if (*p == _T('N'))
|
||||||
|
return PROMPT_NO;
|
||||||
|
if (*p == _T('A'))
|
||||||
|
return PROMPT_ALL;
|
||||||
|
#if 0
|
||||||
|
else if (*p == _T('\03'))
|
||||||
|
return PROMPT_BREAK;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return PROMPT_NO;
|
||||||
|
|
||||||
|
|
||||||
|
/* unfinished sollution */
|
||||||
|
#if 0
|
||||||
|
RemoveBreakHandler ();
|
||||||
|
ConInDisable ();
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
ConInKey (&ir);
|
||||||
|
cKey = _totlower (ir.Event.KeyEvent.uChar.AsciiChar);
|
||||||
|
if (_tcschr (szKeys, cKey[0]) == NULL)
|
||||||
|
cKey = 0;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
while ((ir.Event.KeyEvent.wVirtualKeyCode == VK_SHIFT) ||
|
||||||
|
(ir.Event.KeyEvent.wVirtualKeyCode == VK_MENU) ||
|
||||||
|
(ir.Event.KeyEvent.wVirtualKeyCode == VK_CONTROL));
|
||||||
|
|
||||||
|
AddBreakHandler ();
|
||||||
|
ConInEnable ();
|
||||||
|
|
||||||
|
if ((ir.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE) ||
|
||||||
|
((ir.Event.KeyEvent.wVirtualKeyCode == 'C') &&
|
||||||
|
(ir.Event.KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))))
|
||||||
|
return PROMPT_BREAK;
|
||||||
|
|
||||||
|
return PROMPT_YES;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
|
@ -257,7 +257,6 @@ INT cmd_move (LPTSTR cmd, LPTSTR param)
|
||||||
FindClose (hFile);
|
FindClose (hFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
freep (arg);
|
freep (arg);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue