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

4.104.11
Last change on this file since b6bebc3b was b6bebc3b, checked in by Joel Sherrill <joel.sherrill@…>, on Dec 18, 2008 at 5:14:26 PM

2008-12-18 Joel Sherrill <joel.sherrill@…>

  • libmisc/shell/cmds.c: Revert back to public. Used to execute monitor commands in test code.
  • 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 *-----------------------------------------------------------*/
32int 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.