NuSMV/code/nusmv/shell/cmd/cmd.h File Reference

#include "nusmv/core/utils/utils.h"
#include "nusmv/core/cinit/NuSMVEnv.h"

Go to the source code of this file.

Defines

#define ENV_START_TIME   "cmdStartTime"
 Implements command line interface, and miscellaneous commands.

Typedefs

typedef int(* PFI )(NuSMVEnv_ptr env, int argc, char **argv)

Functions

void Cmd_CommandAdd (NuSMVEnv_ptr env, char *name, PFI funcFp, int changes, boolean reentrant)
 Adds a command to the command table.
int Cmd_CommandExecute (NuSMVEnv_ptr env, char *command)
 Executes a command line.
boolean Cmd_CommandRemove (NuSMVEnv_ptr env, const char *name)
 Removes given command from the command table.
void Cmd_End (NuSMVEnv_ptr env)
 Ends the command package.
FILE * Cmd_FileOpen (const NuSMVEnv_ptr env, char *fileName, char *mode, char **realFileName_p, int silent)
 Opens the file with the given mode.
void Cmd_Init (NuSMVEnv_ptr env)
 Initializes the command package.
int Cmd_Misc_NusmvrcSource (NuSMVEnv_ptr env)
 Sources the .nusmvrc file.
Outcome Cmd_Misc_open_pipe_or_file (NuSMVEnv_ptr const env, const char *dbgFileName, FILE **outstream)
 Tries to set the stream as a pipe or as a given file.
void Cmd_Misc_restore_global_out_stream (NuSMVEnv_ptr env, char *filename, boolean use_a_pipe, FILE *prev_outstream)
 Closes the outstream in the stream mgr, previously opened by Cmd_Misc_set_global_out_stream, and remove it from the StreamMgr. The sets prev_outstream into the stream mgr.
int Cmd_Misc_set_global_out_stream (NuSMVEnv_ptr env, char *filename, boolean useMore, FILE **prev_outstream)
 Open a file or a pipe and sets them into the StreamMgr outstream.
int Cmd_SecureCommandExecute (NuSMVEnv_ptr env, char *command)
 Secure layer for Cmd_CommandExecute.
void CmdCloseFile (FILE *file)
 Closes a previously opened file.
void CmdClosePipe (FILE *file)
 Closes a previously opened pipe.
FILE * CmdOpenFile (const NuSMVEnv_ptr env, const char *filename)
 Open a file whose name is given.
FILE * CmdOpenPipe (const NuSMVEnv_ptr env, int useMore)
 Opens a pipe with a pager.

Define Documentation

#define ENV_START_TIME   "cmdStartTime"

Implements command line interface, and miscellaneous commands.

Author:
Adapted to NuSMV by Marco Roveri
Todo:
: Missing description
Todo:
Missing synopsis
Todo:
Missing description

Typedef Documentation

typedef int(* PFI)(NuSMVEnv_ptr env, int argc, char **argv)
Todo:
Missing synopsis
Todo:
Missing description

Function Documentation

void Cmd_CommandAdd ( NuSMVEnv_ptr  env,
char *  name,
PFI  funcFp,
int  changes,
boolean  reentrant 
)

Adds a command to the command table.

AutomaticStart

Adds a command to the command table. If name already defines an existing command, its definition is replaced. FuncFp is a function pointer to code of the form:

int
CommandTest(argc, argv)
int argc;
char **argv;
{
return 0;
}

argv\[0\] will generally be the command name, and argv\[1\] ... argv\[argc-1\] are the arguments for the command. util_getopt() can be used to parse the arguments, but util_getopt_reset() must be used before calling util_getopt(). The command function should return 0 for normal operation, 1 for any error. The changes flag is used to automatically save the hmgr before executing the command (in order to support undo). The flag reentrant is true if the command execution can be interrupted without leaving the internal status inconsistent.

int Cmd_CommandExecute ( NuSMVEnv_ptr  env,
char *  command 
)

Executes a command line.

Executes a command line. This is the top-level of the command interpreter, and supports multiple commands (separated by ;), alias substitution, etc. For many simple operations, Cmd_CommandExecute() is the easiest way to accomplish a given task. For example, to set a variable, use the code: Cmd_CommandExecute("set color blue").

boolean Cmd_CommandRemove ( NuSMVEnv_ptr  env,
const char *  name 
)

Removes given command from the command table.

Returns true if command was found and removed, false if not found

void Cmd_End ( NuSMVEnv_ptr  env  ) 

Ends the command package.

Ends the command package. Tables are freed.

See also:
Cmd_Init
FILE* Cmd_FileOpen ( const NuSMVEnv_ptr  env,
char *  fileName,
char *  mode,
char **  realFileName_p,
int  silent 
)

Opens the file with the given mode.

Opens the file with the given mode (see fopen()). Tilde expansion (~user/ or ~/) is performed on the fileName, and "-" is allowed as a synonym for stdin (or stdout, depending on the mode). If the file cannot be opened, a message is reported using perror(); the silent flag, if true, suppresses this error action. In either case, A NULL file pointer is returned if any error occurs. The fileName (after tilde expansion) is returned in the pointer realFileName, if realFileName is non-empty. This is a pointer which should be free'd when you are done with it.

void Cmd_Init ( NuSMVEnv_ptr  env  ) 

Initializes the command package.

Todo:
Missing description

Commands are added to the command table.

See also:
Cmd_End
int Cmd_Misc_NusmvrcSource ( NuSMVEnv_ptr  env  ) 

Sources the .nusmvrc file.

Sources the .nusmvrc file. Always sources the .nusmvrc from library. Then source the .nusmvrc from the home directory. If there is none in the home directory, then execute the one in the current directory if one is present. Returns 1 if scripts were successfully executed, else return 0.

Outcome Cmd_Misc_open_pipe_or_file ( NuSMVEnv_ptr const   env,
const char *  dbgFileName,
FILE **  outstream 
)

Tries to set the stream as a pipe or as a given file.

Tries to set the stream as a pipe or as a given file

outstream is changed

void Cmd_Misc_restore_global_out_stream ( NuSMVEnv_ptr  env,
char *  filename,
boolean  use_a_pipe,
FILE *  prev_outstream 
)

Closes the outstream in the stream mgr, previously opened by Cmd_Misc_set_global_out_stream, and remove it from the StreamMgr. The sets prev_outstream into the stream mgr.

See also:
Cmd_Misc_set_global_out_stream
int Cmd_Misc_set_global_out_stream ( NuSMVEnv_ptr  env,
char *  filename,
boolean  useMore,
FILE **  prev_outstream 
)

Open a file or a pipe and sets them into the StreamMgr outstream.

return 0 on success, 1 on failure. Cmd_Misc_restore_global_out_stream must be ALWAYS called before command termination

See also:
Cmd_Misc_restore_global_out_stream
int Cmd_SecureCommandExecute ( NuSMVEnv_ptr  env,
char *  command 
)

Secure layer for Cmd_CommandExecute.

This version is securly callable from scripting languages. Do not call Cmd_CommandExecute directly from a scripting language, otherwise the script execution could be aborted without any warning.

void CmdCloseFile ( FILE *  file  ) 

Closes a previously opened file.

optional

required

See also:
optional
void CmdClosePipe ( FILE *  file  ) 

Closes a previously opened pipe.

optional

required

See also:
optional
FILE* CmdOpenFile ( const NuSMVEnv_ptr  env,
const char *  filename 
)

Open a file whose name is given.

optional

required

See also:
optional
FILE* CmdOpenPipe ( const NuSMVEnv_ptr  env,
int  useMore 
)

Opens a pipe with a pager.

Returns NULL if an error occurs

required

See also:
optional
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 14 Oct 2015 for NuSMV Developers Manual by  doxygen 1.6.1