![]() |
|
|||
File indexing completed on 2025-05-11 08:23:43
0001 /** 0002 * @file 0003 * 0004 * @ingroup shared_cli 0005 * 0006 * @brief Header file for Command Line Interface related stuff 0007 */ 0008 0009 /* Based upon code from MicroMonitor 1.17 from http://www.umonfw.com/ 0010 * which includes this notice: 0011 * 0012 ************************************************************************** 0013 * General notice: 0014 * This code is part of a boot-monitor package developed as a generic base 0015 * platform for embedded system designs. As such, it is likely to be 0016 * distributed to various projects beyond the control of the original 0017 * author. Please notify the author of any enhancements made or bugs found 0018 * so that all may benefit from the changes. In addition, notification back 0019 * to the author will allow the new user to pick up changes that may have 0020 * been made by other users after this version of the code was distributed. 0021 * 0022 * Note1: the majority of this code was edited with 4-space tabs. 0023 * Note2: as more and more contributions are accepted, the term "author" 0024 * is becoming a mis-representation of credit. 0025 * 0026 * Original author: Ed Sutter 0027 * Email: esutter@alcatel-lucent.com 0028 * Phone: 908-582-2351 0029 ************************************************************************** 0030 * 0031 * Ed Sutter has been informed that this code is being used in RTEMS. 0032 * 0033 * This code was reformatted by Joel Sherrill from OAR Corporation and 0034 * Fernando Nicodemos <fgnicodemos@terra.com.br> from NCB - Sistemas 0035 * Embarcados Ltda. (Brazil) to be more compliant with RTEMS coding 0036 * standards and to eliminate C++ style comments. 0037 */ 0038 0039 #ifndef _cli_h 0040 #define _cli_h 0041 0042 #ifdef __cplusplus 0043 extern "C" { 0044 #endif 0045 0046 /** 0047 * @defgroup shared_cli Command table structure 0048 * 0049 * @ingroup shared_umon 0050 * 0051 * @brief Command table structure used by the monitor: 0052 */ 0053 0054 struct monCommand { 0055 char *name; /* Name of command seen by user. */ 0056 int (*func)(int,char **); /* Called when command is invoked. */ 0057 char **helptxt; /* Help text (see notes below). */ 0058 long flags; /* Single-bit flags for various uses */ 0059 /* (see the CMDFLAG_XXX macros). */ 0060 }; 0061 0062 #ifdef __cplusplus 0063 } 0064 #endif 0065 0066 /* Bits currently assigned to command flags used in the monCommand 0067 * structure... 0068 */ 0069 #define CMDFLAG_NOMONRC 1 0070 0071 /* Maximum size of a command line: 0072 */ 0073 #ifndef CMDLINESIZE 0074 #define CMDLINESIZE 128 0075 #endif 0076 0077 /* Maximum number of arguments in a command line: 0078 */ 0079 #define ARGCNT 24 0080 0081 /* Definitions for docommand() return values: 0082 * 0083 * Note that the CMD_SUCCESS, CMD_FAILURE and CMD_PARAM_ERROR are return 0084 * values used by the local command code also. The remaining errors 0085 * (CMD_LINE_ERROR, CMD_ULVL_DENIED and CMD_NOT_FOUND) are used only by 0086 # the docommand() function. 0087 * 0088 * CMD_SUCCESS: 0089 * Everything worked ok. 0090 * CMD_FAILURE: 0091 * Command parameters were valid, but command itself failed for some other 0092 * reason. The docommand() function does not print a message here, it 0093 * is assumed that the error message was printed by the local function. 0094 * CMD_PARAM_ERROR: 0095 * Command line did not parse properly. Control was passed to a 0096 * local command function, but argument syntax caused it to choke. 0097 * In this case docommand() will print out the generic CLI syntax error 0098 * message. 0099 * CMD_LINE_ERROR: 0100 * Command line itself was invalid. Too many args, invalid shell var 0101 * syntax, etc.. Somekind of command line error prior to checking for 0102 * the command name-to-function match. 0103 * CMD_ULVL_DENIED: 0104 * Command's user level is higher than current user level, so access 0105 * is denied. 0106 * CMD_NOT_FOUND: 0107 * Since these same return values are used for each command function 0108 * plus the docommand() function, this error indicates that docommand() 0109 * could not even find the command in the command table. 0110 * CMD_MONRC_DENIED: 0111 * The command cannot execute because it is considered illegal 0112 * when run from within the monrc file. 0113 */ 0114 #define CMD_SUCCESS 0 0115 #define CMD_FAILURE -1 0116 #define CMD_PARAM_ERROR -2 0117 #define CMD_LINE_ERROR -3 0118 #define CMD_ULVL_DENIED -4 0119 #define CMD_NOT_FOUND -5 0120 #define CMD_MONRC_DENIED -6 0121 0122 /* Notes on help text array: 0123 * The monitor's CLI processor assumes that every command's help text 0124 * array abides by a few basic rules... 0125 * First of all, it assumes that every array has AT LEAST two strings. 0126 * The first string in the array of strings is assumed to be a one-line 0127 * abstract describing the command. 0128 * The second string in the array of strings is assumed to be a usage 0129 * message that describes the syntax of the arguments needed by the command. 0130 * If this second string is an empty string (""), the docommand() prints out 0131 * a generic usage string indicating that there are no options or arguements 0132 * to apply to the command. 0133 * All remaining lines are formatted based on the needs of the individual 0134 * command and the final string is a null pointer to let the CLI processor 0135 * know where the end is. 0136 * Following is an example help text array... 0137 * 0138 * char *HelpHelp[] = { 0139 * "Display command set", 0140 * "-[d] [commandname]", 0141 * "Options:", 0142 * " -d list commands and descriptions", 0143 * 0, 0144 * }; 0145 * 0146 */ 0147 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |