| 48 |
#define MAXSTATION 26 * 2 |
#define MAXSTATION 26 * 2 |
| 49 |
#define STATION_PER_LINE 4 |
#define STATION_PER_LINE 4 |
| 50 |
|
|
| 51 |
|
#define BBS_NET_DEFAULT_CHARSET "UTF-8" |
| 52 |
|
|
| 53 |
struct _bbsnet_conf |
struct _bbsnet_conf |
| 54 |
{ |
{ |
| 55 |
char host1[20]; |
char host1[20]; |
| 215 |
{ |
{ |
| 216 |
if (errno == EINVAL) // Incomplete |
if (errno == EINVAL) // Incomplete |
| 217 |
{ |
{ |
| 218 |
|
#ifdef _DEBUG |
| 219 |
|
log_error("iconv(inbytes=%d, outbytes=%d) error: EINVAL\n", in_bytes, out_bytes); |
| 220 |
|
#endif |
| 221 |
*p_buf_len = (int)(p_buf + *p_buf_len - in_buf); |
*p_buf_len = (int)(p_buf + *p_buf_len - in_buf); |
| 222 |
*p_buf_offset = 0; |
*p_buf_offset = 0; |
| 223 |
*p_conv_len = (int)(conv_size - out_bytes); |
*p_conv_len = (int)(conv_size - out_bytes); |
| 234 |
{ |
{ |
| 235 |
if (in_bytes > out_bytes || out_bytes <= 0) |
if (in_bytes > out_bytes || out_bytes <= 0) |
| 236 |
{ |
{ |
| 237 |
errno = E2BIG; |
log_error("iconv(inbytes=%d, outbytes=%d) error: EILSEQ and E2BIG\n", in_bytes, out_bytes); |
| 238 |
return -1; |
return -2; |
| 239 |
} |
} |
| 240 |
|
|
| 241 |
*out_buf++ = *in_buf++; |
*out_buf = *in_buf; |
| 242 |
|
in_buf++; |
| 243 |
|
out_buf++; |
| 244 |
in_bytes--; |
in_bytes--; |
| 245 |
out_bytes--; |
out_bytes--; |
| 246 |
|
|
| 476 |
iflush(); |
iflush(); |
| 477 |
log_common("BBSNET connect to %s:%d\n", remote_addr, remote_port); |
log_common("BBSNET connect to %s:%d\n", remote_addr, remote_port); |
| 478 |
|
|
| 479 |
input_cd = iconv_open(bbsnet_conf[n].charset, "UTF-8"); |
input_cd = iconv_open(bbsnet_conf[n].charset, BBS_NET_DEFAULT_CHARSET); |
| 480 |
if (input_cd == (iconv_t)(-1)) |
if (input_cd == (iconv_t)(-1)) |
| 481 |
{ |
{ |
| 482 |
log_error("iconv_open(UTF8->GBK) error: %d\n", errno); |
log_error("iconv_open(%s->%s) error: %d\n", BBS_NET_DEFAULT_CHARSET, bbsnet_conf[n].charset, errno); |
| 483 |
goto cleanup; |
goto cleanup; |
| 484 |
} |
} |
| 485 |
output_cd = iconv_open("UTF-8", bbsnet_conf[n].charset); |
output_cd = iconv_open(BBS_NET_DEFAULT_CHARSET, bbsnet_conf[n].charset); |
| 486 |
if (input_cd == (iconv_t)(-1)) |
if (input_cd == (iconv_t)(-1)) |
| 487 |
{ |
{ |
| 488 |
log_error("iconv_open(GBK->UTF-8) error: %d\n", errno); |
log_error("iconv_open(%s->%s) error: %d\n", bbsnet_conf[n].charset, BBS_NET_DEFAULT_CHARSET, errno); |
| 489 |
iconv_close(input_cd); |
iconv_close(input_cd); |
| 490 |
goto cleanup; |
goto cleanup; |
| 491 |
} |
} |