sterlinghughes closed pull request #885: sys/config; add conf_save_tree() which 
saves config for single subsystem.
URL: https://github.com/apache/mynewt-core/pull/885
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/sys/config/include/config/config.h 
b/sys/config/include/config/config.h
index 7711b25d7..31a759883 100644
--- a/sys/config/include/config/config.h
+++ b/sys/config/include/config/config.h
@@ -102,6 +102,15 @@ int conf_load(void);
  */
 int conf_save(void);
 
+/**
+ * Save currently running configuration for configuration subtree.
+ *
+ * @param name Name of the configuration subtree.
+ *
+ * @return 0 on success, non-zero on failure.
+ */
+int conf_save_tree(char *name);
+
 /**
  * Write a single configuration value to persisted storage (if it has
  * changed value).
diff --git a/sys/config/src/config.c b/sys/config/src/config.c
index 693309308..67d4d2c06 100644
--- a/sys/config/src/config.c
+++ b/sys/config/src/config.c
@@ -104,7 +104,7 @@ conf_parse_name(char *name, int *name_argc, char 
*name_argv[])
     return 0;
 }
 
-static struct conf_handler *
+struct conf_handler *
 conf_parse_and_lookup(char *name, int *name_argc, char *name_argv[])
 {
     int rc;
diff --git a/sys/config/src/config_priv.h b/sys/config/src/config_priv.h
index 8dfee3dde..0e17b92e9 100644
--- a/sys/config/src/config_priv.h
+++ b/sys/config/src/config_priv.h
@@ -28,12 +28,13 @@ int conf_cli_register(void);
 int conf_nmgr_register(void);
 
 struct mgmt_cbuf;
-int
-conf_cbor_line(struct mgmt_cbuf *cb, char *name, int nlen, char *value, int 
vlen);
-
+int conf_cbor_line(struct mgmt_cbuf *cb, char *name, int nlen, char *value,
+                   int vlen);
 int conf_line_parse(char *buf, char **namep, char **valp);
 int conf_line_make(char *dst, int dlen, const char *name, const char *val);
 int conf_line_make2(char *dst, int dlen, const char *name, const char *value);
+struct conf_handler *conf_parse_and_lookup(char *name, int *name_argc,
+                                           char *name_argv[]);
 
 /*
  * API for config storage.
diff --git a/sys/config/src/config_store.c b/sys/config/src/config_store.c
index afd4f71d1..3501adf78 100644
--- a/sys/config/src/config_store.c
+++ b/sys/config/src/config_store.c
@@ -140,6 +140,23 @@ conf_store_one(char *name, char *value)
     conf_save_one(name, value);
 }
 
+int
+conf_save_tree(char *name)
+{
+    int name_argc;
+    char *name_argv[CONF_MAX_DIR_DEPTH];
+    struct conf_handler *ch;
+
+    ch = conf_parse_and_lookup(name, &name_argc, name_argv);
+    if (!ch) {
+        return OS_INVALID_PARM;
+    }
+    if (ch->ch_export) {
+        return ch->ch_export(conf_store_one, CONF_EXPORT_PERSIST);
+    }
+    return OS_OK;
+}
+
 int
 conf_save(void)
 {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to