--- lbbs/src/menu_proc.c 2005/05/07 12:08:28 1.4 +++ lbbs/src/menu_proc.c 2025/06/04 13:42:53 1.23 @@ -1,16 +1,15 @@ /*************************************************************************** - menu_proc.c - description - ------------------- - begin : Fri May 6 2005 - copyright : (C) 2005 by Leaflet - email : leaflet@leafok.com + menu_proc.c - description + ------------------- + Copyright : (C) 2004-2025 by Leaflet + Email : leaflet@leafok.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * + * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ @@ -18,99 +17,129 @@ #include "bbs.h" #include "bbs_cmd.h" #include "common.h" +#include "log.h" #include "io.h" +#include "screen.h" +#include "menu.h" +#include "user_priv.h" +#include "section_list_display.h" #include #include +#include #include #include #include #include -int -exec_mbem(const char *str) +int list_section(void *param) { - void *hdll; - int (*func) (); - char *c,*s; - char buf[1024]; + section_list_display(param); - strcpy(buf, str); - s = strstr(buf, "@mod:"); - if (s) { - c = strstr(s + 5, "#"); - if (c) { - *c = 0; - c++; - } + return REDRAW; +} + +int exec_mbem(void *param) +{ + void *hdll; + int (*func)(); + char *c, *s; + char buf[FILE_PATH_LEN]; + + strncpy(buf, (const char *)param, sizeof(buf) - 1); + buf[sizeof(buf) - 1] = '\0'; - hdll = dlopen (s + 5, RTLD_LAZY); + s = strstr(buf, "@mod:"); + if (s) + { + c = strstr(s + 5, "#"); + if (c) + { + *c = 0; + c++; + } - if (hdll) { - char *error; + hdll = dlopen(s + 5, RTLD_LAZY); - if ((func = dlsym (hdll, c ? c : "mod_main")) != NULL) - func (); - else if ((error = dlerror ()) != NULL) { - clearscr (); - prints ("%s\r\n", error); - press_any_key (); - } - dlclose (hdll); - } else { - clearscr (); - prints ("加载库文件 [%s] 失败!!\r\n", s + 5); - prints ("失败原因:%s\r\n", dlerror()); - press_any_key (); - } - } + if (hdll) + { + char *error; - return REDRAW; + if ((func = dlsym(hdll, c ? c : "mod_main")) != NULL) + func(); + else if ((error = dlerror()) != NULL) + { + clearscr(); + prints("%s\r\n", error); + press_any_key(); + } + dlclose(hdll); + } + else + { + clearscr(); + prints("加载库文件 [%s] 失败!!\r\n", s + 5); + prints("失败原因:%s\r\n", dlerror()); + press_any_key(); + } + } + + return REDRAW; } -int -exitbbs (const char *s) +int exit_bbs(void *param) { - return EXITBBS; + return EXITBBS; } -int -license (const char *s) +int license(void *param) { - char temp[256]; - - strcpy (temp, app_home_dir); - strcat (temp, "data/license.txt"); - display_file_ex (temp, 0, 1); + display_file(DATA_LICENSE, 1, 0); - return REDRAW; + return REDRAW; } -int -copyright (const char *s) +int copyright(void *param) { - char temp[256]; - - strcpy (temp, app_home_dir); - strcat (temp, "data/copyright.txt"); - display_file_ex (temp, 0, 1); + display_file(DATA_COPYRIGHT, 1, 1); - return REDRAW; + return REDRAW; } -int -reloadbbsmenu (const char *s) +int reload_bbs_conf(void *param) { - if (kill (getppid (), SIG_RELOAD_MENU) < 0) - log_error ("Send SIG_RELOAD_MENU signal failed (%d)\n", errno); + clearscr(); + + if (kill(getppid(), SIGHUP) < 0) + { + log_error("Send SIGHUP signal failed (%d)\n", errno); + + prints("发送指令失败\r\n"); + } + else + { + prints("已发送指令\r\n"); + } + + press_any_key(); + + return REDRAW; +} + +int shutdown_bbs(void *param) +{ + log_common("Notify main process to exit\n"); + + if (kill(getppid(), SIGTERM) < 0) + { + log_error("Send SIGTERM signal failed (%d)\n", errno); + } - return REDRAW; + return REDRAW; } -int -shutdownbbs (const char *s) +int favour_section_filter(void *param) { - if (kill (0, SIG_BBS_EXIT) < 0) - log_error ("Send SIG_BBS_EXIT signal failed (%d)\n", errno); + MENU_ITEM *p_menu_item = param; - return REDRAW; + return (is_favor(&BBS_priv, p_menu_item->priv) && checklevel2(&BBS_priv, p_menu_item->level)); }