/[LeafOK_CVS]/lbbs/src/io.c
ViewVC logotype

Diff of /lbbs/src/io.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.57 by sysadm, Sun Oct 19 02:42:19 2025 UTC Revision 1.59 by sysadm, Sun Oct 19 13:13:07 2025 UTC
# Line 31  Line 31 
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];
# Line 988  int io_buf_conv(iconv_t cd, char *p_buf, Line 988  int io_buf_conv(iconv_t cd, char *p_buf,
988                                          return -2;                                          return -2;
989                                  }                                  }
990    
991                                    // reset in_bytes when "//IGNORE" is applied
992                                    if (in_bytes == 0)
993                                    {
994                                            in_bytes = (size_t)(*p_buf_len - *p_buf_offset);
995                                    }
996    
997                                  *out_buf = *in_buf;                                  *out_buf = *in_buf;
998                                  in_buf++;                                  in_buf++;
999                                  out_buf++;                                  out_buf++;
# Line 1012  int io_buf_conv(iconv_t cd, char *p_buf, Line 1018  int io_buf_conv(iconv_t cd, char *p_buf,
1018    
1019  int io_conv_init(const char *charset)  int io_conv_init(const char *charset)
1020  {  {
1021            char tocode[32];
1022    
1023          if (charset == NULL)          if (charset == NULL)
1024          {          {
1025                  log_error("NULL pointer error\n");                  log_error("NULL pointer error\n");
# Line 1020  int io_conv_init(const char *charset) Line 1028  int io_conv_init(const char *charset)
1028    
1029          io_conv_cleanup();          io_conv_cleanup();
1030    
1031          snprintf(stdio_charset, sizeof(stdio_charset), "%s//TRANSLIT", charset);          strncpy(stdio_charset, charset, sizeof(stdio_charset) - 1);
1032            stdio_charset[sizeof(stdio_charset) - 1] = '\0';
1033    
1034          stdin_cd = iconv_open(BBS_DEFAULT_CHARSET, stdio_charset);          stdin_cd = iconv_open(BBS_DEFAULT_CHARSET "//IGNORE", stdio_charset);
1035          if (stdin_cd == (iconv_t)(-1))          if (stdin_cd == (iconv_t)(-1))
1036          {          {
1037                  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 "//IGNORE", errno);
1038                  return -2;                  return -2;
1039          }          }
1040          stdout_cd = iconv_open(stdio_charset, BBS_DEFAULT_CHARSET);  
1041            snprintf(tocode, sizeof(tocode), "%s//TRANSLIT", stdio_charset);
1042            stdout_cd = iconv_open(tocode, BBS_DEFAULT_CHARSET);
1043          if (stdout_cd == (iconv_t)(-1))          if (stdout_cd == (iconv_t)(-1))
1044          {          {
1045                  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);
1046                  iconv_close(stdin_cd);                  iconv_close(stdin_cd);
1047                  return -2;                  return -2;
1048          }          }


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1