118 if (cmdhist !=
NULL) {
122 cmdhist = cmdhist->
prev;
132 if (cmdhist !=
NULL) {
134 cmdhist = cmdhist->
next;
173 if (
buf[
j - 1] !=
' ')
175 for (
k = --
j;
k >= 0;
k--)
177 if (
buf[
k] ==
' ' ||
k == 0) {
240 if (MustRefresh == 1)
243 for (
i = 0;
i <= iEraseLength ;
i++)
255 if (cmdhist ==
NULL) {
257 if (cmdhist ==
NULL) {
258 printit (
"\nUnable to allocate memory for history buffer -- use the \"flush\" command to clear the buffer.\n");
266 cmdhist = cmdhist->
next;
269 printit (
"\nUnable to allocate memory for history buffer -- use the \"flush\" command to clear the buffer.\n");
272 cmdhist->
next->prev = cmdhist;
273 cmdhist = cmdhist->
next;
277 while (cmdhist->
next)
278 cmdhist = cmdhist->
next;
317 int main(
int ArgC,
char* ArgV[]) {
322 &ConsoleScreenBufferInfo
335 TCHAR ConsoleTitle[255];
375 ConsoleScreenBufferInfo.
dwSize 436 {
"open", 1, 1, 2, -1, 0,
"o[pen] host [port]\n"},
437 {
"close", 2, 0, 0, -1, 0,
NULL},
438 {
"keys", 2, 1, 3, -1, 1,
"ke[ys] l[oad] keymapname [file]\n" 440 "ke[ys] s[witch] number\n"},
442 {
"quit", 1, 0, 0, -1, 0,
NULL},
443 {
"?", 1, 0, 0, -1, 0,
NULL},
444 {
"help", 1, 0, 0, -1, 0,
NULL},
447 {
"display", 1, 0, 0,
KEYS, 0,
NULL},
449 {
"set", 3, 0, 2, -1, 0,
"set will display available groups.\n" 450 "set groupname will display all variables/values in a group.\n" 451 "set [variable [value]] will set variable to value.\n"},
453 {
"z", 1, 0, 0, -1, 0,
"suspend telnet\n"},
454 {
"\04", 1, 0, 0, -1, 0,
NULL},
456 {
"history", 2, 0, 0, -1, 0,
"show command history"},
457 {
"flush", 2, 0, 0, -1, 0,
"flush history buffer"},
459 {
"aliases", 5, 0, 0, -1, 0,
NULL}
463 #define MAX_PARM_COUNT 3 464 #define MAX_TOKEN_COUNT (MAX_PARM_COUNT+2) 467 if ( tokenLen < minM )
return 0;
469 if ( (
unsigned)tokenLen >
strlen(
cmd) )
return 0;
473 for (
i = 0;
i < minM;
i++ )
if (
cmd[
i] !=
token[
i] )
return 0;
475 for (
i = minM;
i < tokenLen;
i++ )
if (
cmd[
i] !=
token[
i] )
return 0;
497 if(!szCommand || !*szCommand)
return EMPTY_LINE;
501 char *token_start = szCommand;
502 for(
p = szCommand;;
p++) {
505 for(
p++; *
p !=
'\"' && *
p != 0;
p++);
509 if(*
p == 0 || *
p ==
' ' || *
p ==
'\t') {
510 tokens[
args] = token_start;
544 if ( curCmd ==
cmdList[
i].isSubCmd ) {
560 for (
int i = 0;
i<
argc;
i++ ) {
568 #define HISTLENGTH 25 573 char *extitle, *newtitle;
581 cmdhist =
cfgets (szCommand, 79, cmdhist);
600 retval = MyConnection.
Open(Parms[0],
"23");
602 retval = MyConnection.
Open(Parms[0], Parms[1]);
607 MyConnection.
Close();
611 MyConnection.
Close();
624 printit(
"Error loading keymap.\n");
627 if(MyConnection.
LoadKeyMap( Parms[1], Parms[0]) != 1)
628 printit(
"Error loading keymap.\n");
640 printit(
"Available groups:\n");
655 extitle =
new char[128];
658 newtitle =
new char[128+
sizeof(
"[suspended]")];
659 strcpy(newtitle, extitle);
660 strncat(newtitle,
"[suspended]", 128+
sizeof(
"[suspended]"));
684 if (cmdhist !=
NULL) {
686 cmdhist = cmdhist->
prev;
687 printf (
"Command history:\n");
692 cmdhist = cmdhist->
next;
697 printf (
"No command history available.\n");
702 if (cmdhist !=
NULL) {
704 cmdhist = cmdhist->
next;
706 cmdhist = cmdhist->
prev;
707 delete cmdhist->
next;
711 printf (
"Command history cleared.\n");
713 printf (
"No command history available.\n");
int LoadKeyMap(const char *file, const char *name)
bool set_value(const char *var, const char *value)
bool Process_Params(int argc, char *argv[])
union _KEY_EVENT_RECORD::@3234 uChar
char * strncat(char *DstString, const char *SrcString, ACPI_SIZE Count)
ACPI_SIZE strlen(const char *String)
int main(int ArgC, char *ArgV[])
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
int get_term_width() const
struct cmdHistory * cfgets(char *buf, unsigned int length, struct cmdHistory *cmdhist)
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
int Open(const char *szHost, const char *strPort="23")
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleScreenBufferSize(HANDLE hConsoleOutput, COORD dwSize)
#define ENABLE_ECHO_INPUT
GLenum GLuint GLenum GLsizei const GLchar * buf
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
static int cmdMatch(const char *cmd, const char *token, int tokenLen, int minM)
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
GLenum GLuint GLenum GLsizei length
const char * get_host() const
int __cdecl system(_In_opt_z_ const char *_Command)
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
BOOL WINAPI SetConsoleTextAttribute(IN HANDLE hConsoleOutput, IN WORD wAttributes)
#define ENABLE_LINE_INPUT
int printit(const char *it)
#define GetModuleFileName
#define LEFT_CTRL_PRESSED
const char * get_keyfile() const
int get_input_redir() const
void init(char *dirname, char *exename)
GLsizeiptr const GLvoid GLenum usage
int get_term_height() const
const char * get_port() const
int printm(LPTSTR szModule, BOOL fSystem, DWORD dwMessageId,...)
#define STD_OUTPUT_HANDLE
int telCommandLine(Telnet &MyConnection)
int GetWin32Version(void)
_CRTIMP char *__cdecl strlwr(_Inout_z_ char *_Str)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
static void printUsage(int cmd)
#define ReadFile(a, b, c, d, e)
bool get_set_title() const
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
char * strcpy(char *DstString, const char *SrcString)
int tokenizeCommand(char *szCommand, int &argc, char **argv)
int strcmp(const char *String1, const char *String2)
#define RIGHT_CTRL_PRESSED
BOOL WINAPI SetConsoleWindowInfo(HANDLE hConsoleOutput, BOOL bAbsolute, CONST SMALL_RECT *lpConsoleWindow)
struct task_struct * current
command cmdList[__COMMAND_LIST_SIZE]