| 252 |
timeout.tv_sec = TIME_OUT; |
timeout.tv_sec = TIME_OUT; |
| 253 |
timeout.tv_usec = 0; |
timeout.tv_usec = 0; |
| 254 |
|
|
| 255 |
result = select (FD_SETSIZE, &testfds, (fd_set *) NULL, |
result = SignalSafeSelect (FD_SETSIZE, &testfds, (fd_set *) NULL, |
| 256 |
(fd_set *) NULL, &timeout); |
(fd_set *) NULL, &timeout); |
| 257 |
|
|
| 258 |
switch (result) |
if (result == 0) |
| 259 |
{ |
{ |
|
case 0: |
|
| 260 |
if (time (0) - BBS_last_access_tm >= MAX_DELAY_TIME) |
if (time (0) - BBS_last_access_tm >= MAX_DELAY_TIME) |
| 261 |
{ |
{ |
| 262 |
loop = 0; |
loop = 0; |
| 263 |
} |
} |
| 264 |
break; |
} |
| 265 |
case -1: |
if (result < 0) |
| 266 |
|
{ |
| 267 |
log_error ("select() error!\n"); |
log_error ("select() error!\n"); |
| 268 |
break; |
loop = 0; |
| 269 |
default: |
} |
| 270 |
|
if (result > 0) |
| 271 |
|
{ |
| 272 |
if (FD_ISSET (0, &testfds)) |
if (FD_ISSET (0, &testfds)) |
| 273 |
{ |
{ |
| 274 |
len = read (0, buf, 255); |
len = read (0, buf, 255); |
| 275 |
if (len == 0) |
if (len == 0) |
| 276 |
{ |
{ |
| 277 |
loop = 0; |
loop = 0; |
|
break; |
|
| 278 |
} |
} |
| 279 |
write (sock, buf, len); |
write (sock, buf, len); |
| 280 |
} |
} |
| 284 |
if (len == 0) |
if (len == 0) |
| 285 |
{ |
{ |
| 286 |
loop = 0; |
loop = 0; |
|
break; |
|
| 287 |
} |
} |
| 288 |
write (1, buf, len); |
write (1, buf, len); |
| 289 |
} |
} |
| 290 |
BBS_last_access_tm = time (0); |
BBS_last_access_tm = time (0); |
|
break; |
|
| 291 |
} |
} |
| 292 |
} |
} |
| 293 |
|
|
| 314 |
clearscr (); |
clearscr (); |
| 315 |
moveto (1, 0); |
moveto (1, 0); |
| 316 |
prints |
prints |
| 317 |
("╭══════════════════════════════════════╮"); |
("?q?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?r"); |
| 318 |
for (i = 2; i < 19; i++) |
for (i = 2; i < 19; i++) |
| 319 |
{ |
{ |
| 320 |
moveto (i, 0); |
moveto (i, 0); |
| 321 |
prints ("║"); |
prints ("?U"); |
| 322 |
moveto (i, 79); |
moveto (i, 79); |
| 323 |
prints ("║"); |
prints ("?U"); |
| 324 |
} |
} |
| 325 |
moveto (19, 0); |
moveto (19, 0); |
| 326 |
prints |
prints |
| 327 |
("║——————————————————————————————————————║"); |
("?U——————————————————————————————————————?U"); |
| 328 |
moveto (22, 0); |
moveto (22, 0); |
| 329 |
prints |
prints |
| 330 |
("╰══════════════════════════════════════╯"); |
("?t?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?T?s"); |
| 331 |
moveto (23, 0); |
moveto (23, 0); |
| 332 |
prints (" [\x1b[1;32mCtrl+C\x1b[m]退出"); |
prints (" [\x1b[1;32mCtrl+C\x1b[m]退出"); |
| 333 |
iflush (); |
iflush (); |
| 340 |
{ |
{ |
| 341 |
moveto (20, 0); |
moveto (20, 0); |
| 342 |
clrtoeol (); |
clrtoeol (); |
| 343 |
prints ("║\x1b[1m单位:\x1b[1;33m%-18s\x1b[m 站名:\x1b[1;33m%s\x1b[m", |
prints ("?U\x1b[1m单位:\x1b[1;33m%-18s\x1b[m 站名:\x1b[1;33m%s\x1b[m", |
| 344 |
bbsnet_conf[new_pos].host2, bbsnet_conf[new_pos].host1); |
bbsnet_conf[new_pos].host2, bbsnet_conf[new_pos].host1); |
| 345 |
moveto (20, 79); |
moveto (20, 79); |
| 346 |
prints ("║"); |
prints ("?U"); |
| 347 |
moveto (21, 0); |
moveto (21, 0); |
| 348 |
clrtoeol (); |
clrtoeol (); |
| 349 |
prints ("║\x1b[1m连往:\x1b[1;33m%-20s", bbsnet_conf[new_pos].ip); |
prints ("?U\x1b[1m连往:\x1b[1;33m%-20s", bbsnet_conf[new_pos].ip); |
| 350 |
if (bbsnet_conf[new_pos].port != 23) |
if (bbsnet_conf[new_pos].port != 23) |
| 351 |
prints (" %d", bbsnet_conf[new_pos].port); |
prints (" %d", bbsnet_conf[new_pos].port); |
| 352 |
prints ("\x1b[m"); |
prints ("\x1b[m"); |
| 353 |
moveto (21, 79); |
moveto (21, 79); |
| 354 |
prints ("║"); |
prints ("?U"); |
| 355 |
iflush (); |
iflush (); |
| 356 |
|
|
| 357 |
return 0; |
return 0; |