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


Interface   Data Structures   File List   Data Fields   Globals  

CLI_command.c File Reference

Handles command looping including file reading. More...

#include <stdio.h>
#include <stdlib.h>
#include <CLI/CLI_msgs.h>
#include <CLI/CLI_pubdefs.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <MDB/MDB_pubdefs.h>
#include <CLI_prvdefs.h>

Defines

#define CLI_OOM   0
#define CLI_EOL   1
#define CLI_EOF   2
#define CLI_QUANTUM   256

Functions

static CLI_ControlCLI_createCtl (const CLI_Syntax *syntax)
 Allocate and initialize a CLI control structure.
static char * CLI_getFile (CLI_Control *ctl)
 Fetch a line of input from a file.
static unsigned int CLI_getLine (FILE *fd, char **flin, int *nlin)
 Construct the next logical line of input in a file.
static char * CLI_getTerm (const char *prompt)
 Fetch a line of input from the terminal.
unsigned int CLI_command (const char *ilin, const char *prompt, const CLI_Syntax *syntax, void *user)
 Parse and dispatch command lines.


Detailed Description

Handles command looping including file reading.

CVS $Id: CLI_command.c,v 1.5 2011/03/25 00:51:25 apw Exp $
Author:
A.P.Waite
CLI_command.c handles command looping including fetching lines from files to satisfy command indirection.

Function Documentation

unsigned int CLI_command ( const char *  ilin,
const char *  prompt,
const CLI_Syntax syntax,
void *  user 
)

Parse and dispatch command lines.

Parameters:
ilin Input line to parse (can be NULL or blank)
prompt Command prompt to use (when in subcommand mode)
syntax (Opaque) pointer to syntax to use to decode lines
user (Opaque) pointer to user parameter(s)
Returns:
Status code
CLI_command parses and dispatches command lines. It handles the direct command case (when ilin contains a real string) and the 'enter subcommand' case (when ilin is NULL or blank).

References CLI_clearFiles(), CLI_clearTokens(), CLI_createCtl(), CLI_getFile(), CLI_getTerm(), CLI_parse(), _CLI_Control::file, _CLI_File::frst, _CLI_Syntax::id, _CLI_File::last, _CLI_File::name, and _CLI_Control::tokens.

Referenced by CLI_parse().

static CLI_Control * CLI_createCtl ( const CLI_Syntax syntax  )  [inline, static]

Allocate and initialize a CLI control structure.

Parameters:
syntax Syntax to use to parse lines
Return values:
NULL Allocation/initialization failed
x Pointer to created control structure

References _CLI_Control::file, _CLI_Control::id, _CLI_Tokens::line, _CLI_Tokens::parm, _CLI_Tokens::qual, _CLI_Control::syntax, _CLI_Control::tokens, and _CLI_Tokens::verb.

Referenced by CLI_command().

static char * CLI_getFile ( CLI_Control ctl  )  [inline, static]

Fetch a line of input from a file.

Parameters:
ctl A CLI control structure
Return values:
NULL End of input
x Pointer to input line

References CLI_clearFiles(), CLI_getLine(), _CLI_File::fd, _CLI_Control::file, _CLI_File::frst, _CLI_File::last, _CLI_File::line, _CLI_File::name, _CLI_File::next, and _CLI_File::stat.

Referenced by CLI_command().

static unsigned int CLI_getLine ( FILE *  fd,
char **  flin,
int *  nlin 
) [inline, static]

Construct the next logical line of input in a file.

Parameters:
fd File desciptor
flin Line (returned)
nlin Number of physical lines in logical line (returned)
Returns:
Status code

Referenced by CLI_getFile().

static char * CLI_getTerm ( const char *  prompt  )  [inline, static]

Fetch a line of input from the terminal.

Parameters:
prompt Terminal prompt
Return values:
NULL End of input
x Pointer to input line

Referenced by CLI_command().


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