summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMarko Kiiskila <marko@runtime.io>2016-06-27 15:26:56 -0700
committerMarko Kiiskila <marko@runtime.io>2016-06-27 15:26:56 -0700
commit9490ca7056298b0b00e33a6f59b91ec0e7fbd4aa (patch)
treeda03a25abdc7d5b43db32078be6b6fe5aa3a584e /sys
parent93f2e1127735784fa5a6bb7536b4da31e9479288 (diff)
sys/config; change export function prototype.
Added argument which tells whether module should export variables it wants to persist, or variables it wants to display.
Diffstat (limited to 'sys')
-rw-r--r--sys/config/include/config/config.h8
-rw-r--r--sys/config/src/config_cli.c2
-rw-r--r--sys/config/src/config_store.c2
-rw-r--r--sys/config/src/test/conf_test.c18
4 files changed, 21 insertions, 9 deletions
diff --git a/sys/config/include/config/config.h b/sys/config/include/config/config.h
index b0bc8aa7..3402b468 100644
--- a/sys/config/include/config/config.h
+++ b/sys/config/include/config/config.h
@@ -42,13 +42,19 @@ enum conf_type {
CONF_DOUBLE
} __attribute__((__packed__));
+enum conf_export_tgt {
+ CONF_EXPORT_PERSIST, /* Value is to be persisted. */
+ CONF_EXPORT_SHOW /* Value is to be displayed. */
+};
+
struct conf_handler {
SLIST_ENTRY(conf_handler) ch_list;
char *ch_name;
char *(*ch_get)(int argc, char **argv, char *val, int val_len_max);
int (*ch_set)(int argc, char **argv, char *val);
int (*ch_commit)(void);
- int (*ch_export)(void (*export_func)(char *name, char *val));
+ int (*ch_export)(void (*export_func)(char *name, char *val),
+ enum conf_export_tgt tgt);
};
int conf_init(void);
diff --git a/sys/config/src/config_cli.c b/sys/config/src/config_cli.c
index 7c395981..29238459 100644
--- a/sys/config/src/config_cli.c
+++ b/sys/config/src/config_cli.c
@@ -48,7 +48,7 @@ conf_dump_running(void)
SLIST_FOREACH(ch, &conf_handlers, ch_list) {
if (ch->ch_export) {
- ch->ch_export(conf_running_one);
+ ch->ch_export(conf_running_one, CONF_EXPORT_SHOW);
}
}
}
diff --git a/sys/config/src/config_store.c b/sys/config/src/config_store.c
index 6bd94a11..87f9955c 100644
--- a/sys/config/src/config_store.c
+++ b/sys/config/src/config_store.c
@@ -159,7 +159,7 @@ conf_save(void)
rc = 0;
SLIST_FOREACH(ch, &conf_handlers, ch_list) {
if (ch->ch_export) {
- rc2 = ch->ch_export(conf_store_one);
+ rc2 = ch->ch_export(conf_store_one, CONF_EXPORT_PERSIST);
if (!rc) {
rc = rc2;
}
diff --git a/sys/config/src/test/conf_test.c b/sys/config/src/test/conf_test.c
index 35ed588e..cde1ccaa 100644
--- a/sys/config/src/test/conf_test.c
+++ b/sys/config/src/test/conf_test.c
@@ -46,15 +46,18 @@ static char *ctest_handle_get(int argc, char **argv, char *val,
int val_len_max);
static int ctest_handle_set(int argc, char **argv, char *val);
static int ctest_handle_commit(void);
-static int ctest_handle_export(void (*cb)(char *name, char *value));
+static int ctest_handle_export(void (*cb)(char *name, char *value),
+ enum conf_export_tgt tgt);
static char *c2_handle_get(int argc, char **argv, char *val,
int val_len_max);
static int c2_handle_set(int argc, char **argv, char *val);
-static int c2_handle_export(void (*cb)(char *name, char *value));
+static int c2_handle_export(void (*cb)(char *name, char *value),
+ enum conf_export_tgt tgt);
static char *c3_handle_get(int argc, char **argv, char *val,
int val_len_max);
static int c3_handle_set(int argc, char **argv, char *val);
-static int c3_handle_export(void (*cb)(char *name, char *value));
+static int c3_handle_export(void (*cb)(char *name, char *value),
+ enum conf_export_tgt tgt);
struct conf_handler config_test_handler = {
.ch_name = "myfoo",
@@ -98,7 +101,8 @@ ctest_handle_commit(void)
}
static int
-ctest_handle_export(void (*cb)(char *name, char *value))
+ctest_handle_export(void (*cb)(char *name, char *value),
+ enum conf_export_tgt tgt)
{
char value[32];
@@ -177,7 +181,8 @@ c2_handle_set(int argc, char **argv, char *val)
}
static int
-c2_handle_export(void (*cb)(char *name, char *value))
+c2_handle_export(void (*cb)(char *name, char *value),
+ enum conf_export_tgt tgt)
{
int i;
char name[32];
@@ -222,7 +227,8 @@ c3_handle_set(int argc, char **argv, char *val)
}
static int
-c3_handle_export(void (*cb)(char *name, char *value))
+c3_handle_export(void (*cb)(char *name, char *value),
+ enum conf_export_tgt tgt)
{
char value[32];