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