void
Cmd_CommandAdd(
char * name,
PFI funcFp,
int changes,
boolean reentrant
)
- 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(
char * command
)
- 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").
void
Cmd_End(
)
- Ends the command package. Tables are freed.
- See Also
Cmd_Init
FILE *
Cmd_FileOpen(
char * fileName,
char * mode,
char ** realFileName_p,
int silent
)
- 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.
char*
Cmd_FlagReadByName(
char * flag
)
- The command parser maintains a table of named values. These
are manipulated using the 'set' and 'unset' commands. The value of the
named flag is returned, or NIL(char) is returned if the flag has not been
set.
void
Cmd_Init(
)
- Initializes the command package.
- Side Effects Commands are added to the command table.
- See Also
Cmd_End
int
Cmd_SecureCommandExecute(
char* command
)
- 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.