| 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" |
| 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_list_display.h" |
| 22 |
#include "user_priv.h" |
#include "user_priv.h" |
| 23 |
#include <dlfcn.h> |
#include <dlfcn.h> |
| 24 |
#include <errno.h> |
#include <errno.h> |
| 36 |
return REDRAW; |
return REDRAW; |
| 37 |
} |
} |
| 38 |
|
|
| 39 |
|
typedef union exec_handler_t |
| 40 |
|
{ |
| 41 |
|
void *p; |
| 42 |
|
int (*handler)(); |
| 43 |
|
} exec_handler; |
| 44 |
|
|
| 45 |
int exec_mbem(void *param) |
int exec_mbem(void *param) |
| 46 |
{ |
{ |
| 47 |
void *hdll; |
void *hdll; |
| 48 |
int (*func)(); |
exec_handler func; |
| 49 |
char *c, *s; |
char *c, *s; |
| 50 |
char buf[FILE_PATH_LEN]; |
char buf[FILE_PATH_LEN]; |
| 51 |
|
|
| 68 |
{ |
{ |
| 69 |
char *error; |
char *error; |
| 70 |
|
|
| 71 |
if ((func = dlsym(hdll, c ? c : "mod_main")) != NULL) |
if ((func.p = dlsym(hdll, c ? c : "mod_main")) != NULL) |
| 72 |
func(); |
{ |
| 73 |
|
func.handler(); |
| 74 |
|
} |
| 75 |
else if ((error = dlerror()) != NULL) |
else if ((error = dlerror()) != NULL) |
| 76 |
{ |
{ |
| 77 |
clearscr(); |
clearscr(); |
| 111 |
return REDRAW; |
return REDRAW; |
| 112 |
} |
} |
| 113 |
|
|
| 114 |
|
int version(void *param) |
| 115 |
|
{ |
| 116 |
|
display_file(DATA_VERSION, 1); |
| 117 |
|
|
| 118 |
|
return REDRAW; |
| 119 |
|
} |
| 120 |
|
|
| 121 |
int reload_bbs_conf(void *param) |
int reload_bbs_conf(void *param) |
| 122 |
{ |
{ |
| 123 |
clearscr(); |
clearscr(); |
| 245 |
return NOREDRAW; |
return NOREDRAW; |
| 246 |
} |
} |
| 247 |
show_top10 = 1; |
show_top10 = 1; |
| 248 |
|
|
| 249 |
clearscr(); |
clearscr(); |
| 250 |
show_top("", BBS_name, ""); |
show_top("", BBS_name, ""); |
| 251 |
show_bottom(""); |
show_bottom(""); |
| 256 |
{ |
{ |
| 257 |
iflush(); |
iflush(); |
| 258 |
ch = igetch(100); |
ch = igetch(100); |
| 259 |
|
|
| 260 |
|
if (ch != KEY_NULL && ch != KEY_TIMEOUT) |
| 261 |
|
{ |
| 262 |
|
BBS_last_access_tm = time(NULL); |
| 263 |
|
} |
| 264 |
|
|
| 265 |
switch (ch) |
switch (ch) |
| 266 |
{ |
{ |
| 267 |
case KEY_NULL: // broken pipe |
case KEY_NULL: // broken pipe |
| 268 |
|
log_error("KEY_NULL\n"); |
| 269 |
show_top10 = 0; |
show_top10 = 0; |
| 270 |
return 0; |
return 0; |
| 271 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 272 |
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
| 273 |
{ |
{ |
| 274 |
|
log_error("User input timeout\n"); |
| 275 |
show_top10 = 0; |
show_top10 = 0; |
| 276 |
return 0; |
return 0; |
| 277 |
} |
} |
| 278 |
continue; |
continue; |
| 279 |
case CR: |
case CR: |
|
igetch_reset(); |
|
| 280 |
default: |
default: |
| 281 |
switch (menu_control(&top10_menu, ch)) |
switch (menu_control(&top10_menu, ch)) |
| 282 |
{ |
{ |
| 295 |
} |
} |
| 296 |
} |
} |
| 297 |
|
|
|
BBS_last_access_tm = time(NULL); |
|
|
|
|
| 298 |
if (ch == EXITMENU) |
if (ch == EXITMENU) |
| 299 |
{ |
{ |
| 300 |
break; |
break; |
| 301 |
} |
} |
| 302 |
} |
} |
| 303 |
} |
} |
| 304 |
|
|
| 305 |
show_top10 = 0; |
show_top10 = 0; |
| 306 |
return REDRAW; |
return REDRAW; |
| 307 |
} |
} |
| 336 |
} |
} |
| 337 |
|
|
| 338 |
return REDRAW; |
return REDRAW; |
| 339 |
|
} |
| 340 |
|
|
| 341 |
|
int list_user(void *param) |
| 342 |
|
{ |
| 343 |
|
if (user_list_display(0) < 0) |
| 344 |
|
{ |
| 345 |
|
log_error("user_list_display(all_user) error\n"); |
| 346 |
|
} |
| 347 |
|
|
| 348 |
|
return REDRAW; |
| 349 |
|
} |
| 350 |
|
|
| 351 |
|
int list_online_user(void *param) |
| 352 |
|
{ |
| 353 |
|
if (user_list_display(1) < 0) |
| 354 |
|
{ |
| 355 |
|
log_error("user_list_display(online_user) error\n"); |
| 356 |
|
} |
| 357 |
|
|
| 358 |
|
return REDRAW; |
| 359 |
} |
} |