| 23 |
#include <fcntl.h> |
#include <fcntl.h> |
| 24 |
#include <unistd.h> |
#include <unistd.h> |
| 25 |
|
|
|
#define ACTIVE_BOARD_HEIGHT 8 |
|
|
|
|
| 26 |
int |
int |
| 27 |
bbs_main () |
bbs_main () |
| 28 |
{ |
{ |
| 85 |
bbs_center () |
bbs_center () |
| 86 |
{ |
{ |
| 87 |
int ch, result; |
int ch, result; |
| 88 |
char key; |
char action[MAX_MENUACTION_LENGTH]; |
| 89 |
time_t t_last_action; |
time_t t_last_action; |
| 90 |
fd_set inputs, testfds; |
fd_set inputs, testfds; |
| 91 |
struct timeval timeout; |
struct timeval timeout; |
| 97 |
|
|
| 98 |
clearscr (); |
clearscr (); |
| 99 |
|
|
| 100 |
show_top ("²âÊÔ"); |
show_top (""); |
| 101 |
show_active_board (); |
show_active_board (); |
| 102 |
display_menu (&bbs_menu); |
display_menu (get_menu (bbs_menu, "TOPMENU")); |
| 103 |
show_bottom ("²âÊÔ"); |
show_bottom (""); |
| 104 |
|
|
| 105 |
while (1) |
while (1) |
| 106 |
{ |
{ |
| 125 |
|
|
| 126 |
switch (ch) |
switch (ch) |
| 127 |
{ |
{ |
|
case KEY_LEFT: |
|
|
ch = 'G'; |
|
| 128 |
default: |
default: |
| 129 |
key = menu_control (&bbs_menu, ch); |
strcpy (action, menu_control (&bbs_menu, ch)); |
| 130 |
switch (key) |
|
| 131 |
{ |
if (strcmp (action, "EXITBBS") == 0) |
| 132 |
case 'G': |
return 0; |
|
return 0; |
|
|
} |
|
| 133 |
} |
} |
| 134 |
} |
} |
| 135 |
break; |
break; |
| 142 |
} |
} |
| 143 |
|
|
| 144 |
return 0; |
return 0; |
|
} |
|
|
|
|
|
int |
|
|
show_top (char *status) |
|
|
{ |
|
|
char buffer[256]; |
|
|
|
|
|
str_space (buffer, 20 - strlen (BBS_current_section_name)); |
|
|
|
|
|
moveto (1, 0); |
|
|
prints ("\033[1;44;33m%-20s \033[37m%20s" |
|
|
" %s\033[33mÌÖÂÛÇø [%s]\033[m", |
|
|
status, BBS_name, buffer, BBS_current_section_name); |
|
|
iflush (); |
|
|
|
|
|
return 0; |
|
|
} |
|
|
|
|
|
int |
|
|
show_bottom (char *msg) |
|
|
{ |
|
|
char str_time[256], str_time_onine[20], buffer[256]; |
|
|
time_t time_online; |
|
|
struct tm *tm_online; |
|
|
|
|
|
get_time_str (str_time, 256); |
|
|
str_space (buffer, 33 - strlen (BBS_username)); |
|
|
|
|
|
time_online = time (0) - BBS_login_tm; |
|
|
tm_online = gmtime (&time_online); |
|
|
|
|
|
moveto (screen_lines, 0); |
|
|
prints ("\033[1;44;33m[\033[36m%s\033[33m]" |
|
|
"%sÕʺÅ[\033[36m%s\033[33m]" |
|
|
"[\033[36m%1d\033[33m:\033[36m%2d\033[33m:\033[36m%2d\033[33m]\033[m", |
|
|
str_time, buffer, BBS_username, tm_online->tm_mday - 1, |
|
|
tm_online->tm_hour, tm_online->tm_min); |
|
|
iflush (); |
|
|
|
|
|
return 0; |
|
|
} |
|
|
|
|
|
int |
|
|
show_active_board () |
|
|
{ |
|
|
char filename[256], buffer[260]; |
|
|
FILE *fin; |
|
|
int i, j; |
|
|
static long int line; |
|
|
|
|
|
sprintf (filename, "%sdata/active_board.txt", app_home_dir); |
|
|
|
|
|
clrline (3, 2 + ACTIVE_BOARD_HEIGHT); |
|
|
|
|
|
moveto (3, 0); |
|
|
|
|
|
if ((fin = fopen (filename, "r")) != NULL) |
|
|
{ |
|
|
for (j = 0; j < line; j++) |
|
|
{ |
|
|
if (fgets (buffer, 255, fin) == NULL) |
|
|
{ |
|
|
line = 0; |
|
|
rewind (fin); |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
for (j = 0; j < ACTIVE_BOARD_HEIGHT; j++) |
|
|
{ |
|
|
if (fgets (buffer, 255, fin) == NULL) |
|
|
{ |
|
|
line = 0; |
|
|
if (j == 0) |
|
|
{ |
|
|
rewind (fin); |
|
|
if (fgets (buffer, 255, fin) == NULL) |
|
|
{ |
|
|
break; |
|
|
} |
|
|
} |
|
|
else |
|
|
{ |
|
|
break; |
|
|
} |
|
|
} |
|
|
line++; |
|
|
i = strlen (buffer); |
|
|
if (buffer[i - 1] == '\n' && buffer[i - 2] != '\r') |
|
|
{ |
|
|
buffer[i - 1] = '\r'; |
|
|
buffer[i] = '\n'; |
|
|
buffer[i + 1] = '\0'; |
|
|
} |
|
|
prints (buffer); |
|
|
iflush (); |
|
|
} |
|
|
fclose (fin); |
|
|
} |
|
|
|
|
|
return 0; |
|
| 145 |
} |
} |