From: nishi Date: Sat, 13 Apr 2024 02:32:54 +0000 (+0000) Subject: works X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=681d3c0621cf040b1ad35f2544999feb7d065d5d;p=mandshurica.git works git-svn-id: file:///raid/svn-main/nishi-mandshurica/trunk@10 f982e544-4a7d-3444-ad1a-fde59a2a69f1 --- diff --git a/DevForge/config.c b/DevForge/config.c index bf20ce7..bc3eb05 100644 --- a/DevForge/config.c +++ b/DevForge/config.c @@ -100,9 +100,19 @@ int devforge_load_config(const char* path) { } void* lib = dlopen(path, RTLD_LAZY); if(lib != NULL) { - void (*init_func)(void (*)(const char*, const char*)) = (void (*)(void (*)(const char*, const char*)))dlsym(lib, "mod_init"); - if(init_func != NULL) init_func(devforge_log); - devforge_add_mod(lib); + int (*init_func)(void (*)(const char*, const char*)) = (int (*)(void (*)(const char*, const char*)))dlsym(lib, "mod_init"); + int ret = 0; + if(init_func != NULL){ + ret = init_func(devforge_log); + } + if(ret == 0){ + devforge_add_mod(lib); + }else{ + char* str = devforge_strcat3("Could not load the module `", path, "`"); + devforge_log(DF_ERROR, str); + free(str); + dlclose(lib); + } } free(path); } @@ -139,6 +149,8 @@ int devforge_create_config(const char* path) { fprintf(f, "# Generated by DevForge " DEVFORGE_VERSION "\n"); fprintf(f, "ServerRoot %s\n", PREFIX); fprintf(f, "LoadModule %s/subversion.so\n", MODULE_PREFIX); + fprintf(f, "LoadModule %s/git.so\n", MODULE_PREFIX); + fprintf(f, "LoadModule %s/cvs.so\n", MODULE_PREFIX); fprintf(f, "LoadModule %s/syslog.so\n", MODULE_PREFIX); fclose(f); devforge_log(DF_LOG, "Created the config"); diff --git a/Module/Makefile b/Module/Makefile index 9e264a3..9c26baa 100644 --- a/Module/Makefile +++ b/Module/Makefile @@ -7,10 +7,13 @@ EXTRA_LIBS = .PHONY: all clean all: ./subversion.so ./syslog.so - -./%.so: ./%.o + +./%.so: ./%.o ./util.o $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS) +./util.o: ../DevForge/util.c + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< + ./%.o: ./%.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< diff --git a/Module/subversion.c b/Module/subversion.c index 215a8e0..e402616 100644 --- a/Module/subversion.c +++ b/Module/subversion.c @@ -30,15 +30,57 @@ #include "../DevForge/devforge.h" #include "../DevForge/df_log.h" +#include "../DevForge/df_util.h" #include #include +#include +#include const char mod_type[] = DF_MOD_VCS; void (*putlog)(const char* name, const char* log); -void mod_init(void (*_putlog)(const char* name, const char* log)) { +char* svn_exec = NULL; + +int mod_init(void (*_putlog)(const char* name, const char* log)) { putlog = _putlog; putlog(DF_INFO, "Subversion Module init"); + char* path = getenv("PATH"); + if(path == NULL){ + putlog(DF_ERROR, "PATH is not set!"); + return 1; + }else{ + char* envpath = devforge_strdup(path); + int i; + int start = 0; + for(i = 0;; i++){ + if(envpath[i] == 0 || envpath[i] == ':'){ + char oldc = envpath[i]; + envpath[i] = 0; + + if(strlen(envpath + start) > 0){ + char* exec = devforge_strcat(envpath + start, "/svn"); + if(access(exec, X_OK) == 0){ + char* found = devforge_strcat3("Found Subversion executable `", exec, "`"); + putlog(DF_INFO, found); + free(found); + svn_exec = exec; + break; + } + free(exec); + } + + start = i + 1; + if(oldc == 0) break; + } + } + if(svn_exec == NULL){ + putlog(DF_ERROR, "Could not find the Subversion executable!"); + free(envpath); + return 1; + } + free(envpath); + } + return 0; } diff --git a/Module/syslog.c b/Module/syslog.c index 0e0c189..535c2da 100644 --- a/Module/syslog.c +++ b/Module/syslog.c @@ -38,9 +38,10 @@ const char mod_type[] = DF_MOD_LOG; void (*putlog)(const char* name, const char* log); -void mod_init(void (*_putlog)(const char* name, const char* log)) { +int mod_init(void (*_putlog)(const char* name, const char* log)) { putlog = _putlog; putlog(DF_INFO, "Syslog Module init"); + return 0; } void mod_log(const char* name, const char* log) {