/[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.74 by sysadm, Thu Dec 18 02:17:39 2025 UTC Revision 1.76 by sysadm, Thu Dec 18 03:23:48 2025 UTC
# Line 282  int iflush(void) Line 282  int iflush(void)
282                  for (int i = 0; i < nfds; i++)                  for (int i = 0; i < nfds; i++)
283                  {                  {
284  #ifdef HAVE_SYS_EPOLL_H  #ifdef HAVE_SYS_EPOLL_H
285                          if (events[i].data.fd == STDOUT_FILENO && (events[i].events & (EPOLLRDHUP | EPOLLHUP | EPOLLERR)))                          if (events[i].data.fd == STDOUT_FILENO && (events[i].events & (EPOLLHUP | EPOLLERR)))
286  #else  #else
287                          if (pfds[i].fd == STDOUT_FILENO && (pfds[i].revents & (POLLRDHUP | POLLHUP | POLLERR)))                          if (pfds[i].fd == STDOUT_FILENO && (pfds[i].revents & (POLLHUP | POLLERR)))
288  #endif  #endif
289                          {                          {
 #ifdef _DEBUG  
290  #ifdef HAVE_SYS_EPOLL_H  #ifdef HAVE_SYS_EPOLL_H
291                                  log_error("STDOUT error events (%d)\n", events[i].events);                                  log_debug("STDOUT error events (%d)\n", events[i].events);
292  #else  #else
293                                  log_error("STDOUT error events (%d)\n", pfds[i].revents);                                  log_debug("STDOUT error events (%d)\n", pfds[i].revents);
 #endif  
294  #endif  #endif
295                                  retry = 0;                                  retry = 0;
296                                  break;                                  break;
# Line 321  int iflush(void) Line 319  int iflush(void)
319                                                  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));
320                                                  if (ret == SSH_ERROR)                                                  if (ret == SSH_ERROR)
321                                                  {                                                  {
322  #ifdef _DEBUG                                                          log_debug("ssh_channel_write() error: %s\n", ssh_get_error(SSH_session));
                                                         log_error("ssh_channel_write() error: %s\n", ssh_get_error(SSH_session));  
 #endif  
323                                                          retry = 0;                                                          retry = 0;
324                                                          break;                                                          break;
325                                                  }                                                  }
# Line 344  int iflush(void) Line 340  int iflush(void)
340                                                  }                                                  }
341                                                  else                                                  else
342                                                  {                                                  {
343  #ifdef _DEBUG                                                          log_debug("write(STDOUT) error (%d)\n", errno);
                                                         log_error("write(STDOUT) error (%d)\n", errno);  
 #endif  
344                                                          retry = 0;                                                          retry = 0;
345                                                          break;                                                          break;
346                                                  }                                                  }
# Line 407  int igetch(int timeout) Line 401  int igetch(int timeout)
401                  {                  {
402                          if (SSH_v2 && ssh_channel_is_closed(SSH_channel))                          if (SSH_v2 && ssh_channel_is_closed(SSH_channel))
403                          {                          {
404  #ifdef _DEBUG                                  log_debug("SSH channel is closed\n");
                                 log_error("SSH channel is closed\n");  
 #endif  
405                                  loop = 0;                                  loop = 0;
406                                  break;                                  break;
407                          }                          }
# Line 448  int igetch(int timeout) Line 440  int igetch(int timeout)
440                                  for (int i = 0; i < nfds; i++)                                  for (int i = 0; i < nfds; i++)
441                                  {                                  {
442  #ifdef HAVE_SYS_EPOLL_H  #ifdef HAVE_SYS_EPOLL_H
443                                          if (events[i].data.fd == STDIN_FILENO && (events[i].events & (EPOLLRDHUP | EPOLLHUP | EPOLLERR)))                                          if (events[i].data.fd == STDIN_FILENO && (events[i].events & (EPOLLHUP | EPOLLERR)))
444  #else  #else
445                                          if (pfds[i].fd == STDIN_FILENO && (pfds[i].revents & (POLLRDHUP | POLLHUP | POLLERR)))                                          if (pfds[i].fd == STDIN_FILENO && (pfds[i].revents & (POLLHUP | POLLERR)))
446  #endif  #endif
447                                          {                                          {
 #ifdef _DEBUG  
448  #ifdef HAVE_SYS_EPOLL_H  #ifdef HAVE_SYS_EPOLL_H
449                                                  log_error("STDIN error events (%d)\n", events[i].events);                                                  log_debug("STDIN error events (%d)\n", events[i].events);
450  #else  #else
451                                                  log_error("STDIN error events (%d)\n", pfds[i].revents);                                                  log_debug("STDIN error events (%d)\n", pfds[i].revents);
 #endif  
452  #endif  #endif
453                                                  loop = 0;                                                  loop = 0;
454                                                  break;                                                  break;
# Line 484  int igetch(int timeout) Line 474  int igetch(int timeout)
474                                                  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);
475                                                  if (ret == SSH_ERROR)                                                  if (ret == SSH_ERROR)
476                                                  {                                                  {
477  #ifdef _DEBUG                                                          log_debug("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));  
 #endif  
478                                                          loop = 0;                                                          loop = 0;
479                                                          break;                                                          break;
480                                                  }                                                  }
# Line 523  int igetch(int timeout) Line 511  int igetch(int timeout)
511                                                  }                                                  }
512                                                  else                                                  else
513                                                  {                                                  {
514  #ifdef _DEBUG                                                          log_debug("read(STDIN) error (%d)\n", errno);
                                                         log_error("read(STDIN) error (%d)\n", errno);  
 #endif  
515                                                          loop = 0;                                                          loop = 0;
516                                                          break;                                                          break;
517                                                  }                                                  }
# Line 548  int igetch(int timeout) Line 534  int igetch(int timeout)
534  #ifdef _DEBUG  #ifdef _DEBUG
535                          for (int j = stdin_buf_offset; j < stdin_buf_len; j++)                          for (int j = stdin_buf_offset; j < stdin_buf_len; j++)
536                          {                          {
537                                  log_error("Debug input: <--[%u]\n", (stdin_buf[j] + 256) % 256);                                  log_debug("input: <--[%u]\n", (stdin_buf[j] + 256) % 256);
538                          }                          }
539  #endif  #endif
540                  }                  }
# Line 566  int igetch(int timeout) Line 552  int igetch(int timeout)
552  #ifdef _DEBUG  #ifdef _DEBUG
553                          for (int j = stdin_conv_offset; j < stdin_conv_len; j++)                          for (int j = stdin_conv_offset; j < stdin_conv_len; j++)
554                          {                          {
555                                  log_error("Debug input_conv: <--[%u]\n", (stdin_conv[j] + 256) % 256);                                  log_debug("input_conv: <--[%u]\n", (stdin_conv[j] + 256) % 256);
556                          }                          }
557  #endif  #endif
558                  }                  }
# Line 1032  int igetch(int timeout) Line 1018  int igetch(int timeout)
1018  #ifdef _DEBUG  #ifdef _DEBUG
1019          if (out != KEY_TIMEOUT && out != KEY_NULL)          if (out != KEY_TIMEOUT && out != KEY_NULL)
1020          {          {
1021                  log_error("Debug: -->[0x %x]\n", out);                  log_debug("output: -->[0x %x]\n", out);
1022          }          }
1023  #endif  #endif
1024    
# Line 1126  int io_buf_conv(iconv_t cd, char *p_buf, Line 1112  int io_buf_conv(iconv_t cd, char *p_buf,
1112                  {                  {
1113                          if (errno == EINVAL) // Incomplete                          if (errno == EINVAL) // Incomplete
1114                          {                          {
1115  #ifdef _DEBUG                                  log_debug("iconv(inbytes=%d, outbytes=%d) error: EINVAL, in_buf[0]=%d\n", in_bytes, out_bytes, in_buf[0]);
                                 log_error("iconv(inbytes=%d, outbytes=%d) error: EINVAL, in_buf[0]=%d\n", in_bytes, out_bytes, in_buf[0]);  
 #endif  
1116                                  if (p_buf != in_buf)                                  if (p_buf != in_buf)
1117                                  {                                  {
1118                                          *p_buf_len -= (int)(in_buf - p_buf);                                          *p_buf_len -= (int)(in_buf - p_buf);
# Line 1156  int io_buf_conv(iconv_t cd, char *p_buf, Line 1140  int io_buf_conv(iconv_t cd, char *p_buf,
1140                                  if (in_bytes == 0)                                  if (in_bytes == 0)
1141                                  {                                  {
1142                                          in_bytes = (size_t)(*p_buf_len - *p_buf_offset);                                          in_bytes = (size_t)(*p_buf_len - *p_buf_offset);
1143  #ifdef _DEBUG                                          log_debug("Reset in_bytes from 0 to %d\n", in_bytes);
                                         log_error("Reset in_bytes from 0 to %d\n", in_bytes);  
 #endif  
1144                                  }                                  }
1145    
1146  #ifdef _DEBUG                                  log_debug("iconv(in_bytes=%d, out_bytes=%d) error: EILSEQ, in_buf[0]=%d\n",
                                 log_error("iconv(in_bytes=%d, out_bytes=%d) error: EILSEQ, in_buf[0]=%d\n",  
1147                                                    in_bytes, out_bytes, in_buf[0]);                                                    in_bytes, out_bytes, in_buf[0]);
 #endif  
1148                                  skip_current = 1;                                  skip_current = 1;
1149                          }                          }
1150                          else // something strange                          else // something strange
1151                          {                          {
1152  #ifdef _DEBUG                                  log_debug("iconv(in_bytes=%d, out_bytes=%d) error: %d, in_buf[0]=%d\n",
                                 log_error("iconv(in_bytes=%d, out_bytes=%d) error: %d, in_buf[0]=%d\n",  
1153                                                    in_bytes, out_bytes, errno, in_buf[0]);                                                    in_bytes, out_bytes, errno, in_buf[0]);
 #endif  
1154                                  *p_buf_offset = (int)(in_buf - p_buf);                                  *p_buf_offset = (int)(in_buf - p_buf);
1155                                  *p_conv_len = (int)(conv_size - out_bytes);                                  *p_conv_len = (int)(conv_size - out_bytes);
1156                                  skip_current = 1;                                  skip_current = 1;


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

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