]> Nishi Git Mirror - mandshurica.git/commitdiff
works
authornishi <nishi@f982e544-4a7d-3444-ad1a-fde59a2a69f1>
Sat, 13 Apr 2024 02:32:54 +0000 (02:32 +0000)
committernishi <nishi@f982e544-4a7d-3444-ad1a-fde59a2a69f1>
Sat, 13 Apr 2024 02:32:54 +0000 (02:32 +0000)
git-svn-id: file:///raid/svn-main/nishi-mandshurica/trunk@10 f982e544-4a7d-3444-ad1a-fde59a2a69f1

DevForge/config.c
Module/Makefile
Module/subversion.c
Module/syslog.c

index bf20ce714bf69cb936fd0db8b7c674ba62e93e57..bc3eb05bb91b4727e1fdc16c793af933006a0437 100644 (file)
@@ -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");
index 9e264a399b255fab12a3b72802a92fdd79dada42..9c26baa5961ffe89f4a9fdb827d293c20cdb9ade 100644 (file)
@@ -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 $@ $<
 
index 215a8e06dc460484fdcf9c7e6fafe52d020c9b53..e402616f264399c9394103a0fb7c658bc5a52433 100644 (file)
 
 #include "../DevForge/devforge.h"
 #include "../DevForge/df_log.h"
+#include "../DevForge/df_util.h"
 
 #include <string.h>
 #include <syslog.h>
+#include <stdlib.h>
+#include <unistd.h>
 
 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;
 }
index 0e0c189c45530a3fa728e2ca623aa84490b73d73..535c2da35a9a52bcaaa9fb47458ce3dc2c5a9ad0 100644 (file)
@@ -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) {