add feature flags for the build process, improve automatic rebuild
[project/uci.git] / libuci.c
index 6bbc874..a503699 100644 (file)
--- a/libuci.c
+++ b/libuci.c
@@ -23,7 +23,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include "uci.h"
-#include "err.h"
 
 static const char *uci_confdir = UCI_CONFDIR;
 static const char *uci_savedir = UCI_SAVEDIR;
@@ -194,4 +193,27 @@ int uci_load(struct uci_context *ctx, const char *name, struct uci_package **pac
        return 0;
 }
 
+int uci_add_backend(struct uci_context *ctx, struct uci_backend *b)
+{
+       struct uci_element *e;
+       UCI_HANDLE_ERR(ctx);
+       e = uci_lookup_list(&ctx->backends, b->e.name);
+       if (e)
+               UCI_THROW(ctx, UCI_ERR_DUPLICATE);
+
+       uci_list_add(&ctx->backends, &b->e.list);
+       return 0;
+}
 
+int uci_set_backend(struct uci_context *ctx, const char *name)
+{
+       struct uci_element *e;
+
+       UCI_HANDLE_ERR(ctx);
+       UCI_ASSERT(ctx, name != NULL);
+       e = uci_lookup_list(&ctx->backends, name);
+       if (!e)
+               UCI_THROW(ctx, UCI_ERR_NOTFOUND);
+       ctx->backend = uci_to_backend(e);
+       return 0;
+}