/[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.39 by sysadm, Fri Oct 17 01:25:08 2025 UTC Revision 1.48 by sysadm, Fri Nov 7 09:53:47 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"  #include "article_favor_display.h"
# Line 26  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 43  int list_section(void *param) Line 37  int list_section(void *param)
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 69  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 110  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 132  int reload_bbs_conf(void *param) Line 141  int reload_bbs_conf(void *param)
141    
142  int shutdown_bbs(void *param)  int shutdown_bbs(void *param)
143  {  {
144          log_common("Notify main process to exit\n");          char buf[2] = "N";
145    
146          if (kill(getppid(), SIGTERM) < 0)          clearscr();
147            get_data(1, 1, "真的要关闭系统吗[y/N]? ", buf, sizeof(buf), 1);
148    
149            if (toupper(buf[0]) == 'Y')
150          {          {
151                  log_error("Send SIGTERM signal failed (%d)\n", errno);                  log_common("Notify main process to exit by [%s]\n", BBS_username);
152    
153                    if (kill(getppid(), SIGTERM) < 0)
154                    {
155                            log_error("Send SIGTERM signal failed (%d)\n", errno);
156                    }
157          }          }
158    
159          return REDRAW;          return REDRAW;
# Line 261  int show_top10_menu(void *param) Line 278  int show_top10_menu(void *param)
278                                  show_top10 = 0;                                  show_top10 = 0;
279                                  return 0;                                  return 0;
280                          case KEY_TIMEOUT:                          case KEY_TIMEOUT:
281                                  if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)                                  if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)
282                                  {                                  {
283                                          log_error("User input timeout\n");                                          log_error("User input timeout\n");
284                                          show_top10 = 0;                                          show_top10 = 0;
# Line 328  int favor_topic(void *param) Line 345  int favor_topic(void *param)
345          }          }
346    
347          return REDRAW;          return REDRAW;
348    }
349    
350    int list_user(void *param)
351    {
352            if (user_list_display(0) < 0)
353            {
354                    log_error("user_list_display(all_user) error\n");
355            }
356    
357            return REDRAW;
358    }
359    
360    int list_online_user(void *param)
361    {
362            if (user_list_display(1) < 0)
363            {
364                    log_error("user_list_display(online_user) error\n");
365            }
366    
367            return REDRAW;
368    }
369    
370    int edit_intro(void *param)
371    {
372            if (user_intro_edit(BBS_priv.uid) < 0)
373            {
374                    log_error("user_intro_edit(%d) error\n", BBS_priv.uid);
375            }
376    
377            return REDRAW;
378  }  }


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

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