From 2e6d469170e9fe20c47b866e4c6d5b2832e40114 Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Sun, 7 Jan 2018 23:59:42 +0100 Subject: [PATCH] more cleanups --- lib/uci/Makefile | 91 -- lib/uci/Makefile.inc | 31 - lib/uci/cli.c | 698 ----------- lib/uci/file.c | 581 --------- lib/uci/history.c | 483 -------- lib/uci/libuci.c | 391 ------- lib/uci/list.c | 719 ------------ lib/uci/list.h | 601 ---------- lib/uci/lua/Makefile | 44 - lib/uci/lua/uci.c | 928 --------------- lib/uci/sh/uci.sh | 178 --- lib/uci/test/Makefile | 2 - lib/uci/test/README | 34 - lib/uci/test/config/network | 25 - lib/uci/test/references/add_section.result | 1 - lib/uci/test/references/export.data | 6 - lib/uci/test/references/export.result | 7 - lib/uci/test/references/get.data | 2 - lib/uci/test/references/get_parsing.data | 5 - lib/uci/test/references/import.data | 7 - lib/uci/test/references/import.result | 6 - .../test/references/set_existing_option.data | 2 - .../references/set_existing_option.result | 1 - .../test/references/set_named_section.result | 1 - .../references/set_nonexisting_option.data | 1 - .../references/set_nonexisting_option.result | 1 - lib/uci/test/references/set_parsing.data | 2 - lib/uci/test/references/show_parsing.data | 2 - .../test/references/ucimap_example_1.result | 15 - .../test/references/ucimap_example_2.result | 14 - lib/uci/test/shunit2/shunit2 | 1040 ----------------- lib/uci/test/tests.d/000_import | 5 - lib/uci/test/tests.d/010_export | 6 - lib/uci/test/tests.d/020_get | 39 - lib/uci/test/tests.d/030_set | 30 - lib/uci/test/tests.d/040_add | 8 - lib/uci/test/tests.d/050_show | 11 - lib/uci/test/tests.d/060-ucimap_example | 9 - lib/uci/test/tests.sh | 78 -- lib/uci/uci.h | 631 ---------- lib/uci/uci_internal.h | 182 --- lib/uci/ucimap-example.c | 318 ----- lib/uci/ucimap.c | 926 --------------- lib/uci/ucimap.h | 324 ----- lib/uci/util.c | 489 -------- 45 files changed, 8975 deletions(-) delete mode 100644 lib/uci/Makefile delete mode 100644 lib/uci/Makefile.inc delete mode 100644 lib/uci/cli.c delete mode 100644 lib/uci/file.c delete mode 100644 lib/uci/history.c delete mode 100644 lib/uci/libuci.c delete mode 100644 lib/uci/list.c delete mode 100644 lib/uci/list.h delete mode 100644 lib/uci/lua/Makefile delete mode 100644 lib/uci/lua/uci.c delete mode 100755 lib/uci/sh/uci.sh delete mode 100644 lib/uci/test/Makefile delete mode 100644 lib/uci/test/README delete mode 100644 lib/uci/test/config/network delete mode 100644 lib/uci/test/references/add_section.result delete mode 100644 lib/uci/test/references/export.data delete mode 100644 lib/uci/test/references/export.result delete mode 100644 lib/uci/test/references/get.data delete mode 100644 lib/uci/test/references/get_parsing.data delete mode 100644 lib/uci/test/references/import.data delete mode 100644 lib/uci/test/references/import.result delete mode 100644 lib/uci/test/references/set_existing_option.data delete mode 100644 lib/uci/test/references/set_existing_option.result delete mode 100644 lib/uci/test/references/set_named_section.result delete mode 100644 lib/uci/test/references/set_nonexisting_option.data delete mode 100644 lib/uci/test/references/set_nonexisting_option.result delete mode 100644 lib/uci/test/references/set_parsing.data delete mode 100644 lib/uci/test/references/show_parsing.data delete mode 100644 lib/uci/test/references/ucimap_example_1.result delete mode 100644 lib/uci/test/references/ucimap_example_2.result delete mode 100644 lib/uci/test/shunit2/shunit2 delete mode 100644 lib/uci/test/tests.d/000_import delete mode 100644 lib/uci/test/tests.d/010_export delete mode 100644 lib/uci/test/tests.d/020_get delete mode 100644 lib/uci/test/tests.d/030_set delete mode 100644 lib/uci/test/tests.d/040_add delete mode 100644 lib/uci/test/tests.d/050_show delete mode 100644 lib/uci/test/tests.d/060-ucimap_example delete mode 100644 lib/uci/test/tests.sh delete mode 100644 lib/uci/uci.h delete mode 100644 lib/uci/uci_internal.h delete mode 100644 lib/uci/ucimap-example.c delete mode 100644 lib/uci/ucimap.c delete mode 100644 lib/uci/ucimap.h delete mode 100644 lib/uci/util.c diff --git a/lib/uci/Makefile b/lib/uci/Makefile deleted file mode 100644 index 11bb472..0000000 --- a/lib/uci/Makefile +++ /dev/null @@ -1,91 +0,0 @@ -VERSION=0.8 - -# optional features -PLUGIN_SUPPORT=1 -DEBUG=0 -DEBUG_TYPECAST=0 - -include Makefile.inc - -LIBS=-lc -ldl -SHLIB_FILE=libuci.$(SHLIB_EXT).$(VERSION) - -define add_feature - @echo "$(if $(findstring 1,$($(1))),#define UCI_$(1) 1,#undef UCI_$(1))" >> $@.tmp -endef - -LIBUCI_DEPS=file.c history.c list.c util.c uci.h uci_config.h uci_internal.h - -all: uci libuci.$(SHLIB_EXT) uci-static ucimap-example - -cli.o: cli.c uci.h uci_config.h -ucimap.o: ucimap.c uci.h uci_config.h ucimap.h - -uci_config.h: FORCE - @rm -f "$@.tmp" - @echo "#define UCI_PREFIX \"$(prefix)\"" > "$@.tmp" - $(call add_feature,PLUGIN_SUPPORT) - $(call add_feature,DEBUG) - $(call add_feature,DEBUG_TYPECAST) - @if [ \! -f "$@" ] || ! cmp "$@.tmp" "$@" >/dev/null; then \ - mv "$@.tmp" "$@"; \ - else \ - rm -f "$@.tmp"; \ - fi - -%.o: %.c - $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $< - -%-shared.o: %.c - $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(FPIC) $< - -%-static.o: %.c - $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $< - -uci: cli.o libuci.$(SHLIB_EXT) - $(CC) -o $@ $< -L. -luci $(LIBS) - -uci-static: cli.o libuci.a - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) - -libuci-static.o: libuci.c $(LIBUCI_DEPS) -libuci-shared.o: libuci.c $(LIBUCI_DEPS) -ucimap-static.o: ucimap.c $(LIBUCI_DEPS) ucimap.h -ucimap-shared.o: ucimap.c $(LIBUCI_DEPS) ucimap.h - -libuci.a: libuci-static.o ucimap-static.o - rm -f $@ - $(AR) rc $@ $^ - $(RANLIB) $@ - -libuci.$(SHLIB_EXT): libuci-shared.o ucimap-shared.o - $(LINK) $(SHLIB_FLAGS) -o $(SHLIB_FILE) $^ $(LIBS) - ln -sf $(SHLIB_FILE) $@ - -ucimap-example.o: ucimap-example.c list.h -ucimap-example: ucimap-example.o libuci.a - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) - -clean: - rm -f uci uci-static *.[oa] *.so* *.dylib* uci_config.h ucimap-example - -install: install-bin install-dev - -install-dev: all - $(MKDIR) -p $(DESTDIR)$(prefix)/lib - $(MKDIR) -p $(DESTDIR)$(prefix)/include - $(INSTALL) -m0644 libuci.a $(DESTDIR)$(prefix)/lib/ - $(INSTALL) -m0644 uci_config.h uci.h ucimap.h $(DESTDIR)$(prefix)/include/ - -install-bin: all - $(MKDIR) -p $(DESTDIR)$(prefix)/lib - $(INSTALL) -m0755 $(SHLIB_FILE) $(DESTDIR)$(prefix)/lib/ - ln -sf $(SHLIB_FILE) $(DESTDIR)$(prefix)/lib/libuci.$(SHLIB_EXT) - $(MKDIR) -p $(DESTDIR)$(prefix)/bin - $(INSTALL) -m0755 uci $(DESTDIR)$(prefix)/bin/ - -test: all ucimap-example - make -C test - -FORCE: ; -.PHONY: FORCE diff --git a/lib/uci/Makefile.inc b/lib/uci/Makefile.inc deleted file mode 100644 index ab5eb25..0000000 --- a/lib/uci/Makefile.inc +++ /dev/null @@ -1,31 +0,0 @@ -prefix=/usr -DESTDIR= - -COPTS=-O2 -WOPTS=-pedantic -Werror -Wall -FPIC=-fPIC -CFLAGS=$(COPTS) $(WOPTS) -std=gnu99 -CPPFLAGS=-I. - -AR=ar -LD=ld -CC=gcc -RANLIB=ranlib -INSTALL=install -MKDIR=mkdir - -ifeq ($(DEBUG),1) - COPTS = -O0 - CFLAGS += -g3 -endif -OS=$(shell uname) -ifeq ($(OS),Darwin) - LINK=$(LD) - SHLIB_EXT=dylib - SHLIB_FLAGS=-dylib -else - LINK=$(CC) - SHLIB_EXT=so - SHLIB_FLAGS=-shared -Wl,-soname,$(SHLIB_FILE) -endif - diff --git a/lib/uci/cli.c b/lib/uci/cli.c deleted file mode 100644 index 7bef7a9..0000000 --- a/lib/uci/cli.c +++ /dev/null @@ -1,698 +0,0 @@ -/* - * cli - Command Line Interface for the Unified Configuration Interface - * Copyright (C) 2008 Felix Fietkau - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#include -#include -#include -#include -#include "uci.h" - -#define MAX_ARGS 4 /* max command line arguments for batch mode */ - -static const char *delimiter = " "; -static const char *appname; -static enum { - CLI_FLAG_MERGE = (1 << 0), - CLI_FLAG_QUIET = (1 << 1), - CLI_FLAG_NOCOMMIT = (1 << 2), - CLI_FLAG_BATCH = (1 << 3), - CLI_FLAG_SHOW_EXT = (1 << 4), - CLI_FLAG_NOPLUGINS= (1 << 5), -} flags; - -static FILE *input; - -static struct uci_context *ctx; -enum { - /* section cmds */ - CMD_GET, - CMD_SET, - CMD_ADD_LIST, - CMD_DEL, - CMD_RENAME, - CMD_REVERT, - CMD_REORDER, - /* package cmds */ - CMD_SHOW, - CMD_CHANGES, - CMD_EXPORT, - CMD_COMMIT, - /* other cmds */ - CMD_ADD, - CMD_IMPORT, - CMD_HELP, -}; - -struct uci_type_list { - unsigned int idx; - const char *name; - struct uci_type_list *next; -}; - -static struct uci_type_list *type_list = NULL; -static char *typestr = NULL; -static const char *cur_section_ref = NULL; - -static int uci_cmd(int argc, char **argv); - -static void -uci_reset_typelist(void) -{ - struct uci_type_list *type; - while (type_list != NULL) { - type = type_list; - type_list = type_list->next; - free(type); - } - if (typestr) { - free(typestr); - typestr = NULL; - } - cur_section_ref = NULL; -} - -static char * -uci_lookup_section_ref(struct uci_section *s) -{ - struct uci_type_list *ti = type_list; - int maxlen; - - if (!s->anonymous || !(flags & CLI_FLAG_SHOW_EXT)) - return s->e.name; - - /* look up in section type list */ - while (ti) { - if (strcmp(ti->name, s->type) == 0) - break; - ti = ti->next; - } - if (!ti) { - ti = malloc(sizeof(struct uci_type_list)); - memset(ti, 0, sizeof(struct uci_type_list)); - ti->next = type_list; - type_list = ti; - ti->name = s->type; - } - - maxlen = strlen(s->type) + 1 + 2 + 10; - if (!typestr) { - typestr = malloc(maxlen); - } else { - typestr = realloc(typestr, maxlen); - } - sprintf(typestr, "@%s[%d]", ti->name, ti->idx); - ti->idx++; - return typestr; -} - -static void uci_usage(void) -{ - fprintf(stderr, - "Usage: %s [] []\n\n" - "Commands:\n" - "\tbatch\n" - "\texport []\n" - "\timport []\n" - "\tchanges []\n" - "\tcommit []\n" - "\tadd \n" - "\tadd_list .
.