/[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.36 by sysadm, Tue Oct 14 00:57:06 2025 UTC Revision 1.51 by sysadm, Tue Nov 11 10:54:22 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     */
8  /***************************************************************************  
9   *                                                                         *  #ifdef HAVE_CONFIG_H
10   *   This program is free software; you can redistribute it and/or modify  *  #include "config.h"
11   *   it under the terms of the GNU General Public License as published by  *  #endif
  *   the Free Software Foundation; either version 3 of the License, or     *  
  *   (at your option) any later version.                                   *  
  *                                                                         *  
  ***************************************************************************/  
12    
13  #include "article_cache.h"  #include "article_cache.h"
14    #include "article_favor_display.h"
15  #include "article_view_log.h"  #include "article_view_log.h"
16  #include "bbs.h"  #include "bbs.h"
17  #include "bbs_cmd.h"  #include "bbs_cmd.h"
# Line 25  Line 22 
22  #include "menu.h"  #include "menu.h"
23  #include "section_list_display.h"  #include "section_list_display.h"
24  #include "screen.h"  #include "screen.h"
25    #include "user_info_update.h"
26    #include "user_list_display.h"
27  #include "user_priv.h"  #include "user_priv.h"
28    #include <ctype.h>
29  #include <dlfcn.h>  #include <dlfcn.h>
30  #include <errno.h>  #include <errno.h>
31  #include <signal.h>  #include <signal.h>
# Line 42  int list_section(void *param) Line 42  int list_section(void *param)
42          return REDRAW;          return REDRAW;
43  }  }
44    
45    typedef union exec_handler_t
46    {
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 131  int reload_bbs_conf(void *param) Line 146  int reload_bbs_conf(void *param)
146    
147  int shutdown_bbs(void *param)  int shutdown_bbs(void *param)
148  {  {
149          log_common("Notify main process to exit\n");          char buf[2] = "N";
150    
151            clearscr();
152            get_data(1, 1, "真的要关闭系统吗[y/N]? ", buf, sizeof(buf), 1);
153    
154          if (kill(getppid(), SIGTERM) < 0)          if (toupper(buf[0]) == 'Y')
155          {          {
156                  log_error("Send SIGTERM signal failed (%d)\n", errno);                  log_common("Notify main process to exit by [%s]\n", BBS_username);
157    
158                    if (kill(getppid(), SIGTERM) < 0)
159                    {
160                            log_error("Send SIGTERM signal failed (%d)\n", errno);
161                    }
162          }          }
163    
164          return REDRAW;          return REDRAW;
# Line 236  int show_top10_menu(void *param) Line 259  int show_top10_menu(void *param)
259                  return NOREDRAW;                  return NOREDRAW;
260          }          }
261          show_top10 = 1;          show_top10 = 1;
262            
263          clearscr();          clearscr();
264          show_top("", BBS_name, "");          show_top("", BBS_name, "");
265          show_bottom("");          show_bottom("");
# Line 247  int show_top10_menu(void *param) Line 270  int show_top10_menu(void *param)
270                  {                  {
271                          iflush();                          iflush();
272                          ch = igetch(100);                          ch = igetch(100);
273    
274                            if (ch != KEY_NULL && ch != KEY_TIMEOUT)
275                            {
276                                    BBS_last_access_tm = time(NULL);
277                            }
278    
279                          switch (ch)                          switch (ch)
280                          {                          {
281                          case KEY_NULL: // broken pipe                          case KEY_NULL: // broken pipe
282                                    log_error("KEY_NULL\n");
283                                  show_top10 = 0;                                  show_top10 = 0;
284                                  return 0;                                  return 0;
285                          case KEY_TIMEOUT:                          case KEY_TIMEOUT:
286                                  if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)                                  if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)
287                                  {                                  {
288                                            log_error("User input timeout\n");
289                                          show_top10 = 0;                                          show_top10 = 0;
290                                          return 0;                                          return 0;
291                                  }                                  }
292                                  continue;                                  continue;
293                          case CR:                          case CR:
                                 igetch_reset();  
294                          default:                          default:
295                                  switch (menu_control(&top10_menu, ch))                                  switch (menu_control(&top10_menu, ch))
296                                  {                                  {
# Line 279  int show_top10_menu(void *param) Line 309  int show_top10_menu(void *param)
309                                  }                                  }
310                          }                          }
311    
                         BBS_last_access_tm = time(NULL);  
   
312                          if (ch == EXITMENU)                          if (ch == EXITMENU)
313                          {                          {
314                                  break;                                  break;
315                          }                          }
316                  }                  }
317          }          }
318            
319          show_top10 = 0;          show_top10 = 0;
320          return REDRAW;          return REDRAW;
321  }  }
# Line 316  int locate_article(void *param) Line 344  int locate_article(void *param)
344    
345  int favor_topic(void *param)  int favor_topic(void *param)
346  {  {
347          clearscr();          if (article_favor_display(&BBS_article_favor) < 0)
348          prints("此功能尚未实现");          {
349          press_any_key();                  log_error("article_favor_display() error\n");
350            }
351    
352            return REDRAW;
353    }
354    
355    int list_user(void *param)
356    {
357            if (user_list_display(0) < 0)
358            {
359                    log_error("user_list_display(all_user) error\n");
360            }
361    
362            return REDRAW;
363    }
364    
365    int list_online_user(void *param)
366    {
367            if (user_list_display(1) < 0)
368            {
369                    log_error("user_list_display(online_user) error\n");
370            }
371    
372            return REDRAW;
373    }
374    
375    int edit_intro(void *param)
376    {
377            if (user_intro_edit(BBS_priv.uid) < 0)
378            {
379                    log_error("user_intro_edit(%d) error\n", BBS_priv.uid);
380            }
381    
382            return REDRAW;
383    }
384    
385    int edit_sign(void *param)
386    {
387            if (user_sign_edit(BBS_priv.uid) < 0)
388            {
389                    log_error("user_sign_edit(%d) error\n", BBS_priv.uid);
390            }
391    
392          return REDRAW;          return REDRAW;
393  }  }


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

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