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_pubdefs.h>
#include <MDB/MDB_pubdefs.h>
#include <CLI_prvdefs.h>
Functions | |
CLI_Syntax * | CLI_createSyntax (const char *name) |
Allocate and initialize a CLI syntax. | |
CLI_KeyList * | CLI_createKeyList (const char *name) |
Allocate and initialize a CLI keyword list. | |
CLI_KeyDef * | CLI_addKey (const CLI_KeyList *list, const char *name) |
Add a key to a CLI keyword list. | |
CLI_ParmDef * | CLI_addParm (CLI_VerbDef *verb, unsigned short opts, unsigned short type, void *sork) |
Add a parameter to a CLI verb. | |
CLI_QualDef * | CLI_addQual (CLI_VerbDef *verb, const char *text, unsigned short opts, unsigned short type, CLI_KeyList *list) |
Add a qualifier to a CLI verb. | |
CLI_VerbDef * | CLI_addVerb (const CLI_Syntax *sntx, const char *name, const char *call, CLI_CB_Func *func) |
Add a verb to a CLI syntax. | |
Variables | |
CLI_Syntax * | CLI_syntaxList = NULL |
Root of a list of all CLI syntaxes. | |
CLI_KeyList * | CLI_keyListList = NULL |
Root of a list of all keyword lists. |
CVS $Id: CLI_syntax.c,v 1.6 2011/03/25 00:51:25 apw Exp $
CLI_KeyDef* CLI_addKey | ( | const CLI_KeyList * | list, | |
const char * | name | |||
) |
Add a key to a CLI keyword list.
list | (Opaque) pointer to keyword list | |
name | Name of this keyword |
NULL | Failure | |
x | Success |
References _CLI_KeyList::key, _CLI_KeyDef::next, _CLI_KeyDef::text, and _CLI_KeyDef::tlen.
CLI_ParmDef* CLI_addParm | ( | CLI_VerbDef * | verb, | |
unsigned short | opts, | |||
unsigned short | type, | |||
void * | sork | |||
) |
Add a parameter to a CLI verb.
verb | (Opaque) pointer to verb | |
opts | Option flags for this parameter | |
type | Type constraints for this parameter | |
sork | Overloaded (opaque) pointer. When the parameter type includes the CLI_T_KEYWORD option, sork should point to a keyword list. When the parameter type is CLI_T_NEWSNTX, sork should point to a syntax. Otherwise this parameter is ignored. (The name derives from Syntax OR Keyword). |
NULL | Failure | |
x | Success |
The opts and type arguments should be supplied as an OR of the provided C macros. There are occasions where options and types interact such that one excludes another (e.g. for a qualifier it makes no sense to define it as both requiring a value (CLI_O_VALUE
) and not requiring a value (CLI_O_NOVALUE
)). Such exclusions are noted in the tables which follow. The CLI routines will detect clashing options/types. When multiple types are OR'd together (e.g. CLI_T_INTEGER | CLI_T_KEYWORD
), the parsed value can be either an integer or be drawn from a keyword list.
Parameter options:
C Macro | Meaning | Excluded Options | Excluded Types |
CLI_O_REQUIRED | Parameter must be provided | none | none |
Parameter types:
C Macro | Meaning | Excluded Options | Excluded Types |
CLI_T_LIST | Value may be a comma separated list of values | none | CLI_T_RESTOFLINE CLI_T_NEWSNTX |
CLI_T_INTEGER | Value must be an integer | none | CLI_T_RESTOFLINE CLI_T_NEWSNTX |
CLI_T_FLOAT | Value must be an floating point number | none | CLI_T_RESTOFLINE CLI_T_NEWSNTX |
CLI_T_KEYWORD | Value must be drawn from a list of keywords | none | CLI_T_RESTOFLINE CLI_T_NEWSNTX |
CLI_T_RESTOFLINE | Value if the rest of the line | All options except CLI_O_REQUIRED | All other types |
CLI_T_NEWSNTX | Pass the rest of the line to a new syntax | All options except CLI_O_REQUIRED | All other types |
References _CLI_ParmDef::next, _CLI_ParmDef::opts, _CLI_VerbDef::parm, _CLI_VerbDef::preq, _CLI_ParmDef::sork, _CLI_ParmDef::type, and _CLI_VerbDef::type.
Referenced by CLI_createSyntax().
CLI_QualDef* CLI_addQual | ( | CLI_VerbDef * | verb, | |
const char * | text, | |||
unsigned short | opts, | |||
unsigned short | type, | |||
CLI_KeyList * | list | |||
) |
Add a qualifier to a CLI verb.
verb | (Opaque) pointer to verb | |
text | Qualifier text (name) | |
opts | Option flags for this qualifier | |
type | Type constraints for this qualifier | |
list | (Opaque) pointer to keyword list (only needed for type "keyword") |
NULL | Failure | |
x | Success |
The opts and type arguments should be supplied as an OR of the provided C macros. There are occasions where options and types interact such that one excludes another (e.g. for a qualifier it makes no sense to define it as both requiring a value (CLI_O_VALUE
) and not
requiring a value (CLI_O_NOVALUE
)). Such exclusions are noted in the tables which follow. The CLI routines will detect clashing options/types. When multiple types are OR'd together (e.g. CLI_T_INTEGER | CLI_T_KEYWORD
), the parsed value can be either an integer or be drawn from a keyword list.
Qualifier options:
C Macro | Meaning | Excluded Options | Excluded Types |
CLI_O_NEGATE | Qualifier can be negated | none | none |
CLI_O_VALUE | Qualifier must have a value | CLI_O_NOVALUE | none |
CLI_O_NOVALUE | Qualifier must not have a value | CLI_O_VALUE | none |
CLI_O_REQUIRED | Qualifier must be provided | none | none |
Qualifier types:
C Macro | Meaning | Excluded Options | Excluded Types |
CLI_T_LIST | Value may be a comma separated list of values | none | none |
CLI_T_INTEGER | Value must be an integer | none | none |
CLI_T_FLOAT | Value must be an floating point number | none | none |
CLI_T_KEYWORD | Value must be drawn from a list of keywords | none | none |
References _CLI_QualDef::list, _CLI_QualDef::next, _CLI_QualDef::opts, _CLI_VerbDef::qual, _CLI_QualDef::spare, _CLI_QualDef::text, _CLI_QualDef::tlen, and _CLI_QualDef::type.
CLI_VerbDef* CLI_addVerb | ( | const CLI_Syntax * | sntx, | |
const char * | name, | |||
const char * | call, | |||
CLI_CB_Func * | func | |||
) |
Add a verb to a CLI syntax.
sntx | (Opaque) pointer to syntax | |
name | Name of the verb | |
call | Name of callback function associated with this verb | |
func | Address of callback function associated with this verb |
NULL | Failure | |
x | Success |
Naming the callback function (argument name) is implemented for future expansion (it has no current use).
References _CLI_VerbDef::call, _CLI_VerbDef::func, _CLI_VerbDef::id, _CLI_VerbDef::next, _CLI_VerbDef::parm, _CLI_VerbDef::preq, _CLI_VerbDef::qual, _CLI_VerbDef::text, _CLI_VerbDef::tlen, _CLI_VerbDef::type, and _CLI_Syntax::verb.
Referenced by CLI_createSyntax().
CLI_KeyList* CLI_createKeyList | ( | const char * | name | ) |
Allocate and initialize a CLI keyword list.
name | Name of keyword list |
NULL | Failure | |
x | Success |
References CLI_keyListList, _CLI_KeyList::id, _CLI_KeyList::key, _CLI_KeyList::name, _CLI_KeyList::next, and _CLI_KeyList::opts.
CLI_Syntax* CLI_createSyntax | ( | const char * | name | ) |
Allocate and initialize a CLI syntax.
name | Name of syntax |
NULL | Failure | |
x | Success |
References _CLI_VerbDef::call, CLI_addParm(), CLI_addVerb(), CLI_dumpSyntax(), CLI_indirect(), CLI_syntaxList, _CLI_Syntax::id, _CLI_Syntax::name, _CLI_Syntax::next, _CLI_VerbDef::text, and _CLI_Syntax::verb.