08 Apr, 2010, Sorressean wrote in the 1st comment:
Votes: 0
Hello all,
I just recently started working to implement mccp2 in my mudbase, and have all the relevant code written. When I connect, Mushclient tells me that it can't parse compressed output, and then closes. Below, I have posted both the code for starting compression and the compression bit of the "flush" function; if anyone could show me where I"m going wrong, it would be really appriciated. I'm slogging through smaug code, and zlib documentation to try to figure it out, but neither are all that explanitory.

//compression initialization:
if ((compress)&&(!_compress)) //make sure that compression isn't already turned on.
{
_cstream=new z_stream();
_cbuff=new unsigned char[2048];
_cstream->next_in=NULL;
_cstream->avail_in=0;
_cstream->next_out=_cbuff;
_cstream->avail_out=2048;
_cstream->opaque = Z_NULL;
_cstream->zalloc=Z_NULL;
_cstream->zfree=Z_NULL;
//try to initialize zlib.
if (deflateInit(_cstream,9)!=Z_OK)
{
_compress=false;
delete _cstream;
delete []_cbuff;
return;
}
Flush();
Write(std::string(TELNET_COMPRESS2_STR));
Flush();
_compress=true;
}


//Flush code:
unsigned char comp[2048];
if (_compress)
{
memset(_cbuff,0,2048);
memset(comp,0,2048);
memcpy(comp,_outBuffer.c_str(),_outBuffer.length());
_cstream->avail_in=_outBuffer.length();
_cstream->next_in=comp;
if (deflate(_cstream,Z_FINISH)!=Z_STREAM_END)
{
if (_control!=-1)
{
write(_control,_cbuff,(2048-_cstream->avail_out));
return true;
}
}
return false;
}


Everything compiles fine (with the exception of a couple typecast warnings from before), it's just the runtime issue I'm having problems with; mush not parsing the compression output, for some reason.
0.0/1