| 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" |
| 38 |
|
|
| 39 |
int list_section(void *param) |
int list_section(void *param) |
| 40 |
{ |
{ |
| 41 |
section_list_display(param); |
section_list_display(param, 0); |
| 42 |
|
|
| 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 |
|
|
| 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(); |
| 89 |
else |
else |
| 90 |
{ |
{ |
| 91 |
clearscr(); |
clearscr(); |
| 92 |
prints("ؿļ [%s] ʧ!!\r\n", s + 5); |
prints("加载库文件 [%s] 失败!!\r\n", s + 5); |
| 93 |
prints("ʧԭ:%s\r\n", dlerror()); |
prints("失败原因:%s\r\n", dlerror()); |
| 94 |
press_any_key(); |
press_any_key(); |
| 95 |
} |
} |
| 96 |
} |
} |
| 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(); |
| 132 |
{ |
{ |
| 133 |
log_error("Send SIGHUP signal failed (%d)\n", errno); |
log_error("Send SIGHUP signal failed (%d)\n", errno); |
| 134 |
|
|
| 135 |
prints("ָʧ\r\n"); |
prints("发送指令失败\r\n"); |
| 136 |
} |
} |
| 137 |
else |
else |
| 138 |
{ |
{ |
| 139 |
prints("ѷָ\r\n"); |
prints("已发送指令\r\n"); |
| 140 |
} |
} |
| 141 |
|
|
| 142 |
press_any_key(); |
press_any_key(); |
| 156 |
return REDRAW; |
return REDRAW; |
| 157 |
} |
} |
| 158 |
|
|
| 159 |
int favour_section_filter(void *param) |
int favor_section_filter(void *param) |
| 160 |
{ |
{ |
| 161 |
MENU_ITEM *p_menu_item = param; |
MENU_ITEM *p_menu_item = param; |
| 162 |
|
|
| 169 |
{ |
{ |
| 170 |
case 0: // Set msg |
case 0: // Set msg |
| 171 |
snprintf(p_ctx->msg, sizeof(p_ctx->msg), |
snprintf(p_ctx->msg, sizeof(p_ctx->msg), |
| 172 |
"| [\033[32m\033[33m,\033[32mESC\033[33m] | " |
"| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] | " |
| 173 |
"ƶ[\033[32m\033[33m/\033[32m\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] | " |
"移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] | " |
| 174 |
"[\033[32mh\033[33m] |"); |
"帮助[\033[32mh\033[33m] |"); |
| 175 |
break; |
break; |
| 176 |
} |
} |
| 177 |
|
|
| 239 |
} |
} |
| 240 |
|
|
| 241 |
return REDRAW; |
return REDRAW; |
| 242 |
|
} |
| 243 |
|
|
| 244 |
|
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; |
| 313 |
|
} |
| 314 |
|
|
| 315 |
|
int locate_article(void *param) |
| 316 |
|
{ |
| 317 |
|
char buf[MAX_MENUITEM_NAME_LENGTH]; |
| 318 |
|
char *sname, *aid, *saveptr; |
| 319 |
|
|
| 320 |
|
strncpy(buf, param, sizeof(buf) - 1); |
| 321 |
|
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) |
| 327 |
|
{ |
| 328 |
|
log_error("top10_locate(%s) error: invalid parameter\n", param); |
| 329 |
|
return NOREDRAW; |
| 330 |
|
} |
| 331 |
|
|
| 332 |
|
section_list_display(sname, atoi(aid)); |
| 333 |
|
|
| 334 |
|
return REDRAW; |
| 335 |
|
} |
| 336 |
|
|
| 337 |
|
int favor_topic(void *param) |
| 338 |
|
{ |
| 339 |
|
if (article_favor_display(&BBS_article_favor) < 0) |
| 340 |
|
{ |
| 341 |
|
log_error("article_favor_display() error\n"); |
| 342 |
|
} |
| 343 |
|
|
| 344 |
|
return REDRAW; |
| 345 |
} |
} |