CNDP 22.08.0
Loading...
Searching...
No Matches
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
12
13#include <sys/queue.h> // for TAILQ_ENTRY, TAILQ_HEAD
14#include <cne_common.h> // for CNDP_API
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20struct cli;
21
22typedef char *(*cli_sfunc_t)(const char *str);
24
25struct env_node {
26 TAILQ_ENTRY(env_node) next;
27 const char *var;
28 const char *val;
29 cli_sfunc_t sfunc;
30};
31
32struct cli_env {
33 TAILQ_HEAD(, env_node) head;
34 int count;
35};
36
43CNDP_API struct cli_env *cli_env_create(void);
44
51CNDP_API void cli_env_destroy(struct cli_env *env);
52
65CNDP_API int cli_env_set(struct cli_env *env, const char *var, const char *val);
66
81CNDP_API int cli_env_string(struct cli_env *env, const char *var, cli_sfunc_t sfunc,
82 const char *val);
83
94CNDP_API const char *cli_env_get(struct cli_env *env, const char *var);
95
106CNDP_API int cli_env_del(struct cli_env *env, const char *var);
107
120CNDP_API void cli_env_substitution(struct cli_env *env, char *line, int sz);
121
130static inline int
131cli_env_count(struct cli_env *env)
132{
133 return env->count;
134}
135
146CNDP_API int cli_env_get_all(struct cli_env *env, struct env_node **list, int max_size);
147
154CNDP_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 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)
char *(*) cli_sfunc_t(const char *str)
Definition cli_env.h:22
CNDP_API const char * cli_env_get(struct cli_env *env, const char *var)
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 struct cli_env * cli_env_create(void)
CNDP_API void cli_env_show(struct cli_env *env)
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)