/[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.71 by sysadm, Sun Nov 23 06:43:51 2025 UTC Revision 1.73 by sysadm, Wed Dec 17 03:56:39 2025 UTC
# Line 64  static int stdout_conv_len = 0; Line 64  static int stdout_conv_len = 0;
64  static int stdin_conv_offset = 0;  static int stdin_conv_offset = 0;
65  static int stdout_conv_offset = 0;  static int stdout_conv_offset = 0;
66    
67  static iconv_t stdin_cd = NULL;  static iconv_t stdin_cd = (iconv_t)(-1);
68  static iconv_t stdout_cd = NULL;  static iconv_t stdout_cd = (iconv_t)(-1);
69    
70  int io_init(void)  int io_init(void)
71  {  {
# Line 308  int iflush(void) Line 308  int iflush(void)
308                                                  ret = ssh_channel_write(SSH_channel, stdout_conv + stdout_conv_offset, (uint32_t)(stdout_conv_len - stdout_conv_offset));                                                  ret = ssh_channel_write(SSH_channel, stdout_conv + stdout_conv_offset, (uint32_t)(stdout_conv_len - stdout_conv_offset));
309                                                  if (ret == SSH_ERROR)                                                  if (ret == SSH_ERROR)
310                                                  {                                                  {
311    #ifdef _DEBUG
312                                                          log_error("ssh_channel_write() error: %s\n", ssh_get_error(SSH_session));                                                          log_error("ssh_channel_write() error: %s\n", ssh_get_error(SSH_session));
313    #endif
314                                                          retry = 0;                                                          retry = 0;
315                                                          break;                                                          break;
316                                                  }                                                  }
# Line 392  int igetch(int timeout) Line 394  int igetch(int timeout)
394                  {                  {
395                          if (SSH_v2 && ssh_channel_is_closed(SSH_channel))                          if (SSH_v2 && ssh_channel_is_closed(SSH_channel))
396                          {                          {
397    #ifdef _DEBUG
398                                  log_error("SSH channel is closed\n");                                  log_error("SSH channel is closed\n");
399    #endif
400                                  loop = 0;                                  loop = 0;
401                                  break;                                  break;
402                          }                          }
# Line 450  int igetch(int timeout) Line 454  int igetch(int timeout)
454                                                  ret = ssh_channel_read_nonblocking(SSH_channel, stdin_buf + stdin_buf_len, sizeof(stdin_buf) - (uint32_t)stdin_buf_len, 0);                                                  ret = ssh_channel_read_nonblocking(SSH_channel, stdin_buf + stdin_buf_len, sizeof(stdin_buf) - (uint32_t)stdin_buf_len, 0);
455                                                  if (ret == SSH_ERROR)                                                  if (ret == SSH_ERROR)
456                                                  {                                                  {
457    #ifdef _DEBUG
458                                                          log_error("ssh_channel_read_nonblocking() error: %s\n", ssh_get_error(SSH_session));                                                          log_error("ssh_channel_read_nonblocking() error: %s\n", ssh_get_error(SSH_session));
459    #endif
460                                                          loop = 0;                                                          loop = 0;
461                                                          break;                                                          break;
462                                                  }                                                  }
# Line 1189  int io_conv_init(const char *charset) Line 1195  int io_conv_init(const char *charset)
1195          {          {
1196                  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);
1197                  iconv_close(stdin_cd);                  iconv_close(stdin_cd);
1198                    stdin_cd = (iconv_t)(-1);
1199                  return -2;                  return -2;
1200          }          }
1201    
# Line 1197  int io_conv_init(const char *charset) Line 1204  int io_conv_init(const char *charset)
1204    
1205  int io_conv_cleanup(void)  int io_conv_cleanup(void)
1206  {  {
1207          if (stdin_cd != NULL)          if (stdin_cd != (iconv_t)(-1))
1208          {          {
1209                  iconv_close(stdin_cd);                  iconv_close(stdin_cd);
1210                  stdin_cd = NULL;                  stdin_cd = (iconv_t)(-1);
1211          }          }
1212          if (stdout_cd != NULL)          if (stdout_cd != (iconv_t)(-1))
1213          {          {
1214                  iconv_close(stdout_cd);                  iconv_close(stdout_cd);
1215                  stdout_cd = NULL;                  stdout_cd = (iconv_t)(-1);
1216          }          }
1217    
1218          return 0;          return 0;


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

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