| 424 |
log_common("BBSNET connect to %s:%d from %s:%d by [%s]\n", |
log_common("BBSNET connect to %s:%d from %s:%d by [%s]\n", |
| 425 |
remote_addr, remote_port, local_addr, local_port, BBS_username); |
remote_addr, remote_port, local_addr, local_port, BBS_username); |
| 426 |
|
|
| 427 |
snprintf(tocode, sizeof(tocode), "%s//TRANSLIT", bbsnet_conf[n].charset); |
snprintf(tocode, sizeof(tocode), "%s%s", bbsnet_conf[n].charset, |
| 428 |
|
(strcasecmp(stdio_charset, bbsnet_conf[n].charset) == 0 ? "" : "//IGNORE")); |
| 429 |
input_cd = iconv_open(tocode, stdio_charset); |
input_cd = iconv_open(tocode, stdio_charset); |
| 430 |
if (input_cd == (iconv_t)(-1)) |
if (input_cd == (iconv_t)(-1)) |
| 431 |
{ |
{ |
| 433 |
goto cleanup; |
goto cleanup; |
| 434 |
} |
} |
| 435 |
|
|
| 436 |
snprintf(tocode, sizeof(tocode), "%s//TRANSLIT", stdio_charset); |
snprintf(tocode, sizeof(tocode), "%s%s", stdio_charset, |
| 437 |
output_cd = iconv_open(stdio_charset, bbsnet_conf[n].charset); |
(strcasecmp(bbsnet_conf[n].charset, stdio_charset) == 0 ? "" : "//TRANSLIT")); |
| 438 |
|
output_cd = iconv_open(tocode, bbsnet_conf[n].charset); |
| 439 |
if (output_cd == (iconv_t)(-1)) |
if (output_cd == (iconv_t)(-1)) |
| 440 |
{ |
{ |
| 441 |
log_error("iconv_open(%s->%s) error: %d\n", bbsnet_conf[n].charset, tocode, errno); |
log_error("iconv_open(%s->%s) error: %d\n", bbsnet_conf[n].charset, tocode, errno); |
| 536 |
} |
} |
| 537 |
else if (ret == 0) |
else if (ret == 0) |
| 538 |
{ |
{ |
| 539 |
|
// Send NO-OP to remote server |
| 540 |
|
input_buf[input_buf_len] = '\0'; |
| 541 |
|
input_buf_len++; |
| 542 |
|
BBS_last_access_tm = time(NULL); |
| 543 |
|
|
| 544 |
stdin_read_wait = 0; |
stdin_read_wait = 0; |
| 545 |
break; // Check whether channel is still open |
break; // Check whether channel is still open |
| 546 |
} |
} |
| 596 |
{ |
{ |
| 597 |
if (input_buf_offset < input_buf_len) |
if (input_buf_offset < input_buf_len) |
| 598 |
{ |
{ |
| 599 |
|
// For debug |
| 600 |
|
#ifdef _DEBUG |
| 601 |
|
for (int j = input_buf_offset; j < input_buf_len; j++) |
| 602 |
|
{ |
| 603 |
|
log_error("Debug input: <--[%u]\n", (input_buf[j] + 256) % 256); |
| 604 |
|
} |
| 605 |
|
#endif |
| 606 |
|
|
| 607 |
ret = io_buf_conv(input_cd, input_buf, &input_buf_len, &input_buf_offset, input_conv, sizeof(input_conv), &input_conv_len); |
ret = io_buf_conv(input_cd, input_buf, &input_buf_len, &input_buf_offset, input_conv, sizeof(input_conv), &input_conv_len); |
| 608 |
if (ret < 0) |
if (ret < 0) |
| 609 |
{ |
{ |
| 610 |
log_error("io_buf_conv(input, %d, %d, %d) error\n", input_buf_len, input_buf_offset, input_conv_len); |
log_error("io_buf_conv(input, %d, %d, %d) error\n", input_buf_len, input_buf_offset, input_conv_len); |
| 611 |
|
input_buf_len = input_buf_offset; // Discard invalid sequence |
| 612 |
|
} |
| 613 |
|
|
| 614 |
|
// For debug |
| 615 |
|
#ifdef _DEBUG |
| 616 |
|
for (int j = input_conv_offset; j < input_conv_len; j++) |
| 617 |
|
{ |
| 618 |
|
log_error("Debug input_conv: <--[%u]\n", (input_conv[j] + 256) % 256); |
| 619 |
} |
} |
| 620 |
|
#endif |
| 621 |
} |
} |
| 622 |
|
|
| 623 |
while (input_conv_offset < input_conv_len && !SYS_server_exit) |
while (input_conv_offset < input_conv_len && !SYS_server_exit) |
| 712 |
if (ret < 0) |
if (ret < 0) |
| 713 |
{ |
{ |
| 714 |
log_error("io_buf_conv(output, %d, %d, %d) error\n", output_buf_len, output_buf_offset, output_conv_len); |
log_error("io_buf_conv(output, %d, %d, %d) error\n", output_buf_len, output_buf_offset, output_conv_len); |
| 715 |
|
output_buf_len = output_buf_offset; // Discard invalid sequence |
| 716 |
} |
} |
| 717 |
} |
} |
| 718 |
|
|
| 802 |
tm_used->tm_mday - 1, tm_used->tm_hour, tm_used->tm_min, |
tm_used->tm_mday - 1, tm_used->tm_hour, tm_used->tm_min, |
| 803 |
tm_used->tm_sec); |
tm_used->tm_sec); |
| 804 |
|
|
| 805 |
|
BBS_last_access_tm = time(NULL); |
| 806 |
|
|
| 807 |
return 0; |
return 0; |
| 808 |
} |
} |
| 809 |
|
|
| 872 |
{ |
{ |
| 873 |
ch = igetch(100); |
ch = igetch(100); |
| 874 |
|
|
| 875 |
if (ch != KEY_NULL && ch != KEY_TIMEOUT) |
if (ch != KEY_NULL && ch != KEY_TIMEOUT) |
| 876 |
{ |
{ |
| 877 |
BBS_last_access_tm = time(NULL); |
BBS_last_access_tm = time(NULL); |
| 878 |
} |
} |
| 879 |
|
|
| 880 |
switch (ch) |
switch (ch) |
| 881 |
{ |
{ |