From 7094588c5338f21a94c1f2244a2bf76d31914158 Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 30 Jan 2017 19:56:06 -0500 Subject: [PATCH] print zlib error codes --- Gzip.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Gzip.cpp b/Gzip.cpp index da9f06b1..db991283 100644 --- a/Gzip.cpp +++ b/Gzip.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2016, The PurpleI2P Project +* Copyright (c) 2013-2017, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -9,11 +9,13 @@ #include #include /* memset */ #include - +#include "Log.h" #include "Gzip.h" -namespace i2p { -namespace data { +namespace i2p +{ +namespace data +{ const size_t GZIP_CHUNK_SIZE = 16384; GzipInflator::GzipInflator (): m_IsDirty (false) @@ -36,9 +38,10 @@ namespace data { m_Inflator.next_out = out; m_Inflator.avail_out = outLen; int err; - if ((err = inflate (&m_Inflator, Z_NO_FLUSH)) == Z_STREAM_END) { + if ((err = inflate (&m_Inflator, Z_NO_FLUSH)) == Z_STREAM_END) return outLen - m_Inflator.avail_out; - } + // else + LogPrint (eLogError, "Gzip: Inflate error ", err); return 0; } @@ -49,17 +52,20 @@ namespace data { m_Inflator.next_in = const_cast(in); m_Inflator.avail_in = inLen; int ret; - do { + do + { m_Inflator.next_out = out; m_Inflator.avail_out = GZIP_CHUNK_SIZE; ret = inflate (&m_Inflator, Z_NO_FLUSH); - if (ret < 0) { + if (ret < 0) + { inflateEnd (&m_Inflator); os.setstate(std::ios_base::failbit); break; } os.write ((char *)out, GZIP_CHUNK_SIZE - m_Inflator.avail_out); - } while (!m_Inflator.avail_out); // more data to read + } + while (!m_Inflator.avail_out); // more data to read delete[] out; } @@ -99,9 +105,10 @@ namespace data { m_Deflator.next_out = out; m_Deflator.avail_out = outLen; int err; - if ((err = deflate (&m_Deflator, Z_FINISH)) == Z_STREAM_END) { + if ((err = deflate (&m_Deflator, Z_FINISH)) == Z_STREAM_END) return outLen - m_Deflator.avail_out; - } /* else */ + // else + LogPrint (eLogError, "Gzip: Deflate error ", err); return 0; } } // data