source: rtems/cpukit/libmisc/shell/cmds.c @ e41eaa88

4.104.115
Last change on this file since e41eaa88 was e41eaa88, checked in by Joel Sherrill <joel.sherrill@…>, on 12/18/08 at 15:25:27

2008-12-18 Sebastian Huber <sebastian.huber@…>

  • 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.
  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 *  XXX -- Just monitor commands until those can be integrated better
3 *
4 *  Author: Fernando RUIZ CASAS
5 *  Work: fernando.ruiz@ctv.es
6 *  Home: correo@fernando-ruiz.com
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#ifdef HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <stdio.h>
20#include <string.h>
21#include <stdlib.h>
22
23#include <rtems.h>
24#include <rtems/monitor.h>
25#include <rtems/shell.h>
26#include "internal.h"
27
28/*-----------------------------------------------------------*
29 * with this you can call at all the rtems monitor commands.
30 * Not all work fine but you can show the rtems status and more.
31 *-----------------------------------------------------------*/
32static int rtems_shell_main_monitor(int argc, char **argv) {
33  const rtems_monitor_command_entry_t *command = NULL;
34
35  if (argc < 1) {
36    return 1;
37  }
38
39  command = rtems_monitor_command_lookup(rtems_monitor_commands, argv [0]);
40
41  if (command == NULL) {
42    return 1;
43  }
44
45  command->command_function(argc, argv, &command->command_arg, 0);
46
47  return 0;
48}
49
50void rtems_shell_register_monitor_commands(void)
51{
52  /* Monitor topic */
53  const rtems_monitor_command_entry_t *e = rtems_monitor_commands;
54
55  while (e != NULL) {
56    /* Exclude EXIT (alias quit)*/
57    if (e->command != NULL && strcmp("exit", e->command) != 0) {
58      rtems_shell_cmd_t *shell_cmd =
59        (rtems_shell_cmd_t *) malloc(sizeof(rtems_shell_cmd_t));
60     
61      if (shell_cmd != NULL) {
62        shell_cmd->name    = e->command;
63        shell_cmd->topic   = "monitor";
64        shell_cmd->usage   = e->usage;
65        shell_cmd->command = rtems_shell_main_monitor;
66        shell_cmd->alias   = NULL;
67        shell_cmd->next    = NULL;
68     
69        if (rtems_shell_add_cmd_struct(shell_cmd) == NULL) {
70          free(shell_cmd);
71        }
72      }
73    }
74    e = e->next;
75  }
76}
Note: See TracBrowser for help on using the repository browser.