commit - e25f23014a4571eb169b860ef5ee4f72f9162e4c
commit + af0c4b66b9814e07545749d15fffac4b1410ef43
blob - 7aab2841b3f234aaffe8d18144053e94047bc48a
blob + 7e8baefd7485690545f4e54b94b76820383a2470
--- de/mud/telnet/TelnetProtocolHandler.java
+++ de/mud/telnet/TelnetProtocolHandler.java
/*
* This file is part of "The Java Telnet Application".
*
- * (c) Matthias L. Jugel, Marcus Meissner 1996-2002. All Rights Reserved.
+ * (c) Matthias L. Jugel, Marcus Meissner 1996-2004. All Rights Reserved.
*
* Please visit http://javatelnet.org/ for updates and contact.
*
/** What IAC SB <xx> we are handling right now */
private byte current_sb;
+
+ /** current SB negotiation buffer */
+ private byte[] sbbuf;
/** IAC - init sequence for telnet negotiation. */
private final static byte IAC = (byte)255;
* Handle an incoming IAC SB <type> <bytes> IAC SE
* @param type type of SB
* @param sbata byte array as <bytes>
- * @param sbcount nr of bytes. may be 0 too.
*/
- private void handle_sb(byte type, byte[] sbdata, int sbcount)
+ private void handle_sb(byte type, byte[] sbdata)
throws IOException {
if(debug > 1)
System.err.println("TelnetIO.handle_sb("+type+")");
switch (type) {
case TELOPT_TTYPE:
- if (sbcount>0 && sbdata[0]==TELQUAL_SEND) {
+ if (sbdata.length>0 && sbdata[0]==TELQUAL_SEND) {
write(IACSB);write(TELOPT_TTYPE);write(TELQUAL_IS);
/* FIXME: need more logic here if we use
* more than one terminal type
public int negotiate(byte nbuf[])
throws IOException
{
- byte sbbuf[] = new byte[tempbuf.length];
int count = tempbuf.length;
byte[] buf = tempbuf;
byte sendbuf[] = new byte[3];
byte b,reply;
- int sbcount = 0;
int boffset = 0, noffset = 0;
boolean dobreak = false;
case SB:
if(debug > 2) System.err.print("SB ");
neg_state = STATE_IACSB;
- sbcount = 0;
break;
default:
if(debug > 2) System.err.print("<UNKNOWN "+b+" > ");
case STATE_IACSBIAC:
if(debug > 2) System.err.println(""+b+" ");
if (b == IAC) {
- sbcount = 0;
+ sbbuf = new byte[0];
current_sb = b;
neg_state = STATE_IACSBDATA;
} else {
break;
default:
current_sb = b;
- sbcount = 0;
+ sbbuf = new byte[0];
neg_state = STATE_IACSBDATA;
break;
}
neg_state = STATE_IACSBDATAIAC;
break;
default:
- sbbuf[sbcount++] = b;
+ byte[] xsb = new byte[sbbuf.length+1];
+ System.arraycopy(sbbuf,0,xsb,0,sbbuf.length);
+ sbbuf = xsb;
+ sbbuf[sbbuf.length-1] = b;
break;
}
break;
switch (b) {
case IAC:
neg_state = STATE_IACSBDATA;
- sbbuf[sbcount++] = IAC;
+ byte[] xsb = new byte[sbbuf.length+1];
+ System.arraycopy(sbbuf,0,xsb,0,sbbuf.length);
+ sbbuf = xsb;
+ sbbuf[sbbuf.length-1] = IAC;
break;
case SE:
- handle_sb(current_sb,sbbuf,sbcount);
+ handle_sb(current_sb,sbbuf);
current_sb = 0;
neg_state = STATE_DATA;
break;
case SB:
- handle_sb(current_sb,sbbuf,sbcount);
+ handle_sb(current_sb,sbbuf);
neg_state = STATE_IACSB;
break;
default: