add revert, merge package handler functions
[project/uci.git] / history.c
index 6be8a9d..73c1bf0 100644 (file)
--- a/history.c
+++ b/history.c
@@ -239,11 +239,11 @@ static int uci_load_history(struct uci_context *ctx, struct uci_package *p, bool
        if (filename)
                free(filename);
        uci_close_stream(f);
-       ctx->errno = 0;
+       ctx->err = 0;
        return changes;
 }
 
-static void uci_filter_history(struct uci_context *ctx, const char *name, char *section, char *option)
+static void uci_filter_history(struct uci_context *ctx, const char *name, const char *section, const char *option)
 {
        struct uci_parse_context *pctx;
        struct uci_element *e, *tmp;
@@ -312,7 +312,7 @@ done:
        uci_cleanup(ctx);
 }
 
-int uci_revert(struct uci_context *ctx, struct uci_package **pkg, char *section, char *option)
+int uci_revert(struct uci_context *ctx, struct uci_package **pkg, const char *section, const char *option)
 {
        struct uci_package *p;
        char *name = NULL;
@@ -340,13 +340,13 @@ int uci_revert(struct uci_context *ctx, struct uci_package **pkg, char *section,
 
        UCI_INTERNAL(uci_load, ctx, name, &p);
        UCI_TRAP_RESTORE(ctx);
-       ctx->errno = 0;
+       ctx->err = 0;
 
 error:
        if (name)
                free(name);
-       if (ctx->errno)
-               UCI_THROW(ctx, ctx->errno);
+       if (ctx->err)
+               UCI_THROW(ctx, ctx->err);
        return 0;
 }
 
@@ -380,7 +380,7 @@ int uci_save(struct uci_context *ctx, struct uci_package *p)
        if ((asprintf(&filename, "%s/%s", ctx->savedir, p->e.name) < 0) || !filename)
                UCI_THROW(ctx, UCI_ERR_MEM);
 
-       ctx->errno = 0;
+       ctx->err = 0;
        UCI_TRAP_SAVE(ctx, done);
        f = uci_open_stream(ctx, filename, SEEK_END, true, true);
        UCI_TRAP_RESTORE(ctx);
@@ -417,8 +417,8 @@ done:
        uci_close_stream(f);
        if (filename)
                free(filename);
-       if (ctx->errno)
-               UCI_THROW(ctx, ctx->errno);
+       if (ctx->err)
+               UCI_THROW(ctx, ctx->err);
 
        return 0;
 }