rem: debug("(telnet) ate %d chars\n", eat_chars);
add: debug(("(telnet) ate %d chars\n", eat_chars));
context: void netcat_telnet_parse(nc_sock_t *ncsock){  static unsigned char getrq[4];  static int l = 0;  unsigned char putrq[4], *buf = ncsock->recvq.pos;  int i, *size = &ncsock->recvq.len, eat_chars = 0, ref_size = *size;  debug_v("netcat_telnet_parse(ncsock=%p)", (void *)ncsock);  /* if the socket object is NULL, assume a reset command */  if (ncsock == NULL) {    l = 0;    return;  }  /* loop all chars of the string */  for (i = 0; i < ref_size; i++) {    /* if we found IAC char OR we are fetching a IAC code string process it */    if ((buf[i] != TELNET_IAC) && (l == 0))      continue;#ifndef USE_OLD_TELNET    /* this is surely a char that will be eaten */    eat_chars++;#endif    /* copy the char in the IAC-code-building buffer */    getrq[l++] = buf[i];    /* if this is the first char (IAC!) go straight to the next one */    if (l == 1)      continue;    /* identify the IAC code. The effect is resolved here. If the char needs       further data the subsection just needs to leave the index 'l' set. */    switch (getrq[1]) {    case TELNET_SE:    case TELNET_NOP:      goto do_eat_chars;    case TELNET_DM:    case TELNET_BRK:    case TELNET_IP:    case TELNET_AO:    case TELNET_AYT:    case TELNET_EC:    case TELNET_EL:    case TELNET_GA:    case TELNET_SB:      goto do_eat_chars;    case TELNET_WILL:    case TELNET_WONT:      if (l < 3) /* need more data */        continue;      /* refuse this option */      putrq[0] = 0xFF;      putrq[1] = TELNET_DONT;      putrq[2] = getrq[2];      /* FIXME: the rfc seems not clean about what to do if the sending queue         is not empty.  Since it's the simplest solution, just override the         queue for now, but this must change in future. */      write(ncsock->fd, putrq, 3);		/* FIXME: handle failures */      goto do_eat_chars;    case TELNET_DO:    case TELNET_DONT:      if (l < 3) /* need more data */        continue;      /* refuse this option */      putrq[0] = 0xFF;      putrq[1] = TELNET_WONT;      putrq[2] = getrq[2];      write(ncsock->fd, putrq, 3);      goto do_eat_chars;    case TELNET_IAC:#ifndef USE_OLD_TELNET      /* insert a byte 255 in the buffer.  Note that we don't know in which         position we are, but there must be at least 1 eaten char where we         can park our data byte.  This effect is senseless if using the old         telnet codes parsing policy. */      buf[i - --eat_chars] = 0xFF;#endif      goto do_eat_chars;    default:      /* FIXME: how to handle the unknown code? */      break;    }    continue; do_eat_chars:    /* ... */    l = 0;#ifndef USE_OLD_TELNET    if (eat_chars > 0) {      unsigned char *from, *to;      debug("(telnet) ate %d chars\n", eat_chars);      /* move the index to the overlapper character */      i++;      /* if this is the end of the string, memmove() does not care of a null         size, it simply does nothing. */      from = &buf[i];      to = &buf[i - eat_chars];      memmove(to, from, ref_size - i);      /* fix the index.  since the loop will auto-increment the index we need         to put it one char before.  this means that it can become negative         but it isn't a big problem since it is signed. */      i -= eat_chars + 1;      ref_size -= eat_chars;      eat_chars = 0;    }#endif  }  /* we are at the end of the buffer. all we have to do now is updating the     authoritative buffer size.  In case that there is a broken-down telnet     code, the do_eat_chars section is not executed, thus there may be some     pending chars that needs to be removed.  This is handled here in an easy     way: since they are at the end of the buffer, just cut them playing with     the buffer length. */#ifdef USE_OLD_TELNET  assert(eat_chars == 0);#endif  *size = ref_size - eat_chars;}