free(old_mods);
}
+struct devforge_config config = {.devforge_log = devforge_log};
+
int devforge_load_config(const char* path) {
if(server_root == NULL) {
server_root = devforge_strdup(PREFIX);
}
void* lib = dlopen(path, RTLD_LAZY);
if(lib != NULL) {
- int (*init_func)(void (*)(const char*, const char*)) = (int (*)(void (*)(const char*, const char*)))dlsym(lib, "mod_init");
+ int (*init_func)(struct devforge_config*) = (int (*)(struct devforge_config*))dlsym(lib, "mod_init");
int ret = 0;
- if(init_func != NULL){
- ret = init_func(devforge_log);
+ if(init_func != NULL) {
+ ret = init_func(&config);
}
- if(ret == 0){
+ if(ret == 0) {
devforge_add_mod(lib);
- }else{
+ } else {
char* str = devforge_strcat3("Could not load the module `", path, "`");
devforge_log(DF_ERROR, str);
free(str);
if(f != NULL) {
fprintf(f, "# Generated by DevForge " DEVFORGE_VERSION "\n");
fprintf(f, "ServerRoot %s\n", PREFIX);
+ fprintf(f, "LoadModule %s/http.so\n", MODULE_PREFIX);
fprintf(f, "LoadModule %s/subversion.so\n", MODULE_PREFIX);
fprintf(f, "LoadModule %s/syslog.so\n", MODULE_PREFIX);
fclose(f);
#define DF_MOD_LOG "LOG"
#define DF_MOD_VCS "VCS"
+#define DF_MOD_SRV "SRV"
+
+struct devforge_config {
+ void (*devforge_log)(const char*, const char*);
+};
#endif
.PHONY: all clean
-all: ./subversion.so ./syslog.so
+all: ./subversion.so ./syslog.so ./http.so
./%.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
+./%.o: ./%.c ../DevForge/devforge.h
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
clean:
--- /dev/null
+/* $Id$ */
+/* --- START LICENSE --- */
+/* -------------------------------------------------------------------------- */
+/* DevForge - Build Automation */
+/* -------------------------------------------------------------------------- */
+/* Copyright (c) 2024 Nishi. */
+/* Redistribution and use in source and binary forms, with or without modific */
+/* ation, are permitted provided that the following conditions are met: */
+/* 1. Redistributions of source code must retain the above copyright noti */
+/* ce, this list of conditions and the following disclaimer. */
+/* 2. Redistributions in binary form must reproduce the above copyright n */
+/* otice, this list of conditions and the following disclaimer in the documen */
+/* tation and/or other materials provided with the distribution. */
+/* 3. Neither the name of the copyright holder nor the names of its contr */
+/* ibutors may be used to endorse or promote products derived from this softw */
+/* are without specific prior written permission. */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS */
+/* " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, TH */
+/* E IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPO */
+/* SE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS */
+/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CON */
+/* SEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITU */
+/* TE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPT */
+/* ION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, S */
+/* TRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN AN */
+/* Y WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY */
+/* OF SUCH DAMAGE. */
+/* -------------------------------------------------------------------------- */
+/* --- END LICENSE --- */
+
+#include "../DevForge/devforge.h"
+#include "../DevForge/df_log.h"
+
+const char mod_type[] = DF_MOD_SRV;
+
+struct devforge_config* config;
+
+int mod_init(struct devforge_config* _config) {
+ config = _config;
+ config->devforge_log(DF_INFO, "HTTP Module init");
+ return 0;
+}
#include "../DevForge/df_log.h"
#include "../DevForge/df_util.h"
+#include <stdlib.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);
+struct devforge_config* config;
char* svn_exec = NULL;
-int mod_init(void (*_putlog)(const char* name, const char* log)) {
- putlog = _putlog;
- putlog(DF_INFO, "Subversion Module init");
+int mod_init(struct devforge_config* _config) {
+ config = _config;
+ config->devforge_log(DF_INFO, "Subversion Module init");
char* path = getenv("PATH");
- if(path == NULL){
- putlog(DF_ERROR, "PATH is not set!");
+ if(path == NULL) {
+ config->devforge_log(DF_ERROR, "PATH is not set!");
return 1;
- }else{
+ } else {
char* envpath = devforge_strdup(path);
int i;
int start = 0;
- for(i = 0;; i++){
- if(envpath[i] == 0 || envpath[i] == ':'){
+ for(i = 0;; i++) {
+ if(envpath[i] == 0 || envpath[i] == ':') {
char oldc = envpath[i];
envpath[i] = 0;
- if(strlen(envpath + start) > 0){
+ if(strlen(envpath + start) > 0) {
char* exec = devforge_strcat(envpath + start, "/svn");
- if(access(exec, X_OK) == 0){
+ if(access(exec, X_OK) == 0) {
char* found = devforge_strcat3("Found the Subversion executable `", exec, "`");
- putlog(DF_INFO, found);
+ config->devforge_log(DF_INFO, found);
free(found);
svn_exec = exec;
break;
if(oldc == 0) break;
}
}
- if(svn_exec == NULL){
- putlog(DF_ERROR, "Could not find the Subversion executable!");
+ if(svn_exec == NULL) {
+ config->devforge_log(DF_ERROR, "Could not find the Subversion executable!");
free(envpath);
return 1;
}
const char mod_type[] = DF_MOD_LOG;
-void (*putlog)(const char* name, const char* log);
+struct devforge_config* config;
-int mod_init(void (*_putlog)(const char* name, const char* log)) {
- putlog = _putlog;
- putlog(DF_INFO, "Syslog Module init");
+int mod_init(struct devforge_config* _config) {
+ config = _config;
+ config->devforge_log(DF_INFO, "Syslog Module init");
return 0;
}