adding mccp

Posted by Typhon on Fri 16 Apr 2004 02:48 PM — 15 posts, 41,297 views.

USA #0
im trying to add mccp support to my mud and it seems that with alot of effort ive gotten no where. if i comment out #define MCCP in mud.h the mud compiles fine and runs no problems. however, when i try to compile it with mccp i get..
Quote:

make pr
hacking...comm.c...
comm.o(.text+0x2622): In function `write_to_descriptor':
/home/lod/src/comm.c:1687: undefined reference to `deflate'
comm.o(.text+0x7867): In function `compressStart':
/home/lod/src/comm.c:4319: undefined reference to `deflateInit_'
comm.o(.text+0x79bd): In function `compressEnd':
/home/lod/src/comm.c:4351: undefined reference to `deflate'
comm.o(.text+0x79f5):/home/lod/src/comm.c:4357: undefined reference to `deflateEnd'
collect2: ld returned 1 exit status
make: *** [pr] Error 1

i get the same problem if i compile it on a linux box or in cygwin.
tanks
typ.
Canada #1
Sounds like your either missing
#include <zlib.h>
at the top of the file. If you have that, you may be missing the zlib package for cygwin, in which case you would need to go get it.
USA #2
lol yea ive included zlid.h but both my copy of cygwin and the server both have the zlib package. still cant seem to figure it out :\
Australia Forum Administrator #3
These are link errors, right? You need to link against the zlib library. Make sure you have -lz as one of your options on the link line in the Makefile.
USA #4
thats there too :(
Australia Forum Administrator #5
Where did you get the MCCP code from?
USA #6
http://www.dotd.com/source/
i downloaded both mccp.patch and mccp2.patch i worked from tehre. my mud is highly modded so i couldnt patch it :\
had to do it all manually.
Australia Forum Administrator #7
I downloaded the mccp2 patch and applied it to smaug 1.4a.

I got the same messages you got, but changed the makefile to add the library, as I suggested earlier, and it linked OK:


L_FLAGS = $(OPT_FLAG) $(PROF) $(SOLARIS_LINK) $(NEED_CRYPT) -lz


However when testing I got these messages:


Sat Apr 17 14:24:17 2004 :: [*****] BUG: Starting compression for descriptor 10
Sat Apr 17 14:24:17 2004 :: [*****] BUG: Stopping compression for descriptor 10


So, it would seem it is not working perfectly, however you should be able to get it to compile. ;)

Australia Forum Administrator #8
I worked out why it was turning compression off.

It seems the server is sending IAC WILL COMPRESS *and* IAC WILL COMPRESS2 (MCCP version 1, and MCCP version 2).

MUSHclient replies IAC DO COMPRESS2 and IAC DONT COMPRESS (indicating it supports MCCP version 2) however the IAC DONT COMPRESS turns off the compression.

I'm not sure where the bug is here exactly, but commenting out the code to detect turning off MCCP version 1 seemed to work. eg.


#ifdef MCCP
        if ( d->inbuf[i] == (signed char)IAC )
            iac=1;
        else if ( iac==1 && (d->inbuf[i] == (signed char)DO || d->inbuf[i] == (signed char)DONT) )
            iac=2;
        else if ( iac==2 )
        {
            iac = 0;
            /*if ( d->inbuf[i] == (signed char)TELOPT_COMPRESS )
            {
                if ( d->inbuf[i-1] == (signed char)DO )
                    compressStart(d, TELOPT_COMPRESS);
                else if ( d->inbuf[i-1] == (signed char)DONT )
                    compressEnd(d);
            }
            else */ if ( d->inbuf[i] == (signed char)TELOPT_COMPRESS2 )
            {
                if ( d->inbuf[i-1] == (signed char)DO )
                    compressStart(d, TELOPT_COMPRESS2);
                else if ( d->inbuf[i-1] == (signed char)DONT )
                    compressEnd(d);
            }
        }
        else
#endif


This could probably be handled better. For instance, you would remember which sort of compression you were doing so that rather than just calling compressEnd you would say something like:

if (d->compress_type == 1)
compressEnd (d);

Amended on Sat 17 Apr 2004 05:52 AM by Nick Gammon
USA #9
L_FLAGS = $(PROF) $(L) -lm -lz
:\ i still cant figure out why its not linking... the flag is there and zlib.h is on the server :\
USA #10
well
commenting out that part of the code worked
thanks nick :)
Australia Forum Administrator #11
Quote:

i still cant figure out why its not linking... the flag is there and zlib.h is on the server


zlib.h is needed for *compiling*. However for *linking* you need libz.a which is the library. When you use -lz it adds "lib" to the front and ".a" to the back, and then looks for it in the library directory, whatever that is.
USA #12
lol for whatevre reason the mud doesnt like that code that you commented out. thanks again :)
Australia Forum Administrator #13
Is the matter resolved or not? Did you ever get it to compile (and link)? In what way does it not like the commented-out code? Is there an error?
USA #14
yes it compiles now :)