mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 01:24:38 +00:00
added ver command
improved command line editing svn path=/trunk/; revision=383
This commit is contained in:
parent
97c260445b
commit
ebb6fcbc30
1 changed files with 56 additions and 28 deletions
|
@ -1,6 +1,9 @@
|
||||||
#include <ddk/ntddk.h>
|
#include <windows.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
|
||||||
HANDLE InputHandle, OutputHandle;
|
HANDLE InputHandle, OutputHandle;
|
||||||
|
|
||||||
|
@ -15,6 +18,11 @@ void debug_printf(char* fmt, ...)
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExecuteVer(void)
|
||||||
|
{
|
||||||
|
debug_printf("Reactos Simple Shell\n");
|
||||||
|
}
|
||||||
|
|
||||||
void ExecuteCd(char* cmdline)
|
void ExecuteCd(char* cmdline)
|
||||||
{
|
{
|
||||||
if (!SetCurrentDirectoryA(cmdline))
|
if (!SetCurrentDirectoryA(cmdline))
|
||||||
|
@ -27,8 +35,8 @@ void ExecuteDir(char* cmdline)
|
||||||
{
|
{
|
||||||
HANDLE shandle;
|
HANDLE shandle;
|
||||||
WIN32_FIND_DATA FindData;
|
WIN32_FIND_DATA FindData;
|
||||||
int nFile=0,nRep=0;
|
int nFile=0, nRep=0;
|
||||||
TIME_FIELDS fTime;
|
// TIME_FIELDS fTime;
|
||||||
|
|
||||||
shandle = FindFirstFile("*",&FindData);
|
shandle = FindFirstFile("*",&FindData);
|
||||||
|
|
||||||
|
@ -41,7 +49,7 @@ void ExecuteDir(char* cmdline)
|
||||||
{
|
{
|
||||||
debug_printf("%-15.15s",FindData.cAlternateFileName);
|
debug_printf("%-15.15s",FindData.cAlternateFileName);
|
||||||
if(FindData.dwFileAttributes &FILE_ATTRIBUTE_DIRECTORY)
|
if(FindData.dwFileAttributes &FILE_ATTRIBUTE_DIRECTORY)
|
||||||
debug_printf("<REP> "),nRep++;
|
debug_printf("<DIR> "),nRep++;
|
||||||
else
|
else
|
||||||
debug_printf(" %10d ",FindData.nFileSizeLow),nFile++;
|
debug_printf(" %10d ",FindData.nFileSizeLow),nFile++;
|
||||||
// RtlTimeToTimeFields(&FindData.ftLastWriteTime ,&fTime);
|
// RtlTimeToTimeFields(&FindData.ftLastWriteTime ,&fTime);
|
||||||
|
@ -158,6 +166,11 @@ void ExecuteCommand(char* line)
|
||||||
ExecuteType(tail);
|
ExecuteType(tail);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (strcmp(cmd,"ver")==0)
|
||||||
|
{
|
||||||
|
ExecuteVer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (strcmp(cmd,"validate")==0)
|
if (strcmp(cmd,"validate")==0)
|
||||||
{
|
{
|
||||||
debug_printf("Validating heap...");
|
debug_printf("Validating heap...");
|
||||||
|
@ -189,9 +202,10 @@ void ReadLine(char* line)
|
||||||
DWORD Result;
|
DWORD Result;
|
||||||
UCHAR CurrentDir[255];
|
UCHAR CurrentDir[255];
|
||||||
char ch;
|
char ch;
|
||||||
|
int length = 0;
|
||||||
|
|
||||||
GetCurrentDirectoryA(255,CurrentDir);
|
GetCurrentDirectoryA(255,CurrentDir);
|
||||||
debug_printf(CurrentDir);
|
debug_printf("%s>", CurrentDir);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -204,9 +218,23 @@ void ReadLine(char* line)
|
||||||
debug_printf("Failed to read from console\n");
|
debug_printf("Failed to read from console\n");
|
||||||
for(;;);
|
for(;;);
|
||||||
}
|
}
|
||||||
|
switch (ch)
|
||||||
|
{
|
||||||
|
case '\b':
|
||||||
|
if (length > 0)
|
||||||
|
{
|
||||||
|
debug_printf("\b \b");
|
||||||
|
line--;
|
||||||
|
length--;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
debug_printf("%c", ch);
|
debug_printf("%c", ch);
|
||||||
*line = ch;
|
*line = ch;
|
||||||
line++;
|
line++;
|
||||||
|
length++;
|
||||||
|
}
|
||||||
} while (ch != '\n');
|
} while (ch != '\n');
|
||||||
line--;
|
line--;
|
||||||
*line = 0;
|
*line = 0;
|
||||||
|
|
Loading…
Reference in a new issue