--- lbbs/src/main.c 2025/06/21 02:15:18 1.55 +++ lbbs/src/main.c 2025/06/26 12:17:02 1.60 @@ -26,26 +26,27 @@ #include #include #include +#include #include #include #include #include #include -void app_help(void) +static void app_help(void) { - prints("Usage: bbsd [-fhv] [...]\n\n" - "-f\t--foreground\t\tForce program run in foreground\n" - "-h\t--help\t\t\tDisplay this help message\n" - "-v\t--version\t\tDisplay version information\n" - "\t--display-log\t\tDisplay standard log information\n" - "\t--display-error-log\tDisplay error log information\n" - "\n If meet any bug, please report to \n\n"); + fprintf(stderr, "Usage: bbsd [-fhv] [...]\n\n" + "-f\t--foreground\t\tForce program run in foreground\n" + "-h\t--help\t\t\tDisplay this help message\n" + "-v\t--version\t\tDisplay version information\n" + "\t--display-log\t\tDisplay standard log information\n" + "\t--display-error-log\tDisplay error log information\n" + "\n If meet any bug, please report to \n\n"); } -void arg_error(void) +static void arg_error(void) { - prints("Invalid arguments\n"); + fprintf(stderr, "Invalid arguments\n"); app_help(); } @@ -204,13 +205,7 @@ int main(int argc, char *argv[]) } // Load menus - p_bbs_menu = calloc(1, sizeof(MENU_SET)); - if (p_bbs_menu == NULL) - { - log_error("OOM: calloc(MENU_SET)\n"); - goto cleanup; - } - if (load_menu(p_bbs_menu, CONF_MENU) < 0) + if (load_menu(&bbs_menu, CONF_MENU) < 0) { goto cleanup; } @@ -229,10 +224,10 @@ int main(int argc, char *argv[]) } } - // Load section config - if (load_section_config_from_db() < 0) + // Load section config and gen_ex + if (load_section_config_from_db(1) < 0) { - log_error("load_section_config_from_db() error\n"); + log_error("load_section_config_from_db(0) error\n"); goto cleanup; } @@ -288,9 +283,7 @@ cleanup: file_loader_cleanup(); // Cleanup menu - unload_menu(p_bbs_menu); - free(p_bbs_menu); - p_bbs_menu = NULL; + unload_menu(&bbs_menu); // Cleanup data pools section_list_cleanup(); @@ -312,5 +305,7 @@ cleanup: log_common("Main process exit normally\n"); + log_end(); + return 0; }