+ if( len == 0 ) return ;
+ if( len == -1 ) {
+ return ;
+ }
+ // handle options
+ int last_flush = 0;
+ for( int i = 0; i < len; i ++ )
+ {
+ switch(Client->Mode)
+ {
+ case MODE_IAC:
+ Client->Mode = MODE_DATA;
+ switch(buf[i])
+ {
+ case 240: // End of subnegotiation parameters
+ case 241: // Nop
+ break;
+ case 242: // SYNCH
+ case 243: // NVT Break
+ case 244: // Function 'IP' (Ctrl-C)
+
+ break;
+ case 245: // Function 'AO'
+ case 246: // Function 'AYT'
+ case 247: // Function 'EC'
+ case 248: // Function 'EL'
+ case 249: // GA Signal
+ case 250: // Subnegotation
+ break;
+ case 251: // WILL
+ Client->Mode = MODE_WILL;
+ break;
+ case 252: // WONT
+ Client->Mode = MODE_WILL;
+ break;
+ case 253: // DO
+ Client->Mode = MODE_WILL;
+ break;
+ case 254: // DONT
+ Client->Mode = MODE_WILL;
+ break;
+ case 255: // Literal 255
+ Client->Mode = MODE_DATA;
+ i --; // hacky!
+ break;
+ }
+ break;
+ case MODE_WILL:
+ _SysDebug("Option %i WILL", buf[i]);
+ Client->Mode = MODE_DATA;
+ break;
+ case MODE_WONT:
+ _SysDebug("Option %i WONT", buf[i]);
+ Client->Mode = MODE_DATA;
+ break;
+ case MODE_DO:
+ _SysDebug("Option %i DO", buf[i]);
+ Client->Mode = MODE_DATA;
+ break;
+ case MODE_DONT:
+ _SysDebug("Option %i DONT", buf[i]);
+ Client->Mode = MODE_DATA;
+ break;
+ case MODE_DATA:
+ if( buf[i] == 255 )
+ Client->Mode = MODE_IAC;
+ else
+ _SysWrite(Client->pty, buf+i, 1);
+ break;
+ }
+ }