summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/shell/cmds.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-18 15:25:27 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-18 15:25:27 +0000
commite41eaa881a1a0ba6645d4a23d1313088c8ccfb7f (patch)
tree01edbddc5c654a1fb474fbccf56654bf35eadf1b /cpukit/libmisc/shell/cmds.c
parent2008-12-17 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-e41eaa881a1a0ba6645d4a23d1313088c8ccfb7f.tar.bz2
2008-12-18 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libmisc/serdbg/termios_printk.c, libmisc/serdbg/termios_printk.h: Fixed incompatible return value. * libmisc/cpuuse/cpuusagereport.c: Changed output format. * libmisc/Makefile.am, libmisc/monitor/mon-editor.c: New file. * libmisc/capture/capture-cli.c, libmisc/monitor/mon-command.c, libmisc/monitor/mon-monitor.c, libmisc/monitor/mon-object.c, libmisc/monitor/mon-prmisc.c, libmisc/monitor/mon-symbols.c, libmisc/monitor/monitor.h, libmisc/shell/cat_file.c, libmisc/shell/cmds.c, libmisc/shell/internal.h, libmisc/shell/main_help.c, libmisc/shell/shell.c, libmisc/shell/shell.h, libmisc/shell/shell_cmdset.c, libmisc/shell/shell_getchar.c, libmisc/shell/str2int.c: Various global data is now read only. Added 'const' qualifier to many pointer parameters. It is no longer possible to remove monitor commands. Moved monitor line editor into a separate file to avoid unnecessary dependencies.
Diffstat (limited to 'cpukit/libmisc/shell/cmds.c')
-rw-r--r--cpukit/libmisc/shell/cmds.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/cpukit/libmisc/shell/cmds.c b/cpukit/libmisc/shell/cmds.c
index aa63a46a3b..9cb48d9d76 100644
--- a/cpukit/libmisc/shell/cmds.c
+++ b/cpukit/libmisc/shell/cmds.c
@@ -29,40 +29,48 @@
* with this you can call at all the rtems monitor commands.
* Not all work fine but you can show the rtems status and more.
*-----------------------------------------------------------*/
-int rtems_shell_main_monitor(int argc,char * argv[]) {
- rtems_monitor_command_entry_t *command;
+static int rtems_shell_main_monitor(int argc, char **argv) {
+ const rtems_monitor_command_entry_t *command = NULL;
- if ((command=rtems_monitor_command_lookup(rtems_monitor_commands,argc,argv)))
- command->command_function(argc, argv, &command->command_arg, 0);
+ if (argc < 1) {
+ return 1;
+ }
+
+ command = rtems_monitor_command_lookup(rtems_monitor_commands, argv [0]);
+
+ if (command == NULL) {
+ return 1;
+ }
+
+ command->command_function(argc, argv, &command->command_arg, 0);
return 0;
}
void rtems_shell_register_monitor_commands(void)
{
- rtems_monitor_command_entry_t *command;
-
- /* monitor topic */
- command = rtems_monitor_commands;
-
- while (command) {
- /* Exclude EXIT (alias quit)*/
- if (strcmp("exit",command->command)) {
- rtems_shell_cmd_t *shell_cmd;
-
- shell_cmd = (rtems_shell_cmd_t *) malloc(sizeof(rtems_shell_cmd_t));
- shell_cmd->name = command->command;
- shell_cmd->topic = "monitor";
- shell_cmd->usage = command->usage;
- shell_cmd->command = rtems_shell_main_monitor;
- shell_cmd->alias = (rtems_shell_cmd_t *) NULL;
- shell_cmd->next = (rtems_shell_cmd_t *) NULL;
+ /* Monitor topic */
+ const rtems_monitor_command_entry_t *e = rtems_monitor_commands;
- if (rtems_shell_add_cmd_struct( shell_cmd ) == NULL) {
- free( shell_cmd );
- shell_cmd = NULL;
- }
- }
- command = command->next;
+ 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);
+ }
+ }
+ }
+ e = e->next;
}
}