]> Nishi Git Mirror - mandshurica.git/commitdiff
module info
authornishi <nishi@f982e544-4a7d-3444-ad1a-fde59a2a69f1>
Sun, 21 Apr 2024 23:35:33 +0000 (23:35 +0000)
committernishi <nishi@f982e544-4a7d-3444-ad1a-fde59a2a69f1>
Sun, 21 Apr 2024 23:35:33 +0000 (23:35 +0000)
git-svn-id: file:///raid/svn-main/nishi-mandshurica/trunk@59 f982e544-4a7d-3444-ad1a-fde59a2a69f1

Mandshurica/config.c
Mandshurica/main.c

index 743247add46a9e7cc23ed4074dfb4d4a5c4c9b40..740652b4b5c259d04f5fe6b0f5515085b156ed46 100644 (file)
@@ -46,6 +46,9 @@
 #include <stdlib.h>
 #include <string.h>
 
+int nloaded_mods = 0;
+int nerror_mods = 0;
+
 void mandshurica_add_mod(void* lib) {
        struct mandshurica_mod** old_mods = loaded_mods;
        int i;
@@ -158,8 +161,10 @@ int mandshurica_load_config(const char* path) {
                                                                                ret = init_func(&config);
                                                                        }
                                                                        if(ret == 0) {
+                                                                               nloaded_mods++;
                                                                                mandshurica_add_mod(lib);
                                                                        } else {
+                                                                               nerror_mods++;
                                                                                char* str = mandshurica_strcat3("Could not load the module `", path, "`");
                                                                                mandshurica_log(MS_ERROR, str);
                                                                                free(str);
index 27478668e1081fd30029d46fb63b3e0472276acb..a9cbfd8842e9c8b2d42db234141f10f38711c23d 100644 (file)
@@ -43,6 +43,9 @@
 
 extern struct mandshurica_config config;
 
+extern int nloaded_mods;
+extern int nerror_mods;
+
 int main(int argc, char** argv) {
        int i;
        bool loaded_config = false;
@@ -77,6 +80,10 @@ int main(int argc, char** argv) {
                int ret = mandshurica_load_config(PREFIX "/etc/mandshurica.conf");
                if(ret != 0) return ret;
        }
+       char* log = malloc(1024);
+       sprintf(log, "Loaded %d module(s) successfully, failed to load %d module(s)", nloaded_mods, nerror_mods);
+       mandshurica_log(MS_INFO, log);
+       free(log);
        mandshurica_log(MS_INFO, "Hello World, initialization done");
        if(loaded_mods != NULL) {
                mandshurica_log(MS_INFO, "Starting server");