|
CNDP
22.08.0
|
#include <libgen.h>#include <sys/queue.h>#include <cne_common.h>#include <cne_log.h>#include <cli_common.h>#include <cli_env.h>#include <cli_search.h>#include <cli_file.h>#include <cli_gapbuf.h>#include <cli_help.h>#include <cli_history.h>#include <cli_map.h>#include <cne_strings.h>#include <stdint.h>#include <string.h>#include "cne_stdio.h"Go to the source code of this file.
Data Structures | |
| struct | cli_cmd |
| struct | cli_alias |
| struct | cli_file |
| struct | cli_str |
Macros | |
| #define | CLI_USE_TIMERS (1 << 8) |
| #define | CLI_NODES_UNLIMITED (1 << 9) |
| #define | c_dir(n) { CLI_DIR_NODE, .dir = {.name = (n), .bin = 0} } |
Typedefs | |
| typedef int(* | cli_cfunc_t) (int argc, char **argv) |
| typedef int(* | cli_ffunc_t) (struct cli_node *node, char *buff, int len, uint32_t opt) |
| typedef int(* | cli_prompt_t) (int continuation) |
| typedef int(* | cli_tree_t) (void) |
Enumerations | |
| enum | { CLI_MAX_ARGVS = 64 , CLI_DEFAULT_NB_NODES = 256 , CLI_DEFAULT_HIST_LINES = 128 , CLI_MAX_PATH_LENGTH = 2048 , CLI_MAX_SCRATCH_LENGTH = 4096 , CLI_NAME_LEN = 64 , CLI_MAX_LIST_NODES = 128 , CLI_MAX_BINS = 32 , CLI_DEFAULT_NODES = 0 , CLI_SCREEN_WIDTH = 80 } |
| enum | node_type_t { CLI_UNK_NODE = 0x0000 , CLI_DIR_NODE = 0x0001 , CLI_CMD_NODE = 0x0002 , CLI_FILE_NODE = 0x0004 , CLI_ALIAS_NODE = 0x0008 , CLI_STR_NODE = 0x0010 } |
Functions | |
| static struct cli_node * | get_root (void) |
| static struct cli_node * | get_cwd (void) |
| static void | set_cwd (struct cli_node *node) |
| static int | is_cli_valid (void) |
| static int | is_match (const char *s1, const char *s2) |
| static int | is_node (struct cli_node *node, uint32_t types) |
| static int | is_command (struct cli_node *node) |
| static int | is_alias (struct cli_node *node) |
| static int | is_file (struct cli_node *node) |
| static int | is_directory (struct cli_node *node) |
| static int | is_executable (struct cli_node *node) |
| static int | cli_usage (void) |
| static const char * | cli_node_type (struct cli_node *node) |
| static char * | cli_path_string (struct cli_node *node, char *path) |
| static char * | cli_cwd_path (void) |
| static void | cli_pwd (struct cli_node *node) |
| static int | cli_set_history_size (uint32_t nb_hist) |
| static uint32_t | cli_get_history_size (void) |
| static void | cli_history_list (void) |
| static struct cli_node * | cli_root_node (void) |
| CNDP_API int | cli_create (struct cli_cfg *cfg) |
| CNDP_API int | cli_create_with_defaults (struct cli_cfg *cfg) |
| CNDP_API int | cli_setup (cli_prompt_t prompt, cli_tree_t default_func) |
| CNDP_API int | cli_setup_with_defaults (void) |
| CNDP_API int | cli_setup_with_tree (cli_tree_t tree) |
| CNDP_API cli_prompt_t | cli_set_prompt (cli_prompt_t prompt) |
| CNDP_API struct cli_node * | cli_create_root (const char *dirname) |
| CNDP_API int | cli_default_tree_init (void) |
| CNDP_API void | cli_destroy (void) |
| CNDP_API void | cli_start (const char *msg) |
| CNDP_API void | cli_start_with_timers (const char *msg) |
| CNDP_API int | cli_execute (void) |
| CNDP_API int | cli_add_bin (struct cli_node *node) |
| CNDP_API int | cli_del_bin (struct cli_node *node) |
| CNDP_API int | cli_add_bin_path (const char *path) |
| CNDP_API struct cli_node * | cli_add_dir (const char *dirname, struct cli_node *parent) |
| CNDP_API struct cli_node * | cli_add_cmd (const char *name, struct cli_node *dir, cli_cfunc_t func, const char *short_desc) |
| CNDP_API struct cli_node * | cli_add_alias (const char *name, struct cli_node *dir, const char *line, const char *short_desc) |
| CNDP_API struct cli_node * | cli_add_file (const char *name, struct cli_node *dir, cli_ffunc_t func, const char *short_desc) |
| CNDP_API int | cli_add_str (const char *name, cli_sfunc_t func, const char *str) |
| CNDP_API int | cli_add_tree (struct cli_node *dir, struct cli_tree *tree) |
| static int | cli_add_cmdfile (const char *filename) |
| CNDP_API int | cli_execute_cmdfile (const char *path) |
| CNDP_API int | cli_execute_cmdfiles (void) |
| CNDP_API int | cli_remove_node (struct cli_node *node) |
| CNDP_API void | cli_use_timers (void) |
| CNDP_API int | cli_nodes_unlimited (void) |
| CNDP_API int | cli_execute_cmd (int argc, char **argv) |
| CNDP_API int | cli_get_quit_flag (void) |
| CNDP_API void | cli_set_quit_flag (void) |
Variables | |
| struct cli_node | __cne_cache_aligned |
| cli_files_t | cli_cmd_files |
CNE Command line interface
Definition in file cli.h.
| #define CLI_NODES_UNLIMITED (1 << 9) |
| #define c_dir | ( | n | ) | { CLI_DIR_NODE, .dir = {.name = (n), .bin = 0} } |
< Used to help create a directory tree
| typedef int(* cli_cfunc_t) (int argc, char **argv) |
| typedef int(* cli_ffunc_t) (struct cli_node *node, char *buff, int len, uint32_t opt) |
| typedef int(* cli_prompt_t) (int continuation) |
| typedef int(* cli_tree_t) (void) |
| anonymous enum |
| enum node_type_t |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Create the current working directory string, which is the complete path to node. Uses CLI routines to output the string to the console.
| node | Starting node or last file/dir to be printed |
| path | Pointer to a path buffer string. |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Return the CLI root node.
| CNDP_API int cli_create | ( | struct cli_cfg * | cfg | ) |
Create the CLI engine
| cfg | The struyct cli_cfg pointer, if NULL use all default values |
| CNDP_API int cli_create_with_defaults | ( | struct cli_cfg * | cfg | ) |
Create the CLI and add the default set of commands.
| cfg | The struct cli_cfg pointer, can be NULL will use defaults. |
| CNDP_API int cli_setup | ( | cli_prompt_t | prompt, |
| cli_tree_t | default_func | ||
| ) |
Setup the CLI prompt callback and default setup function
| prompt | The function to call when the prompt needs to be displayed |
| default_func | The function pointer to setup the CLI files, directories and executables. |
| CNDP_API int cli_setup_with_defaults | ( | void | ) |
Create the CLI engine using system defaults.
| CNDP_API int cli_setup_with_tree | ( | cli_tree_t | tree | ) |
Create the CLI engine using system defaults and supplied tree init function.
| tree | The user supplied function to init the tree or can be NULL. If NULL then a default tree is initialized with default commands. |
| CNDP_API cli_prompt_t cli_set_prompt | ( | cli_prompt_t | prompt | ) |
Set the CLI prompt function pointer
| prompt | Function pointer to display the prompt |
| CNDP_API struct cli_node* cli_create_root | ( | const char * | dirname | ) |
Create the root directory
| dirname | Name of root directory, if null uses '/' |
| CNDP_API int cli_default_tree_init | ( | void | ) |
Create the default directory tree
| CNDP_API void cli_destroy | ( | void | ) |
Destroy the CLI engine
| CNDP_API void cli_start | ( | const char * | msg | ) |
Start the CLI running
| msg | User message to be displayed on startup |
| CNDP_API void cli_start_with_timers | ( | const char * | msg | ) |
Start the CLI running and use timerss
| msg | User message to be displayed on startup |
| CNDP_API int cli_execute | ( | void | ) |
Execute command line string in cli->input
| CNDP_API int cli_add_bin | ( | struct cli_node * | node | ) |
Add a bin directory to the bin list
| node | Directory to add to bin list |
| CNDP_API int cli_del_bin | ( | struct cli_node * | node | ) |
Remove a bin directory from the bin list
| node | Directory to add to bin list |
| CNDP_API int cli_add_bin_path | ( | const char * | path | ) |
Add a bin directory to the bin list using path
| path | path to bin directory to add, must exist first. |
| CNDP_API struct cli_node* cli_add_dir | ( | const char * | dirname, |
| struct cli_node * | parent | ||
| ) |
Add a cli directory
| dirname | String pointing to the directory name |
| parent | Parent node of the new directory |
| CNDP_API struct cli_node* cli_add_cmd | ( | const char * | name, |
| struct cli_node * | dir, | ||
| cli_cfunc_t | func, | ||
| const char * | short_desc | ||
| ) |
Add a command to a directory
| name | Pointer to command name string |
| dir | Directory node pointer |
| func | Pointer to function to execute |
| short_desc | Short string for help to display |
| CNDP_API struct cli_node* cli_add_alias | ( | const char * | name, |
| struct cli_node * | dir, | ||
| const char * | line, | ||
| const char * | short_desc | ||
| ) |
Add an alias string or special command type
| name | Pointer to command name string |
| dir | Directory node pointer |
| line | Pointer to alias string |
| short_desc | Short string for help to display |
| CNDP_API struct cli_node* cli_add_file | ( | const char * | name, |
| struct cli_node * | dir, | ||
| cli_ffunc_t | func, | ||
| const char * | short_desc | ||
| ) |
Add an file to a directory
| name | Pointer to command name string |
| dir | Directory node pointer |
| func | Pointer to a function attached to the file. |
| short_desc | Short string for help to display |
| CNDP_API int cli_add_str | ( | const char * | name, |
| cli_sfunc_t | func, | ||
| const char * | str | ||
| ) |
Add a string to the system.
| name | Pointer to command name string |
| func | Pointer to a function attached to the string. |
| str | Value of string if no function defined. |
| CNDP_API int cli_add_tree | ( | struct cli_node * | dir, |
| struct cli_tree * | tree | ||
| ) |
Add a list of nodes to a directory
| dir | Node pointer to directory for add commands |
| tree | Pointer to list of nodes to add to the tree |
|
inlinestatic |
Add filenames to the CLI command list.
| filename | Path of command file. |
| CNDP_API int cli_execute_cmdfile | ( | const char * | path | ) |
execute a command file
| path | Pointer to path to file |
| CNDP_API int cli_execute_cmdfiles | ( | void | ) |
execute a list for command files
| CNDP_API int cli_remove_node | ( | struct cli_node * | node | ) |
Remove a node from the directory tree
| node | The pointer to the node to remove |
| CNDP_API void cli_use_timers | ( | void | ) |
Handle calling the timer_manage routine if trimers are enabled
| CNDP_API int cli_nodes_unlimited | ( | void | ) |
return true if allocating unlimited nodes are enabled.
| CNDP_API int cli_execute_cmd | ( | int | argc, |
| char ** | argv | ||
| ) |
Execute a command file from the CLI directories
| argc | The number of arguments in the argv array |
| argv | The array of string pointers to the arguments of the command. |
| CNDP_API int cli_get_quit_flag | ( | void | ) |
Return the state of the CLI quit flag
| CNDP_API void cli_set_quit_flag | ( | void | ) |
Set the quit flag to true to allow CLI to quit.
| struct cli __cne_cache_aligned |
Structure for each node type
|
extern |
array of command filename pointers