#include <stdlib.h>
#include <string.h>
-void devforge_add_mod(void* lib){
+void devforge_add_mod(void* lib) {
void** old_mods = loaded_mods;
int i;
- for(i = 0; old_mods[i] != NULL; i++);
+ for(i = 0; old_mods[i] != NULL; i++)
+ ;
loaded_mods = malloc(sizeof(*loaded_mods) * (i + 2));
- for(i = 0; old_mods[i] != NULL; i++){
+ for(i = 0; old_mods[i] != NULL; i++) {
loaded_mods[i] = old_mods[i];
}
loaded_mods[i] = lib;
}
int devforge_load_config(const char* path) {
- if(server_root == NULL){
+ if(server_root == NULL) {
server_root = devforge_strdup(PREFIX);
}
- if(loaded_mods == NULL){
+ if(loaded_mods == NULL) {
loaded_mods = malloc(sizeof(*loaded_mods));
loaded_mods[0] = NULL;
}
} else if(str[0] == '#') {
} else {
int i;
- for(i = 0; str[i] != 0; i++){
- if(str[i] == ' ' || str[i] == '\t'){
+ for(i = 0; str[i] != 0; i++) {
+ if(str[i] == ' ' || str[i] == '\t') {
for(; str[i] != 0 && (str[i] == ' ' || str[i] == '\t'); i++) str[i] = 0;
char* key = str;
char* value = str + i;
- if(strcmp(key, "ServerRoot") == 0){
+ if(strcmp(key, "ServerRoot") == 0) {
free(server_root);
server_root = devforge_strdup(value);
- }else if(strcmp(key, "LoadModule") == 0){
+ } else if(strcmp(key, "LoadModule") == 0) {
char* path;
- if(value[0] == '/'){
+ if(value[0] == '/') {
path = devforge_strdup(value);
- }else{
+ } else {
path = devforge_strcat3(server_root, "/", value);
}
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(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);
}
if(f != NULL) {
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/syslog.so\n", MODULE_PREFIX);
fclose(f);
devforge_log(DF_LOG, "Created the config");
#define DEVFORGE_VERSION "0.0"
#define DF_MOD_LOG "LOG"
+#define DF_MOD_VCS "VCS"
#endif
DF_CONFIG_PREFIX char* server_root
#ifdef DF_CONFIG_SRC
- = NULL
+ = NULL
#endif
-;
+ ;
DF_CONFIG_PREFIX void** loaded_mods
#ifdef DF_CONFIG_SRC
- = NULL
+ = NULL
#endif
-;
+ ;
#endif
#include "df_log.h"
-#include "df_config.h"
#include "devforge.h"
+#include "df_config.h"
-#include <stdio.h>
-#include <time.h>
-#include <stdbool.h>
#include <dlfcn.h>
+#include <stdbool.h>
+#include <stdio.h>
#include <string.h>
+#include <time.h>
void devforge_log(const char* name, const char* log) {
bool fallback = true;
- if(loaded_mods != NULL){
+ if(loaded_mods != NULL) {
int i;
- for(i = 0; loaded_mods[i] != NULL; i++){
+ for(i = 0; loaded_mods[i] != NULL; i++) {
const char* type = (const char*)dlsym(loaded_mods[i], "mod_type");
- if(strcmp(type, DF_MOD_LOG) == 0){
- void(*mod_log)(const char*, const char*) = (void(*)(const char*, const char*))dlsym(loaded_mods[i], "mod_log");
- if(mod_log != NULL){
+ if(strcmp(type, DF_MOD_LOG) == 0) {
+ void (*mod_log)(const char*, const char*) = (void (*)(const char*, const char*))dlsym(loaded_mods[i], "mod_log");
+ if(mod_log != NULL) {
fallback = false;
mod_log(name, log);
break;
}
}
- if(fallback){
+ if(fallback) {
char timestr[256];
time_t t = time(NULL);
struct tm* tm = localtime(&t);
return r;
}
-char* devforge_strdup(const char* str){
+char* devforge_strdup(const char* str) {
char* r = malloc(strlen(str) + 1);
memcpy(r, str, strlen(str));
r[strlen(str)] = 0;
/* OF SUCH DAMAGE. */
/* -------------------------------------------------------------------------- */
/* --- END LICENSE --- */
+
+#include "../DevForge/devforge.h"
+#include "../DevForge/df_log.h"
+
+#include <string.h>
+#include <syslog.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)) {
+ putlog = _putlog;
+ putlog(DF_INFO, "Subversion Module init");
+}
#include "../DevForge/devforge.h"
#include "../DevForge/df_log.h"
-#include <syslog.h>
#include <string.h>
+#include <syslog.h>
const char mod_type[] = DF_MOD_LOG;
-void(*putlog)(const char* name, const char* log);
+void (*putlog)(const char* name, const char* log);
-void mod_init(void(*_putlog)(const char* name, const char* log)){
+void mod_init(void (*_putlog)(const char* name, const char* log)) {
putlog = _putlog;
putlog(DF_INFO, "Syslog Module init");
}
-void mod_log(const char* name, const char* log){
- if(strcmp(name, DF_INFO) == 0){
+void mod_log(const char* name, const char* log) {
+ if(strcmp(name, DF_INFO) == 0) {
syslog(LOG_INFO, log);
- }else if(strcmp(name, DF_LOG) == 0){
+ } else if(strcmp(name, DF_LOG) == 0) {
syslog(LOG_NOTICE, log);
- }else if(strcmp(name, DF_ERROR) == 0){
+ } else if(strcmp(name, DF_ERROR) == 0) {
syslog(LOG_ERR, log);
- }else if(strcmp(name, DF_WARN) == 0){
+ } else if(strcmp(name, DF_WARN) == 0) {
syslog(LOG_WARNING, log);
}
}