else if (c == DM) { in_synch = 0; telnet_state = TOPLEVEL; }
static void do_telnet_read (char *buf, int len) {    unsigned char b[10];    while (len--) {	int c = (unsigned char) *buf++;	switch (telnet_state) {	  case TOPLEVEL:	  case SEENCR:	    if (c == NUL && telnet_state == SEENCR)		telnet_state = TOPLEVEL;	    else if (c == IAC)		telnet_state = SEENIAC;	    else {		b[0] = c;#if 0		if (!in_synch)#endif		    c_write (b, 1);		if (c == CR)		    telnet_state = SEENCR;		else		    telnet_state = TOPLEVEL;	    }	    break;	  case SEENIAC:	    if (c == DO) telnet_state = SEENDO;	    else if (c == DONT) telnet_state = SEENDONT;	    else if (c == WILL) telnet_state = SEENWILL;	    else if (c == WONT) telnet_state = SEENWONT;	    else if (c == SB) telnet_state = SEENSB;	    else {		/* ignore everything else; print it if it's IAC */		if (c == IAC) {		    b[0] = c;		    c_write(b,1);		}		telnet_state = TOPLEVEL;	    }	    break;	  case SEENWILL:	    proc_rec_opt (WILL, c);	    telnet_state = TOPLEVEL;	    break;	  case SEENWONT:	    proc_rec_opt (WONT, c);	    telnet_state = TOPLEVEL;	    break;	  case SEENDO:	    proc_rec_opt (DO, c);	    telnet_state = TOPLEVEL;	    break;	  case SEENDONT:	    proc_rec_opt (DONT, c);	    telnet_state = TOPLEVEL;	    break;	  case SEENSB:	    sb_opt = c;	    sb_len = 0;	    telnet_state = SUBNEGOT;	    break;	  case SUBNEGOT:	    if (c == IAC)		telnet_state = SUBNEG_IAC;	    else {		subneg_addchar:		if (sb_len >= sb_size) {		    char *newbuf;		    sb_size += SB_DELTA;		    newbuf = (sb_buf ?			      realloc(sb_buf, sb_size) :			      malloc(sb_size));		    if (newbuf)			sb_buf = newbuf;		    else			sb_size -= SB_DELTA;		}		if (sb_len < sb_size)		    sb_buf[sb_len++] = c;		telnet_state = SUBNEGOT;/* in case we came here by goto */	    }	    break;	  case SUBNEG_IAC:	    if (c != SE)		goto subneg_addchar;   /* yes, it's a hack, I know, but... */	    else {		process_subneg();		telnet_state = TOPLEVEL;	    }	    break;	}    }}