Helper Reference Manual
1.7.1
|
Command line interface.
This API allows control of ODP CLI server, which may be connected to using a telnet client. CLI commands may be used to get information from an ODP instance, for debugging purposes.
Data Structures | |
struct | odph_cli_param_t |
ODP CLI server parameters. More... | |
Typedefs | |
typedef void(* | odph_cli_user_cmd_func_t) (int argc, char *argv[]) |
User defined command function type. More... | |
Functions | |
void | odph_cli_param_init (odph_cli_param_t *param) |
Initialize CLI server params. More... | |
int | odph_cli_init (const odph_cli_param_t *param) |
Initialize CLI helper. More... | |
int | odph_cli_register_command (const char *name, odph_cli_user_cmd_func_t func, const char *help) |
Register a user defined command. More... | |
int | odph_cli_run (void) |
Run CLI server. More... | |
int | odph_cli_stop (void) |
Stop CLI server. More... | |
int | odph_cli_log (const char *fmt,...) |
Print to CLI. More... | |
int | odph_cli_log_va (const char *fmt, va_list in_args) |
Print to CLI. More... | |
int | odph_cli_term (void) |
Terminate CLI helper. More... | |
typedef void(* odph_cli_user_cmd_func_t) (int argc, char *argv[]) |
User defined command function type.
See odph_cli_register_command().
The arguments (argv) are the arguments to the command given in the CLI client. For example, having registered a command with the name "my_command", and given the command "my_command one two" in the CLI client, the user command function would be called with argc = 2, argv[0] = "one" and argv[1] = "two".
void odph_cli_param_init | ( | odph_cli_param_t * | param | ) |
Initialize CLI server params.
Initialize an odph_cli_param_t to its default values for all fields.
[out] | param | Pointer to parameter structure |
int odph_cli_init | ( | const odph_cli_param_t * | param | ) |
Initialize CLI helper.
This function initializes the CLI helper. It must be called before odph_cli_register_command() and odph_cli_run().
In process mode (ODPH_PROC_MODE), this function must be called before creating the thread which calls odph_cli_run().
param | CLI server parameters to use |
0 | Success |
<0 | Failure |
int odph_cli_register_command | ( | const char * | name, |
odph_cli_user_cmd_func_t | func, | ||
const char * | help | ||
) |
Register a user defined command.
Register a command with a name, function, and an optional help text. The registered command is displayed in the output of the "help" command. When the command is invoked by the CLI client, the registered function is called with the parameters entered by the CLI client user.
Command names are case-insensitive. In the CLI client, they are displayed in the case they were registered in, but they may be invoked using any case.
This function should be called after odph_cli_init() and before odph_cli_run().
name | Command name (case-insensitive) |
func | Command function |
help | Help or description for the command. This appears in the output of the "help" command. May be NULL. |
0 | Success |
<0 | Failure |
int odph_cli_run | ( | void | ) |
Run CLI server.
When executing this function, the CLI is accepting client connections and running commands from a client, if one is connected.
This function should be called after odph_cli_init() and after any odph_cli_register_command() calls. After calling this function, odph_cli_stop() must be called before calling this function again.
Returns only on a fatal error, or after odph_cli_stop() is called.
0 | Success |
<0 | Failure |
int odph_cli_stop | ( | void | ) |
Stop CLI server.
Stop accepting new client connections and disconnect any connected client.
0 | Success |
<0 | Failure |
int odph_cli_log | ( | const char * | fmt, |
... | |||
) |
Print to CLI.
A user defined command may call this function to print to the CLI client. This function should only be called in a user defined command (see odph_cli_register_command()). If called anywhere else, the behavior is undefined.
fmt | printf-style message format |
int odph_cli_log_va | ( | const char * | fmt, |
va_list | in_args | ||
) |
Print to CLI.
Similar to odph_cli_log(), except that this one takes its arguments as a va_list.
fmt | printf-style message format |
in_args | variadic arguments |
int odph_cli_term | ( | void | ) |
Terminate CLI helper.
Free any resources allocated by the CLI helper.
0 | Success |
<0 | Failure |