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

DevForge/config.c
DevForge/devforge.h
DevForge/df_config.h
DevForge/log.c
DevForge/util.c
Module/subversion.c
Module/syslog.c

index 5d843eb1199e2faa54d9be0431557e33a2b08eea..bf20ce714bf69cb936fd0db8b7c674ba62e93e57 100644 (file)
 #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;
@@ -56,11 +57,11 @@ void devforge_add_mod(void* 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;
        }
@@ -82,24 +83,24 @@ int devforge_load_config(const char* path) {
                                } 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);
                                                                }
@@ -137,6 +138,7 @@ int devforge_create_config(const char* path) {
        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");
index 72a91a54a3ba2f0d47b1d9546ccf90c22db317aa..8f7e7346b1505c501bd85380a20e31759dd4629a 100644 (file)
@@ -34,5 +34,6 @@
 #define DEVFORGE_VERSION "0.0"
 
 #define DF_MOD_LOG "LOG"
+#define DF_MOD_VCS "VCS"
 
 #endif
index aab73ee072f17de17f2cd3aa147064d922c2868c..c48ef9f1b22c2d0062b27c3d7c33eacbb31c31aa 100644 (file)
@@ -44,14 +44,14 @@ int devforge_create_config(const char* path);
 
 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
index 288d03b6d854251bd785772fb858866ce91266d4..62a739ee218019ca6afd975d4f610466317f08d3 100644 (file)
 
 #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;
@@ -56,7 +56,7 @@ void devforge_log(const char* name, const char* log) {
                }
        }
 
-       if(fallback){
+       if(fallback) {
                char timestr[256];
                time_t t = time(NULL);
                struct tm* tm = localtime(&t);
index 9d1572340066786dca4211a276e45c701fe2a92b..7bafa91e7d6c074b854ed1132525068b9807ed30 100644 (file)
@@ -22,7 +22,7 @@ char* devforge_strcat3(const char* str1, const char* str2, const char* str3) {
        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;
index 98aac2a925cd96e69c626159c93feb2c30e44f05..215a8e06dc460484fdcf9c7e6fafe52d020c9b53 100644 (file)
 /* 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");
+}
index c013f36e8de2ded6b3e9618a5e2befe28cb1408c..0e0c189c45530a3fa728e2ca623aa84490b73d73 100644 (file)
 #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);
        }
 }