/[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.62 by sysadm, Tue Nov 4 13:49:51 2025 UTC Revision 1.65 by sysadm, Tue Nov 11 00:28:05 2025 UTC
# Line 3  Line 3 
3   * io   * io
4   *   - basic terminal-based user input / output features   *   - basic terminal-based user input / output features
5   *   *
6   * Copyright (C) 2004-2025 by Leaflet <leaflet@leafok.com>   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>
7   */   */
8    
9    #ifdef HAVE_CONFIG_H
10    #include "config.h"
11    #endif
12    
13  #include "common.h"  #include "common.h"
14  #include "io.h"  #include "io.h"
15  #include "log.h"  #include "log.h"
# Line 23  Line 27 
27  #include <libssh/libssh.h>  #include <libssh/libssh.h>
28  #include <libssh/server.h>  #include <libssh/server.h>
29    
30  char stdio_charset[20] = BBS_DEFAULT_CHARSET;  const char BBS_default_charset[CHARSET_MAX_LEN + 1] = "UTF-8";
31    char stdio_charset[CHARSET_MAX_LEN + 1] = "UTF-8";
32    
33  // static input / output buffer  // static input / output buffer
34  static char stdin_buf[LINE_BUFFER_LEN];  static char stdin_buf[LINE_BUFFER_LEN];
# Line 1026  int io_buf_conv(iconv_t cd, char *p_buf, Line 1031  int io_buf_conv(iconv_t cd, char *p_buf,
1031    
1032  int io_conv_init(const char *charset)  int io_conv_init(const char *charset)
1033  {  {
1034          char tocode[32];          char tocode[CHARSET_MAX_LEN + 20];
1035    
1036          if (charset == NULL)          if (charset == NULL)
1037          {          {
# Line 1039  int io_conv_init(const char *charset) Line 1044  int io_conv_init(const char *charset)
1044          strncpy(stdio_charset, charset, sizeof(stdio_charset) - 1);          strncpy(stdio_charset, charset, sizeof(stdio_charset) - 1);
1045          stdio_charset[sizeof(stdio_charset) - 1] = '\0';          stdio_charset[sizeof(stdio_charset) - 1] = '\0';
1046    
1047          snprintf(tocode, sizeof(tocode), "%s%s", BBS_DEFAULT_CHARSET,          snprintf(tocode, sizeof(tocode), "%s%s", BBS_default_charset,
1048                           (strcasecmp(stdio_charset, BBS_DEFAULT_CHARSET) == 0 ? "" : "//IGNORE"));                           (strcasecmp(stdio_charset, BBS_default_charset) == 0 ? "" : "//IGNORE"));
1049          stdin_cd = iconv_open(tocode, stdio_charset);          stdin_cd = iconv_open(tocode, stdio_charset);
1050          if (stdin_cd == (iconv_t)(-1))          if (stdin_cd == (iconv_t)(-1))
1051          {          {
# Line 1049  int io_conv_init(const char *charset) Line 1054  int io_conv_init(const char *charset)
1054          }          }
1055    
1056          snprintf(tocode, sizeof(tocode), "%s%s", stdio_charset,          snprintf(tocode, sizeof(tocode), "%s%s", stdio_charset,
1057                           (strcasecmp(BBS_DEFAULT_CHARSET, stdio_charset) == 0 ? "" : "//TRANSLIT"));                           (strcasecmp(BBS_default_charset, stdio_charset) == 0 ? "" : "//TRANSLIT"));
1058          stdout_cd = iconv_open(tocode, BBS_DEFAULT_CHARSET);          stdout_cd = iconv_open(tocode, BBS_default_charset);
1059          if (stdout_cd == (iconv_t)(-1))          if (stdout_cd == (iconv_t)(-1))
1060          {          {
1061                  log_error("iconv_open(%s->%s) error: %d\n", BBS_DEFAULT_CHARSET, tocode, errno);                  log_error("iconv_open(%s->%s) error: %d\n", BBS_default_charset, tocode, errno);
1062                  iconv_close(stdin_cd);                  iconv_close(stdin_cd);
1063                  return -2;                  return -2;
1064          }          }


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

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