version 1.1.2.2, 2010/03/09 13:47:02
|
version 1.1.2.5, 2010/03/18 23:40:56
|
Line 38 int io_Cmd_Help(void *cmds, FILE *out, char ** __restr
|
Line 38 int io_Cmd_Help(void *cmds, FILE *out, char ** __restr
|
|
|
if (!args) { |
if (!args) { |
fprintf(out, "\n"); |
fprintf(out, "\n"); |
for (i = 0; commands[i].cmd_name; i++) | fflush(out); |
| for (i = 0; commands[i].cmd_name; i++) { |
fprintf(out, "%s\t\t%s\n", commands[i].cmd_name, commands[i].cmd_doc); |
fprintf(out, "%s\t\t%s\n", commands[i].cmd_name, commands[i].cmd_doc); |
|
fflush(out); |
|
} |
} else { |
} else { |
if (!args[1]) | if (!args[1]) { |
fprintf(out, "Help screen::\n"); |
fprintf(out, "Help screen::\n"); |
else | fflush(out); |
| } else |
if (!strncmp(args[1], "---", 3)) |
if (!strncmp(args[1], "---", 3)) |
return 0; |
return 0; |
|
|
Line 53 int io_Cmd_Help(void *cmds, FILE *out, char ** __restr
|
Line 57 int io_Cmd_Help(void *cmds, FILE *out, char ** __restr
|
|
|
fprintf(out, "%s%s\t\t%s\n", args[1] ? "Syntax::\n\t" : "", commands[i].cmd_name, |
fprintf(out, "%s%s\t\t%s\n", args[1] ? "Syntax::\n\t" : "", commands[i].cmd_name, |
args[1] ? commands[i].cmd_help : commands[i].cmd_doc); |
args[1] ? commands[i].cmd_help : commands[i].cmd_doc); |
|
fflush(out); |
} |
} |
} |
} |
|
|
Line 69 int io_Cmd_Help(void *cmds, FILE *out, char ** __restr
|
Line 74 int io_Cmd_Help(void *cmds, FILE *out, char ** __restr
|
int io_Cmd_Unsupported(void *cmds, FILE *out, char ** __restrict args) |
int io_Cmd_Unsupported(void *cmds, FILE *out, char ** __restrict args) |
{ |
{ |
fprintf(out, "Command %s not supported in this version ...\n", args[0]); |
fprintf(out, "Command %s not supported in this version ...\n", args[0]); |
|
fflush(out); |
return 0; |
return 0; |
} |
} |
|
|
// ------------------------------------------------------------ |
// ------------------------------------------------------------ |
|
|
|
/* |
|
* io_Comp_Filename() Builtin helper function for filename completion arguments |
|
* @text = Text line |
|
* @state = Position state |
|
* return: NULL not found filename, != NULL filename |
|
*/ |
|
char *io_Comp_Filename(const char *text, int state) |
|
{ |
|
return rl_filename_completion_function(text, state); |
|
} |
|
|
|
// ------------------------------------------------------------ |
|
|
#pragma GCC visibility push(hidden) |
#pragma GCC visibility push(hidden) |
|
|
ioCommands_t io_stdCmds[] = { |
ioCommands_t io_stdCmds[] = { |
{ "test", io_Cmd_Unsupported, "Test - Don`t use default command structure!", "test <cr>", NULL }, | { "test", io_Cmd_Unsupported, "Test - Don`t use default command structure!", "test <cr>", io_Comp_Filename }, |
{ "-------", NULL, "---------------------", NULL, NULL }, |
{ "-------", NULL, "---------------------", NULL, NULL }, |
{ "help", io_Cmd_Help, "Help screen", "help [command] <cr>", NULL }, |
{ "help", io_Cmd_Help, "Help screen", "help [command] <cr>", NULL }, |
{ "exit", io_Cmd_Exit, "Exit from console", "exit <cr>", NULL }, |
{ "exit", io_Cmd_Exit, "Exit from console", "exit <cr>", NULL }, |
Line 131 int ioCLIExec(ioCommands_t *cmdList, FILE *out, const
|
Line 150 int ioCLIExec(ioCommands_t *cmdList, FILE *out, const
|
{ |
{ |
int len = strlen(text); |
int len = strlen(text); |
|
|
for (i = state; cmdList[i].cmd_name; i++) | for (i = state; cmdList[i].cmd_name; i++) { |
if (strncmp(cmdList[i].cmd_name, "---", 3) && |
if (strncmp(cmdList[i].cmd_name, "---", 3) && |
!strncmp(cmdList[i].cmd_name, text, len)) |
!strncmp(cmdList[i].cmd_name, text, len)) |
return strdup(cmdList[i].cmd_name); |
return strdup(cmdList[i].cmd_name); |
|
} |
|
|
return NULL; |
return NULL; |
} |
} |
Line 142 int ioCLIExec(ioCommands_t *cmdList, FILE *out, const
|
Line 162 int ioCLIExec(ioCommands_t *cmdList, FILE *out, const
|
if (!start) |
if (!start) |
matches = rl_completion_matches(text, cmdCompGet); |
matches = rl_completion_matches(text, cmdCompGet); |
else |
else |
for (i = 0; cmdList[i].cmd_name; i++) | for (i = 0; cmdList[i].cmd_name; i++) { |
if (cmdList[i].cmd_comp && !strncmp(rl_line_buffer, | if (!cmdList[i].cmd_comp) |
cmdList[i].cmd_name, strlen(cmdList[i].cmd_name))) | continue; |
| if (!strncmp(rl_line_buffer, cmdList[i].cmd_name, strlen(cmdList[i].cmd_name))) |
matches = rl_completion_matches(text, cmdList[i].cmd_comp); |
matches = rl_completion_matches(text, cmdList[i].cmd_comp); |
|
} |
|
|
return matches; |
return matches; |
} |
} |
Line 191 int ioCLIExec(ioCommands_t *cmdList, FILE *out, const
|
Line 213 int ioCLIExec(ioCommands_t *cmdList, FILE *out, const
|
} |
} |
if (!cmd) { |
if (!cmd) { |
fprintf(out, "Command '%s' not found!\n", items[0]); |
fprintf(out, "Command '%s' not found!\n", items[0]); |
|
fflush(out); |
ret = -1; |
ret = -1; |
} else |
} else |
ret = cmd->cmd_func(cmdList, out, items); |
ret = cmd->cmd_func(cmdList, out, items); |