]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_ziplink.cpp
Change the SQLutils and SQL providers to also use interfaces for proper unload order...
[user/henk/code/inspircd.git] / src / modules / extra / m_ziplink.cpp
index 71f7105512a7340fc45ba07ed38431ff7f1c84f0..ab40acb46556514faa9c7241622db6ca048523a3 100644 (file)
@@ -2,21 +2,15 @@
  *       | 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"
@@ -328,8 +322,9 @@ class ModuleZLib : public Module
                                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))
                                {
@@ -338,14 +333,19 @@ class ModuleZLib : public Module
                                                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;
 
                }
@@ -443,7 +443,7 @@ class ModuleZLib : public Module
        
        void CloseSession(izip_session* session)
        {
-               if (session->status = IZIP_OPEN)
+               if (session->status == IZIP_OPEN)
                {
                        session->status = IZIP_CLOSED;
                        session->outbuf = "";