/[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.41 by sysadm, Sat Oct 18 12:06:10 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 42  int list_section(void *param) Line 43  int list_section(void *param)
43          return REDRAW;          return REDRAW;
44  }  }
45    
46    typedef union exec_handler_t{
47            void *p;
48            int (*handler)();
49    } exec_handler;
50    
51  int exec_mbem(void *param)  int exec_mbem(void *param)
52  {  {
53          void *hdll;          void *hdll;
54          int (*func)();          exec_handler func;
55          char *c, *s;          char *c, *s;
56          char buf[FILE_PATH_LEN];          char buf[FILE_PATH_LEN];
57    
# Line 68  int exec_mbem(void *param) Line 74  int exec_mbem(void *param)
74                  {                  {
75                          char *error;                          char *error;
76    
77                          if ((func = dlsym(hdll, c ? c : "mod_main")) != NULL)                          if ((func.p = dlsym(hdll, c ? c : "mod_main")) != NULL)
78                                  func();                          {
79                                    func.handler();
80                            }
81                          else if ((error = dlerror()) != NULL)                          else if ((error = dlerror()) != NULL)
82                          {                          {
83                                  clearscr();                                  clearscr();
# Line 109  int copyright(void *param) Line 117  int copyright(void *param)
117          return REDRAW;          return REDRAW;
118  }  }
119    
120    int version(void *param)
121    {
122            display_file(DATA_VERSION, 1);
123    
124            return REDRAW;
125    }
126    
127  int reload_bbs_conf(void *param)  int reload_bbs_conf(void *param)
128  {  {
129          clearscr();          clearscr();
# Line 211  int list_ex_section(void *param) Line 226  int list_ex_section(void *param)
226  {  {
227          SECTION_LIST *p_section;          SECTION_LIST *p_section;
228    
229          p_section = section_list_find_by_name(param, NULL);          p_section = section_list_find_by_name(param);
230          if (p_section == NULL)          if (p_section == NULL)
231          {          {
232                  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 241  int list_ex_section(void *param)
241          return REDRAW;          return REDRAW;
242  }  }
243    
244  int top10_menu(void *param)  int show_top10_menu(void *param)
245  {  {
246            static int show_top10 = 0;
247            int ch = 0;
248    
249            if (show_top10)
250            {
251                    return NOREDRAW;
252            }
253            show_top10 = 1;
254    
255            clearscr();
256            show_top("", BBS_name, "");
257            show_bottom("");
258    
259            if (display_menu(&top10_menu) == 0)
260            {
261                    while (!SYS_server_exit)
262                    {
263                            iflush();
264                            ch = igetch(100);
265    
266                            if (ch != KEY_NULL && ch != KEY_TIMEOUT)
267                            {
268                                    BBS_last_access_tm = time(NULL);
269                            }
270    
271                            switch (ch)
272                            {
273                            case KEY_NULL: // broken pipe
274                                    log_error("KEY_NULL\n");
275                                    show_top10 = 0;
276                                    return 0;
277                            case KEY_TIMEOUT:
278                                    if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)
279                                    {
280                                            log_error("User input timeout\n");
281                                            show_top10 = 0;
282                                            return 0;
283                                    }
284                                    continue;
285                            case CR:
286                            default:
287                                    switch (menu_control(&top10_menu, ch))
288                                    {
289                                    case EXITMENU:
290                                            ch = EXITMENU;
291                                            break;
292                                    case REDRAW:
293                                            clearscr();
294                                            show_bottom("");
295                                            display_menu(&top10_menu);
296                                            break;
297                                    case NOREDRAW:
298                                    case UNKNOWN_CMD:
299                                    default:
300                                            break;
301                                    }
302                            }
303    
304                            if (ch == EXITMENU)
305                            {
306                                    break;
307                            }
308                    }
309            }
310    
311            show_top10 = 0;
312          return REDRAW;          return REDRAW;
313  }  }
314    
315  int locate_article(void *param)  int locate_article(void *param)
316  {  {
317            char buf[MAX_MENUITEM_NAME_LENGTH];
318          char *sname, *aid, *saveptr;          char *sname, *aid, *saveptr;
319    
320          sname = strtok_r(param, " ", &saveptr);          strncpy(buf, param, sizeof(buf) - 1);
321          aid = strtok_r(NULL, " ", &saveptr);          buf[sizeof(buf) - 1] = '\0';
322    
323            sname = strtok_r(buf, "|", &saveptr);
324            aid = strtok_r(NULL, "|", &saveptr);
325    
326          if (sname == NULL || aid == NULL)          if (sname == NULL || aid == NULL)
327          {          {
328                  log_error("top10_locate() error: invalid parameter\n", (const char *)param);                  log_error("top10_locate(%s) error: invalid parameter\n", param);
329                  return NOREDRAW;                  return NOREDRAW;
330          }          }
331    
# Line 251  int locate_article(void *param) Line 336  int locate_article(void *param)
336    
337  int favor_topic(void *param)  int favor_topic(void *param)
338  {  {
339          clearscr();          if (article_favor_display(&BBS_article_favor) < 0)
340          prints("此功能尚未实现");          {
341          press_any_key();                  log_error("article_favor_display() error\n");
342            }
343    
344          return REDRAW;          return REDRAW;
345  }  }


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

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