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

4.115
Last change on this file since ffd5285 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • 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.org/license/LICENSE.
11 */
12
13#ifdef HAVE_CONFIG_H
14#include "config.h"
15#endif
16
17#include <stdio.h>
18#include <string.h>
19#include <stdlib.h>
20
21#include <rtems.h>
22#include <rtems/monitor.h>
23#include <rtems/shell.h>
24#include "internal.h"
25
26/*-----------------------------------------------------------*
27 * with this you can call at all the rtems monitor commands.
28 * Not all work fine but you can show the rtems status and more.
29 *-----------------------------------------------------------*/
30int rtems_shell_main_monitor(int argc, char **argv) {
31  const rtems_monitor_command_entry_t *command = NULL;
32
33  if (argc < 1) {
34    return 1;
35  }
36
37  command = rtems_monitor_command_lookup(argv [0]);
38
39  if (command == NULL) {
40    return 1;
41  }
42
43  command->command_function(argc, argv, &command->command_arg, 0);
44
45  return 0;
46}
47
48static bool rtems_shell_register_command(const rtems_monitor_command_entry_t *e, void *arg __attribute__((unused)))
49{
50  /* Exclude EXIT (alias quit)*/
51  if (strcmp("exit", e->command) != 0) {
52    rtems_shell_cmd_t *shell_cmd =
53      (rtems_shell_cmd_t *) malloc(sizeof(rtems_shell_cmd_t));
54
55    if (shell_cmd != NULL) {
56      shell_cmd->name    = e->command;
57      shell_cmd->topic   = "monitor";
58      shell_cmd->usage   = e->usage;
59      shell_cmd->command = rtems_shell_main_monitor;
60      shell_cmd->alias   = NULL;
61      shell_cmd->next    = NULL;
62
63      if (rtems_shell_add_cmd_struct(shell_cmd) == NULL) {
64        free(shell_cmd);
65      }
66    }
67  }
68
69  return true;
70}
71
72void rtems_shell_register_monitor_commands(void)
73{
74  rtems_monitor_command_iterate(rtems_shell_register_command, NULL);
75}
Note: See TracBrowser for help on using the repository browser.