| 21 |
#include "menu.h" |
#include "menu.h" |
| 22 |
#include "bbs_cmd.h" |
#include "bbs_cmd.h" |
| 23 |
#include <time.h> |
#include <time.h> |
|
#include <fcntl.h> |
|
|
#include <unistd.h> |
|
| 24 |
#include <string.h> |
#include <string.h> |
| 25 |
|
|
| 26 |
int |
int |
| 84 |
int |
int |
| 85 |
bbs_center () |
bbs_center () |
| 86 |
{ |
{ |
| 87 |
int ch, result; |
int ch, result, redraw; |
| 88 |
char action[MAX_MENUACTION_LENGTH]; |
char action[MAX_MENUACTION_LENGTH], temp[256]; |
| 89 |
time_t t_last_action; |
time_t t_last_action; |
|
fd_set inputs, testfds; |
|
|
struct timeval timeout; |
|
| 90 |
|
|
| 91 |
FD_ZERO (&inputs); |
BBS_last_access_tm = t_last_action = time (0); |
|
FD_SET (0, &inputs); |
|
|
|
|
|
t_last_action = time (0); |
|
| 92 |
|
|
| 93 |
clearscr (); |
clearscr (); |
| 94 |
|
|
| 99 |
|
|
| 100 |
while (1) |
while (1) |
| 101 |
{ |
{ |
| 102 |
testfds = inputs; |
ch = igetch (); |
|
timeout.tv_sec = 0; |
|
|
timeout.tv_usec = 100000; |
|
|
|
|
|
result = select (FD_SETSIZE, &testfds, (fd_set *) NULL, |
|
|
(fd_set *) NULL, &timeout); |
|
| 103 |
|
|
|
switch (result) |
|
|
{ |
|
|
case 0: |
|
|
break; |
|
|
case -1: |
|
|
log_error ("select() error!\n"); |
|
|
break; |
|
|
default: |
|
|
if (FD_ISSET (0, &testfds)) |
|
|
{ |
|
|
ch = igetch (); |
|
|
|
|
|
switch (ch) |
|
|
{ |
|
|
case KEY_NULL: |
|
|
return 0; |
|
|
default: |
|
|
strcpy (action, menu_control (&bbs_menu, ch)); |
|
|
switch (get_cmd_value (action)) |
|
|
{ |
|
|
case EXITBBS: |
|
|
return 0; |
|
|
case BBSNET: |
|
|
bbs_net (); |
|
|
clearscr (); |
|
|
show_top (""); |
|
|
show_active_board (); |
|
|
show_bottom (""); |
|
|
display_current_menu (&bbs_menu); |
|
|
break; |
|
|
case UNKNOWN_CMD: |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
break; |
|
|
} |
|
| 104 |
if (time (0) - t_last_action >= 10) |
if (time (0) - t_last_action >= 10) |
| 105 |
{ |
{ |
| 106 |
t_last_action = time (0); |
t_last_action = time (0); |
| 107 |
show_active_board (); |
show_active_board (); |
| 108 |
show_bottom (""); |
show_bottom (""); |
| 109 |
} |
} |
| 110 |
|
|
| 111 |
|
switch (ch) |
| 112 |
|
{ |
| 113 |
|
case KEY_NULL: |
| 114 |
|
return 0; |
| 115 |
|
case KEY_TIMEOUT: |
| 116 |
|
if (time (0) - BBS_last_access_tm >= MAX_DELAY_TIME) |
| 117 |
|
{ |
| 118 |
|
return -1; |
| 119 |
|
} |
| 120 |
|
continue; |
| 121 |
|
default: |
| 122 |
|
strcpy (action, menu_control (&bbs_menu, ch)); |
| 123 |
|
redraw = 1; |
| 124 |
|
switch (get_cmd_value (action)) |
| 125 |
|
{ |
| 126 |
|
case EXITBBS: |
| 127 |
|
return 0; |
| 128 |
|
case BBSNET: |
| 129 |
|
bbs_net (); |
| 130 |
|
break; |
| 131 |
|
case LICENSE: |
| 132 |
|
strcpy (temp, app_home_dir); |
| 133 |
|
strcat (temp, "data/license.txt"); |
| 134 |
|
display_file_ex (temp, 0, 1); |
| 135 |
|
break; |
| 136 |
|
case COPYRIGHT: |
| 137 |
|
strcpy (temp, app_home_dir); |
| 138 |
|
strcat (temp, "data/copyright.txt"); |
| 139 |
|
display_file_ex (temp, 0, 1); |
| 140 |
|
break; |
| 141 |
|
case UNKNOWN_CMD: |
| 142 |
|
default: |
| 143 |
|
redraw = 0; |
| 144 |
|
break; |
| 145 |
|
} |
| 146 |
|
if (redraw) |
| 147 |
|
{ |
| 148 |
|
clearscr (); |
| 149 |
|
show_top (""); |
| 150 |
|
show_active_board (); |
| 151 |
|
show_bottom (""); |
| 152 |
|
display_current_menu (&bbs_menu); |
| 153 |
|
} |
| 154 |
|
} |
| 155 |
|
BBS_last_access_tm = time (0); |
| 156 |
} |
} |
| 157 |
|
|
| 158 |
return 0; |
return 0; |