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;
295 if (chr ==
'\b' &&
current > 0) {
317int 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++ ) {
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 strcmp(const char *String1, const char *String2)
char * strncat(char *DstString, const char *SrcString, ACPI_SIZE Count)
ACPI_SIZE strlen(const char *String)
char * strcpy(char *DstString, const char *SrcString)
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
BOOL WINAPI SetConsoleTextAttribute(IN HANDLE hConsoleOutput, IN WORD wAttributes)
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
int get_term_height() const
bool set_value(const char *var, const char *value)
int get_input_redir() const
bool get_set_title() const
bool Process_Params(int argc, char *argv[])
int get_term_width() const
void init(char *dirname, char *exename)
const char * get_keyfile() const
const char * get_host() const
const char * get_port() const
int LoadKeyMap(const char *file, const char *name)
int Open(const char *szHost, const char *strPort="23")
#define ReadFile(a, b, c, d, e)
BOOL WINAPI SetConsoleWindowInfo(HANDLE hConsoleOutput, BOOL bAbsolute, CONST SMALL_RECT *lpConsoleWindow)
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleScreenBufferSize(HANDLE hConsoleOutput, COORD dwSize)
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GLsizeiptr const GLvoid GLenum usage
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
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
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
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
struct task_struct * current
int __cdecl system(_In_opt_z_ const char *_Command)
_CRTIMP char *__cdecl strlwr(_Inout_z_ char *_Str)
_CRT_RESTORE_GCC_WARNINGS _CRT_DISABLE_GCC_WARNINGS _Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
union _KEY_EVENT_RECORD::@3285 uChar
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
int printit(const char *it)
int printm(LPTSTR szModule, BOOL fSystem, DWORD dwMessageId,...)
int tokenizeCommand(char *szCommand, int &argc, char **argv)
static int cmdMatch(const char *cmd, const char *token, int tokenLen, int minM)
command cmdList[__COMMAND_LIST_SIZE]
int telCommandLine(Telnet &MyConnection)
struct cmdHistory * cfgets(char *buf, unsigned int length, struct cmdHistory *cmdhist)
int GetWin32Version(void)
#define STD_OUTPUT_HANDLE
#define GetModuleFileName
#define LEFT_CTRL_PRESSED
#define ENABLE_ECHO_INPUT
#define RIGHT_CTRL_PRESSED
#define ENABLE_LINE_INPUT