summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/shell/cmds.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-19 14:59:35 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-19 14:59:35 +0000
commiteb961961837bd288fb57799c189326fc944047b5 (patch)
treee857eea22b553b5288811467a2089ab87ad368ad /cpukit/libmisc/shell/cmds.c
parent2008-12-18 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-eb961961837bd288fb57799c189326fc944047b5.tar.bz2
2008-12-19 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libblock/src/ide_part_table.c: Fixed NULL pointer access. * libmisc/monitor/mon-command.c, libmisc/monitor/mon-editor.c, libmisc/monitor/mon-monitor.c, libmisc/monitor/monitor.h, libmisc/shell/cmds.c: The list of registered monitor commands is now private and only accessible via a lookup and iterate function.
Diffstat (limited to 'cpukit/libmisc/shell/cmds.c')
-rw-r--r--cpukit/libmisc/shell/cmds.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/cpukit/libmisc/shell/cmds.c b/cpukit/libmisc/shell/cmds.c
index 4664f482ea..2a3a029add 100644
--- a/cpukit/libmisc/shell/cmds.c
+++ b/cpukit/libmisc/shell/cmds.c
@@ -36,7 +36,7 @@ int rtems_shell_main_monitor(int argc, char **argv) {
return 1;
}
- command = rtems_monitor_command_lookup(rtems_monitor_commands, argv [0]);
+ command = rtems_monitor_command_lookup(argv [0]);
if (command == NULL) {
return 1;
@@ -47,30 +47,31 @@ int rtems_shell_main_monitor(int argc, char **argv) {
return 0;
}
-void rtems_shell_register_monitor_commands(void)
+static bool rtems_shell_register_command(const rtems_monitor_command_entry_t *e, void *arg)
{
- /* Monitor topic */
- const rtems_monitor_command_entry_t *e = rtems_monitor_commands;
-
- while (e != NULL) {
- /* Exclude EXIT (alias quit)*/
- if (e->command != NULL && strcmp("exit", e->command) != 0) {
- rtems_shell_cmd_t *shell_cmd =
- (rtems_shell_cmd_t *) malloc(sizeof(rtems_shell_cmd_t));
-
- if (shell_cmd != NULL) {
- shell_cmd->name = e->command;
- shell_cmd->topic = "monitor";
- shell_cmd->usage = e->usage;
- shell_cmd->command = rtems_shell_main_monitor;
- shell_cmd->alias = NULL;
- shell_cmd->next = NULL;
-
- if (rtems_shell_add_cmd_struct(shell_cmd) == NULL) {
- free(shell_cmd);
- }
+ /* Exclude EXIT (alias quit)*/
+ if (strcmp("exit", e->command) != 0) {
+ rtems_shell_cmd_t *shell_cmd =
+ (rtems_shell_cmd_t *) malloc(sizeof(rtems_shell_cmd_t));
+
+ if (shell_cmd != NULL) {
+ shell_cmd->name = e->command;
+ shell_cmd->topic = "monitor";
+ shell_cmd->usage = e->usage;
+ shell_cmd->command = rtems_shell_main_monitor;
+ shell_cmd->alias = NULL;
+ shell_cmd->next = NULL;
+
+ if (rtems_shell_add_cmd_struct(shell_cmd) == NULL) {
+ free(shell_cmd);
}
}
- e = e->next;
}
+
+ return true;
+}
+
+void rtems_shell_register_monitor_commands(void)
+{
+ rtems_monitor_command_iterate(rtems_shell_register_command, NULL);
}