projects
/
quassel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
common: Don't add quotes to exit exceptions
[quassel.git]
/
src
/
common
/
compressor.cpp
diff --git
a/src/common/compressor.cpp
b/src/common/compressor.cpp
index
d2634e4
..
8a66c8c
100644
(file)
--- a/
src/common/compressor.cpp
+++ b/
src/common/compressor.cpp
@@
-1,5
+1,5
@@
/***************************************************************************
/***************************************************************************
- * Copyright (C) 2005-201
4
by the Quassel Project *
+ * Copyright (C) 2005-201
9
by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
@@
-23,8
+23,12
@@
#include <QTcpSocket>
#include <QTimer>
#include <QTcpSocket>
#include <QTimer>
-#define MINIZ_HEADER_FILE_ONLY
-#include "../../3rdparty/miniz/miniz.c"
+#ifdef HAVE_ZLIB
+# include <zlib.h>
+#else
+# define MINIZ_HEADER_FILE_ONLY
+# include "../../3rdparty/miniz/miniz.c"
+#endif
const int maxBufferSize = 64 * 1024 * 1024; // protect us from zip bombs
const int ioBufferSize = 64 * 1024; // chunk size for inflate/deflate; should not be too large as we preallocate that space!
const int maxBufferSize = 64 * 1024 * 1024; // protect us from zip bombs
const int ioBufferSize = 64 * 1024; // chunk size for inflate/deflate; should not be too large as we preallocate that space!
@@
-93,7
+97,7
@@
bool Compressor::initStreams()
_deflater = new z_stream;
memset(_deflater, 0, sizeof(z_stream));
if (Z_OK != deflateInit(_deflater, zlevel)) {
_deflater = new z_stream;
memset(_deflater, 0, sizeof(z_stream));
if (Z_OK != deflateInit(_deflater, zlevel)) {
- qWarning() << "Could not intialize the deflate stream!";
+ qWarning() << "Could not in
i
tialize the deflate stream!";
return false;
}
return false;
}
@@
-176,7
+180,7
@@
void Compressor::readData()
_readBuffer.resize(_readBuffer.size() + ioBufferSize);
_inputBuffer.append(_socket->read(ioBufferSize - _inputBuffer.size()));
_readBuffer.resize(_readBuffer.size() + ioBufferSize);
_inputBuffer.append(_socket->read(ioBufferSize - _inputBuffer.size()));
- _inflater->next_in = reinterpret_cast<
const unsigned char *>(_inputBuffer.constD
ata());
+ _inflater->next_in = reinterpret_cast<
unsigned char *>(_inputBuffer.d
ata());
_inflater->avail_in = _inputBuffer.size();
_inflater->next_out = reinterpret_cast<unsigned char *>(_readBuffer.data() + _readBuffer.size() - ioBufferSize);
_inflater->avail_out = ioBufferSize;
_inflater->avail_in = _inputBuffer.size();
_inflater->next_out = reinterpret_cast<unsigned char *>(_readBuffer.data() + _readBuffer.size() - ioBufferSize);
_inflater->avail_out = ioBufferSize;
@@
-186,7
+190,7
@@
void Compressor::readData()
int status = inflate(_inflater, Z_SYNC_FLUSH); // get as much data as possible
// adjust input and output buffers
int status = inflate(_inflater, Z_SYNC_FLUSH); // get as much data as possible
// adjust input and output buffers
- _readBuffer.resize(_inflater->next_out - reinterpret_cast<
const unsigned char *>(_readBuffer.constD
ata()));
+ _readBuffer.resize(_inflater->next_out - reinterpret_cast<
unsigned char *>(_readBuffer.d
ata()));
if (_inflater->avail_in > 0)
memmove(_inputBuffer.data(), _inflater->next_in, _inflater->avail_in);
_inputBuffer.resize(_inflater->avail_in);
if (_inflater->avail_in > 0)
memmove(_inputBuffer.data(), _inflater->next_in, _inflater->avail_in);
_inputBuffer.resize(_inflater->avail_in);
@@
-225,7
+229,7
@@
void Compressor::writeData()
return;
}
return;
}
- _deflater->next_in = reinterpret_cast<
const unsigned char *>(_writeBuffer.constD
ata());
+ _deflater->next_in = reinterpret_cast<
unsigned char *>(_writeBuffer.d
ata());
_deflater->avail_in = _writeBuffer.size();
int status;
_deflater->avail_in = _writeBuffer.size();
int status;
@@
-239,7
+243,7
@@
void Compressor::writeData()
return;
}
return;
}
- if (_deflater->avail_out ==
ioBufferSize
)
+ if (_deflater->avail_out ==
static_cast<unsigned int>(ioBufferSize)
)
continue; // nothing to write here
if (!_socket->write(_outputBuffer.constData(), ioBufferSize - _deflater->avail_out)) {
continue; // nothing to write here
if (!_socket->write(_outputBuffer.constData(), ioBufferSize - _deflater->avail_out)) {