]> pilppa.org Git - libplp.git/blobdiff - src/config.c
revert previous save_immediately flag
[libplp.git] / src / config.c
index 92c8df303875424f5e455f9203f20a2006be875f..32f0a93b63ee0d5c1b30819e69031874d44f9d65 100644 (file)
@@ -3,16 +3,14 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <uci.h>
-#include <stdbool.h>
 
-#include "log.h"
 #include "config.h"
+#include "log.h"
 
 static int uci_create_named_section(struct uci_context *ctx,
                                const char *conf_file_name,
                                const char *section_type,
-                               const char *section_name,
-                               bool save_immediately)
+                               const char *section_name)
 {
        struct uci_ptr  ptr;
        int             ret_val;
@@ -36,9 +34,7 @@ static int uci_create_named_section(struct uci_context *ctx,
                        if (uci_lookup_ptr(ctx, &ptr, cmd_data, true) == UCI_OK) {
                                ret_val = uci_set(ctx, &ptr);
                                if (ret_val == UCI_OK) {
-                                       if (save_immediately) {
-                                               ret_val = uci_save(ctx, ptr.p);
-                                       }
+                                       ret_val = uci_save(ctx, ptr.p);
                                }
                        }
                        free(cmd_data);
@@ -52,8 +48,7 @@ bool set_config_value_to_section(const char *conf_dir_name,
                        const char *section_type,
                        const char *section_name,
                        const char *key,
-                       const char *value,
-                       bool save_immediately) {
+                       const char *value) {
        struct uci_context      *ctx;
        struct uci_package      *pkg;
        struct uci_section      *sct;
@@ -105,8 +100,7 @@ bool set_config_value_to_section(const char *conf_dir_name,
                                                err_flg = uci_create_named_section(ctx,
                                                                        conf_file_name,
                                                                        section_type,
-                                                                       section_name,
-                                                                       false);
+                                                                       section_name);
                                                if (err_flg == UCI_OK) {
                                                        uci_foreach_element(&pkg->sections, elem) {
                                                                tmp_sct = uci_to_section(elem);
@@ -127,16 +121,15 @@ bool set_config_value_to_section(const char *conf_dir_name,
                                                        ptr.value       = value;
                                                        err_flg         = uci_set(ctx, &ptr);
                                                        if (err_flg == UCI_OK) {
-                                                               if (save_immediately == true) {
-                                                                       err_flg = uci_save(ctx, pkg);
-                                                                       if (err_flg != UCI_OK) {
-                                                                               log_error("Failed to set value to configuration file: %s\n. Could not save the file\n", fname);
-                                                                       }
-                                                               }
+                                                               err_flg = uci_save(ctx, pkg);
                                                                if (err_flg == UCI_OK) {
                                                                        ret_val = true;
                                                                        log_debug("Set value to section %s in configuration file: %s\n", section_name, fname);
                                                                }
+                                                               else {
+                                                                       log_error("Failed to set value to configuration file: %s\n. Could not save the file\n", fname);
+                                                               }
+
                                                        }
                                                        else {
                                                                log_error("Failed to set value to configuration file: %s\n. Could not set new value\n", fname);