CNDP  22.08.0
cli_env.h File Reference
#include <sys/queue.h>
#include <cne_common.h>

Go to the source code of this file.

Typedefs

typedef char *(* cli_sfunc_t) (const char *str)
 

Functions

CNDP_API struct cli_env * cli_env_create (void)
 
CNDP_API void cli_env_destroy (struct cli_env *env)
 
CNDP_API int cli_env_set (struct cli_env *env, const char *var, const char *val)
 
CNDP_API int cli_env_string (struct cli_env *env, const char *var, cli_sfunc_t sfunc, const char *val)
 
CNDP_API const char * cli_env_get (struct cli_env *env, const char *var)
 
CNDP_API int cli_env_del (struct cli_env *env, const char *var)
 
CNDP_API void cli_env_substitution (struct cli_env *env, char *line, int sz)
 
static int cli_env_count (struct cli_env *env)
 
CNDP_API int cli_env_get_all (struct cli_env *env, struct env_node **list, int max_size)
 
CNDP_API void cli_env_show (struct cli_env *env)
 

Detailed Description

CNE Command line interface

Definition in file cli_env.h.

Typedef Documentation

◆ cli_sfunc_t

typedef char*(* cli_sfunc_t) (const char *str)

CLI function pointer type for a Environment node

Definition at line 22 of file cli_env.h.

Function Documentation

◆ cli_env_create()

CNDP_API struct cli_env* cli_env_create ( void  )

Create a environment for the cli

Returns
NULL on error or cli_env pointer

◆ cli_env_destroy()

CNDP_API void cli_env_destroy ( struct cli_env *  env)

Delete the environment for the CLI

Parameters
envThe pointer to the environment structure

◆ cli_env_set()

CNDP_API int cli_env_set ( struct cli_env *  env,
const char *  var,
const char *  val 
)

Set a environment variable for the CLI

Parameters
envThe cli_env pointer
varPointer to the variable name const string
valPointer to the string assigned to the variable
Returns
0 is OK was added or replaced or -1 if not valid

◆ cli_env_string()

CNDP_API int cli_env_string ( struct cli_env *  env,
const char *  var,
cli_sfunc_t  sfunc,
const char *  val 
)

Set a environment variable for the CLI with a function pointer

Parameters
envThe cli_env pointer
varPointer to the variable name const string.
sfuncPointer to function (optional)
valPointer to the string assigned to the variable
Returns
0 is OK was added or replaced or -1 if not valid

◆ cli_env_get()

CNDP_API const char* cli_env_get ( struct cli_env *  env,
const char *  var 
)

Get the environment variable from the cli

Parameters
envThe cli_env pointer
varThe const string variable name
Returns
NULL if not found or the const string

◆ cli_env_del()

CNDP_API int cli_env_del ( struct cli_env *  env,
const char *  var 
)

Remove the environment variable from the cli

Parameters
envThe cli_env pointer
varThe const string variable name
Returns
0 is OK or -1 if not found.

◆ cli_env_substitution()

CNDP_API void cli_env_substitution ( struct cli_env *  env,
char *  line,
int  sz 
)

Do environment variable substitution on the line.

Parameters
envPointer to the environment structure
linePointer to the line to parse
szNumber of total characters the line can hold.
Returns
N/A

◆ cli_env_count()

static int cli_env_count ( struct cli_env *  env)
inlinestatic

Get the number of variables in the environment

Parameters
envPointer to environment structure
Returns
Number of environment variables

Definition at line 131 of file cli_env.h.

◆ cli_env_get_all()

CNDP_API int cli_env_get_all ( struct cli_env *  env,
struct env_node **  list,
int  max_size 
)

Get all of the environment variables

Parameters
envPointer to environment list
listArray of env_node pointers to be returned
max_sizeMax size of the list array

◆ cli_env_show()

CNDP_API void cli_env_show ( struct cli_env *  env)

Show all environment variable

Parameters
envPointer to the cli_env structure.