$(1).static.o: $(2)
endef
+SOURCES = libuci.c file.c ucimap.c util.c
all: uci libuci.$(SHLIB_EXT) uci-static ucimap-example
-$(eval $(call add_dep,libuci,history.c list.c util.c uci.h uci_config.h uci_internal.h))
+$(eval $(call add_dep,libuci,history.c 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
ucimap.c: ucimap.h uci.h
-libuci.a: libuci.static.o ucimap.static.o file.static.o
+libuci.a: $(patsubst %.c,%.static.o, $(SOURCES))
rm -f $@
$(AR) rc $@ $^
$(RANLIB) $@
-libuci.$(SHLIB_EXT): libuci.shared.o file.shared.o ucimap.shared.o
+libuci.$(SHLIB_EXT): $(patsubst %.c,%.shared.o, $(SOURCES))
$(LINK) $(SHLIB_FLAGS) -o $(SHLIB_FILE) $^ $(LIBS)
ln -sf $(SHLIB_FILE) $@
static void uci_unload_plugin(struct uci_context *ctx, struct uci_plugin *p);
#include "uci_internal.h"
-#include "util.c"
#include "list.c"
#include "history.c"
return o;
}
+/* Based on an efficient hash function published by D. J. Bernstein */
+static unsigned int djbhash(unsigned int hash, char *str)
+{
+ int len = strlen(str);
+ int i;
+
+ /* initial value */
+ if (hash == ~0)
+ hash = 5381;
+
+ for(i = 0; i < len; i++) {
+ hash = ((hash << 5) + hash) + str[i];
+ }
+ return (hash & 0x7FFFFFFF);
+}
+
/* fix up an unnamed section, e.g. after adding options to it */
__private void uci_fixup_section(struct uci_context *ctx, struct uci_section *s)
{
* This file contains misc utility functions and wrappers to standard
* functions, which throw exceptions upon failure.
*/
+#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <ctype.h>
#include <fcntl.h>
#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "uci.h"
+#include "uci_internal.h"
__plugin void *uci_malloc(struct uci_context *ctx, size_t size)
{
return ptr;
}
-/* Based on an efficient hash function published by D. J. Bernstein */
-static unsigned int djbhash(unsigned int hash, char *str)
-{
- int len = strlen(str);
- int i;
-
- /* initial value */
- if (hash == ~0)
- hash = 5381;
-
- for(i = 0; i < len; i++) {
- hash = ((hash << 5) + hash) + str[i];
- }
- return (hash & 0x7FFFFFFF);
-}
-
/*
* validate strings for names and types, reject special characters
* for names, only alphanum and _ is allowed (shell compatibility)