source: rtems/c/src/lib/libbsp/shared/umon/cli.h @ c193baad

4.104.115
Last change on this file since c193baad was e5764ee, checked in by Joel Sherrill <joel.sherrill@…>, on 11/30/09 at 22:00:47

2009-11-30 Fernando Nicodemos <fgnicodemos@…>

  • umon/cli.h, umon/monlib.c, umon/monlib.h, umon/tfs.h, umon/tfsDriver.c, umon/umon.h, umon/umonrtemsglue.c: Update to match development version.
  • Property mode set to 100644
File size: 4.9 KB
Line 
1/*
2 *  cli.h - Header file for Command Line Interface related stuff
3 *
4 *  Based upon code from MicroMonitor 1.17 from http://www.umonfw.com/
5 *  which includes this notice:
6 *
7 **************************************************************************
8 *  General notice:
9 *  This code is part of a boot-monitor package developed as a generic base
10 *  platform for embedded system designs.  As such, it is likely to be
11 *  distributed to various projects beyond the control of the original
12 *  author.  Please notify the author of any enhancements made or bugs found
13 *  so that all may benefit from the changes.  In addition, notification back
14 *  to the author will allow the new user to pick up changes that may have
15 *  been made by other users after this version of the code was distributed.
16 *
17 *  Note1: the majority of this code was edited with 4-space tabs.
18 *  Note2: as more and more contributions are accepted, the term "author"
19 *         is becoming a mis-representation of credit.
20 *
21 *  Original author:    Ed Sutter
22 *  Email:              esutter@alcatel-lucent.com
23 *  Phone:              908-582-2351
24 **************************************************************************
25 *
26 *  Ed Sutter has been informed that this code is being used in RTEMS.
27 *
28 *  This code was reformatted by Joel Sherrill from OAR Corporation and
29 *  Fernando Nicodemos <fgnicodemos@terra.com.br> from NCB - Sistemas
30 *  Embarcados Ltda. (Brazil) to be more compliant with RTEMS coding
31 *  standards and to eliminate C++ style comments.
32 *
33 *  $Id$
34 */
35
36#ifndef _cli_h
37#define _cli_h
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43/* Command table structure used by the monitor:
44 */
45struct  monCommand {
46    char    *name;                                      /* Name of command seen by user. */
47    int     (*func)(int,char **);       /* Called when command is invoked. */
48    char    **helptxt;                          /* Help text (see notes below). */
49        long    flags;                                  /* Single-bit flags for various uses */
50                                                                        /* (see the CMDFLAG_XXX macros). */
51};
52
53#ifdef __cplusplus
54}
55#endif
56
57/* Bits currently assigned to command flags used in the monCommand
58 * structure...
59 */
60#define CMDFLAG_NOMONRC 1
61
62/* Maximum size of a command line:
63 */
64#ifndef CMDLINESIZE
65#define CMDLINESIZE     128
66#endif
67
68/* Maximum number of arguments in a command line:
69 */
70#define ARGCNT          24
71
72/* Definitions for docommand() return values:
73 *
74 * Note that the CMD_SUCCESS, CMD_FAILURE and CMD_PARAM_ERROR are return
75 * values used by the local command code also.  The remaining errors
76 * (CMD_LINE_ERROR, CMD_ULVL_DENIED and CMD_NOT_FOUND) are used only by
77 # the docommand() function.
78 *
79 *      CMD_SUCCESS:
80 *              Everything worked ok.
81 *      CMD_FAILURE:
82 *              Command parameters were valid, but command itself failed for some other
83 *              reason. The docommand() function does not print a message here, it
84 *              is assumed that the error message was printed by the local function.
85 *      CMD_PARAM_ERROR:
86 *              Command line did not parse properly.  Control was passed to a
87 *              local command function, but argument syntax caused it to choke.
88 *              In this case docommand() will print out the generic CLI syntax error
89 *              message.
90 *      CMD_LINE_ERROR:
91 *              Command line itself was invalid.  Too many args, invalid shell var
92 *              syntax, etc.. Somekind of command line error prior to checking for
93 *              the command name-to-function match.
94 *      CMD_ULVL_DENIED:
95 *              Command's user level is higher than current user level, so access
96 *              is denied.
97 *      CMD_NOT_FOUND:
98 *              Since these same return values are used for each command function
99 *              plus the docommand() function, this error indicates that docommand()
100 *              could not even find the command in the command table.
101 *      CMD_MONRC_DENIED:
102 *              The command cannot execute because it is considered illegal
103 *              when run from within the monrc file.
104 */
105#define CMD_SUCCESS                     0
106#define CMD_FAILURE                     -1
107#define CMD_PARAM_ERROR         -2
108#define CMD_LINE_ERROR          -3
109#define CMD_ULVL_DENIED         -4
110#define CMD_NOT_FOUND           -5
111#define CMD_MONRC_DENIED        -6
112
113/* Notes on help text array:
114 * The monitor's CLI processor assumes that every command's help text
115 * array abides by a few basic rules...
116 * First of all, it assumes that every array has AT LEAST two strings.
117 * The first string in the array of strings is assumed to be a one-line
118 * abstract describing the command.
119 * The second string in the array of strings is assumed to be a usage
120 * message that describes the syntax of the arguments needed by the command.
121 * If this second string is an empty string (""), the docommand() prints out
122 * a generic usage string indicating that there are no options or arguements
123 * to apply to the command.
124 * All remaining lines are formatted based on the needs of the individual
125 * command and the final string is a null pointer to let the CLI processor
126 * know where the end is.
127 * Following is an example help text array...
128 *
129 *      char *HelpHelp[] = {
130 *                      "Display command set",
131 *                      "-[d] [commandname]",
132 *                      "Options:",
133 *                      " -d   list commands and descriptions",
134 *                      0,
135 *      };
136 *
137 */
138#endif
Note: See TracBrowser for help on using the repository browser.