/[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.77 by sysadm, Thu Dec 18 11:18:29 2025 UTC Revision 1.78 by sysadm, Thu Dec 18 11:37:08 2025 UTC
# Line 132  int io_init(void) Line 132  int io_init(void)
132                          log_error("epoll_ctl(STDOUT_FILENO) error (%d)\n", errno);                          log_error("epoll_ctl(STDOUT_FILENO) error (%d)\n", errno);
133                          if (close(stdout_epollfd) < 0)                          if (close(stdout_epollfd) < 0)
134                          {                          {
135                                  log_error("close(stdout_epollfd) error (%d)\n");                                  log_error("close(stdout_epollfd) error (%d)\n", errno);
136                          }                          }
137                          stdout_epollfd = -1;                          stdout_epollfd = -1;
138                          return -1;                          return -1;
# Line 214  void io_cleanup(void) Line 214  void io_cleanup(void)
214    
215                  if (close(stdout_epollfd) < 0)                  if (close(stdout_epollfd) < 0)
216                  {                  {
217                          log_error("close(stdout_epollfd) error (%d)\n");                          log_error("close(stdout_epollfd) error (%d)\n", errno);
218                  }                  }
219                  stdout_epollfd = -1;                  stdout_epollfd = -1;
220          }          }
# Line 262  int prints(const char *format, ...) Line 262  int prints(const char *format, ...)
262                          errno = EAGAIN;                          errno = EAGAIN;
263                          int need = stdout_buf_len + ret - OUTPUT_BUF_SIZE;                          int need = stdout_buf_len + ret - OUTPUT_BUF_SIZE;
264                          log_error("Output buffer is full, additional %d is required\n", need);                          log_error("Output buffer is full, additional %d is required\n", need);
265                            ret = -1;
266                  }                  }
267          }          }
268    
# Line 1166  int io_buf_conv(iconv_t cd, char *p_buf, Line 1167  int io_buf_conv(iconv_t cd, char *p_buf,
1167                  {                  {
1168                          if (errno == EINVAL) // Incomplete                          if (errno == EINVAL) // Incomplete
1169                          {                          {
1170                                  log_debug("iconv(inbytes=%ld, outbytes=%ld) error: EINVAL, in_buf[0]=%d\n", in_bytes, out_bytes, in_buf[0]);                                  log_debug("iconv(inbytes=%zu, outbytes=%zu) error: EINVAL, in_buf[0]=%d\n",
1171                                                      in_bytes, out_bytes, (unsigned char)in_buf[0]);
1172                                  if (p_buf != in_buf)                                  if (p_buf != in_buf)
1173                                  {                                  {
1174                                          *p_buf_len -= (int)(in_buf - p_buf);                                          *p_buf_len -= (int)(in_buf - p_buf);
# Line 1179  int io_buf_conv(iconv_t cd, char *p_buf, Line 1181  int io_buf_conv(iconv_t cd, char *p_buf,
1181                          }                          }
1182                          else if (errno == E2BIG)                          else if (errno == E2BIG)
1183                          {                          {
1184                                  log_error("iconv(inbytes=%ld, outbytes=%ld) error: E2BIG\n", in_bytes, out_bytes);                                  log_error("iconv(inbytes=%zu, outbytes=%zu) error: E2BIG\n", in_bytes, out_bytes);
1185                                  return -1;                                  return -1;
1186                          }                          }
1187                          else if (errno == EILSEQ)                          else if (errno == EILSEQ)
1188                          {                          {
1189                                  if (in_bytes > out_bytes || out_bytes <= 0)                                  if (in_bytes > out_bytes || out_bytes <= 0)
1190                                  {                                  {
1191                                          log_error("iconv(inbytes=%ld, outbytes=%ld) error: EILSEQ and E2BIG\n", in_bytes, out_bytes);                                          log_error("iconv(inbytes=%zu, outbytes=%zu) error: EILSEQ\n", in_bytes, out_bytes);
1192                                          return -2;                                          return -2;
1193                                  }                                  }
1194    
# Line 1194  int io_buf_conv(iconv_t cd, char *p_buf, Line 1196  int io_buf_conv(iconv_t cd, char *p_buf,
1196                                  if (in_bytes == 0)                                  if (in_bytes == 0)
1197                                  {                                  {
1198                                          in_bytes = (size_t)(*p_buf_len - *p_buf_offset);                                          in_bytes = (size_t)(*p_buf_len - *p_buf_offset);
1199                                          log_debug("Reset in_bytes from 0 to %ld\n", in_bytes);                                          log_debug("Reset in_bytes from 0 to %zu\n", in_bytes);
1200                                  }                                  }
1201    
1202                                  log_debug("iconv(in_bytes=%ld, out_bytes=%ld) error: EILSEQ, in_buf[0]=%d\n",                                  log_debug("iconv(in_bytes=%zu, out_bytes=%zu) error: EILSEQ, in_buf[0]=%d\n",
1203                                                    in_bytes, out_bytes, in_buf[0]);                                                    in_bytes, out_bytes, (unsigned char)in_buf[0]);
1204                                  skip_current = 1;                                  skip_current = 1;
1205                          }                          }
1206                          else // something strange                          else // something strange
1207                          {                          {
1208                                  log_debug("iconv(in_bytes=%ld, out_bytes=%ld) error: %d, in_buf[0]=%d\n",                                  log_debug("iconv(in_bytes=%zu, out_bytes=%zu) error: %d, in_buf[0]=%d\n",
1209                                                    in_bytes, out_bytes, errno, in_buf[0]);                                                    in_bytes, out_bytes, errno, (unsigned char)in_buf[0]);
1210                                  *p_buf_offset = (int)(in_buf - p_buf);                                  *p_buf_offset = (int)(in_buf - p_buf);
1211                                  *p_conv_len = (int)(conv_size - out_bytes);                                  *p_conv_len = (int)(conv_size - out_bytes);
1212                                  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