* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * GNU Lesser General Public License for more details.
*/
/*
#include <glob.h>
#include "uci.h"
-static const char *uci_confdir = UCI_CONFDIR;
-static const char *uci_savedir = UCI_SAVEDIR;
-
static const char *uci_errstr[] = {
[UCI_OK] = "Success",
[UCI_ERR_MEM] = "Out of memory",
#include "uci_internal.h"
#include "list.c"
-#include "history.c"
+
+__private const char *uci_confdir = UCI_CONFDIR;
+__private const char *uci_savedir = UCI_SAVEDIR;
/* exported functions */
struct uci_context *uci_alloc_context(void)
memset(ctx, 0, sizeof(struct uci_context));
uci_list_init(&ctx->root);
- uci_list_init(&ctx->history_path);
+ uci_list_init(&ctx->delta_path);
uci_list_init(&ctx->backends);
uci_list_init(&ctx->hooks);
uci_list_init(&ctx->plugins);
- ctx->flags = UCI_FLAG_STRICT | UCI_FLAG_SAVED_HISTORY;
+ ctx->flags = UCI_FLAG_STRICT | UCI_FLAG_SAVED_DELTA;
ctx->confdir = (char *) uci_confdir;
ctx->savedir = (char *) uci_savedir;
struct uci_package *p = uci_to_package(e);
uci_free_package(&p);
}
- uci_foreach_element_safe(&ctx->history_path, tmp, e) {
+ uci_foreach_element_safe(&ctx->delta_path, tmp, e) {
uci_free_element(e);
}
UCI_TRAP_RESTORE(ctx);
if (dest) {
err = asprintf(dest, format,
(prefix ? prefix : ""), (prefix ? ": " : ""),
- (ctx->func ? ctx->func : ""), (ctx->func ? ": " : ""),
+ (ctx && ctx->func ? ctx->func : ""), (ctx && ctx->func ? ": " : ""),
uci_errstr[err],
error_info);
if (err < 0)
strcat(error_info, "\n");
fprintf(stderr, format,
(prefix ? prefix : ""), (prefix ? ": " : ""),
- (ctx->func ? ctx->func : ""), (ctx->func ? ": " : ""),
+ (ctx && ctx->func ? ctx->func : ""), (ctx && ctx->func ? ": " : ""),
uci_errstr[err],
error_info);
}
struct uci_hook *h = uci_to_hook(e);
if (h->ops == ops) {
uci_list_del(&e->list);
+ uci_free_element(e);
return 0;
}
}