/[LeafOK_CVS]/lbbs/src/menu_proc.c
ViewVC logotype

Diff of /lbbs/src/menu_proc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.29 by sysadm, Tue Jun 24 12:32:16 2025 UTC Revision 1.47 by sysadm, Wed Nov 5 14:59:31 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /* SPDX-License-Identifier: GPL-3.0-or-later */
2                                                    menu_proc.c  -  description  /*
3                                                           -------------------   * menu_proc
4          Copyright            : (C) 2004-2025 by Leaflet   *   - handler functions of menu commands
5          Email                : leaflet@leafok.com   *
6   ***************************************************************************/   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>
7     */
 /***************************************************************************  
  *                                                                         *  
  *   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 3 of the License, or     *  
  *   (at your option) any later version.                                   *  
  *                                                                         *  
  ***************************************************************************/  
8    
9  #include "article_cache.h"  #include "article_cache.h"
10    #include "article_favor_display.h"
11  #include "article_view_log.h"  #include "article_view_log.h"
12  #include "bbs.h"  #include "bbs.h"
13  #include "bbs_cmd.h"  #include "bbs_cmd.h"
# Line 25  Line 18 
18  #include "menu.h"  #include "menu.h"
19  #include "section_list_display.h"  #include "section_list_display.h"
20  #include "screen.h"  #include "screen.h"
21    #include "user_info_update.h"
22    #include "user_list_display.h"
23  #include "user_priv.h"  #include "user_priv.h"
24  #include <dlfcn.h>  #include <dlfcn.h>
25  #include <errno.h>  #include <errno.h>
# Line 37  Line 32 
32    
33  int list_section(void *param)  int list_section(void *param)
34  {  {
35          section_list_display(param);          section_list_display(param, 0);
36    
37          return REDRAW;          return REDRAW;
38  }  }
39    
40    typedef union exec_handler_t
41    {
42            void *p;
43            int (*handler)();
44    } exec_handler;
45    
46  int exec_mbem(void *param)  int exec_mbem(void *param)
47  {  {
48          void *hdll;          void *hdll;
49          int (*func)();          exec_handler func;
50          char *c, *s;          char *c, *s;
51          char buf[FILE_PATH_LEN];          char buf[FILE_PATH_LEN];
52    
# Line 68  int exec_mbem(void *param) Line 69  int exec_mbem(void *param)
69                  {                  {
70                          char *error;                          char *error;
71    
72                          if ((func = dlsym(hdll, c ? c : "mod_main")) != NULL)                          if ((func.p = dlsym(hdll, c ? c : "mod_main")) != NULL)
73                                  func();                          {
74                                    func.handler();
75                            }
76                          else if ((error = dlerror()) != NULL)                          else if ((error = dlerror()) != NULL)
77                          {                          {
78                                  clearscr();                                  clearscr();
# Line 81  int exec_mbem(void *param) Line 84  int exec_mbem(void *param)
84                  else                  else
85                  {                  {
86                          clearscr();                          clearscr();
87                          prints("ؿļ [%s] ʧ!!\r\n", s + 5);                          prints("加载库文件 [%s] 失败!!\r\n", s + 5);
88                          prints("ʧԭ:%s\r\n", dlerror());                          prints("失败原因:%s\r\n", dlerror());
89                          press_any_key();                          press_any_key();
90                  }                  }
91          }          }
# Line 109  int copyright(void *param) Line 112  int copyright(void *param)
112          return REDRAW;          return REDRAW;
113  }  }
114    
115    int version(void *param)
116    {
117            display_file(DATA_VERSION, 1);
118    
119            return REDRAW;
120    }
121    
122  int reload_bbs_conf(void *param)  int reload_bbs_conf(void *param)
123  {  {
124          clearscr();          clearscr();
# Line 117  int reload_bbs_conf(void *param) Line 127  int reload_bbs_conf(void *param)
127          {          {
128                  log_error("Send SIGHUP signal failed (%d)\n", errno);                  log_error("Send SIGHUP signal failed (%d)\n", errno);
129    
130                  prints("ָʧ\r\n");                  prints("发送指令失败\r\n");
131          }          }
132          else          else
133          {          {
134                  prints("ѷָ\r\n");                  prints("已发送指令\r\n");
135          }          }
136    
137          press_any_key();          press_any_key();
# Line 141  int shutdown_bbs(void *param) Line 151  int shutdown_bbs(void *param)
151          return REDRAW;          return REDRAW;
152  }  }
153    
154  int favour_section_filter(void *param)  int favor_section_filter(void *param)
155  {  {
156          MENU_ITEM *p_menu_item = param;          MENU_ITEM *p_menu_item = param;
157    
# Line 154  static int display_ex_article_key_handle Line 164  static int display_ex_article_key_handle
164          {          {
165          case 0: // Set msg          case 0: // Set msg
166                  snprintf(p_ctx->msg, sizeof(p_ctx->msg),                  snprintf(p_ctx->msg, sizeof(p_ctx->msg),
167                                   "| [\033[32m\033[33m,\033[32mESC\033[33m] | "                                   "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] | "
168                                   "ƶ[\033[32m\033[33m/\033[32m\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] | "                                   "移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] | "
169                                   "[\033[32mh\033[33m] |");                                   "帮助[\033[32mh\033[33m] |");
170                  break;                  break;
171          }          }
172    
# Line 224  int list_ex_section(void *param) Line 234  int list_ex_section(void *param)
234          }          }
235    
236          return REDRAW;          return REDRAW;
237    }
238    
239    int show_top10_menu(void *param)
240    {
241            static int show_top10 = 0;
242            int ch = 0;
243    
244            if (show_top10)
245            {
246                    return NOREDRAW;
247            }
248            show_top10 = 1;
249    
250            clearscr();
251            show_top("", BBS_name, "");
252            show_bottom("");
253    
254            if (display_menu(&top10_menu) == 0)
255            {
256                    while (!SYS_server_exit)
257                    {
258                            iflush();
259                            ch = igetch(100);
260    
261                            if (ch != KEY_NULL && ch != KEY_TIMEOUT)
262                            {
263                                    BBS_last_access_tm = time(NULL);
264                            }
265    
266                            switch (ch)
267                            {
268                            case KEY_NULL: // broken pipe
269                                    log_error("KEY_NULL\n");
270                                    show_top10 = 0;
271                                    return 0;
272                            case KEY_TIMEOUT:
273                                    if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)
274                                    {
275                                            log_error("User input timeout\n");
276                                            show_top10 = 0;
277                                            return 0;
278                                    }
279                                    continue;
280                            case CR:
281                            default:
282                                    switch (menu_control(&top10_menu, ch))
283                                    {
284                                    case EXITMENU:
285                                            ch = EXITMENU;
286                                            break;
287                                    case REDRAW:
288                                            clearscr();
289                                            show_bottom("");
290                                            display_menu(&top10_menu);
291                                            break;
292                                    case NOREDRAW:
293                                    case UNKNOWN_CMD:
294                                    default:
295                                            break;
296                                    }
297                            }
298    
299                            if (ch == EXITMENU)
300                            {
301                                    break;
302                            }
303                    }
304            }
305    
306            show_top10 = 0;
307            return REDRAW;
308    }
309    
310    int locate_article(void *param)
311    {
312            char buf[MAX_MENUITEM_NAME_LENGTH];
313            char *sname, *aid, *saveptr;
314    
315            strncpy(buf, param, sizeof(buf) - 1);
316            buf[sizeof(buf) - 1] = '\0';
317    
318            sname = strtok_r(buf, "|", &saveptr);
319            aid = strtok_r(NULL, "|", &saveptr);
320    
321            if (sname == NULL || aid == NULL)
322            {
323                    log_error("top10_locate(%s) error: invalid parameter\n", param);
324                    return NOREDRAW;
325            }
326    
327            section_list_display(sname, atoi(aid));
328    
329            return REDRAW;
330    }
331    
332    int favor_topic(void *param)
333    {
334            if (article_favor_display(&BBS_article_favor) < 0)
335            {
336                    log_error("article_favor_display() error\n");
337            }
338    
339            return REDRAW;
340    }
341    
342    int list_user(void *param)
343    {
344            if (user_list_display(0) < 0)
345            {
346                    log_error("user_list_display(all_user) error\n");
347            }
348    
349            return REDRAW;
350    }
351    
352    int list_online_user(void *param)
353    {
354            if (user_list_display(1) < 0)
355            {
356                    log_error("user_list_display(online_user) error\n");
357            }
358    
359            return REDRAW;
360    }
361    
362    int edit_intro(void *param)
363    {
364            if (user_intro_edit(BBS_priv.uid) < 0)
365            {
366                    log_error("user_intro_edit(%d) error\n", BBS_priv.uid);
367            }
368    
369            return REDRAW;
370  }  }


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1