X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=libuci.c;h=a9e70e883ee3d55009bc3fe01edc87ae24733194;hp=550eca23db04390205429eec340899d1ff2477cf;hb=e1bf4356e1b513e158e1b5049147087ed6342cfd;hpb=e4516d01a7d2b0a5a8def7b5791c7d4032138287 diff --git a/libuci.c b/libuci.c index 550eca2..a9e70e8 100644 --- a/libuci.c +++ b/libuci.c @@ -56,11 +56,11 @@ struct uci_context *uci_alloc_context(void) uci_list_init(&ctx->root); uci_list_init(&ctx->delta_path); uci_list_init(&ctx->backends); - uci_list_init(&ctx->hooks); ctx->flags = UCI_FLAG_STRICT | UCI_FLAG_SAVED_DELTA; ctx->confdir = (char *) uci_confdir; ctx->savedir = (char *) uci_savedir; + uci_add_delta_path(ctx, uci_savedir); uci_list_add(&ctx->backends, &uci_file_backend.e.list); ctx->backend = &uci_file_backend; @@ -210,16 +210,10 @@ int uci_commit(struct uci_context *ctx, struct uci_package **package, bool overw int uci_load(struct uci_context *ctx, const char *name, struct uci_package **package) { struct uci_package *p; - struct uci_element *e; UCI_HANDLE_ERR(ctx); UCI_ASSERT(ctx, ctx->backend && ctx->backend->load); p = ctx->backend->load(ctx, name); - uci_foreach_element(&ctx->hooks, e) { - struct uci_hook *h = uci_to_hook(e); - if (h->ops->load) - h->ops->load(h->ops, p); - } if (package) *package = p; @@ -238,40 +232,3 @@ int uci_set_backend(struct uci_context *ctx, const char *name) ctx->backend = uci_to_backend(e); return 0; } - -int uci_add_hook(struct uci_context *ctx, const struct uci_hook_ops *ops) -{ - struct uci_element *e; - struct uci_hook *h; - - UCI_HANDLE_ERR(ctx); - - /* check for duplicate elements */ - uci_foreach_element(&ctx->hooks, e) { - h = uci_to_hook(e); - if (h->ops == ops) - return UCI_ERR_INVAL; - } - - h = uci_alloc_element(ctx, hook, "", 0); - h->ops = ops; - uci_list_init(&h->e.list); - uci_list_add(&ctx->hooks, &h->e.list); - - return 0; -} - -int uci_remove_hook(struct uci_context *ctx, const struct uci_hook_ops *ops) -{ - struct uci_element *e; - - uci_foreach_element(&ctx->hooks, e) { - struct uci_hook *h = uci_to_hook(e); - if (h->ops == ops) { - uci_list_del(&e->list); - uci_free_element(e); - return 0; - } - } - return UCI_ERR_NOTFOUND; -}