/[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.33 by sysadm, Mon Oct 13 05:39:45 2025 UTC Revision 1.43 by sysadm, Wed Oct 22 04:48:53 2025 UTC
# Line 15  Line 15 
15   ***************************************************************************/   ***************************************************************************/
16    
17  #include "article_cache.h"  #include "article_cache.h"
18    #include "article_favor_display.h"
19  #include "article_view_log.h"  #include "article_view_log.h"
20  #include "bbs.h"  #include "bbs.h"
21  #include "bbs_cmd.h"  #include "bbs_cmd.h"
# Line 25  Line 26 
26  #include "menu.h"  #include "menu.h"
27  #include "section_list_display.h"  #include "section_list_display.h"
28  #include "screen.h"  #include "screen.h"
29    #include "user_list_display.h"
30  #include "user_priv.h"  #include "user_priv.h"
31  #include <dlfcn.h>  #include <dlfcn.h>
32  #include <errno.h>  #include <errno.h>
# Line 42  int list_section(void *param) Line 44  int list_section(void *param)
44          return REDRAW;          return REDRAW;
45  }  }
46    
47    typedef union exec_handler_t{
48            void *p;
49            int (*handler)();
50    } exec_handler;
51    
52  int exec_mbem(void *param)  int exec_mbem(void *param)
53  {  {
54          void *hdll;          void *hdll;
55          int (*func)();          exec_handler func;
56          char *c, *s;          char *c, *s;
57          char buf[FILE_PATH_LEN];          char buf[FILE_PATH_LEN];
58    
# Line 68  int exec_mbem(void *param) Line 75  int exec_mbem(void *param)
75                  {                  {
76                          char *error;                          char *error;
77    
78                          if ((func = dlsym(hdll, c ? c : "mod_main")) != NULL)                          if ((func.p = dlsym(hdll, c ? c : "mod_main")) != NULL)
79                                  func();                          {
80                                    func.handler();
81                            }
82                          else if ((error = dlerror()) != NULL)                          else if ((error = dlerror()) != NULL)
83                          {                          {
84                                  clearscr();                                  clearscr();
# Line 109  int copyright(void *param) Line 118  int copyright(void *param)
118          return REDRAW;          return REDRAW;
119  }  }
120    
121    int version(void *param)
122    {
123            display_file(DATA_VERSION, 1);
124    
125            return REDRAW;
126    }
127    
128  int reload_bbs_conf(void *param)  int reload_bbs_conf(void *param)
129  {  {
130          clearscr();          clearscr();
# Line 211  int list_ex_section(void *param) Line 227  int list_ex_section(void *param)
227  {  {
228          SECTION_LIST *p_section;          SECTION_LIST *p_section;
229    
230          p_section = section_list_find_by_name(param, NULL);          p_section = section_list_find_by_name(param);
231          if (p_section == NULL)          if (p_section == NULL)
232          {          {
233                  log_error("Section %s not found\n", (const char *)param);                  log_error("Section %s not found\n", (const char *)param);
# Line 226  int list_ex_section(void *param) Line 242  int list_ex_section(void *param)
242          return REDRAW;          return REDRAW;
243  }  }
244    
245  int top10_menu(void *param)  int show_top10_menu(void *param)
246  {  {
247            static int show_top10 = 0;
248            int ch = 0;
249    
250            if (show_top10)
251            {
252                    return NOREDRAW;
253            }
254            show_top10 = 1;
255    
256            clearscr();
257            show_top("", BBS_name, "");
258            show_bottom("");
259    
260            if (display_menu(&top10_menu) == 0)
261            {
262                    while (!SYS_server_exit)
263                    {
264                            iflush();
265                            ch = igetch(100);
266    
267                            if (ch != KEY_NULL && ch != KEY_TIMEOUT)
268                            {
269                                    BBS_last_access_tm = time(NULL);
270                            }
271    
272                            switch (ch)
273                            {
274                            case KEY_NULL: // broken pipe
275                                    log_error("KEY_NULL\n");
276                                    show_top10 = 0;
277                                    return 0;
278                            case KEY_TIMEOUT:
279                                    if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)
280                                    {
281                                            log_error("User input timeout\n");
282                                            show_top10 = 0;
283                                            return 0;
284                                    }
285                                    continue;
286                            case CR:
287                            default:
288                                    switch (menu_control(&top10_menu, ch))
289                                    {
290                                    case EXITMENU:
291                                            ch = EXITMENU;
292                                            break;
293                                    case REDRAW:
294                                            clearscr();
295                                            show_bottom("");
296                                            display_menu(&top10_menu);
297                                            break;
298                                    case NOREDRAW:
299                                    case UNKNOWN_CMD:
300                                    default:
301                                            break;
302                                    }
303                            }
304    
305                            if (ch == EXITMENU)
306                            {
307                                    break;
308                            }
309                    }
310            }
311    
312            show_top10 = 0;
313          return REDRAW;          return REDRAW;
314  }  }
315    
316  int locate_article(void *param)  int locate_article(void *param)
317  {  {
318            char buf[MAX_MENUITEM_NAME_LENGTH];
319          char *sname, *aid, *saveptr;          char *sname, *aid, *saveptr;
320    
321          sname = strtok_r(param, " ", &saveptr);          strncpy(buf, param, sizeof(buf) - 1);
322          aid = strtok_r(NULL, " ", &saveptr);          buf[sizeof(buf) - 1] = '\0';
323    
324            sname = strtok_r(buf, "|", &saveptr);
325            aid = strtok_r(NULL, "|", &saveptr);
326    
327          if (sname == NULL || aid == NULL)          if (sname == NULL || aid == NULL)
328          {          {
329                  log_error("top10_locate() error: invalid parameter\n", (const char *)param);                  log_error("top10_locate(%s) error: invalid parameter\n", param);
330                  return NOREDRAW;                  return NOREDRAW;
331          }          }
332    
# Line 251  int locate_article(void *param) Line 337  int locate_article(void *param)
337    
338  int favor_topic(void *param)  int favor_topic(void *param)
339  {  {
340          clearscr();          if (article_favor_display(&BBS_article_favor) < 0)
341          prints("此功能尚未实现");          {
342          press_any_key();                  log_error("article_favor_display() error\n");
343            }
344    
345            return REDRAW;
346    }
347    
348    int list_user(void *param)
349    {
350            if (user_list_display(0) < 0)
351            {
352                    log_error("user_list_display(all_user) error\n");
353            }
354    
355            return REDRAW;
356    }
357    
358    int list_online_user(void *param)
359    {
360            if (user_list_display(1) < 0)
361            {
362                    log_error("user_list_display(online_user) error\n");
363            }
364    
365          return REDRAW;          return REDRAW;
366  }  }


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

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