}
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);
}
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");
.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 $@ $<
#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;
}
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) {