Line 485... |
Line 485... |
bufOut[0] = 8;
|
bufOut[0] = 8;
|
bufOut[1] = ' ';
|
bufOut[1] = ' ';
|
bufOut[2] = 8;
|
bufOut[2] = 8;
|
for(i = 0; i < length; ++i)
|
for(i = 0; i < length; ++i)
|
IPWrite(socket, (uint8*)bufOut, 3);
|
IPWrite(socket, (uint8*)bufOut, 3);
|
if(CommandIndex && CommandPtr[CommandIndex-1])
|
|
strcpy(command, CommandPtr[CommandIndex-1]);
|
|
else
|
|
command[0] = 0;
|
command[0] = 0;
|
|
if(CommandIndex && CommandPtr[CommandIndex-1])
|
|
strncat(command, CommandPtr[CommandIndex-1], COMMAND_BUFFER_SIZE-1);
|
length = (int)strlen(command);
|
length = (int)strlen(command);
|
IPWrite(socket, (uint8*)command, length);
|
IPWrite(socket, (uint8*)command, length);
|
j += 2;
|
j += 2;
|
}
|
}
|
else
|
else
|
Line 508... |
Line 507... |
ptr = strstr(command, "\r\n");
|
ptr = strstr(command, "\r\n");
|
if(ptr)
|
if(ptr)
|
{
|
{
|
ptr[0] = 0;
|
ptr[0] = 0;
|
bufOut[0] = 0;
|
bufOut[0] = 0;
|
if(command[0])
|
length = (int)strlen(command);
|
|
if(command[0] && length < COMMAND_BUFFER_SIZE)
|
{
|
{
|
// Save command in CommandHistory
|
// Save command in CommandHistory
|
memcpy(CommandHistory + length + 1, CommandHistory,
|
memmove(CommandHistory + length + 1, CommandHistory,
|
sizeof(CommandHistory) - length - 1);
|
sizeof(CommandHistory) - length - 1);
|
|
strcpy(CommandHistory, command);
|
|
CommandHistory[sizeof(CommandHistory)-1] = 0;
|
for(i = COMMAND_BUFFER_COUNT-2; i >= 0; --i)
|
for(i = COMMAND_BUFFER_COUNT-2; i >= 0; --i)
|
{
|
{
|
if(CommandPtr[i+1] && CommandPtr[i+1] + length + 1 >=
|
if(CommandPtr[i] == NULL || CommandPtr[i] + length + 1 >=
|
CommandHistory + sizeof(CommandHistory))
|
CommandHistory + sizeof(CommandHistory))
|
CommandPtr[i+1] = NULL;
|
CommandPtr[i+1] = NULL;
|
else if(CommandPtr[i])
|
else
|
CommandPtr[i+1] = CommandPtr[i] + length + 1;
|
CommandPtr[i+1] = CommandPtr[i] + length + 1;
|
}
|
}
|
CommandPtr[CommandIndex] = CommandHistory;
|
CommandPtr[0] = CommandHistory;
|
strcpy(CommandHistory, command);
|
|
}
|
}
|
if(strncmp(command, "help", 4) == 0)
|
if(strncmp(command, "help", 4) == 0)
|
{
|
{
|
sprintf((char*)bufOut, "Commands: help, exit, cat, cp, ls, mkdir, rm, flasherase");
|
sprintf((char*)bufOut, "Commands: help, exit, cat, cp, ls, mkdir, rm, flasherase");
|
for(i = 0; TelnetFuncList[i].name; ++i)
|
for(i = 0; TelnetFuncList[i].name; ++i)
|
Line 854... |
Line 855... |
fclose(file);
|
fclose(file);
|
IPPrintf(socket, "Created myfile.txt");
|
IPPrintf(socket, "Created myfile.txt");
|
}
|
}
|
|
|
|
|
|
#ifdef DLL_SETUP
|
|
#define DLL_ADDRESS 0x10100000
|
|
#include "dll.h"
|
|
static void ConsoleRun(IPSocket *socket, char *command)
|
|
{
|
|
OS_FILE *file;
|
|
char buf[COMMAND_BUFFER_SIZE], name[80], arg0[80], arg1[80];
|
|
int bytes;
|
|
DllFunc funcPtr;
|
|
|
|
memset(arg0, 0, sizeof(arg0));
|
|
memset(arg1, 0, sizeof(arg1));
|
|
sscanf(command, "%s %s %s %s", buf, name, arg0, arg1);
|
|
file = fopen(name, "r");
|
|
if(file == NULL)
|
|
{
|
|
IPPrintf(socket, "Can't find %s", name);
|
|
return;
|
|
}
|
|
memset((void*)DLL_ADDRESS, 0, 1024*256);
|
|
bytes = fread((uint8*)DLL_ADDRESS, 1, 1024*1024*8, file);
|
|
fclose(file);
|
|
funcPtr = (DllFunc)DLL_ADDRESS;
|
|
funcPtr(DllFList, socket, arg0, arg1);
|
|
}
|
|
#endif
|
|
|
|
|
static TelnetFunc_t MyFuncs[] = {
|
static TelnetFunc_t MyFuncs[] = {
|
{"info", 0, ConsoleInfo},
|
{"info", 0, ConsoleInfo},
|
{"math", 0, ConsoleMath},
|
{"math", 0, ConsoleMath},
|
{"ping", 0, ConsolePing},
|
{"ping", 0, ConsolePing},
|
{"ftp", 0, ConsoleFtp},
|
{"ftp", 0, ConsoleFtp},
|
{"tftp", 0, ConsoleTftp},
|
{"tftp", 0, ConsoleTftp},
|
{"show", 0, ConsoleShow},
|
{"show", 0, ConsoleShow},
|
{"clear", 0, ConsoleClear},
|
{"clear", 0, ConsoleClear},
|
{"mkfile", 0, ConsoleMkfile},
|
{"mkfile", 0, ConsoleMkfile},
|
|
#ifdef DLL_SETUP
|
|
{"run", 0, ConsoleRun},
|
|
#endif
|
{NULL, 0, NULL}
|
{NULL, 0, NULL}
|
};
|
};
|
|
|
|
|
void ConsoleInit(void)
|
void ConsoleInit(void)
|