GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> CLI / V0-1-2 > cli / rhel6-64
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <CLI/CLI_msgs.h>
#include <CLI/CLI_pubdefs.h>
#include <MDB/MDB_pubdefs.h>
#include <CLI_prvdefs.h>
Typedefs | |
typedef enum _CLI_Mode | CLI_Mode |
Typedef for enum _CLI_Mode. | |
Enumerations | |
enum | _CLI_Mode { CLI_MD_VERB, CLI_MD_QUAL, CLI_MD_PVAL, CLI_MD_QVAL } |
Parsing mode. More... | |
Functions | |
static unsigned int | dispatch (CLI_Control *ctl, void *user) |
Dispatch a CLI command. | |
static unsigned int | reportQual (unsigned int status, char *tbeg, char *tend) |
A "standardized" message code report for qualifiers. | |
static unsigned int | reportVerb (unsigned int status, char *tbeg, char *tend) |
A "standardized" message code report for verbs. | |
static unsigned int | savePval (char *tbeg, char *tend, CLI_ParmDef *pdef, CLI_Parm **plst) |
Validate and save a parameter value. | |
static unsigned int | saveQual (char *tbeg, char *tend, CLI_VerbDef *vdef, CLI_Qual *qhed, CLI_Qual **qret, CLI_QualDef **qdef) |
Validate and save a qualifier. | |
static unsigned int | saveQval (char *tbeg, char *tend, CLI_Qual *qual, CLI_QualDef *qdef) |
Validate and save a qualifier value. | |
static unsigned int | saveRest (char *tbeg, CLI_Parm **plst) |
Save the rest of the line as a single parameter. | |
static unsigned int | saveVerb (char *tbeg, char *tend, CLI_Control *ctl, CLI_VerbDef **vdef) |
Validate and save a verb. | |
unsigned int | CLI_parse (const char *ilin, CLI_Control *ctl, void *user) |
Parse a command line with the given syntax. |
CVS $Id: CLI_parse.c,v 1.7 2011/03/25 00:51:25 apw Exp $
enum _CLI_Mode |
unsigned int CLI_parse | ( | const char * | ilin, | |
CLI_Control * | ctl, | |||
void * | user | |||
) |
Parse a command line with the given syntax.
ilin | Input line to parse | |
ctl | CLI control structure | |
user | (Opaque) pointer to user parameter(s) |
References CLI_clearTokens(), CLI_command(), CLI_MD_PVAL, CLI_MD_QUAL, CLI_MD_QVAL, CLI_present(), CLI_squeeze(), dispatch(), _CLI_Tokens::line, _CLI_QualDef::next, _CLI_ParmDef::next, _CLI_Qual::next, _CLI_QualDef::opts, _CLI_VerbDef::parm, _CLI_Tokens::parm, _CLI_VerbDef::preq, _CLI_VerbDef::qual, _CLI_Tokens::qual, savePval(), saveQual(), saveQval(), saveRest(), saveVerb(), _CLI_ParmDef::sork, _CLI_QualDef::text, _CLI_Control::tokens, and _CLI_ParmDef::type.
Referenced by CLI_command().
static unsigned int dispatch | ( | CLI_Control * | ctl, | |
void * | user | |||
) | [inline, static] |
Dispatch a CLI command.
ctl | CLI control structure | |
user | (Opaque) pointer to user parameter(s) |
References _CLI_VerbDef::func, _CLI_VerbDef::next, _CLI_Control::syntax, _CLI_VerbDef::text, _CLI_Control::tokens, _CLI_Tokens::verb, and _CLI_Syntax::verb.
Referenced by CLI_parse().
static unsigned int reportQual | ( | unsigned int | status, | |
char * | tbeg, | |||
char * | tend | |||
) | [inline, static] |
A "standardized" message code report for qualifiers.
status | (in) Message code | |
tbeg | (in) First character | |
tend | (in) (One past) the last character |
status | The value of status (after it's been reported) |
Referenced by saveQual().
static unsigned int reportVerb | ( | unsigned int | status, | |
char * | tbeg, | |||
char * | tend | |||
) | [inline, static] |
A "standardized" message code report for verbs.
status | (in) Message code | |
tbeg | (in) First character | |
tend | (in) (One past) the last character |
status | The value of status (after it's been reported) |
Referenced by saveVerb().
static unsigned int savePval | ( | char * | tbeg, | |
char * | tend, | |||
CLI_ParmDef * | pdef, | |||
CLI_Parm ** | plst | |||
) | [inline, static] |
Validate and save a parameter value.
tbeg | First character | |
tend | (One past) the last character | |
pdef | Parameter definition | |
plst | Where to link the new parameter structure (if successful) |
CLI_AMBGKEY | Keyword is ambiguous | |
CLI_BADALLOC | Memory allocation failure | |
CLI_BADPAREN | Unexpected/unbalanced parentheses | |
CLI_BADQUOTE | Unexpected/unbalanced quotation marks | |
CLI_NOTAFLT | Value is not a floating point number | |
CLI_NOTALIST | Unexpected list of values | |
CLI_NOTANINT | Value is not an integer | |
CLI_NOTAKEY | Value is not a valid keyword | |
CLI_SUCCESS | Success | |
CLI_VALUEND | Unexpected end of value |
References CLI_parseValue(), _CLI_Parm::curr, _CLI_Parm::flag, _CLI_Parm::list, _CLI_Parm::next, _CLI_ParmDef::sork, and _CLI_ParmDef::type.
Referenced by CLI_parse().
static unsigned int saveQual | ( | char * | tbeg, | |
char * | tend, | |||
CLI_VerbDef * | vdef, | |||
CLI_Qual * | qhed, | |||
CLI_Qual ** | qret, | |||
CLI_QualDef ** | qdef | |||
) | [inline, static] |
Validate and save a qualifier.
tbeg | First character | |
tend | (One past) the last character | |
vdef | Primary verb (for looking up qualifiers) | |
qhed | Head of already parsed qualifier list | |
qret | Qualifier token pointer (returned) | |
qdef | Qualifier definition pointer (returned) |
CLI_AMBGQUAL | Qualifier is ambiguous | |
CLI_BADALLOC | Memory allocation failure | |
CLI_NONEGATE | Qualifier is not negateable | |
CLI_NOTAQUAL | Not a valid qualifier | |
CLI_NOVLQUAL | Qualifier never takes a value | |
CLI_SUCCESS | Success | |
CLI_VALUQUAL | Qualifier always takes a value |
References _CLI_Qual::curr, _CLI_Qual::flag, _CLI_Qual::list, _CLI_Valu::next, _CLI_Qual::next, _CLI_QualDef::next, _CLI_QualDef::opts, _CLI_VerbDef::qual, reportQual(), _CLI_Valu::text, _CLI_Qual::text, _CLI_QualDef::text, and _CLI_QualDef::tlen.
Referenced by CLI_parse().
static unsigned int saveQval | ( | char * | tbeg, | |
char * | tend, | |||
CLI_Qual * | qual, | |||
CLI_QualDef * | qdef | |||
) | [inline, static] |
Validate and save a qualifier value.
tbeg | First character | |
tend | (One past) the last character | |
qual | Qualifier structure which stores the value(s) | |
qdef | Qualifier definition |
CLI_AMBGKEY | Keyword is ambiguous | |
CLI_BADPAREN | Unexpected/unbalanced parentheses | |
CLI_BADQUOTE | Unexpected/unbalanced quotation marks | |
CLI_BADALLOC | Memory allocation failure | |
CLI_NOTAFLT | Value is not a floating point number | |
CLI_NOTALIST | Unexpected list of values | |
CLI_NOTANINT | Value is not an integer | |
CLI_NOTAKEY | Value is not a valid keyword | |
CLI_SUCCESS | Success | |
CLI_VALUEND | Unexpected end of value |
References CLI_parseValue(), _CLI_Qual::list, _CLI_QualDef::list, and _CLI_QualDef::type.
Referenced by CLI_parse().
static unsigned int saveRest | ( | char * | tbeg, | |
CLI_Parm ** | plst | |||
) | [inline, static] |
Save the rest of the line as a single parameter.
tbeg | First character | |
plst | Where to link the new parameter structure (if successful) |
CLI_BADALLOC | Memory allocation failure | |
CLI_SUCCESS | Success |
References _CLI_Parm::flag, _CLI_Parm::list, _CLI_Valu::next, _CLI_Parm::next, and _CLI_Valu::text.
Referenced by CLI_parse().
static unsigned int saveVerb | ( | char * | tbeg, | |
char * | tend, | |||
CLI_Control * | ctl, | |||
CLI_VerbDef ** | vdef | |||
) | [inline, static] |
Validate and save a verb.
tbeg | First character | |
tend | (One past) the last character | |
ctl | CLI control structure (contains the syntax) | |
vdef | Verb definition (returned) |
References _CLI_VerbDef::next, reportVerb(), _CLI_Control::syntax, _CLI_VerbDef::text, _CLI_VerbDef::tlen, _CLI_Control::tokens, _CLI_Tokens::verb, and _CLI_Syntax::verb.
Referenced by CLI_parse().