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

4.104.115
Last change on this file since b6bebc3b was b6bebc3b, checked in by Joel Sherrill <joel.sherrill@…>, on 12/18/08 at 17:14:26

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
RevLine 
[dd74e612]1/*
[814d9588]2 *  XXX -- Just monitor commands until those can be integrated better
3 *
[4e5299f]4 *  Author: Fernando RUIZ CASAS
[dd74e612]5 *  Work: fernando.ruiz@ctv.es
6 *  Home: correo@fernando-ruiz.com
7 *
[4e5299f]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.
[dd74e612]11 *
12 *  $Id$
13 */
14
[550c3df7]15#ifdef HAVE_CONFIG_H
16#include "config.h"
17#endif
18
[dd74e612]19#include <stdio.h>
20#include <string.h>
[9d773936]21#include <stdlib.h>
[dd74e612]22
23#include <rtems.h>
24#include <rtems/monitor.h>
25#include <rtems/shell.h>
[4e5299f]26#include "internal.h"
[dd74e612]27
[aed742c]28/*-----------------------------------------------------------*
[4e5299f]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.
[dd74e612]31 *-----------------------------------------------------------*/
[b6bebc3b]32int rtems_shell_main_monitor(int argc, char **argv) {
[e41eaa88]33  const rtems_monitor_command_entry_t *command = NULL;
[dd74e612]34
[e41eaa88]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);
[dd74e612]46
[b2712e3]47  return 0;
48}
[4e5299f]49
[2eeb648c]50void rtems_shell_register_monitor_commands(void)
[814d9588]51{
[e41eaa88]52  /* Monitor topic */
53  const rtems_monitor_command_entry_t *e = rtems_monitor_commands;
[9d773936]54
[e41eaa88]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;
[4e5299f]75  }
[dd74e612]76}
Note: See TracBrowser for help on using the repository browser.