| 109 |
return 0; |
return 0; |
| 110 |
} |
} |
| 111 |
|
|
|
// from Maple-hightman |
|
|
// added by flyriver, 2001.3.3 |
|
|
int |
|
|
telnetopt (int fd, char *buf, int max) |
|
|
{ |
|
|
unsigned char c, d, e; |
|
|
int pp = 0; |
|
|
unsigned char tmp[30]; |
|
|
|
|
|
while (pp < max) |
|
|
{ |
|
|
c = buf[pp++]; |
|
|
if (c == 255) |
|
|
{ |
|
|
d = buf[pp++]; |
|
|
e = buf[pp++]; |
|
|
iflush (); |
|
|
if ((d == 253) && (e == 3 || e == 24)) |
|
|
{ |
|
|
tmp[0] = 255; |
|
|
tmp[1] = 251; |
|
|
tmp[2] = e; |
|
|
write (fd, tmp, 3); |
|
|
continue; |
|
|
} |
|
|
if ((d == 251 || d == 252) && (e == 1 || e == 3 || e == 24)) |
|
|
{ |
|
|
tmp[0] = 255; |
|
|
tmp[1] = 253; |
|
|
tmp[2] = e; |
|
|
write (fd, tmp, 3); |
|
|
continue; |
|
|
} |
|
|
if (d == 251 || d == 252) |
|
|
{ |
|
|
tmp[0] = 255; |
|
|
tmp[1] = 254; |
|
|
tmp[2] = e; |
|
|
write (fd, tmp, 3); |
|
|
continue; |
|
|
} |
|
|
if (d == 253 || d == 254) |
|
|
{ |
|
|
tmp[0] = 255; |
|
|
tmp[1] = 252; |
|
|
tmp[2] = e; |
|
|
write (fd, tmp, 3); |
|
|
continue; |
|
|
} |
|
|
if (d == 250) |
|
|
{ |
|
|
while (e != 240 && pp < max) |
|
|
e = buf[pp++]; |
|
|
tmp[0] = 255; |
|
|
tmp[1] = 250; |
|
|
tmp[2] = 24; |
|
|
tmp[3] = 0; |
|
|
tmp[4] = 65; |
|
|
tmp[5] = 78; |
|
|
tmp[6] = 83; |
|
|
tmp[7] = 73; |
|
|
tmp[8] = 255; |
|
|
tmp[9] = 240; |
|
|
write (fd, tmp, 10); |
|
|
} |
|
|
} |
|
|
else |
|
|
outc (c); |
|
|
} |
|
|
iflush (); |
|
|
return 0; |
|
|
} |
|
|
|
|
| 112 |
static void |
static void |
| 113 |
process_bar (int n, int len) |
process_bar (int n, int len) |
| 114 |
{ |
{ |
| 148 |
struct timeval timeout; |
struct timeval timeout; |
| 149 |
struct hostent *pHost = NULL; |
struct hostent *pHost = NULL; |
| 150 |
int rc, rv, tos = 020, i; |
int rc, rv, tos = 020, i; |
| 151 |
|
char remote_addr[256]; |
| 152 |
|
int remote_port; |
| 153 |
|
time_t t_used; |
| 154 |
|
struct tm * tm_used; |
| 155 |
|
|
| 156 |
prints ("\033[1;32m正在测试往 %s (%s) 的连接,请稍候... \033[m\n", |
prints ("\033[1;32m正在测试往 %s (%s) 的连接,请稍候... \033[m\n", |
| 157 |
bbsnet_conf[n].host1, bbsnet_conf[n].ip); |
bbsnet_conf[n].host1, bbsnet_conf[n].ip); |
| 187 |
inet_ntoa (sin.sin_addr), ntohs (sin.sin_port)); |
inet_ntoa (sin.sin_addr), ntohs (sin.sin_port)); |
| 188 |
return -2; |
return -2; |
| 189 |
} |
} |
| 190 |
|
|
| 191 |
bzero (&sin, sizeof (sin)); |
bzero (&sin, sizeof (sin)); |
| 192 |
sin.sin_family = AF_INET; |
sin.sin_family = AF_INET; |
|
sin.sin_port = htons (bbsnet_conf[n].port); |
|
| 193 |
sin.sin_addr = *(struct in_addr *) pHost->h_addr_list[0]; |
sin.sin_addr = *(struct in_addr *) pHost->h_addr_list[0]; |
| 194 |
|
sin.sin_port = htons (bbsnet_conf[n].port); |
| 195 |
|
|
| 196 |
|
strcpy (remote_addr, inet_ntoa (sin.sin_addr)); |
| 197 |
|
remote_port = ntohs (sin.sin_port); |
| 198 |
|
|
| 199 |
prints ("\033[1;32m穿梭进度条提示您当前已使用的时间。\033[m\n"); |
prints ("\033[1;32m穿梭进度条提示您当前已使用的时间。\033[m\n"); |
| 200 |
process_bar (0, MAX_PROCESS_BAR_LEN); |
process_bar (0, MAX_PROCESS_BAR_LEN); |
| 229 |
return -1; |
return -1; |
| 230 |
} |
} |
| 231 |
setsockopt (sock, IPPROTO_IP, IP_TOS, &tos, sizeof (int)); |
setsockopt (sock, IPPROTO_IP, IP_TOS, &tos, sizeof (int)); |
| 232 |
|
|
| 233 |
prints ("\033[1;31m连接成功!\033[m\n"); |
prints ("\033[1;31m连接成功!\033[m\n"); |
| 234 |
|
log_std ("BBSNET connect to %s:%d\n", |
| 235 |
|
remote_addr, remote_port); |
| 236 |
|
|
| 237 |
FD_ZERO (&inputs); |
FD_ZERO (&inputs); |
| 238 |
FD_SET (0, &inputs); |
FD_SET (0, &inputs); |
| 239 |
FD_SET (sock, &inputs); |
FD_SET (sock, &inputs); |
| 240 |
|
|
| 241 |
BBS_last_access_tm = time (0); |
BBS_last_access_tm = t_used = time (0); |
| 242 |
|
|
| 243 |
loop = 1; |
loop = 1; |
| 244 |
|
|
| 293 |
log_error ("Close socket failed\n"); |
log_error ("Close socket failed\n"); |
| 294 |
} |
} |
| 295 |
|
|
| 296 |
|
t_used = time (0) - t_used; |
| 297 |
|
tm_used = gmtime (&t_used); |
| 298 |
|
|
| 299 |
|
log_std ("BBSNET disconnect, %d days %d hours %d minutes %d seconds used\n", |
| 300 |
|
tm_used->tm_mday - 1, tm_used->tm_hour, tm_used->tm_min, tm_used->tm_sec); |
| 301 |
|
|
| 302 |
return 0; |
return 0; |
| 303 |
} |
} |
| 304 |
|
|