| 14 |
* * |
* * |
| 15 |
***************************************************************************/ |
***************************************************************************/ |
| 16 |
|
|
|
#define _POSIX_C_SOURCE 200809L |
|
|
|
|
| 17 |
#include "bbs.h" |
#include "bbs.h" |
| 18 |
#include "common.h" |
#include "common.h" |
| 19 |
#include "log.h" |
#include "log.h" |
| 20 |
#include "io.h" |
#include "io.h" |
| 21 |
#include "screen.h" |
#include "screen.h" |
| 22 |
#include "menu.h" |
#include "menu.h" |
| 23 |
|
#include "login.h" |
| 24 |
#include <stdio.h> |
#include <stdio.h> |
| 25 |
#include <stdarg.h> |
#include <stdarg.h> |
| 26 |
#include <errno.h> |
#include <errno.h> |
| 217 |
struct tm *tm_used; |
struct tm *tm_used; |
| 218 |
int ch; |
int ch; |
| 219 |
|
|
| 220 |
|
if (user_online_update("BBS_NET") < 0) |
| 221 |
|
{ |
| 222 |
|
log_error("user_online_update(BBS_NET) error\n"); |
| 223 |
|
} |
| 224 |
|
|
| 225 |
clearscr(); |
clearscr(); |
| 226 |
|
|
| 227 |
moveto(0, 0); |
moveto(0, 0); |
| 412 |
goto cleanup; |
goto cleanup; |
| 413 |
} |
} |
| 414 |
|
|
| 415 |
BBS_last_access_tm = t_used = time(0); |
BBS_last_access_tm = t_used = time(NULL); |
| 416 |
loop = 1; |
loop = 1; |
| 417 |
|
|
| 418 |
while (loop && !SYS_server_exit) |
while (loop && !SYS_server_exit) |
| 437 |
} |
} |
| 438 |
else if (nfds == 0) // timeout |
else if (nfds == 0) // timeout |
| 439 |
{ |
{ |
| 440 |
if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME) |
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
| 441 |
{ |
{ |
| 442 |
break; |
break; |
| 443 |
} |
} |
| 504 |
else |
else |
| 505 |
{ |
{ |
| 506 |
input_buf_len += ret; |
input_buf_len += ret; |
| 507 |
BBS_last_access_tm = time(0); |
BBS_last_access_tm = time(NULL); |
| 508 |
continue; |
continue; |
| 509 |
} |
} |
| 510 |
} |
} |
| 581 |
} |
} |
| 582 |
else if (ret == 0) // broken pipe |
else if (ret == 0) // broken pipe |
| 583 |
{ |
{ |
| 584 |
log_common("read(socket) EOF\n"); |
#ifdef _DEBUG |
| 585 |
|
log_error("read(socket) EOF\n"); |
| 586 |
|
#endif |
| 587 |
sock_read_wait = 0; |
sock_read_wait = 0; |
| 588 |
loop = 0; |
loop = 0; |
| 589 |
break; |
break; |
| 635 |
} |
} |
| 636 |
else if (ret == 0) // broken pipe |
else if (ret == 0) // broken pipe |
| 637 |
{ |
{ |
| 638 |
log_common("write(STDOUT) EOF\n"); |
#ifdef _DEBUG |
| 639 |
|
log_error("write(STDOUT) EOF\n"); |
| 640 |
|
#endif |
| 641 |
stdout_write_wait = 0; |
stdout_write_wait = 0; |
| 642 |
loop = 0; |
loop = 0; |
| 643 |
break; |
break; |
| 676 |
log_error("Close socket failed\n"); |
log_error("Close socket failed\n"); |
| 677 |
} |
} |
| 678 |
|
|
| 679 |
t_used = time(0) - t_used; |
t_used = time(NULL) - t_used; |
| 680 |
tm_used = gmtime(&t_used); |
tm_used = gmtime(&t_used); |
| 681 |
|
|
| 682 |
log_common("BBSNET disconnect, %d days %d hours %d minutes %d seconds used\n", |
log_common("BBSNET disconnect, %d days %d hours %d minutes %d seconds used\n", |
| 742 |
|
|
| 743 |
load_bbsnet_conf(CONF_BBSNET); |
load_bbsnet_conf(CONF_BBSNET); |
| 744 |
|
|
| 745 |
BBS_last_access_tm = time(0); |
BBS_last_access_tm = time(NULL); |
| 746 |
|
|
| 747 |
clearscr(); |
clearscr(); |
| 748 |
bbsnet_refresh(); |
bbsnet_refresh(); |
| 752 |
while (!SYS_server_exit) |
while (!SYS_server_exit) |
| 753 |
{ |
{ |
| 754 |
ch = igetch(100); |
ch = igetch(100); |
| 755 |
|
|
| 756 |
switch (ch) |
switch (ch) |
| 757 |
{ |
{ |
| 758 |
case KEY_NULL: // broken pipe |
case KEY_NULL: // broken pipe |
| 760 |
case Ctrl('C'): // user cancel |
case Ctrl('C'): // user cancel |
| 761 |
goto cleanup; |
goto cleanup; |
| 762 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 763 |
if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME) |
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
| 764 |
{ |
{ |
| 765 |
goto cleanup; |
goto cleanup; |
| 766 |
} |
} |
| 809 |
bbsnet_selchange(); |
bbsnet_selchange(); |
| 810 |
break; |
break; |
| 811 |
} |
} |
| 812 |
BBS_last_access_tm = time(0); |
BBS_last_access_tm = time(NULL); |
| 813 |
} |
} |
| 814 |
|
|
| 815 |
cleanup: |
cleanup: |