--- lbbs/src/menu_proc.c 2025/11/07 09:53:47 1.48 +++ lbbs/src/menu_proc.c 2026/01/03 10:27:14 1.63 @@ -3,14 +3,20 @@ * menu_proc * - handler functions of menu commands * - * Copyright (C) 2004-2025 Leaflet + * Copyright (C) 2004-2026 Leaflet */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "article_cache.h" #include "article_favor_display.h" #include "article_view_log.h" #include "bbs.h" #include "bbs_cmd.h" +#include "bbs_net.h" +#include "chicken.h" #include "common.h" #include "io.h" #include "log.h" @@ -21,6 +27,7 @@ #include "user_info_update.h" #include "user_list_display.h" #include "user_priv.h" +#include #include #include #include @@ -63,6 +70,7 @@ int exec_mbem(void *param) c++; } +#ifdef _ENABLE_SHARED hdll = dlopen(s + 5, RTLD_LAZY); if (hdll) @@ -88,6 +96,25 @@ int exec_mbem(void *param) prints("失败原因:%s\r\n", dlerror()); press_any_key(); } +#else + (void)hdll; + (void)func; + + if (strcasecmp(c, "bbs_net") == 0) + { + bbs_net(); + } + else if (strcasecmp(c, "chicken_main") == 0) + { + chicken_main(); + } + else + { + clearscr(); + prints("未知入口 [%s] !!\r\n", c); + press_any_key(); + } +#endif } return REDRAW; @@ -98,6 +125,13 @@ int exit_bbs(void *param) return EXITBBS; } +int eula(void *param) +{ + display_file(DATA_EULA, 0); + + return REDRAW; +} + int license(void *param) { display_file(DATA_LICENSE, 0); @@ -125,7 +159,7 @@ int reload_bbs_conf(void *param) if (kill(getppid(), SIGHUP) < 0) { - log_error("Send SIGHUP signal failed (%d)\n", errno); + log_error("Send SIGHUP signal failed (%d)", errno); prints("发送指令失败\r\n"); } @@ -148,11 +182,11 @@ int shutdown_bbs(void *param) if (toupper(buf[0]) == 'Y') { - log_common("Notify main process to exit by [%s]\n", BBS_username); + log_common("Notify main process to exit by [%s]", BBS_username); if (kill(getppid(), SIGTERM) < 0) { - log_error("Send SIGTERM signal failed (%d)\n", errno); + log_error("Send SIGTERM signal failed (%d)", errno); } } @@ -193,19 +227,19 @@ int view_ex_article(void *param) p_article = article_block_find_by_aid(aid); if (p_article == NULL) { - log_error("article_block_find_by_aid(%d) error\n", aid); + log_error("article_block_find_by_aid(%d) error", aid); return NOREDRAW; } if (article_cache_load(&cache, VAR_ARTICLE_CACHE_DIR, p_article) < 0) { - log_error("article_cache_load(aid=%d, cid=%d) error\n", p_article->aid, p_article->cid); + log_error("article_cache_load(aid=%d, cid=%d) error", p_article->aid, p_article->cid); return NOREDRAW; } if (user_online_update("VIEW_ARTICLE") < 0) { - log_error("user_online_update(VIEW_ARTICLE) error\n"); + log_error("user_online_update(VIEW_ARTICLE) error"); } ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 0, @@ -213,13 +247,13 @@ int view_ex_article(void *param) if (article_cache_unload(&cache) < 0) { - log_error("article_cache_unload(aid=%d, cid=%d) error\n", p_article->aid, p_article->cid); + log_error("article_cache_unload(aid=%d, cid=%d) error", p_article->aid, p_article->cid); } // Update article_view_log if (article_view_log_set_viewed(p_article->aid, &BBS_article_view_log) < 0) { - log_error("article_view_log_set_viewed(aid=%d) error\n", p_article->aid); + log_error("article_view_log_set_viewed(aid=%d) error", p_article->aid); } return REDRAW; @@ -232,13 +266,13 @@ int list_ex_section(void *param) p_section = section_list_find_by_name(param); if (p_section == NULL) { - log_error("Section %s not found\n", (const char *)param); + log_error("Section %s not found", (const char *)param); return -1; } if (section_list_ex_dir_display(p_section) < 0) { - log_error("section_list_ex_dir_display(sid=%d) error\n", p_section->sid); + log_error("section_list_ex_dir_display(sid=%d) error", p_section->sid); } return REDRAW; @@ -248,6 +282,7 @@ int show_top10_menu(void *param) { static int show_top10 = 0; int ch = 0; + int loop; if (show_top10) { @@ -261,7 +296,7 @@ int show_top10_menu(void *param) if (display_menu(&top10_menu) == 0) { - while (!SYS_server_exit) + for (loop = 1; !SYS_server_exit && loop;) { iflush(); ch = igetch(100); @@ -271,18 +306,23 @@ int show_top10_menu(void *param) BBS_last_access_tm = time(NULL); } + if (user_online_update("TOP10_MENU") < 0) + { + log_error("user_online_update(TOP10_MENU) error"); + } + switch (ch) { case KEY_NULL: // broken pipe - log_error("KEY_NULL\n"); - show_top10 = 0; - return 0; + log_debug("KEY_NULL"); + loop = 0; + break; case KEY_TIMEOUT: if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time) { - log_error("User input timeout\n"); - show_top10 = 0; - return 0; + log_debug("User input timeout"); + loop = 0; + break; } continue; case CR: @@ -290,7 +330,7 @@ int show_top10_menu(void *param) switch (menu_control(&top10_menu, ch)) { case EXITMENU: - ch = EXITMENU; + loop = 0; break; case REDRAW: clearscr(); @@ -303,11 +343,6 @@ int show_top10_menu(void *param) break; } } - - if (ch == EXITMENU) - { - break; - } } } @@ -328,7 +363,7 @@ int locate_article(void *param) if (sname == NULL || aid == NULL) { - log_error("top10_locate(%s) error: invalid parameter\n", param); + log_error("top10_locate(%s) error: invalid parameter", param); return NOREDRAW; } @@ -341,7 +376,7 @@ int favor_topic(void *param) { if (article_favor_display(&BBS_article_favor) < 0) { - log_error("article_favor_display() error\n"); + log_error("article_favor_display() error"); } return REDRAW; @@ -351,7 +386,7 @@ int list_user(void *param) { if (user_list_display(0) < 0) { - log_error("user_list_display(all_user) error\n"); + log_error("user_list_display(all_user) error"); } return REDRAW; @@ -361,7 +396,7 @@ int list_online_user(void *param) { if (user_list_display(1) < 0) { - log_error("user_list_display(online_user) error\n"); + log_error("user_list_display(online_user) error"); } return REDRAW; @@ -371,7 +406,17 @@ int edit_intro(void *param) { if (user_intro_edit(BBS_priv.uid) < 0) { - log_error("user_intro_edit(%d) error\n", BBS_priv.uid); + log_error("user_intro_edit(%d) error", BBS_priv.uid); + } + + return REDRAW; +} + +int edit_sign(void *param) +{ + if (user_sign_edit(BBS_priv.uid) < 0) + { + log_error("user_sign_edit(%d) error", BBS_priv.uid); } return REDRAW;