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

4.104.115
Last change on this file since e4a3d93 was 031deada, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/02/09 at 13:04:13

Add attribute((unused)) to unused function args.

  • 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(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
50static bool rtems_shell_register_command(const rtems_monitor_command_entry_t *e, void *arg __attribute__((unused)))
51{
52  /* Exclude EXIT (alias quit)*/
53  if (strcmp("exit", e->command) != 0) {
54    rtems_shell_cmd_t *shell_cmd =
55      (rtems_shell_cmd_t *) malloc(sizeof(rtems_shell_cmd_t));
56   
57    if (shell_cmd != NULL) {
58      shell_cmd->name    = e->command;
59      shell_cmd->topic   = "monitor";
60      shell_cmd->usage   = e->usage;
61      shell_cmd->command = rtems_shell_main_monitor;
62      shell_cmd->alias   = NULL;
63      shell_cmd->next    = NULL;
64   
65      if (rtems_shell_add_cmd_struct(shell_cmd) == NULL) {
66        free(shell_cmd);
67      }
68    }
69  }
70
71  return true;
72}
73
74void rtems_shell_register_monitor_commands(void)
75{
76  rtems_monitor_command_iterate(rtems_shell_register_command, NULL);
77}
Note: See TracBrowser for help on using the repository browser.