| 1 |
/*************************************************************************** |
/*************************************************************************** |
| 2 |
bbsd.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 |
| 15 |
* * |
* * |
| 16 |
***************************************************************************/ |
***************************************************************************/ |
| 17 |
|
|
| 18 |
|
#include "bbs.h" |
| 19 |
#include "common.h" |
#include "common.h" |
| 20 |
|
#include "io.h" |
| 21 |
|
|
| 22 |
int |
int |
| 23 |
bbs_main() |
bbs_main() |
| 24 |
{ |
{ |
| 25 |
log_std("bbs_main()\n"); |
char temp[256]; |
| 26 |
|
int ret; |
| 27 |
return 0; |
|
| 28 |
|
set_input_echo(0); |
| 29 |
|
|
| 30 |
|
bbs_info(); |
| 31 |
|
|
| 32 |
|
//Welcome |
| 33 |
|
bbs_welcome(); |
| 34 |
|
|
| 35 |
|
//Login |
| 36 |
|
ret = bbs_login(); |
| 37 |
|
if (ret < 0) |
| 38 |
|
return -1; |
| 39 |
|
clearscr(); |
| 40 |
|
|
| 41 |
|
//BBS Top 10 |
| 42 |
|
strcpy (temp, app_home_dir); |
| 43 |
|
strcat (temp, "data/bbs_top.txt"); |
| 44 |
|
display_file_ex (temp, 1, 1); |
| 45 |
|
|
| 46 |
|
//Main |
| 47 |
|
bbs_center(); |
| 48 |
|
|
| 49 |
|
//Logout |
| 50 |
|
bbs_exit(); |
| 51 |
|
|
| 52 |
|
return 0; |
| 53 |
|
} |
| 54 |
|
|
| 55 |
|
int |
| 56 |
|
bbs_info() |
| 57 |
|
{ |
| 58 |
|
prints( |
| 59 |
|
"»¶Ó¹âÁÙ \033[1;33m%s \033[32m[%s] \033[37m( %s )\r\n", |
| 60 |
|
BBS_name, BBS_server, app_version); |
| 61 |
|
|
| 62 |
|
iflush(); |
| 63 |
|
|
| 64 |
|
return 0; |
| 65 |
|
} |
| 66 |
|
|
| 67 |
|
int |
| 68 |
|
bbs_exit() |
| 69 |
|
{ |
| 70 |
|
char temp[256]; |
| 71 |
|
|
| 72 |
|
strcpy (temp, app_home_dir); |
| 73 |
|
strcat (temp, "data/goodbye.txt"); |
| 74 |
|
display_file_ex (temp, 1, 0); |
| 75 |
|
|
| 76 |
|
sleep(1); |
| 77 |
|
|
| 78 |
|
return 0; |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
int |
| 82 |
|
bbs_center() |
| 83 |
|
{ |
| 84 |
|
clearscr (); |
| 85 |
|
|
| 86 |
|
show_top ("²âÊÔ"); |
| 87 |
|
show_bottom ("²âÊÔ"); |
| 88 |
|
|
| 89 |
|
igetch(); |
| 90 |
|
|
| 91 |
|
return 0; |
| 92 |
|
} |
| 93 |
|
|
| 94 |
|
int |
| 95 |
|
show_top (char *status) |
| 96 |
|
{ |
| 97 |
|
char buffer[256]; |
| 98 |
|
|
| 99 |
|
str_space (buffer, 20-strlen(BBS_current_section_name)); |
| 100 |
|
|
| 101 |
|
moveto (1, 0); |
| 102 |
|
prints ("\033[1;44;33m%-20s \033[37m%20s" |
| 103 |
|
" %s\033[33mÌÖÂÛÇø [%s]\033[m", |
| 104 |
|
status, BBS_name, buffer, BBS_current_section_name); |
| 105 |
|
iflush (); |
| 106 |
|
|
| 107 |
|
return 0; |
| 108 |
|
} |
| 109 |
|
|
| 110 |
|
int |
| 111 |
|
show_bottom (char *msg) |
| 112 |
|
{ |
| 113 |
|
char str_time[256], str_time_onine[20], buffer[256]; |
| 114 |
|
time_t time_online; |
| 115 |
|
struct tm *tm_online; |
| 116 |
|
|
| 117 |
|
get_time_str (str_time, 256); |
| 118 |
|
str_space (buffer, 33-strlen(BBS_username)); |
| 119 |
|
|
| 120 |
|
time_online = time (0) - BBS_login_tm; |
| 121 |
|
tm_online = gmtime (&time_online); |
| 122 |
|
|
| 123 |
|
moveto (screen_lines, 0); |
| 124 |
|
prints ("\033[1;44;33m[\033[36m%s\033[33m]" |
| 125 |
|
"%sÕʺÅ[\033[36m%s\033[33m]" |
| 126 |
|
"[\033[36m%1d\033[33m:\033[36m%2d\033[33m:\033[36m%2d\033[33m]\033[m", |
| 127 |
|
str_time, buffer, BBS_username, tm_online->tm_mday - 1, |
| 128 |
|
tm_online->tm_hour, tm_online->tm_min); |
| 129 |
|
iflush (); |
| 130 |
|
|
| 131 |
|
return 0; |
| 132 |
} |
} |