From: nishi Date: Sun, 21 Apr 2024 23:35:33 +0000 (+0000) Subject: module info X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=0923760d8eff7c6131cedd6d0fd2d1b0052d8ccf;p=mandshurica.git module info git-svn-id: file:///raid/svn-main/nishi-mandshurica/trunk@59 f982e544-4a7d-3444-ad1a-fde59a2a69f1 --- diff --git a/Mandshurica/config.c b/Mandshurica/config.c index 743247a..740652b 100644 --- a/Mandshurica/config.c +++ b/Mandshurica/config.c @@ -46,6 +46,9 @@ #include #include +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); diff --git a/Mandshurica/main.c b/Mandshurica/main.c index 2747866..a9cbfd8 100644 --- a/Mandshurica/main.c +++ b/Mandshurica/main.c @@ -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");