BRL-CAD
Sub-Command Processing

Routine(s) for processing subcommands. More...

Collaboration diagram for Sub-Command Processing:

Files

file  cmd.h
 

Data Structures

struct  bu_cmdtab
 

Macros

#define BU_CMD_NULL   (int (*)(void *, int, const char **))NULL
 

Functions

int bu_cmd (const struct bu_cmdtab *cmds, int argc, const char *argv[], int cmd_index, void *data, int *result)
 Routine(s) for processing subcommands. More...
 
int bu_cmd_valid (const struct bu_cmdtab *cmds, const char *cmdname)
 
DEPRECATED int bu_cmdhist_history (void *data, int argc, const char **argv)
 Routines for maintaining a command history. More...
 
DEPRECATED int bu_cmdhist_add (void *data, int argc, const char **argv)
 
DEPRECATED int bu_cmdhist_curr (void *data, int argc, const char **argv)
 
DEPRECATED int bu_cmdhist_next (void *data, int argc, const char **argv)
 
DEPRECATED int bu_cmdhist_prev (void *data, int argc, const char **argv)
 

Detailed Description

Routine(s) for processing subcommands.

Macro Definition Documentation

◆ BU_CMD_NULL

#define BU_CMD_NULL   (int (*)(void *, int, const char **))NULL

Definition at line 37 of file cmd.h.

Function Documentation

◆ bu_cmd()

int bu_cmd ( const struct bu_cmdtab cmds,
int  argc,
const char *  argv[],
int  cmd_index,
void *  data,
int *  result 
)

Routine(s) for processing subcommands.

This function is intended to be used for parsing subcommands. If the command is found in the array of commands, the associated function is called. Otherwise, an error message is printed along with a list of available commands. This behavior can be suppressed by registering a bu_log() callback.

struct bu_hook_list saved_hooks = BU_HOOK_LIST_INIT_ZERO;
bu_log_hook_save_all(&saved_hooks);
bu_log_add_hook(NULL, NULL); // disables logging
bu_cmd(...);
int bu_cmd(const struct bu_cmdtab *cmds, int argc, const char *argv[], int cmd_index, void *data, int *result)
Routine(s) for processing subcommands.
void bu_log_hook_restore_all(struct bu_hook_list *restore_hlp)
void bu_log_hook_delete_all(void)
void bu_log_add_hook(bu_hook_t func, void *clientdata)
void bu_log_hook_save_all(struct bu_hook_list *save_hlp)
#define BU_HOOK_LIST_INIT_ZERO
Definition: hook.h:61
Parameters
cmds- commands and related function pointers
argc- number of arguments in argv
argv- command to execute and its arguments
cmd_index- indicates which argv element holds the subcommand
data- data/state associated with the command
result- if non-NULL, return value from the command
Returns
BRLCAD_OK if command was found, otherwise, BRLCAD_ERROR.

◆ bu_cmd_valid()

int bu_cmd_valid ( const struct bu_cmdtab cmds,
const char *  cmdname 
)

Returns BRLCAD_OK if cmdname defines a command in the cmds table, and BRLCAD_ERROR otherwise

◆ bu_cmdhist_history()

DEPRECATED int bu_cmdhist_history ( void *  data,
int  argc,
const char **  argv 
)

Routines for maintaining a command history.

Prints out the command history.

USAGE: history [-delays] [-outfile filename]

◆ bu_cmdhist_add()

DEPRECATED int bu_cmdhist_add ( void *  data,
int  argc,
const char **  argv 
)

Add a command to the history list.

USAGE: procname add cmd

◆ bu_cmdhist_curr()

DEPRECATED int bu_cmdhist_curr ( void *  data,
int  argc,
const char **  argv 
)

Return the current command.

USAGE: procname curr

◆ bu_cmdhist_next()

DEPRECATED int bu_cmdhist_next ( void *  data,
int  argc,
const char **  argv 
)

Set the current command to the next command.

USAGE: procname next

◆ bu_cmdhist_prev()

DEPRECATED int bu_cmdhist_prev ( void *  data,
int  argc,
const char **  argv 
)

Set the current command to the previous command.

USAGE: procname prev