--- lbbs/src/menu_proc.c 2025/05/15 08:22:29 1.15 +++ lbbs/src/menu_proc.c 2025/06/24 12:32:16 1.29 @@ -14,29 +14,42 @@ * * ***************************************************************************/ +#include "article_cache.h" +#include "article_view_log.h" #include "bbs.h" #include "bbs_cmd.h" #include "common.h" -#include "log.h" #include "io.h" -#include "screen.h" +#include "log.h" +#include "login.h" #include "menu.h" +#include "section_list_display.h" +#include "screen.h" +#include "user_priv.h" #include #include #include +#include #include -#include #include #include +#include + +int list_section(void *param) +{ + section_list_display(param); + + return REDRAW; +} -int exec_mbem(const char *str) +int exec_mbem(void *param) { void *hdll; int (*func)(); char *c, *s; char buf[FILE_PATH_LEN]; - strncpy(buf, str, sizeof(buf) - 1); + strncpy(buf, (const char *)param, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; s = strstr(buf, "@mod:"); @@ -77,26 +90,26 @@ int exec_mbem(const char *str) return REDRAW; } -int exitbbs(const char *s) +int exit_bbs(void *param) { return EXITBBS; } -int license(const char *s) +int license(void *param) { - display_file_ex(DATA_LICENSE, 1, 1); + display_file(DATA_LICENSE, 0); return REDRAW; } -int copyright(const char *s) +int copyright(void *param) { - display_file_ex(DATA_COPYRIGHT, 1, 1); + display_file(DATA_COPYRIGHT, 1); return REDRAW; } -int reloadbbsmenu(const char *s) +int reload_bbs_conf(void *param) { clearscr(); @@ -116,9 +129,9 @@ int reloadbbsmenu(const char *s) return REDRAW; } -int shutdownbbs(const char *s) +int shutdown_bbs(void *param) { - log_std("Notify main process to exit\n"); + log_common("Notify main process to exit\n"); if (kill(getppid(), SIGTERM) < 0) { @@ -126,4 +139,89 @@ int shutdownbbs(const char *s) } return REDRAW; +} + +int favour_section_filter(void *param) +{ + MENU_ITEM *p_menu_item = param; + + return (is_favor(&BBS_priv, p_menu_item->priv) && checklevel2(&BBS_priv, p_menu_item->level)); +} + +static int display_ex_article_key_handler(int *p_key, DISPLAY_CTX *p_ctx) +{ + switch (*p_key) + { + 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] |"); + break; + } + + return 0; +} + +int view_ex_article(void *param) +{ + ARTICLE_CACHE cache; + ARTICLE *p_article; + int32_t aid = atoi(param); + int ret; + + (void)ret; + + p_article = article_block_find_by_aid(aid); + if (p_article == NULL) + { + log_error("article_block_find_by_aid(%d) error\n", 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); + return NOREDRAW; + } + + if (user_online_update("VIEW_ARTICLE") < 0) + { + log_error("user_online_update(VIEW_ARTICLE) error\n"); + } + + ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 0, + display_ex_article_key_handler, DATA_READ_HELP); + + if (article_cache_unload(&cache) < 0) + { + log_error("article_cache_unload(aid=%d, cid=%d) error\n", 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); + } + + 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; }