| 14 |
* * |
* * |
| 15 |
***************************************************************************/ |
***************************************************************************/ |
| 16 |
|
|
| 17 |
#include "bbs_main.h" |
#include "article_view_log.h" |
| 18 |
#include "bbs.h" |
#include "bbs.h" |
| 19 |
#include "login.h" |
#include "bbs_cmd.h" |
| 20 |
#include "user_priv.h" |
#include "bbs_main.h" |
| 21 |
#include "common.h" |
#include "common.h" |
| 22 |
#include "database.h" |
#include "database.h" |
| 23 |
#include "article_view_log.h" |
#include "editor.h" |
|
#include "log.h" |
|
| 24 |
#include "io.h" |
#include "io.h" |
| 25 |
#include "screen.h" |
#include "log.h" |
| 26 |
|
#include "login.h" |
| 27 |
#include "menu.h" |
#include "menu.h" |
| 28 |
#include "bbs_cmd.h" |
#include "screen.h" |
| 29 |
#include "section_list.h" |
#include "section_list.h" |
| 30 |
#include "trie_dict.h" |
#include "trie_dict.h" |
| 31 |
#include "editor.h" |
#include "user_priv.h" |
| 32 |
#include <unistd.h> |
#include <errno.h> |
| 33 |
#include <time.h> |
#include <signal.h> |
|
#include <string.h> |
|
| 34 |
#include <stdlib.h> |
#include <stdlib.h> |
| 35 |
|
#include <string.h> |
| 36 |
|
#include <time.h> |
| 37 |
|
#include <unistd.h> |
| 38 |
|
|
| 39 |
int bbs_info() |
int bbs_info() |
| 40 |
{ |
{ |
| 206 |
show_top("", BBS_name, ""); |
show_top("", BBS_name, ""); |
| 207 |
show_active_board(); |
show_active_board(); |
| 208 |
show_bottom(""); |
show_bottom(""); |
| 209 |
display_menu(p_bbs_menu); |
display_menu(&bbs_menu); |
| 210 |
iflush(); |
iflush(); |
| 211 |
|
|
| 212 |
while (!SYS_server_exit) |
while (!SYS_server_exit) |
| 213 |
{ |
{ |
| 214 |
ch = igetch(100); |
ch = igetch(100); |
| 215 |
|
|
| 216 |
if (p_bbs_menu->choose_step == 0 && time(NULL) - t_last_action >= 10) |
if (bbs_menu.choose_step == 0 && time(NULL) - t_last_action >= 10) |
| 217 |
{ |
{ |
| 218 |
t_last_action = time(NULL); |
t_last_action = time(NULL); |
| 219 |
|
|
| 220 |
show_active_board(); |
show_active_board(); |
| 221 |
show_bottom(""); |
show_bottom(""); |
| 222 |
display_menu_cursor(p_bbs_menu, 1); |
display_menu_cursor(&bbs_menu, 1); |
| 223 |
iflush(); |
iflush(); |
| 224 |
} |
} |
| 225 |
|
|
| 241 |
case CR: |
case CR: |
| 242 |
igetch_reset(); |
igetch_reset(); |
| 243 |
default: |
default: |
| 244 |
switch (menu_control(p_bbs_menu, ch)) |
switch (menu_control(&bbs_menu, ch)) |
| 245 |
{ |
{ |
| 246 |
case EXITBBS: |
case EXITBBS: |
| 247 |
|
case EXITMENU: |
| 248 |
return 0; |
return 0; |
| 249 |
case REDRAW: |
case REDRAW: |
| 250 |
t_last_action = time(NULL); |
t_last_action = time(NULL); |
| 252 |
show_top("", BBS_name, ""); |
show_top("", BBS_name, ""); |
| 253 |
show_active_board(); |
show_active_board(); |
| 254 |
show_bottom(""); |
show_bottom(""); |
| 255 |
display_menu(p_bbs_menu); |
display_menu(&bbs_menu); |
| 256 |
break; |
break; |
| 257 |
case NOREDRAW: |
case NOREDRAW: |
| 258 |
case UNKNOWN_CMD: |
case UNKNOWN_CMD: |
| 270 |
|
|
| 271 |
int bbs_main() |
int bbs_main() |
| 272 |
{ |
{ |
| 273 |
|
struct sigaction act = {0}; |
| 274 |
|
|
| 275 |
|
// Set signal handler |
| 276 |
|
act.sa_handler = SIG_IGN; |
| 277 |
|
if (sigaction(SIGHUP, &act, NULL) == -1) |
| 278 |
|
{ |
| 279 |
|
log_error("set signal action of SIGHUP error: %d\n", errno); |
| 280 |
|
goto cleanup; |
| 281 |
|
} |
| 282 |
|
act.sa_handler = SIG_DFL; |
| 283 |
|
if (sigaction(SIGCHLD, &act, NULL) == -1) |
| 284 |
|
{ |
| 285 |
|
log_error("set signal action of SIGCHLD error: %d\n", errno); |
| 286 |
|
goto cleanup; |
| 287 |
|
} |
| 288 |
|
|
| 289 |
// Set data pools in shared memory readonly |
// Set data pools in shared memory readonly |
| 290 |
if (set_trie_dict_shm_readonly() < 0) |
if (set_trie_dict_shm_readonly() < 0) |
| 291 |
{ |
{ |
| 301 |
} |
} |
| 302 |
|
|
| 303 |
// Load menu in shared memory |
// Load menu in shared memory |
| 304 |
if (set_menu_shm_readonly(p_bbs_menu) < 0) |
if (set_menu_shm_readonly(&bbs_menu) < 0) |
| 305 |
{ |
{ |
| 306 |
goto cleanup; |
goto cleanup; |
| 307 |
} |
} |
| 371 |
article_view_log_unload(&BBS_article_view_log); |
article_view_log_unload(&BBS_article_view_log); |
| 372 |
|
|
| 373 |
// Detach menu in shared memory |
// Detach menu in shared memory |
| 374 |
detach_menu_shm(p_bbs_menu); |
detach_menu_shm(&bbs_menu); |
|
free(p_bbs_menu); |
|
|
p_bbs_menu = NULL; |
|
| 375 |
|
|
| 376 |
// Detach data pools shm |
// Detach data pools shm |
| 377 |
detach_section_list_shm(); |
detach_section_list_shm(); |