| 18 |
#include "bbs.h" |
#include "bbs.h" |
| 19 |
#include "common.h" |
#include "common.h" |
| 20 |
#include "io.h" |
#include "io.h" |
| 21 |
|
#include "menu.h" |
| 22 |
|
#include "bbs_cmd.h" |
| 23 |
|
#include <time.h> |
| 24 |
|
#include <string.h> |
| 25 |
|
|
| 26 |
int |
int |
| 27 |
bbs_main() |
bbs_main () |
| 28 |
{ |
{ |
| 29 |
char temp[256]; |
char temp[256]; |
| 30 |
int ret; |
int ret; |
| 31 |
|
|
| 32 |
|
set_input_echo (0); |
| 33 |
|
|
| 34 |
|
bbs_info (); |
| 35 |
|
|
| 36 |
//Welcome |
//Welcome |
| 37 |
bbs_info(); |
bbs_welcome (); |
|
bbs_welcome(); |
|
| 38 |
|
|
| 39 |
//Login |
//Login |
| 40 |
ret = bbs_login(); |
ret = bbs_login (); |
| 41 |
if (ret < 0) |
if (ret < 0) |
| 42 |
return -1; |
return -1; |
| 43 |
|
log_std ("User \"%s\"(%ld) login from %s:%d\n", |
| 44 |
//Show information |
BBS_username, BBS_priv.uid, hostaddr_client, port_client); |
| 45 |
|
clearscr (); |
| 46 |
|
|
| 47 |
|
//BBS Top 10 |
| 48 |
strcpy (temp, app_home_dir); |
strcpy (temp, app_home_dir); |
| 49 |
strcat (temp, "data/bbs_top.txt"); |
strcat (temp, "data/bbs_top.txt"); |
| 50 |
clearscr(); |
display_file_ex (temp, 1, 1); |
|
display_file(temp); |
|
|
press_any_key(); |
|
| 51 |
|
|
| 52 |
//Main |
//Main |
| 53 |
bbs_center(); |
bbs_center (); |
| 54 |
|
|
| 55 |
//Logout |
//Logout |
| 56 |
bbs_exit(); |
bbs_exit (); |
| 57 |
|
log_std ("User logout\n"); |
| 58 |
|
|
| 59 |
return 0; |
return 0; |
| 60 |
} |
} |
| 61 |
|
|
| 62 |
int |
int |
| 63 |
bbs_info() |
bbs_info () |
| 64 |
{ |
{ |
| 65 |
prints( |
prints ("������ \033[1;33m%s \033[32m[%s] \033[37m( %s )\r\n", |
| 66 |
"\033[1;37m»¶Ó¹âÁÙ \033[33m%s \033[32m[%s] \033[37m( %s )\r\n", |
BBS_name, BBS_server, app_version); |
| 67 |
BBS_name, BBS_server, app_version); |
|
| 68 |
|
iflush (); |
|
iflush(); |
|
| 69 |
|
|
| 70 |
return 0; |
return 0; |
| 71 |
} |
} |
| 72 |
|
|
| 73 |
int |
int |
| 74 |
bbs_exit() |
bbs_exit () |
| 75 |
{ |
{ |
| 76 |
prints("\033[0;37m\r\n"); |
char temp[256]; |
| 77 |
iflush(); |
|
| 78 |
|
strcpy (temp, app_home_dir); |
| 79 |
|
strcat (temp, "data/goodbye.txt"); |
| 80 |
|
display_file_ex (temp, 1, 0); |
| 81 |
|
|
| 82 |
|
sleep (1); |
| 83 |
|
|
|
sleep(1); |
|
|
|
|
| 84 |
return 0; |
return 0; |
| 85 |
} |
} |
| 86 |
|
|
| 87 |
int |
int |
| 88 |
bbs_center() |
bbs_center () |
| 89 |
{ |
{ |
| 90 |
show_top(); |
int ch, result, redraw; |
| 91 |
|
char temp[256]; |
| 92 |
|
time_t t_last_action; |
| 93 |
|
|
| 94 |
|
BBS_last_access_tm = t_last_action = time (0); |
| 95 |
|
|
| 96 |
|
clearscr (); |
| 97 |
|
|
| 98 |
show_bottom(); |
show_top (""); |
| 99 |
|
show_active_board (); |
| 100 |
|
show_bottom (""); |
| 101 |
|
display_menu (get_menu (&bbs_menu, "TOPMENU")); |
| 102 |
|
|
| 103 |
|
while (1) |
| 104 |
|
{ |
| 105 |
|
ch = igetch (); |
| 106 |
|
|
| 107 |
|
if (time (0) - t_last_action >= 10) |
| 108 |
|
{ |
| 109 |
|
t_last_action = time (0); |
| 110 |
|
show_active_board (); |
| 111 |
|
show_bottom (""); |
| 112 |
|
} |
| 113 |
|
|
| 114 |
|
switch (ch) |
| 115 |
|
{ |
| 116 |
|
case KEY_NULL: |
| 117 |
|
return 0; |
| 118 |
|
case KEY_TIMEOUT: |
| 119 |
|
if (time (0) - BBS_last_access_tm >= MAX_DELAY_TIME) |
| 120 |
|
{ |
| 121 |
|
return -1; |
| 122 |
|
} |
| 123 |
|
continue; |
| 124 |
|
default: |
| 125 |
|
redraw = 1; |
| 126 |
|
switch (menu_control (&bbs_menu, ch)) |
| 127 |
|
{ |
| 128 |
|
case EXITBBS: |
| 129 |
|
return 0; |
| 130 |
|
case REDRAW: |
| 131 |
|
break; |
| 132 |
|
case NOREDRAW: |
| 133 |
|
case UNKNOWN_CMD: |
| 134 |
|
default: |
| 135 |
|
redraw = 0; |
| 136 |
|
break; |
| 137 |
|
} |
| 138 |
|
if (redraw) |
| 139 |
|
{ |
| 140 |
|
clearscr (); |
| 141 |
|
show_top (""); |
| 142 |
|
show_active_board (); |
| 143 |
|
show_bottom (""); |
| 144 |
|
display_current_menu (&bbs_menu); |
| 145 |
|
} |
| 146 |
|
} |
| 147 |
|
BBS_last_access_tm = time (0); |
| 148 |
|
} |
| 149 |
|
|
| 150 |
return 0; |
return 0; |
| 151 |
} |
} |