summaryrefslogtreecommitdiff
path: root/plugins/CryptoPP/src/cpp_gzip.cpp
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2012-07-20 16:21:49 +0000
committerKirill Volinsky <mataes2007@gmail.com>2012-07-20 16:21:49 +0000
commitf424a18112032cf61d2871a6b91a5af607c171ae (patch)
tree88fedc4e28941ceecda7026f0b06eba6271f91d5 /plugins/CryptoPP/src/cpp_gzip.cpp
parentbfe1bd0fc087be44c70904aee0fe4276643d206d (diff)
CryptoPP:
changed folder structure git-svn-id: http://svn.miranda-ng.org/main/trunk@1083 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/CryptoPP/src/cpp_gzip.cpp')
-rw-r--r--plugins/CryptoPP/src/cpp_gzip.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/plugins/CryptoPP/src/cpp_gzip.cpp b/plugins/CryptoPP/src/cpp_gzip.cpp
new file mode 100644
index 0000000000..36a4ae7e20
--- /dev/null
+++ b/plugins/CryptoPP/src/cpp_gzip.cpp
@@ -0,0 +1,57 @@
+#include "commonheaders.h"
+
+// gzip data
+BYTE *cpp_gzip(BYTE *pData, size_t nLen, size_t& nCompressedLen) {
+
+ string zipped;
+ Gzip gzip(new StringSink(zipped),5); // 1 is fast, 9 is slow
+ gzip.Put(pData, nLen);
+ gzip.MessageEnd();
+
+ nCompressedLen = (int) zipped.length();
+ PBYTE pCompressed = (PBYTE) malloc(nCompressedLen+1);
+ memcpy(pCompressed,zipped.data(),nCompressedLen);
+
+ return pCompressed;
+}
+
+// gunzip data
+BYTE *cpp_gunzip(BYTE *pCompressedData, size_t nCompressedLen, size_t& nLen) {
+
+ string unzipped;
+ Gunzip gunzip(new StringSink(unzipped));
+ gunzip.Put((PBYTE)pCompressedData,nCompressedLen);
+ gunzip.MessageEnd();
+
+ nLen = (int) unzipped.length();
+ PBYTE pData = (PBYTE) malloc(nLen+1);
+ memcpy(pData,unzipped.data(),nLen);
+
+ return pData;
+}
+
+// zlibc data
+string cpp_zlibc(string& pData) {
+
+ string zipped;
+
+ ZlibCompressor zlib(new StringSink(zipped),5); // 1 is fast, 9 is slow
+ zlib.Put((PBYTE)pData.data(), pData.length());
+ zlib.MessageEnd();
+
+ return zipped;
+}
+
+// zlibd data
+string cpp_zlibd(string& pData) {
+
+ string unzipped;
+
+ ZlibDecompressor zlib(new StringSink(unzipped));
+ zlib.Put((PBYTE)pData.data(),pData.length());
+ zlib.MessageEnd();
+
+ return unzipped;
+}
+
+// EOF