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