You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/04/08 19:36:58 UTC

[2/2] incubator-mynewt-core git commit: config; add CLI command to dump current running config.

config; add CLI command to dump current running config.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/46849c55
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/46849c55
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/46849c55

Branch: refs/heads/develop
Commit: 46849c552bb1b2687c3c47f8efa0c39af23c3ed9
Parents: 15400db
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Apr 8 10:36:26 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Apr 8 10:36:26 2016 -0700

----------------------------------------------------------------------
 sys/config/src/config_cli.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/46849c55/sys/config/src/config_cli.c
----------------------------------------------------------------------
diff --git a/sys/config/src/config_cli.c b/sys/config/src/config_cli.c
index 2090652..72fd801 100644
--- a/sys/config/src/config_cli.c
+++ b/sys/config/src/config_cli.c
@@ -35,6 +35,24 @@ static struct shell_cmd shell_conf_cmd = {
     .sc_cmd_func = shell_conf_command
 };
 
+static void
+conf_dump_one(struct conf_handler *ch, char *name, char *val)
+{
+    console_printf("%s/%s = %s\n", ch->ch_name, name, val ? val : "<del>");
+}
+
+static void
+conf_dump(void)
+{
+    struct conf_handler *ch;
+
+    SLIST_FOREACH(ch, &conf_handlers, ch_list) {
+        if (ch->ch_export) {
+            ch->ch_export(conf_dump_one);
+        }
+    }
+}
+
 static int
 shell_conf_command(int argc, char **argv)
 {
@@ -65,6 +83,12 @@ shell_conf_command(int argc, char **argv)
         console_printf("%s", val);
         return 0;
     }
+    if (!strcmp(name, "dump")) {
+        if (!val || !strcmp(val, "running")) {
+            conf_dump();
+        }
+        return 0;
+    }
     if (!val) {
         val = conf_get_value(name, tmp_buf, sizeof(tmp_buf));
         if (!val) {