| 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" |
| 11 |
#include "article_view_log.h" |
#include "article_view_log.h" |
| 12 |
#include "bbs.h" |
#include "bbs.h" |
| 13 |
#include "bbs_cmd.h" |
#include "bbs_cmd.h" |
| 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> |
| 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 |
|
|
| 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(); |
| 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(); |
| 221 |
{ |
{ |
| 222 |
SECTION_LIST *p_section; |
SECTION_LIST *p_section; |
| 223 |
|
|
| 224 |
p_section = section_list_find_by_name(param, NULL); |
p_section = section_list_find_by_name(param); |
| 225 |
if (p_section == NULL) |
if (p_section == NULL) |
| 226 |
{ |
{ |
| 227 |
log_error("Section %s not found\n", (const char *)param); |
log_error("Section %s not found\n", (const char *)param); |
| 246 |
return NOREDRAW; |
return NOREDRAW; |
| 247 |
} |
} |
| 248 |
show_top10 = 1; |
show_top10 = 1; |
| 249 |
|
|
| 250 |
clearscr(); |
clearscr(); |
| 251 |
show_top("", BBS_name, ""); |
show_top("", BBS_name, ""); |
| 252 |
show_bottom(""); |
show_bottom(""); |
| 257 |
{ |
{ |
| 258 |
iflush(); |
iflush(); |
| 259 |
ch = igetch(100); |
ch = igetch(100); |
| 260 |
|
|
| 261 |
|
if (ch != KEY_NULL && ch != KEY_TIMEOUT) |
| 262 |
|
{ |
| 263 |
|
BBS_last_access_tm = time(NULL); |
| 264 |
|
} |
| 265 |
|
|
| 266 |
switch (ch) |
switch (ch) |
| 267 |
{ |
{ |
| 268 |
case KEY_NULL: // broken pipe |
case KEY_NULL: // broken pipe |
| 269 |
|
log_error("KEY_NULL\n"); |
| 270 |
show_top10 = 0; |
show_top10 = 0; |
| 271 |
return 0; |
return 0; |
| 272 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 273 |
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time) |
| 274 |
{ |
{ |
| 275 |
|
log_error("User input timeout\n"); |
| 276 |
show_top10 = 0; |
show_top10 = 0; |
| 277 |
return 0; |
return 0; |
| 278 |
} |
} |
| 279 |
continue; |
continue; |
| 280 |
case CR: |
case CR: |
|
igetch_reset(); |
|
| 281 |
default: |
default: |
| 282 |
switch (menu_control(&top10_menu, ch)) |
switch (menu_control(&top10_menu, ch)) |
| 283 |
{ |
{ |
| 296 |
} |
} |
| 297 |
} |
} |
| 298 |
|
|
|
BBS_last_access_tm = time(NULL); |
|
|
|
|
| 299 |
if (ch == EXITMENU) |
if (ch == EXITMENU) |
| 300 |
{ |
{ |
| 301 |
break; |
break; |
| 302 |
} |
} |
| 303 |
} |
} |
| 304 |
} |
} |
| 305 |
|
|
| 306 |
show_top10 = 0; |
show_top10 = 0; |
| 307 |
return REDRAW; |
return REDRAW; |
| 308 |
} |
} |
| 331 |
|
|
| 332 |
int favor_topic(void *param) |
int favor_topic(void *param) |
| 333 |
{ |
{ |
| 334 |
clearscr(); |
if (article_favor_display(&BBS_article_favor) < 0) |
| 335 |
prints("此功能尚未实现"); |
{ |
| 336 |
press_any_key(); |
log_error("article_favor_display() error\n"); |
| 337 |
|
} |
| 338 |
|
|
| 339 |
|
return REDRAW; |
| 340 |
|
} |
| 341 |
|
|
| 342 |
|
int list_user(void *param) |
| 343 |
|
{ |
| 344 |
|
if (user_list_display(0) < 0) |
| 345 |
|
{ |
| 346 |
|
log_error("user_list_display(all_user) error\n"); |
| 347 |
|
} |
| 348 |
|
|
| 349 |
|
return REDRAW; |
| 350 |
|
} |
| 351 |
|
|
| 352 |
|
int list_online_user(void *param) |
| 353 |
|
{ |
| 354 |
|
if (user_list_display(1) < 0) |
| 355 |
|
{ |
| 356 |
|
log_error("user_list_display(online_user) error\n"); |
| 357 |
|
} |
| 358 |
|
|
| 359 |
|
return REDRAW; |
| 360 |
|
} |
| 361 |
|
|
| 362 |
|
int edit_intro(void *param) |
| 363 |
|
{ |
| 364 |
|
if (user_intro_edit(BBS_priv.uid) < 0) |
| 365 |
|
{ |
| 366 |
|
log_error("user_intro_edit(%d) error\n", BBS_priv.uid); |
| 367 |
|
} |
| 368 |
|
|
| 369 |
return REDRAW; |
return REDRAW; |
| 370 |
} |
} |