From a50ed49eebd2f89d8cac90fa3815d0c22ec27dd7 Mon Sep 17 00:00:00 2001 From: nishi Date: Sat, 11 May 2024 00:58:24 +0000 Subject: [PATCH] adding tool for html git-svn-id: file:///raid/svn-main/nishi-mandshurica/trunk@74 f982e544-4a7d-3444-ad1a-fde59a2a69f1 --- GNUmakefile | 8 ++++++-- Mandshurica/config.c | 4 ++++ Mandshurica/main.c | 2 +- Module/{Makefile => GNUmakefile} | 0 Tool/GNUmakefile | 24 ++++++++++++++++++++++++ Tool/html-manage.c | 12 ++++++++++++ Webroot/{Makefile => GNUmakefile} | 0 7 files changed, 47 insertions(+), 3 deletions(-) rename Module/{Makefile => GNUmakefile} (100%) create mode 100644 Tool/GNUmakefile create mode 100644 Tool/html-manage.c rename Webroot/{Makefile => GNUmakefile} (100%) diff --git a/GNUmakefile b/GNUmakefile index fe19645..84ce8d2 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -10,9 +10,9 @@ CFLAGS := -g -std=c99 -DPREFIX=\\\"$(PREFIX)\\\" -DWEBROOT_PREFIX=\\\"$(WEBROOT_ LDFLAGS := LIBS := -.PHONY: all clean format replace ./Mandshurica ./Module +.PHONY: all clean format replace ./Mandshurica ./Module ./Tool -all: ./Mandshurica ./Module +all: ./Mandshurica ./Module ./Tool ./Mandshurica:: $(MAKE) -C $@ CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" @@ -20,6 +20,9 @@ all: ./Mandshurica ./Module ./Module:: $(MAKE) -C $@ CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" +./Tool:: + $(MAKE) -C $@ CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" + format: clang-format -i $(wildcard Module/*.c Module/*.h Mandshurica/*.c Mandshurica/*.h) @@ -35,3 +38,4 @@ replace: clean: $(MAKE) -C ./Mandshurica clean $(MAKE) -C ./Module clean + $(MAKE) -C ./Tool clean diff --git a/Mandshurica/config.c b/Mandshurica/config.c index 7c500e6..00535e4 100644 --- a/Mandshurica/config.c +++ b/Mandshurica/config.c @@ -49,6 +49,8 @@ int nloaded_mods = 0; int nerror_mods = 0; +char* loaded_config = NULL; + void mandshurica_add_mod(void* lib) { struct mandshurica_mod** old_mods = loaded_mods; int i; @@ -95,6 +97,8 @@ char* mandshurica_get_param(const char* param) { struct mandshurica_config config = {.mandshurica_log = mandshurica_log, .mandshurica_get_param = mandshurica_get_param, .mandshurica_parse_template = mandshurica_parse_template, .mandshurica_load = mandshurica_load, .mandshurica_sha512 = mandshurica_sha512}; int mandshurica_load_config(const char* path) { + if(loaded_config != NULL) free(loaded_config); + loaded_config = mandshurica_strdup(path); if(server_root == NULL) { server_root = mandshurica_strdup(PREFIX); } diff --git a/Mandshurica/main.c b/Mandshurica/main.c index 2b844b4..b0c113b 100644 --- a/Mandshurica/main.c +++ b/Mandshurica/main.c @@ -59,7 +59,7 @@ int main(int argc, char** argv) { if(argv[i] == NULL) { fprintf(stderr, "%s: %s: needs argument\n", argv[0], argv[i - 1]); return 1; - } else { + } else if(!loaded_config) { int ret = mandshurica_load_config(argv[i]); if(ret != 0) return ret; loaded_config = true; diff --git a/Module/Makefile b/Module/GNUmakefile similarity index 100% rename from Module/Makefile rename to Module/GNUmakefile diff --git a/Tool/GNUmakefile b/Tool/GNUmakefile new file mode 100644 index 0000000..da09fae --- /dev/null +++ b/Tool/GNUmakefile @@ -0,0 +1,24 @@ +# $Id$ + +EXTRA_CFLAGS = +EXTRA_LDFLAGS = +EXTRA_LIBS = + +.PHONY: all clean + +all: ./html-manage + +./html-manage: ./html-manage.o ./util.o ./db.o + $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS) + +./html-manage.o: ./html-manage.c + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< + +./util.o: ../Mandshurica/util.c + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< + +./db.o: ../Mandshurica/db.c + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< + +clean: + rm -f ./html-manage *.o diff --git a/Tool/html-manage.c b/Tool/html-manage.c new file mode 100644 index 0000000..fae0cbc --- /dev/null +++ b/Tool/html-manage.c @@ -0,0 +1,12 @@ +/* $Id$ */ +/* --- START LICENSE --- */ +/* --- END LICENSE --- */ + +#include + +int main(int argc, char** argv){ + if(argc < 2){ + printf("invalid usage\n"); + } + printf("%s\n", argv[1]); +} diff --git a/Webroot/Makefile b/Webroot/GNUmakefile similarity index 100% rename from Webroot/Makefile rename to Webroot/GNUmakefile -- 2.43.0