-
-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;
-}