...
 
......@@ -11,20 +11,26 @@ OPTION(BUILD_LUA "build Lua binding" ON)
IF(BUILD_STATIC)
FIND_LIBRARY(ubox_library NAMES ubox.a)
FIND_LIBRARY(ubus_library NAMES ubus.a)
FIND_LIBRARY(ece_library NAMES ece.a)
ELSE(BUILD_STATIC)
FIND_LIBRARY(ubox_library NAMES ubox)
FIND_LIBRARY(ubus_library NAMES ubus)
FIND_LIBRARY(ece_library NAMES ece)
ENDIF(BUILD_STATIC)
FIND_PATH(ubox_include_dir libubox/usock.h)
FIND_PATH(ubus_include_dir libubus.h)
FIND_PATH(ece_include_dir libece.h)
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/uci_config.h.in ${CMAKE_SOURCE_DIR}/uci_config.h )
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${ubox_include_dir})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${ubox_include_dir} ${ubus_include_dir} ${ece_include_dir})
SET(LIB_SOURCES libuci.c file.c util.c delta.c parse.c blob.c)
SET(LIB_SOURCES libuci.c file.c ece.c util.c delta.c parse.c blob.c)
ADD_LIBRARY(uci SHARED ${LIB_SOURCES})
TARGET_LINK_LIBRARIES(uci ${ubox_library})
TARGET_LINK_LIBRARIES(uci ${ubox_library} ${ubus_library} ${ece_library})
SET_TARGET_PROPERTIES(uci PROPERTIES OUTPUT_NAME uci)
ADD_EXECUTABLE(cli cli.c)
......@@ -44,4 +50,3 @@ INSTALL(TARGETS uci cli
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
This diff is collapsed. Click to expand it.
......@@ -47,11 +47,18 @@ __private const char *uci_savedir = UCI_SAVEDIR;
struct uci_context *uci_alloc_context(void)
{
struct uci_context *ctx;
struct uci_backend *backend;
ctx = (struct uci_context *) malloc(sizeof(struct uci_context));
if (!ctx)
return NULL;
backend = uci_ece_init();
if (!backend) {
free(ctx);
return NULL;
}
memset(ctx, 0, sizeof(struct uci_context));
uci_list_init(&ctx->root);
uci_list_init(&ctx->delta_path);
......@@ -62,8 +69,8 @@ struct uci_context *uci_alloc_context(void)
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;
uci_list_add(&ctx->backends, &backend->e.list);
ctx->backend = backend;
return ctx;
}
......@@ -87,6 +94,7 @@ void uci_free_context(struct uci_context *ctx)
uci_free_element(e);
}
UCI_TRAP_RESTORE(ctx);
uci_ece_free(ctx->backend);
free(ctx);
ignore:
......
......@@ -69,6 +69,9 @@ __private struct uci_element *uci_expand_ptr(struct uci_context *ctx, struct uci
__private int uci_load_delta(struct uci_context *ctx, struct uci_package *p, bool flush);
__private struct uci_backend * uci_ece_init(void);
__private void uci_ece_free(struct uci_backend *backend);
static inline bool uci_validate_package(const char *str)
{
return uci_validate_str(str, false, true);
......