1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

* shell_commands can be added as a module to user defined shell commands

This commit is contained in:
Oliver Hahm 2010-11-04 19:06:46 +01:00
parent 3b218ec24a
commit c389518a09

View File

@ -47,17 +47,30 @@ and the mailinglist (subscription via web site)
#include <malloc.h>
#include <stdlib.h>
#include <shell.h>
#include <shell_commands.h>
#include <stdint.h>
static void(*find_handler(const shell_command_t *command_list, char *command))(char*) {
const shell_command_t *entry = command_list;
const shell_command_t* entry = command_list;
while(entry->name != NULL) {
while (entry->name != NULL) {
if ( strcmp(entry->name, command) == 0) {
return entry->handler;
} else {
entry++;
}
}
#ifdef MODULE_SHELL_COMMANDS
entry = _shell_command_list;
while (entry->name != NULL) {
if ( strcmp(entry->name, command) == 0) {
return entry->handler;
} else {
entry++;
}
}
#endif
return NULL;
}
@ -65,11 +78,20 @@ static void print_help(const shell_command_t *command_list) {
const shell_command_t *entry = command_list;
printf("%-20s %s\n", "Command", "Description");
puts("---------------------------------------");
while(entry->name != NULL) {
while (entry->name != NULL) {
printf("%-20s %s\n", entry->name, entry->desc);
entry++;
}
#ifdef MODULE_SHELL_COMMANDS
entry = _shell_command_list;
while (entry->name != NULL) {
printf("%-20s %s\n", entry->name, entry->desc);
entry++;
}
#endif
}
static void handle_input_line(shell_t *shell, char* line) {
@ -122,7 +144,7 @@ void shell_run(shell_t *shell) {
char line_buf[255];
while(1) {
shell->put_char('> ');
shell->put_char('>');
int res = readline(shell, line_buf, sizeof(line_buf));
if (! res ) {
char* line_copy = strdup(line_buf);