fix uci_set
authorFelix Fietkau <nbd@openwrt.org>
Tue, 12 Feb 2008 10:49:56 +0000 (11:49 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 12 Feb 2008 10:49:56 +0000 (11:49 +0100)
file.c
history.c
list.c
uci.h
util.c

diff --git a/file.c b/file.c
index 9f59637d06ff33471227effe86ea9cbf4af64d64..d2fdf5862cd9a0eb92f6e3f78a97f0b908508f98 100644 (file)
--- a/file.c
+++ b/file.c
@@ -293,7 +293,6 @@ int uci_import(struct uci_context *ctx, FILE *stream, const char *name, struct u
        UCI_HANDLE_ERR(ctx);
 
        /* make sure no memory from previous parse attempts is leaked */
        UCI_HANDLE_ERR(ctx);
 
        /* make sure no memory from previous parse attempts is leaked */
-       ctx->internal = true;
        uci_cleanup(ctx);
 
        uci_alloc_parse_context(ctx);
        uci_cleanup(ctx);
 
        uci_alloc_parse_context(ctx);
@@ -375,7 +374,7 @@ void uci_file_commit(struct uci_context *ctx, struct uci_package **package, bool
 
        /* flush unsaved changes and reload from history file */
        UCI_TRAP_SAVE(ctx, done);
 
        /* flush unsaved changes and reload from history file */
        UCI_TRAP_SAVE(ctx, done);
-       if (p->confdir) {
+       if (p->has_history) {
                if (!overwrite) {
                        name = uci_strdup(ctx, p->e.name);
                        path = uci_strdup(ctx, p->path);
                if (!overwrite) {
                        name = uci_strdup(ctx, p->e.name);
                        path = uci_strdup(ctx, p->path);
@@ -392,7 +391,7 @@ void uci_file_commit(struct uci_context *ctx, struct uci_package **package, bool
                        UCI_INTERNAL(uci_import, ctx, f, name, &p, true);
 
                        p->path = path;
                        UCI_INTERNAL(uci_import, ctx, f, name, &p, true);
 
                        p->path = path;
-                       p->confdir = true;
+                       p->has_history = true;
                        *package = p;
 
                        /* freed together with the uci_package */
                        *package = p;
 
                        /* freed together with the uci_package */
@@ -517,7 +516,7 @@ static struct uci_package *uci_file_load(struct uci_context *ctx, const char *na
 
        if (package) {
                package->path = filename;
 
        if (package) {
                package->path = filename;
-               package->confdir = confdir;
+               package->has_history = confdir;
                uci_load_history(ctx, package, false);
        }
 
                uci_load_history(ctx, package, false);
        }
 
index 089bcef67d75ee6a287537e1e01b2550fdc3cf18..c46c408c73ff4f2a0aabcc27fedec3ff3d0eb564 100644 (file)
--- a/history.c
+++ b/history.c
@@ -217,7 +217,7 @@ static int uci_load_history(struct uci_context *ctx, struct uci_package *p, bool
        FILE *f = NULL;
        int changes = 0;
 
        FILE *f = NULL;
        int changes = 0;
 
-       if (!p->confdir)
+       if (!p->has_history)
                return 0;
 
        uci_foreach_element(&ctx->history_path, e) {
                return 0;
 
        uci_foreach_element(&ctx->history_path, e) {
@@ -321,7 +321,7 @@ int uci_revert(struct uci_context *ctx, struct uci_package **pkg, char *section,
        UCI_ASSERT(ctx, pkg != NULL);
        p = *pkg;
        UCI_ASSERT(ctx, p != NULL);
        UCI_ASSERT(ctx, pkg != NULL);
        p = *pkg;
        UCI_ASSERT(ctx, p != NULL);
-       UCI_ASSERT(ctx, p->confdir);
+       UCI_ASSERT(ctx, p->has_history);
 
        /* 
         * - flush unwritten changes
 
        /* 
         * - flush unwritten changes
@@ -365,7 +365,7 @@ int uci_save(struct uci_context *ctx, struct uci_package *p)
         * directly.
         * does not modify the uci_package pointer
         */
         * directly.
         * does not modify the uci_package pointer
         */
-       if (!p->confdir)
+       if (!p->has_history)
                return uci_commit(ctx, &p, false);
 
        if (uci_list_empty(&p->history))
                return uci_commit(ctx, &p, false);
 
        if (uci_list_empty(&p->history))
diff --git a/list.c b/list.c
index a28c5e17a2aa51d0a4c18c15c31b252346d1e705..aabcab0582a0d0dc14fa6016b452237b75fbae4d 100644 (file)
--- a/list.c
+++ b/list.c
@@ -291,7 +291,7 @@ int uci_del_element(struct uci_context *ctx, struct uci_element *e)
        }
 
        p = s->package;
        }
 
        p = s->package;
-       if (!internal && p->confdir)
+       if (!internal && p->has_history)
                uci_add_history(ctx, &p->history, UCI_CMD_REMOVE, s->e.name, option, NULL);
 
        switch(e->type) {
                uci_add_history(ctx, &p->history, UCI_CMD_REMOVE, s->e.name, option, NULL);
 
        switch(e->type) {
@@ -354,7 +354,7 @@ int uci_set_element_value(struct uci_context *ctx, struct uci_element **element,
                return 0;
        }
        p = s->package;
                return 0;
        }
        p = s->package;
-       if (!internal && p->confdir)
+       if (!internal && p->has_history)
                uci_add_history(ctx, &p->history, UCI_CMD_CHANGE, section, option, value);
 
        uci_list_del(&e->list);
                uci_add_history(ctx, &p->history, UCI_CMD_CHANGE, section, option, value);
 
        uci_list_del(&e->list);
@@ -388,7 +388,7 @@ int uci_rename(struct uci_context *ctx, struct uci_package *p, char *section, ch
        /* NB: p, section, option validated by uci_lookup */
        UCI_INTERNAL(uci_lookup, ctx, &e, p, section, option);
 
        /* NB: p, section, option validated by uci_lookup */
        UCI_INTERNAL(uci_lookup, ctx, &e, p, section, option);
 
-       if (!internal && p->confdir)
+       if (!internal && p->has_history)
                uci_add_history(ctx, &p->history, UCI_CMD_RENAME, section, option, name);
 
        name = uci_strdup(ctx, name);
                uci_add_history(ctx, &p->history, UCI_CMD_RENAME, section, option, name);
 
        name = uci_strdup(ctx, name);
@@ -493,7 +493,7 @@ notfound:
                UCI_THROW(ctx, UCI_ERR_NOTFOUND);
 
        /* now add the missing entry */
                UCI_THROW(ctx, UCI_ERR_NOTFOUND);
 
        /* now add the missing entry */
-       if (!internal && p->confdir)
+       if (!internal && p->has_history)
                uci_add_history(ctx, &p->history, UCI_CMD_CHANGE, section, option, value);
        if (s) {
                o = uci_alloc_option(s, option, value);
                uci_add_history(ctx, &p->history, UCI_CMD_CHANGE, section, option, value);
        if (s) {
                o = uci_alloc_option(s, option, value);
diff --git a/uci.h b/uci.h
index 44f947f615267a6d1dd65fb33909582102cbb16c..5bc20612c3d8ade20044e8de29f49366711c9a61 100644 (file)
--- a/uci.h
+++ b/uci.h
@@ -341,7 +341,7 @@ struct uci_package
        struct uci_element e;
        struct uci_list sections;
        struct uci_context *ctx;
        struct uci_element e;
        struct uci_list sections;
        struct uci_context *ctx;
-       bool confdir;
+       bool has_history;
        char *path;
 
        /* private: */
        char *path;
 
        /* private: */
diff --git a/util.c b/util.c
index f098c4bbcd29d1c5b34f9a9022d601a22f4ce7b9..35aa2b6e8a66dca190a55ab21383824cbefd4b50 100644 (file)
--- a/util.c
+++ b/util.c
@@ -371,7 +371,6 @@ int uci_parse_argument(struct uci_context *ctx, FILE *stream, char **str, char *
 
        if (ctx->pctx) {
                if (ctx->pctx->file != stream) {
 
        if (ctx->pctx) {
                if (ctx->pctx->file != stream) {
-                       ctx->internal = true;
                        uci_cleanup(ctx);
                }
        } else {
                        uci_cleanup(ctx);
                }
        } else {