GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> CLI / V0-1-2 > cli / rhel6-64


Interface   Data Structures   File List   Data Fields   Globals  

CLI_parse.c File Reference

Parses the input line according to the provided syntax. More...

#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.


Detailed Description

Parses the input line according to the provided syntax.

CVS $Id: CLI_parse.c,v 1.7 2011/03/25 00:51:25 apw Exp $
Author:
A.P.Waite
CLI_parse.c parses the input line according to the provided syntax.

Enumeration Type Documentation

enum _CLI_Mode

Parsing mode.

Enumerator:
CLI_MD_QUAL  Verb
CLI_MD_PVAL  Qualifier
CLI_MD_QVAL  Parameter value

Qualifier value


Function Documentation

unsigned int CLI_parse ( const char *  ilin,
CLI_Control ctl,
void *  user 
)

Parse a command line with the given syntax.

Parameters:
ilin Input line to parse
ctl CLI control structure
user (Opaque) pointer to user parameter(s)
Returns:
Status code
CLI_parse parses a line of text (the command line) using the syntax defined in ctl->syntax and if the line makes sense, dispatches it to the user defined callback routine.

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.

Parameters:
ctl CLI control structure
user (Opaque) pointer to user parameter(s)
Returns:
Status code
Dispatch a CLI command for execution.

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.

Parameters:
status (in) Message code
tbeg (in) First character
tend (in) (One past) the last character
Return values:
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.

Parameters:
status (in) Message code
tbeg (in) First character
tend (in) (One past) the last character
Return values:
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.

Parameters:
tbeg First character
tend (One past) the last character
pdef Parameter definition
plst Where to link the new parameter structure (if successful)
Return values:
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.

Parameters:
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)
Return values:
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.

Parameters:
tbeg First character
tend (One past) the last character
qual Qualifier structure which stores the value(s)
qdef Qualifier definition
Return values:
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.

Parameters:
tbeg First character
plst Where to link the new parameter structure (if successful)
Return values:
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.

Parameters:
tbeg First character
tend (One past) the last character
ctl CLI control structure (contains the syntax)
vdef Verb definition (returned)
Returns:
Status code

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().


Generated on Tue Nov 29 16:30:28 2011 by  doxygen 1.5.8