CNDP  22.08.0
cli_env.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2019-2022 Intel Corporation.
3  */
4 
5 #ifndef _CLI_ENV_H_
6 #define _CLI_ENV_H_
7 
13 #include <sys/queue.h> // for TAILQ_ENTRY, TAILQ_HEAD
14 #include <cne_common.h> // for CNDP_API
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 struct cli;
21 
22 typedef char *(*cli_sfunc_t)(const char *str);
25 struct env_node {
26  TAILQ_ENTRY(env_node) next;
27  const char *var;
28  const char *val;
29  cli_sfunc_t sfunc;
30 };
31 
32 struct cli_env {
33  TAILQ_HEAD(, env_node) head;
34  int count;
35 };
36 
43 CNDP_API struct cli_env *cli_env_create(void);
44 
51 CNDP_API void cli_env_destroy(struct cli_env *env);
52 
65 CNDP_API int cli_env_set(struct cli_env *env, const char *var, const char *val);
66 
81 CNDP_API int cli_env_string(struct cli_env *env, const char *var, cli_sfunc_t sfunc,
82  const char *val);
83 
94 CNDP_API const char *cli_env_get(struct cli_env *env, const char *var);
95 
106 CNDP_API int cli_env_del(struct cli_env *env, const char *var);
107 
120 CNDP_API void cli_env_substitution(struct cli_env *env, char *line, int sz);
121 
130 static inline int
131 cli_env_count(struct cli_env *env)
132 {
133  return env->count;
134 }
135 
146 CNDP_API int cli_env_get_all(struct cli_env *env, struct env_node **list, int max_size);
147 
154 CNDP_API void cli_env_show(struct cli_env *env);
155 
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif /* _CLI_ENV_H_ */
static int cli_env_count(struct cli_env *env)
Definition: cli_env.h:131
CNDP_API struct cli_env * cli_env_create(void)
char *(* cli_sfunc_t)(const char *str)
Definition: cli_env.h:22
CNDP_API int cli_env_get_all(struct cli_env *env, struct env_node **list, int max_size)
CNDP_API void cli_env_substitution(struct cli_env *env, char *line, int sz)
CNDP_API int cli_env_set(struct cli_env *env, const char *var, const char *val)
CNDP_API int cli_env_del(struct cli_env *env, const char *var)
CNDP_API void cli_env_show(struct cli_env *env)
CNDP_API const char * cli_env_get(struct cli_env *env, const char *var)
CNDP_API int cli_env_string(struct cli_env *env, const char *var, cli_sfunc_t sfunc, const char *val)
CNDP_API void cli_env_destroy(struct cli_env *env)
TAILQ_HEAD(pktdev_driver_list, pktdev_driver)