/[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.2 by sysadm, Fri May 6 16:15:28 2005 UTC Revision 1.12 by sysadm, Thu May 8 08:05:58 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2                            menu_proc.c  -  description                                                    menu_proc.c  -  description
3                               -------------------                                                           -------------------
4      begin                : Fri May 6 2005          Copyright            : (C) 2004-2025 by Leaflet
5      copyright            : (C) 2005 by Leaflet          Email                : leaflet@leafok.com
     email                : leaflet@leafok.com  
6   ***************************************************************************/   ***************************************************************************/
7    
8  /***************************************************************************  /***************************************************************************
9   *                                                                         *   *                                                                         *
10   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
11   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
12   *   the Free Software Foundation; either version 2 of the License, or     *   *   the Free Software Foundation; either version 3 of the License, or     *
13   *   (at your option) any later version.                                   *   *   (at your option) any later version.                                   *
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
# Line 18  Line 17 
17  #include "bbs.h"  #include "bbs.h"
18  #include "bbs_cmd.h"  #include "bbs_cmd.h"
19  #include "common.h"  #include "common.h"
20    #include "log.h"
21  #include "io.h"  #include "io.h"
22    #include "screen.h"
23    #include "menu.h"
24  #include <dlfcn.h>  #include <dlfcn.h>
25  #include <time.h>  #include <errno.h>
26    #include <signal.h>
27  #include <string.h>  #include <string.h>
28    #include <sys/types.h>
29    #include <time.h>
30    #include <unistd.h>
31    
32    int exec_mbem(const char *str)
33    {
34            void *hdll;
35            int (*func)();
36            char *c, *s;
37            char buf[FILE_PATH_LEN];
38    
39            strncpy(buf, str, sizeof(buf) - 1);
40            buf[sizeof(buf) - 1] = '\0';
41    
42            s = strstr(buf, "@mod:");
43            if (s)
44            {
45                    c = strstr(s + 5, "#");
46                    if (c)
47                    {
48                            *c = 0;
49                            c++;
50                    }
51    
52                    hdll = dlopen(s + 5, RTLD_LAZY);
53    
54                    if (hdll)
55                    {
56                            char *error;
57    
58                            if ((func = dlsym(hdll, c ? c : "mod_main")) != NULL)
59                                    func();
60                            else if ((error = dlerror()) != NULL)
61                            {
62                                    clearscr();
63                                    prints("%s\r\n", error);
64                                    press_any_key();
65                            }
66                            dlclose(hdll);
67                    }
68                    else
69                    {
70                            clearscr();
71                            prints("加载库文件 [%s] 失败!!\r\n", s + 5);
72                            prints("失败原因:%s\r\n", dlerror());
73                            press_any_key();
74                    }
75            }
76    
77            return REDRAW;
78    }
79    
80  int  int exitbbs(const char *s)
 exec_mbem(const char *str)  
81  {  {
82      void *hdll;          return EXITBBS;
83      int (*func) ();  }
84      char *c,*s;  
85      char buf[1024];  int license(const char *s)
   
     strcpy(buf, str);  
     s = strstr(buf, "@mod:");  
     if (s) {  
         c = strstr(s + 5, "#");  
         if (c) {  
             *c = 0;  
             c++;  
         }  
   
         hdll = dlopen (s + 5, RTLD_LAZY);  
   
         if (hdll) {  
             char *error;  
   
             if ((func = dlsym (hdll, c ? c : "mod_main")) != NULL)  
                 func ();  
             else if ((error = dlerror ()) != NULL) {  
                 clearscr ();  
                 prints ("%s\r\n", error);  
                 press_any_key ();  
             }  
             dlclose (hdll);  
         } else {  
             clearscr ();  
             prints ("加载库文件 [%s] 失败!!\r\n", s + 5);  
             prints ("失败原因:%s\r\n", dlerror());  
             press_any_key ();  
         }  
     }  
   
         return REDRAW;  
 }  
   
 int  
 exitbbs (const char *s)  
86  {  {
87          return EXITBBS;          display_file_ex(DATA_LICENSE, 1, 1);
88    
89            return REDRAW;
90  }  }
91    
92  int  int copyright(const char *s)
 license (const char *s)  
93  {  {
94          char temp[256];          display_file_ex(DATA_COPYRIGHT, 1, 1);
           
     strcpy (temp, app_home_dir);  
     strcat (temp, "data/license.txt");  
     display_file_ex (temp, 0, 1);  
95    
96          return REDRAW;          return REDRAW;
97  }  }
98    
99  int  int reloadbbsmenu(const char *s)
 copyright (const char *s)  
100  {  {
101          char temp[256];          MENU_SET new_menu;
102    
103            clearscr();
104    
105            if (load_menu(&new_menu, CONF_MENU) < 0)
106            {
107                    log_error("Reload menu failed\n");
108    
109                    unload_menu(&new_menu);
110    
111                    prints("菜单配置校验失败\r\n");
112            }
113            else
114            {
115                    unload_menu(&new_menu);
116    
117                    if (kill(getppid(), SIG_RELOAD_MENU) < 0)
118                    {
119                            log_error("Send SIG_RELOAD_MENU signal failed (%d)\n", errno);
120                    
121      strcpy (temp, app_home_dir);                          prints("发送指令失败\r\n");
122      strcat (temp, "data/copyright.txt");                  }
123      display_file_ex (temp, 0, 1);                  else
124                    {
125                            prints("已发送指令\r\n");
126                    }
127            }
128    
129            press_any_key();
130    
131            return REDRAW;
132    }
133    
134    int shutdownbbs(const char *s)
135    {
136            if (kill(0, SIGTERM) < 0)
137            {
138                    log_error("Send SIGTERM signal failed (%d)\n", errno);
139            }
140    
141          return REDRAW;          return REDRAW;
142  }  }


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

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