--- lbbs/src/menu_proc.c 2025/06/24 10:01:24 1.28 +++ lbbs/src/menu_proc.c 2025/10/21 11:11:28 1.42 @@ -15,6 +15,7 @@ ***************************************************************************/ #include "article_cache.h" +#include "article_favor_display.h" #include "article_view_log.h" #include "bbs.h" #include "bbs_cmd.h" @@ -25,6 +26,7 @@ #include "menu.h" #include "section_list_display.h" #include "screen.h" +#include "user_list_display.h" #include "user_priv.h" #include #include @@ -37,15 +39,20 @@ int list_section(void *param) { - section_list_display(param); + section_list_display(param, 0); return REDRAW; } +typedef union exec_handler_t{ + void *p; + int (*handler)(); +} exec_handler; + int exec_mbem(void *param) { void *hdll; - int (*func)(); + exec_handler func; char *c, *s; char buf[FILE_PATH_LEN]; @@ -68,8 +75,10 @@ int exec_mbem(void *param) { char *error; - if ((func = dlsym(hdll, c ? c : "mod_main")) != NULL) - func(); + if ((func.p = dlsym(hdll, c ? c : "mod_main")) != NULL) + { + func.handler(); + } else if ((error = dlerror()) != NULL) { clearscr(); @@ -81,8 +90,8 @@ int exec_mbem(void *param) else { clearscr(); - prints("加载库文件 [%s] 失败!!\r\n", s + 5); - prints("失败原因:%s\r\n", dlerror()); + prints("鍔犺浇搴撴枃浠 [%s] 澶辫触!!\r\n", s + 5); + prints("澶辫触鍘熷洜:%s\r\n", dlerror()); press_any_key(); } } @@ -109,6 +118,13 @@ int copyright(void *param) return REDRAW; } +int version(void *param) +{ + display_file(DATA_VERSION, 1); + + return REDRAW; +} + int reload_bbs_conf(void *param) { clearscr(); @@ -117,11 +133,11 @@ int reload_bbs_conf(void *param) { log_error("Send SIGHUP signal failed (%d)\n", errno); - prints("发送指令失败\r\n"); + prints("鍙戦佹寚浠ゅけ璐r\n"); } else { - prints("已发送指令\r\n"); + prints("宸插彂閫佹寚浠r\n"); } press_any_key(); @@ -141,7 +157,7 @@ int shutdown_bbs(void *param) return REDRAW; } -int favour_section_filter(void *param) +int favor_section_filter(void *param) { MENU_ITEM *p_menu_item = param; @@ -154,9 +170,9 @@ static int display_ex_article_key_handle { case 0: // Set msg snprintf(p_ctx->msg, sizeof(p_ctx->msg), - "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] | " - "移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] | " - "帮助[\033[32mh\033[33m] |"); + "| 杩斿洖[\033[32m鈫怽033[33m,\033[32mESC\033[33m] | " + "绉诲姩[\033[32m鈫慭033[33m/\033[32m鈫揬033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] | " + "甯姪[\033[32mh\033[33m] |"); break; } @@ -205,4 +221,136 @@ int view_ex_article(void *param) } return REDRAW; +} + +int list_ex_section(void *param) +{ + SECTION_LIST *p_section; + + p_section = section_list_find_by_name(param); + if (p_section == NULL) + { + log_error("Section %s not found\n", (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); + } + + return REDRAW; +} + +int show_top10_menu(void *param) +{ + static int show_top10 = 0; + int ch = 0; + + if (show_top10) + { + return NOREDRAW; + } + show_top10 = 1; + + clearscr(); + show_top("", BBS_name, ""); + show_bottom(""); + + if (display_menu(&top10_menu) == 0) + { + while (!SYS_server_exit) + { + iflush(); + ch = igetch(100); + + if (ch != KEY_NULL && ch != KEY_TIMEOUT) + { + BBS_last_access_tm = time(NULL); + } + + switch (ch) + { + case KEY_NULL: // broken pipe + log_error("KEY_NULL\n"); + show_top10 = 0; + return 0; + case KEY_TIMEOUT: + if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) + { + log_error("User input timeout\n"); + show_top10 = 0; + return 0; + } + continue; + case CR: + default: + switch (menu_control(&top10_menu, ch)) + { + case EXITMENU: + ch = EXITMENU; + break; + case REDRAW: + clearscr(); + show_bottom(""); + display_menu(&top10_menu); + break; + case NOREDRAW: + case UNKNOWN_CMD: + default: + break; + } + } + + if (ch == EXITMENU) + { + break; + } + } + } + + show_top10 = 0; + return REDRAW; +} + +int locate_article(void *param) +{ + char buf[MAX_MENUITEM_NAME_LENGTH]; + char *sname, *aid, *saveptr; + + strncpy(buf, param, sizeof(buf) - 1); + buf[sizeof(buf) - 1] = '\0'; + + sname = strtok_r(buf, "|", &saveptr); + aid = strtok_r(NULL, "|", &saveptr); + + if (sname == NULL || aid == NULL) + { + log_error("top10_locate(%s) error: invalid parameter\n", param); + return NOREDRAW; + } + + section_list_display(sname, atoi(aid)); + + return REDRAW; +} + +int favor_topic(void *param) +{ + if (article_favor_display(&BBS_article_favor) < 0) + { + log_error("article_favor_display() error\n"); + } + + return REDRAW; +} + +int user_list(void *param) +{ + if (user_list_display() < 0) + { + log_error("user_list_display() error\n"); + } + + return REDRAW; }