* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- * E-mail:
- * <brain@chatspike.net>
- * <Craig@chatspike.net>
- *
- * Written by Craig Edwards, Craig McLure, and others.
+ * InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
* This program is free but copyrighted software; see
* the file COPYING for details.
*
* ---------------------------------------------------
*/
-#include <string>
-#include <vector>
-
-#include "zlib.h"
-
-#include "inspircd_config.h"
-#include "configreader.h"
+#include "inspircd.h"
+#include <zlib.h>
#include "users.h"
#include "channels.h"
#include "modules.h"
-
#include "socket.h"
#include "hashcomp.h"
-#include "inspircd.h"
-
#include "transport.h"
/* $ModDesc: Provides zlib link support for servers */
}
/* Handle InspSocketHook API requests */
- virtual char* OnRequest(Request* request)
+ virtual char* OnRequest(Request* request)
{
ISHRequest* ISR = (ISHRequest*)request;
if (strcmp("IS_NAME", request->GetId()) == 0)
session->d_stream.avail_in = 0;
session->d_stream.next_out = (Bytef*)(buffer + offset);
+ /* If we cant call this, well, we're boned. */
if (inflateInit(&session->d_stream) != Z_OK)
- return -EBADF;
+ return 0;
while ((session->d_stream.total_out < count) && (session->d_stream.total_in < (unsigned int)size))
{
break;
}
+ /* Stick a fork in me, i'm done */
inflateEnd(&session->d_stream);
+ /* Update counters and offsets */
total_size += session->d_stream.total_out;
total_in_uncompressed += session->d_stream.total_out;
offset += session->d_stream.total_out;
}
+ /* Null-terminate the buffer -- this doesnt harm binary data */
buffer[total_size] = 0;
+
+ /* Set the read size to the correct total size */
readresult = total_size;
}
return 0;
}
}
- /* Finish the stream */
+ /* Finish the stream */
for (session->c_stream.avail_out = 1; deflate(&session->c_stream, Z_FINISH) != Z_STREAM_END; session->c_stream.avail_out = 1);
deflateEnd(&session->c_stream);
return 0;
else
{
- session->outbuf = "";
+ session->outbuf.clear();
return 0;
}
}
else
{
- session->outbuf = "";
+ session->outbuf.clear();
return 0;
}
}
void CloseSession(izip_session* session)
{
- if (session->status = IZIP_OPEN)
+ if (session->status == IZIP_OPEN)
{
session->status = IZIP_CLOSED;
- session->outbuf = "";
+ session->outbuf.clear();
delete session->inbuf;
}
}
};
-class ModuleZLibFactory : public ModuleFactory
-{
- public:
- ModuleZLibFactory()
- {
- }
-
- ~ModuleZLibFactory()
- {
- }
-
- virtual Module * CreateModule(InspIRCd* Me)
- {
- return new ModuleZLib(Me);
- }
-};
-
+MODULE_INIT(ModuleZLib);
-extern "C" void * init_module( void )
-{
- return new ModuleZLibFactory;
-}