From 8d3c6acc8cb23eb87d00395a0bf399470b190f08 Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 10 Dec 2006 13:49:00 +0000 Subject: More stuff git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5910 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/extra/m_ziplink.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/modules/extra/m_ziplink.cpp') diff --git a/src/modules/extra/m_ziplink.cpp b/src/modules/extra/m_ziplink.cpp index a595bd856..59ae89605 100644 --- a/src/modules/extra/m_ziplink.cpp +++ b/src/modules/extra/m_ziplink.cpp @@ -165,11 +165,21 @@ class ModuleZLib : public Module inflateEnd(&session->d_stream); readresult = session->d_stream.total_out; + + buffer[readresult] = 0; + + ServerInstance->Log(DEBUG,"DECOMPRESSED: '%s'", buffer); } else { /* XXX: We need to buffer here, really. */ - ServerInstance->Log(DEBUG,"Didnt read whole frame!"); + if (readresult == -1) + { + ServerInstance->Log(DEBUG,"Error: %s", strerror(errno)); + if (errno == EAGAIN) + ServerInstance->Log(DEBUG,"(EAGAIN)"); + } + ServerInstance->Log(DEBUG,"Didnt read whole frame, got %d bytes of %d!", readresult, size); } return (readresult > 0); @@ -186,7 +196,7 @@ class ModuleZLib : public Module return 1; } - unsigned char compr[count*2]; + unsigned char compr[count*2+4]; izip_session* session = &sessions[fd]; @@ -209,7 +219,7 @@ class ModuleZLib : public Module } session->c_stream.next_in = (Bytef*)buffer; - session->c_stream.next_out = compr; + session->c_stream.next_out = compr+4; while ((session->c_stream.total_in < (unsigned int)count) && (session->c_stream.total_out < (unsigned int)count*2)) { @@ -230,9 +240,9 @@ class ModuleZLib : public Module } ServerInstance->Log(DEBUG,"Write %d compressed bytes", session->c_stream.total_out); - unsigned int x = htonl(session->c_stream.total_out); - write(fd, &x, sizeof(x)); - write(fd, compr, session->c_stream.total_out); + int x = htonl(session->c_stream.total_out); + memcpy(compr, &x, sizeof(x)); + write(fd, compr, session->c_stream.total_out+4); deflateEnd(&session->c_stream); -- cgit v1.2.3