| 1 |
/*************************************************************************** |
/*************************************************************************** |
| 2 |
menu_proc.c - description |
menu_proc.c - description |
| 3 |
------------------- |
------------------- |
| 4 |
begin : Fri May 6 2005 |
begin : Fri May 6 2005 |
| 5 |
copyright : (C) 2005 by Leaflet |
copyright : (C) 2005 by Leaflet |
| 6 |
email : leaflet@leafok.com |
email : leaflet@leafok.com |
| 7 |
***************************************************************************/ |
***************************************************************************/ |
| 8 |
|
|
| 9 |
/*************************************************************************** |
/*************************************************************************** |
| 20 |
#include "common.h" |
#include "common.h" |
| 21 |
#include "io.h" |
#include "io.h" |
| 22 |
#include <dlfcn.h> |
#include <dlfcn.h> |
| 23 |
#include <time.h> |
#include <errno.h> |
| 24 |
|
#include <signal.h> |
| 25 |
#include <string.h> |
#include <string.h> |
| 26 |
|
#include <sys/types.h> |
| 27 |
|
#include <time.h> |
| 28 |
|
#include <unistd.h> |
| 29 |
|
|
| 30 |
|
int exec_mbem(const char *str) |
| 31 |
|
{ |
| 32 |
|
void *hdll; |
| 33 |
|
int (*func)(); |
| 34 |
|
char *c, *s; |
| 35 |
|
char buf[1024]; |
| 36 |
|
|
| 37 |
|
strcpy(buf, str); |
| 38 |
|
s = strstr(buf, "@mod:"); |
| 39 |
|
if (s) |
| 40 |
|
{ |
| 41 |
|
c = strstr(s + 5, "#"); |
| 42 |
|
if (c) |
| 43 |
|
{ |
| 44 |
|
*c = 0; |
| 45 |
|
c++; |
| 46 |
|
} |
| 47 |
|
|
| 48 |
|
hdll = dlopen(s + 5, RTLD_LAZY); |
| 49 |
|
|
| 50 |
|
if (hdll) |
| 51 |
|
{ |
| 52 |
|
char *error; |
| 53 |
|
|
| 54 |
|
if ((func = dlsym(hdll, c ? c : "mod_main")) != NULL) |
| 55 |
|
func(); |
| 56 |
|
else if ((error = dlerror()) != NULL) |
| 57 |
|
{ |
| 58 |
|
clearscr(); |
| 59 |
|
prints("%s\r\n", error); |
| 60 |
|
press_any_key(); |
| 61 |
|
} |
| 62 |
|
dlclose(hdll); |
| 63 |
|
} |
| 64 |
|
else |
| 65 |
|
{ |
| 66 |
|
clearscr(); |
| 67 |
|
prints("加载库文件 [%s] 失败!!\r\n", s + 5); |
| 68 |
|
prints("失败原因:%s\r\n", dlerror()); |
| 69 |
|
press_any_key(); |
| 70 |
|
} |
| 71 |
|
} |
| 72 |
|
|
| 73 |
|
return REDRAW; |
| 74 |
|
} |
| 75 |
|
|
| 76 |
int |
int exitbbs(const char *s) |
|
exec_mbem(const char *str) |
|
| 77 |
{ |
{ |
| 78 |
void *hdll; |
return EXITBBS; |
|
int (*func) (); |
|
|
char *c,*s; |
|
|
char buf[1024]; |
|
|
|
|
|
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; |
|
| 79 |
} |
} |
| 80 |
|
|
| 81 |
int |
int license(const char *s) |
|
exitbbs (const char *s) |
|
| 82 |
{ |
{ |
| 83 |
return EXITBBS; |
char temp[256]; |
| 84 |
|
|
| 85 |
|
strcpy(temp, app_home_dir); |
| 86 |
|
strcat(temp, "data/license.txt"); |
| 87 |
|
display_file_ex(temp, 0, 1); |
| 88 |
|
|
| 89 |
|
return REDRAW; |
| 90 |
} |
} |
| 91 |
|
|
| 92 |
int |
int copyright(const char *s) |
|
license (const char *s) |
|
| 93 |
{ |
{ |
| 94 |
char temp[256]; |
char temp[256]; |
|
|
|
|
strcpy (temp, app_home_dir); |
|
|
strcat (temp, "data/license.txt"); |
|
|
display_file_ex (temp, 0, 1); |
|
| 95 |
|
|
| 96 |
return REDRAW; |
strcpy(temp, app_home_dir); |
| 97 |
|
strcat(temp, "data/copyright.txt"); |
| 98 |
|
display_file_ex(temp, 0, 1); |
| 99 |
|
|
| 100 |
|
return REDRAW; |
| 101 |
} |
} |
| 102 |
|
|
| 103 |
int |
int reloadbbsmenu(const char *s) |
|
copyright (const char *s) |
|
| 104 |
{ |
{ |
| 105 |
char temp[256]; |
if (kill(getppid(), SIG_RELOAD_MENU) < 0) |
| 106 |
|
log_error("Send SIG_RELOAD_MENU signal failed (%d)\n", errno); |
|
strcpy (temp, app_home_dir); |
|
|
strcat (temp, "data/copyright.txt"); |
|
|
display_file_ex (temp, 0, 1); |
|
| 107 |
|
|
| 108 |
return REDRAW; |
return REDRAW; |
| 109 |
} |
} |
| 110 |
|
|
| 111 |
int |
int shutdownbbs(const char *s) |
|
notify_reload_menu (const char *s) |
|
| 112 |
{ |
{ |
| 113 |
kill (0, SIG_RELOAD_MENU); |
if (kill(0, SIGTERM) < 0) |
| 114 |
|
log_error("Send SIGTERM signal failed (%d)\n", errno); |
| 115 |
|
|
| 116 |
return REDRAW; |
return REDRAW; |
| 117 |
} |
} |