| 31 |
#include <libssh/libssh.h> |
#include <libssh/libssh.h> |
| 32 |
#include <libssh/server.h> |
#include <libssh/server.h> |
| 33 |
|
|
| 34 |
char stdio_charset[32] = BBS_DEFAULT_CHARSET; |
char stdio_charset[20] = BBS_DEFAULT_CHARSET; |
| 35 |
|
|
| 36 |
// static input / output buffer |
// static input / output buffer |
| 37 |
static char stdin_buf[LINE_BUFFER_LEN]; |
static char stdin_buf[LINE_BUFFER_LEN]; |
| 1012 |
|
|
| 1013 |
int io_conv_init(const char *charset) |
int io_conv_init(const char *charset) |
| 1014 |
{ |
{ |
| 1015 |
|
char tocode[32]; |
| 1016 |
|
|
| 1017 |
if (charset == NULL) |
if (charset == NULL) |
| 1018 |
{ |
{ |
| 1019 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error\n"); |
| 1022 |
|
|
| 1023 |
io_conv_cleanup(); |
io_conv_cleanup(); |
| 1024 |
|
|
| 1025 |
snprintf(stdio_charset, sizeof(stdio_charset), "%s//TRANSLIT", charset); |
strncpy(stdio_charset, charset, sizeof(stdio_charset) - 1); |
| 1026 |
|
stdio_charset[sizeof(stdio_charset) - 1] = '\0'; |
| 1027 |
|
|
| 1028 |
stdin_cd = iconv_open(BBS_DEFAULT_CHARSET, stdio_charset); |
stdin_cd = iconv_open(BBS_DEFAULT_CHARSET "//TRANSLIT", stdio_charset); |
| 1029 |
if (stdin_cd == (iconv_t)(-1)) |
if (stdin_cd == (iconv_t)(-1)) |
| 1030 |
{ |
{ |
| 1031 |
log_error("iconv_open(%s->%s) error: %d\n", stdio_charset, BBS_DEFAULT_CHARSET, errno); |
log_error("iconv_open(%s->%s) error: %d\n", stdio_charset, BBS_DEFAULT_CHARSET "//TRANSLIT", errno); |
| 1032 |
return -2; |
return -2; |
| 1033 |
} |
} |
| 1034 |
stdout_cd = iconv_open(stdio_charset, BBS_DEFAULT_CHARSET); |
|
| 1035 |
|
snprintf(tocode, sizeof(tocode), "%s//TRANSLIT", stdio_charset); |
| 1036 |
|
stdout_cd = iconv_open(tocode, BBS_DEFAULT_CHARSET); |
| 1037 |
if (stdout_cd == (iconv_t)(-1)) |
if (stdout_cd == (iconv_t)(-1)) |
| 1038 |
{ |
{ |
| 1039 |
log_error("iconv_open(%s->%s) error: %d\n", BBS_DEFAULT_CHARSET, stdio_charset, errno); |
log_error("iconv_open(%s->%s) error: %d\n", BBS_DEFAULT_CHARSET, tocode, errno); |
| 1040 |
iconv_close(stdin_cd); |
iconv_close(stdin_cd); |
| 1041 |
return -2; |
return -2; |
| 1042 |
} |
} |