From: Felix Fietkau Date: Fri, 20 Aug 2010 13:27:22 +0000 (+0200) Subject: split off and compile delta.c separately X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=commitdiff_plain;h=b03329065717161f591ac0e28030568e462ed31e split off and compile delta.c separately --- diff --git a/Makefile b/Makefile index 9f5b313..8062bd4 100644 --- a/Makefile +++ b/Makefile @@ -19,11 +19,11 @@ $(1).shared.o: $(2) $(1).static.o: $(2) endef -SOURCES = libuci.c file.c ucimap.c util.c +SOURCES = libuci.c file.c ucimap.c util.c delta.c all: uci libuci.$(SHLIB_EXT) uci-static ucimap-example -$(eval $(call add_dep,libuci,delta.c list.c uci.h uci_config.h uci_internal.h)) +$(eval $(call add_dep,libuci,list.c uci.h uci_config.h uci_internal.h)) $(eval $(call add_dep,ucimap,uci.h uci_config.h ucimap.h)) cli.o: cli.c uci.h uci_config.h diff --git a/delta.c b/delta.c index e0fa1b1..f697141 100644 --- a/delta.c +++ b/delta.c @@ -25,6 +25,11 @@ #include #include #include +#include +#include + +#include "uci.h" +#include "uci_internal.h" /* record a change that was done to a package */ void @@ -157,7 +162,7 @@ static void uci_parse_delta_line(struct uci_context *ctx, struct uci_package *p, switch(cmd) { case UCI_CMD_REORDER: - expand_ptr(ctx, &ptr, true); + uci_expand_ptr(ctx, &ptr, true); if (!ptr.s) UCI_THROW(ctx, UCI_ERR_NOTFOUND); UCI_INTERNAL(uci_reorder_section, ctx, ptr.s, strtoul(ptr.value, NULL, 10)); @@ -349,7 +354,7 @@ int uci_revert(struct uci_context *ctx, struct uci_ptr *ptr) char *option = NULL; UCI_HANDLE_ERR(ctx); - expand_ptr(ctx, ptr, false); + uci_expand_ptr(ctx, ptr, false); UCI_ASSERT(ctx, ptr->p->has_delta); /* diff --git a/libuci.c b/libuci.c index 1a09fc7..d669c79 100644 --- a/libuci.c +++ b/libuci.c @@ -26,9 +26,6 @@ #include #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", @@ -44,7 +41,9 @@ static void uci_unload_plugin(struct uci_context *ctx, struct uci_plugin *p); #include "uci_internal.h" #include "list.c" -#include "delta.c" + +__private const char *uci_confdir = UCI_CONFDIR; +__private const char *uci_savedir = UCI_SAVEDIR; /* exported functions */ struct uci_context *uci_alloc_context(void) diff --git a/list.c b/list.c index cee1063..0b3a3f2 100644 --- a/list.c +++ b/list.c @@ -36,7 +36,7 @@ static inline void uci_list_fixup(struct uci_list *ptr) * uci_alloc_generic allocates a new uci_element with payload * payload is appended to the struct to save memory and reduce fragmentation */ -static struct uci_element * +__private struct uci_element * uci_alloc_generic(struct uci_context *ctx, int type, const char *name, int size) { struct uci_element *e; @@ -62,7 +62,7 @@ done: return e; } -static void +__private void uci_free_element(struct uci_element *e) { if (e->name) @@ -417,8 +417,8 @@ notfound: return 0; } -static struct uci_element * -expand_ptr(struct uci_context *ctx, struct uci_ptr *ptr, bool complete) +__private struct uci_element * +uci_expand_ptr(struct uci_context *ctx, struct uci_ptr *ptr, bool complete) { UCI_ASSERT(ctx, ptr != NULL); @@ -469,7 +469,7 @@ int uci_rename(struct uci_context *ctx, struct uci_ptr *ptr) UCI_HANDLE_ERR(ctx); - e = expand_ptr(ctx, ptr, true); + e = uci_expand_ptr(ctx, ptr, true); p = ptr->p; UCI_ASSERT(ctx, ptr->s); @@ -530,7 +530,7 @@ int uci_delete(struct uci_context *ctx, struct uci_ptr *ptr) UCI_HANDLE_ERR(ctx); - e = expand_ptr(ctx, ptr, true); + e = uci_expand_ptr(ctx, ptr, true); p = ptr->p; UCI_ASSERT(ctx, ptr->s); @@ -557,7 +557,7 @@ int uci_add_list(struct uci_context *ctx, struct uci_ptr *ptr) UCI_HANDLE_ERR(ctx); - expand_ptr(ctx, ptr, false); + uci_expand_ptr(ctx, ptr, false); UCI_ASSERT(ctx, ptr->s); UCI_ASSERT(ctx, ptr->value); @@ -595,7 +595,7 @@ int uci_set(struct uci_context *ctx, struct uci_ptr *ptr) bool internal = ctx->internal; UCI_HANDLE_ERR(ctx); - expand_ptr(ctx, ptr, false); + uci_expand_ptr(ctx, ptr, false); UCI_ASSERT(ctx, ptr->value); UCI_ASSERT(ctx, ptr->s || (!ptr->option && ptr->section)); if (!ptr->option && ptr->value[0]) { diff --git a/uci_internal.h b/uci_internal.h index 728920d..32f2951 100644 --- a/uci_internal.h +++ b/uci_internal.h @@ -40,6 +40,9 @@ struct uci_parse_context int bufsz; }; +extern const char *uci_confdir; +extern const char *uci_savedir; + __plugin void *uci_malloc(struct uci_context *ctx, size_t size); __plugin void *uci_realloc(struct uci_context *ctx, void *ptr, size_t size); __plugin char *uci_strdup(struct uci_context *ctx, const char *str); @@ -59,6 +62,9 @@ __private void uci_cleanup(struct uci_context *ctx); __private struct uci_element *uci_lookup_list(struct uci_list *list, const char *name); __private void uci_fixup_section(struct uci_context *ctx, struct uci_section *s); __private void uci_free_package(struct uci_package **package); +__private struct uci_element *uci_alloc_generic(struct uci_context *ctx, int type, const char *name, int size); +__private void uci_free_element(struct uci_element *e); +__private struct uci_element *uci_expand_ptr(struct uci_context *ctx, struct uci_ptr *ptr, bool complete); __private int uci_load_delta(struct uci_context *ctx, struct uci_package *p, bool flush);