Doxygen Documentation

Main Index

Package Index

Package:

CLI

Version:

V0-0-5

Marked:

(not marked)

Constituent:

cli

Tag:

linux-gcc


Interface   Compound List   File List   Compound Members   File Members  

CLI_syntax.c File Reference

All syntax construction routines. More...

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "CLI/CLI_pubdefs.h"
#include "CLI_prvdefs.h"

Functions

CLI_SyntaxCLI_createSyntax (const char *name)
 Create a new CLI syntax.

CLI_KeyListCLI_createKeyList (const char *name)
 Create a new CLI keyword list.

CLI_KeyDefCLI_addKey (const CLI_KeyList *list, const char *name)
 Add a key to a CLI keyword list.

CLI_VerbDefCLI_addVerb (const CLI_Syntax *sntx, const char *name, const char *call, CLI_CB_Func *func)
 Add a verb to a CLI syntax.

CLI_ParmDefCLI_addParm (CLI_VerbDef *verb, unsigned short opts, unsigned short type, void *sork)
 Add a parameter to a CLI verb.

CLI_QualDefCLI_addQual (CLI_VerbDef *verb, const char *text, unsigned short opts, unsigned short type, CLI_KeyList *list)
 Add a qualifier to a CLI verb.


Variables

CLI_SyntaxCLI_syntaxList = NULL
 Root of a list of all CLI syntaxes.

CLI_KeyListCLI_keyListList = NULL
 Root of a list of all keyword lists.


Detailed Description

All syntax construction routines.

CVS $Id: CLI_syntax.c,v 1.4 2003/12/12 06:13:49 apw Exp $
Author:
A.P.Waite - apw@slac.stanford.edu
CLI_syntax.c contains all the implementations of routines used during the construction of a CLI syntax.

Function Documentation

CLI_KeyDef* CLI_addKey const CLI_KeyList list,
const char *  name
 

Add a key to a CLI keyword list.

Parameters:
list (Opaque) pointer to keyword list
name Name of this keyword
Return values:
NULL Failure
x Success
Add a keyword to a CLI keyword list. Returns a handle to the keyword.

CLI_ParmDef* CLI_addParm CLI_VerbDef verb,
unsigned short  opts,
unsigned short  type,
void *  sork
 

Add a parameter to a CLI verb.

Parameters:
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).
Return values:
NULL Failure
x Success
Add a parameter to a CLI verb. Returns a handle for the parameter.

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

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.

Parameters:
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")
Return values:
NULL Failure
x Success
Add a qualifier to a CLI verb. Returns a handle to the qualifier.

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

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.

Parameters:
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
Return values:
NULL Failure
x Success
Add a verb to a CLI syntax. Returns a handle which the caller uses in subsequent calls to CLI_addParm() and CLI_addQual() to build up the syntax associated with this verb.

Naming the callback function (argument name) is implemented for future expansion (it has no current use).

CLI_KeyList* CLI_createKeyList const char *  name  ) 
 

Create a new CLI keyword list.

Parameters:
name Name of keyword list
Return values:
NULL Failure
x Success
Allocate and initialize a CLI keyword list. Returns a handle which the caller uses in subsequent calls to CLI_addKey() to populate the list.

CLI_Syntax* CLI_createSyntax const char *  name  ) 
 

Create a new CLI syntax.

Parameters:
name Name of syntax
Return values:
NULL Failure
x Success
Allocate and initialize a CLI syntax. Returns a handle which the caller uses in subsequent calls to CLI_addVerb() to build the list of verbs the syntax accepts.


Generated on Thu Dec 11 22:17:32 2003 by doxygen 1.3.3