--- lbbs/src/main.c 2025/05/15 05:14:57 1.32 +++ lbbs/src/main.c 2025/05/18 07:51:17 1.38 @@ -21,6 +21,7 @@ #include "log.h" #include "io.h" #include "menu.h" +#include "file_loader.h" #include #include #include @@ -144,6 +145,12 @@ int main(int argc, char *argv[]) return -2; } + // Load BBS cmd + if (load_cmd() < 0) + { + return -3; + } + // Load menus p_bbs_menu = calloc(1, sizeof(MENU_SET)); if (p_bbs_menu == NULL) @@ -154,20 +161,35 @@ int main(int argc, char *argv[]) if (load_menu(p_bbs_menu, CONF_MENU) < 0) { unload_menu(p_bbs_menu); + free(p_bbs_menu); return -3; } + // Load data files + if (file_loader_init() < 0) + { + log_error("file_loader_init() error\n"); + return -4; + } + for (int i = 0; i < data_files_load_startup_count; i++) + { + if (load_file_shm(data_files_load_startup[i]) < 0) + { + log_error("load_file_mmap(%s) error\n", data_files_load_startup[i]); + } + } + // Set signal handler signal(SIGHUP, sig_hup_handler); signal(SIGCHLD, sig_chld_handler); signal(SIGTERM, sig_term_handler); // Initialize socket server - if (net_server(BBS_address, BBS_port) < 0) - { - return -4; - } + net_server(BBS_address, BBS_port); + // Cleanup loaded data files + file_loader_cleanup(); + // Cleanup menu unload_menu(p_bbs_menu); free(p_bbs_menu);