Skip to content

Commit fc4d1b5

Browse files
committed
feat: Update configlib
1 parent c4d7b5c commit fc4d1b5

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

lib/plumcore-configlib/src/configlib.c

+13-3
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ static conf_ret_t configlib_walk(Conf *self, enum conf_dir direction, Conf **nex
7171
}
7272

7373

74-
static conf_ret_t configlib_stat(Conf *self, const char **name, enum conf_type *type) {
74+
static conf_ret_t configlib_stat(Conf *self, const char **name, enum conf_type *type, enum conf_flag *flags) {
7575
ConfiglibValue *value = self->parent;
7676

7777
*name = value->name;
7878
*type = value->type;
79-
/** @todo add flags */
79+
*flags = value->flags;
8080

8181
return CONF_RET_OK;
8282
}
@@ -116,6 +116,15 @@ configlib_ret_t configlib_map(ConfiglibValue *self, void *var, enum conf_type ty
116116
}
117117

118118

119+
configlib_ret_t configlib_map_string(ConfiglibValue *self, char *str, size_t size) {
120+
self->var = str;
121+
self->size = size;
122+
self->type = CONF_STR;
123+
124+
return CONFIGLIB_RET_OK;
125+
}
126+
127+
119128
configlib_ret_t configlib_append(ConfiglibValue *self, ConfiglibValue *parent, enum conf_dir dir) {
120129
if (dir == CONF_DIR_CHILD) {
121130
if (parent->child == NULL) {
@@ -172,7 +181,8 @@ static void configlib_log_walk_subtree(Conf *self, uint32_t indent) {
172181

173182
const char *conf_name = NULL;
174183
enum conf_type conf_type = CONF_SUBTREE;
175-
self->vmt->stat(self, &conf_name, &conf_type);
184+
enum conf_flag conf_flags;
185+
self->vmt->stat(self, &conf_name, &conf_type, &conf_flags);
176186

177187
union conf_val val = {0};
178188
self->vmt->read(self, &val);

lib/plumcore-configlib/src/configlib.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,19 @@ typedef struct configlib_value {
3232
ConfiglibValue *parent;
3333

3434
void *var;
35+
size_t *len;
36+
size_t size;
37+
3538
const char *name;
3639
enum conf_type type;
37-
40+
enum conf_flag flags;
3841

3942
} ConfiglibValue;
4043

4144

4245
configlib_ret_t configlib_init(ConfiglibValue *self, const char *name);
4346
configlib_ret_t configlib_map(ConfiglibValue *self, void *var, enum conf_type type);
47+
configlib_ret_t configlib_map_string(ConfiglibValue *self, char *str, size_t size);
4448
configlib_ret_t configlib_append(ConfiglibValue *self, ConfiglibValue *parent, enum conf_dir dir);
4549

4650

0 commit comments

Comments
 (0)