nfs-ganesha 1.4
Defines | Functions | Variables

shell.h File Reference

Internal routines for the shell. More...

#include "shell_types.h"

Go to the source code of this file.

Defines

#define MAX_LINE_LEN   1024
#define MAX_ARGS   256
#define SHELL_SUCCESS   0
#define SHELL_ERROR   -1
#define SHELL_NOT_FOUND   -2
#define SHELL_SYNTAX_ERROR   -22

Functions

int shell_Init (int verbose, char *input_file, char *prompt, int shell_index)
int shell_Launch ()
int shell_BarrierInit (int nb_threads)
int shell_ParseLine (char *in_out_line, char **out_arglist, int *p_argcount)
void shell_CleanArgs (int argc, char **in_out_argv, int *in_allocated)
int shell_SolveArgs (int argc, char **in_out_argv, int *out_allocated)
int shell_Execute (int argc, char **argv, FILE *output)
void shell_PrintError (shell_state_t *context, char *error_msg)
void shell_PrintTrace (shell_state_t *context, char *msg)
int shell_SetLayer (shell_state_t *context, char *layer_name)
layer_def_tshell_GetLayer (shell_state_t *context)
int shell_SetStatus (shell_state_t *context, int returned_status)
int shell_GetStatus (shell_state_t *context)
int shell_SetVerbose (shell_state_t *context, char *str_verbose)
int shell_GetVerbose (shell_state_t *context)
int shell_SetDbgLvl (shell_state_t *context, char *str_debug_level)
int shell_GetDbgLvl (shell_state_t *context)
FILE * shell_GetInputStream (shell_state_t *context)
int shell_SetInput (shell_state_t *context, char *file_name)
int shell_SetPrompt (shell_state_t *context, char *str_prompt)
char * shell_GetPrompt (shell_state_t *context)
int shell_SetShellId (shell_state_t *context, int shell_index)
int shell_SetLine (shell_state_t *context, int lineno)
int shell_GetLine (shell_state_t *context)
int shellcmd_help (int argc, char **argv, FILE *output)
int shellcmd_if (int argc, char **argv, FILE *output)
int shellcmd_interactive (int argc, char **argv, FILE *output)
int shellcmd_set (int argc, char **argv, FILE *output)
int shellcmd_unset (int argc, char **argv, FILE *output)
int shellcmd_print (int argc, char **argv, FILE *output)
int shellcmd_varlist (int argc, char **argv, FILE *output)
int shellcmd_time (int argc, char **argv, FILE *output)
int shellcmd_quit (int argc, char **argv, FILE *output)
int shellcmd_barrier (int argc, char **argv, FILE *output)

Variables

char * shell_special_vars []

Detailed Description

Internal routines for the shell.

Author:
Author:
leibovic
Date:
Date:
2006/02/23 07:42:53
Version:
Revision:
1.7
Log:
shell.h,v

Revision 1.7 2006/02/23 07:42:53 leibovic Adding -n option to shell.

Revision 1.6 2005/07/26 12:54:47 leibovic Multi-thread shell with synchronisation routines.

Revision 1.5 2005/07/25 12:50:46 leibovic Adding thr_create and thr_join commands.

Revision 1.4 2005/05/27 12:01:48 leibovic Adding write command.

Revision 1.3 2005/05/11 15:53:37 leibovic Adding time function.

Revision 1.2 2005/05/09 14:54:59 leibovic Adding if.

Revision 1.1 2005/05/09 12:23:55 leibovic Version 2 of ganeshell.

Definition in file shell.h.


Define Documentation

#define MAX_ARGS   256

Definition at line 41 of file shell.h.

#define MAX_LINE_LEN   1024

Definition at line 40 of file shell.h.

#define SHELL_ERROR   -1

Definition at line 48 of file shell.h.

#define SHELL_NOT_FOUND   -2

Definition at line 49 of file shell.h.

#define SHELL_SUCCESS   0

Definition at line 47 of file shell.h.

#define SHELL_SYNTAX_ERROR   -22

Definition at line 50 of file shell.h.


Function Documentation

int shell_BarrierInit ( int  nb_threads)

Initialize the barrier for shell synchronization routines. The number of threads to wait for is given as parameter.

Definition at line 202 of file shell.c.

void shell_CleanArgs ( int  argc,
char **  in_out_argv,
int *  in_allocated 
)

shell_CleanArgs: Free allocated arguments.

Parameters:
argcThe number of command line tokens.
in_out_argvThe list of command line tokens (modified).
in_allocatedIndicates which tokens must be freed.
Returns:
0 if no errors.

shell_CleanArgs: Free allocated arguments.

Parameters:
argcThe number of command line tokens.
in_out_argvThe list of command line tokens (modified).
in_allocatedIndicates which tokens must be freed.

Definition at line 1045 of file shell.c.

int shell_Execute ( int  argc,
char **  argv,
FILE *  output 
)

shell_Execute: Execute a command.

Parameters:
argcThe number of arguments of this command.
argvThe arguments for this command.
outputThe output stream of this command.
Returns:
The returned status of this command.

shell_Execute: Commands dispatcher.

Parameters:
argcThe number of arguments of this command.
argvThe arguments for this command.
outputThe output stream of this command.
Returns:
The returned status of this command.

Definition at line 1076 of file shell.c.

int shell_GetDbgLvl ( shell_state_t context)

shell_GetDbgLvl Get the special variable $DEBUG_LEVEL and $DBG_LVL (internal use).

Definition at line 1478 of file shell.c.

FILE* shell_GetInputStream ( shell_state_t context)

shell_GetInputStream Get the input stream for reading commands (internal use).

Definition at line 1600 of file shell.c.

layer_def_t* shell_GetLayer ( shell_state_t context)

shell_GetLayer: Retrieves the current active layer (internal use).

Definition at line 1302 of file shell.c.

int shell_GetLine ( shell_state_t context)

shell_GetLine Get the special variable $LINE

Definition at line 1691 of file shell.c.

char* shell_GetPrompt ( shell_state_t context)

shell_GetPrompt Get the special variable $PROMPT

Definition at line 1631 of file shell.c.

int shell_GetStatus ( shell_state_t context)

shell_GetStatus Get the special variables $? or $STATUS (internal use).

Definition at line 1349 of file shell.c.

int shell_GetVerbose ( shell_state_t context)

shell_GetVerbose Get the special variable $VERBOSE (internal use).

Definition at line 1414 of file shell.c.

int shell_Init ( int  verbose,
char *  input_file,
char *  prompt,
int  shell_index 
)

Initialize the shell. The command line for the shell is given as parameter.

Parameters:
input_filethe file to read from (NULL if stdin).

Definition at line 344 of file shell.c.

int shell_Launch ( )

Launch the interpreter.

Run the interpreter.

Definition at line 486 of file shell.c.

int shell_ParseLine ( char *  in_out_line,
char **  out_arglist,
int *  p_argcount 
)

shell_ParseLine: Extract an arglist from a command line.

Parameters:
in_out_lineThe command line (modified).
out_arglistThe list of command line tokens.
p_argcountThe number of command line tokens.
Returns:
0 if no errors.

Definition at line 664 of file shell.c.

void shell_PrintError ( shell_state_t context,
char *  error_msg 
)

shell_PrintError: Prints an error.

Definition at line 1207 of file shell.c.

void shell_PrintTrace ( shell_state_t context,
char *  msg 
)

shell_PrintTrace: Prints a verbose trace.

Definition at line 1221 of file shell.c.

int shell_SetDbgLvl ( shell_state_t context,
char *  str_debug_level 
)

shell_SetDbgLvl Set the special variables $DEBUG_LEVEL and $DBG_LVL

Definition at line 1423 of file shell.c.

int shell_SetInput ( shell_state_t context,
char *  file_name 
)

shell_SetInput Set the input for reading commands and set the value of $INPUT and $INTERACTIVE.

Parameters:
file_name,:a script file or NULL for reading from stdin.

Definition at line 1491 of file shell.c.

int shell_SetLayer ( shell_state_t context,
char *  layer_name 
)

shell_SetLayer: Set the current active layer.

Returns:
0 if OK. else, an error code.

Definition at line 1246 of file shell.c.

int shell_SetLine ( shell_state_t context,
int  lineno 
)

shell_SetLine Set the special variable $LINE

Definition at line 1664 of file shell.c.

int shell_SetPrompt ( shell_state_t context,
char *  str_prompt 
)

shell_SetPrompt Set the special variable $PROMPT

Definition at line 1612 of file shell.c.

int shell_SetShellId ( shell_state_t context,
int  shell_index 
)

shell_SetShellId Set the special variable $SHELLID

Definition at line 1640 of file shell.c.

int shell_SetStatus ( shell_state_t context,
int  returned_status 
)

shell_SetStatus Set the special variables $? and $STATUS.

Definition at line 1313 of file shell.c.

int shell_SetVerbose ( shell_state_t context,
char *  str_verbose 
)

shell_SetVerbose Set the special variable $VERBOSE.

Definition at line 1358 of file shell.c.

int shell_SolveArgs ( int  argc,
char **  in_out_argv,
int *  out_allocated 
)

shell_SolveArgs: Interprets arguments if they are vars or commands.

Parameters:
argcThe number of command line tokens.
in_out_argvThe list of command line tokens (modified).
out_allocatedIndicates which tokens must be freed.
Returns:
0 if no errors.

Definition at line 768 of file shell.c.

int shellcmd_barrier ( int  argc,
char **  argv,
FILE *  output 
)

Definition at line 2166 of file shell.c.

int shellcmd_help ( int  argc,
char **  argv,
FILE *  output 
)

Definition at line 1700 of file shell.c.

int shellcmd_if ( int  argc,
char **  argv,
FILE *  output 
)

Definition at line 1771 of file shell.c.

int shellcmd_interactive ( int  argc,
char **  argv,
FILE *  output 
)

Definition at line 1861 of file shell.c.

int shellcmd_print ( int  argc,
char **  argv,
FILE *  output 
)

Definition at line 2052 of file shell.c.

int shellcmd_quit ( int  argc,
char **  argv,
FILE *  output 
)

Definition at line 2141 of file shell.c.

int shellcmd_set ( int  argc,
char **  argv,
FILE *  output 
)

Definition at line 1887 of file shell.c.

int shellcmd_time ( int  argc,
char **  argv,
FILE *  output 
)

Definition at line 2096 of file shell.c.

int shellcmd_unset ( int  argc,
char **  argv,
FILE *  output 
)

Definition at line 1994 of file shell.c.

int shellcmd_varlist ( int  argc,
char **  argv,
FILE *  output 
)

Definition at line 2070 of file shell.c.


Variable Documentation

List of the shell special variables

Definition at line 146 of file shell.c.