summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
-rw-r--r--src/mir_app/src/utils.cpp42
3 files changed, 44 insertions, 0 deletions
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index d0abb0ecb0..0f02928081 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -875,3 +875,4 @@ Clist_RemoveEvent @989
?Clist_GetEventByMenu@@YGPAUCListEvent@@H@Z @990 NONAME
?Clist_GetEventCount@@YGHXZ @991 NONAME
?Chat_EmptyHistory@@YGXPAUSESSION_INFO@@@Z @992 NONAME
+?Utils_Unzip@@YG?AVMBinBuffer@@PBXI@Z @993 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index ce3a55a6fd..9fe2e92c6a 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -875,3 +875,4 @@ Clist_RemoveEvent @989
?Clist_GetEventByMenu@@YAPEAUCListEvent@@H@Z @990 NONAME
?Clist_GetEventCount@@YAHXZ @991 NONAME
?Chat_EmptyHistory@@YAXPEAUSESSION_INFO@@@Z @992 NONAME
+?Utils_Unzip@@YA?AVMBinBuffer@@PEBX_K@Z @993 NONAME
diff --git a/src/mir_app/src/utils.cpp b/src/mir_app/src/utils.cpp
index 42e916d7d7..1c23ded07a 100644
--- a/src/mir_app/src/utils.cpp
+++ b/src/mir_app/src/utils.cpp
@@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "stdafx.h"
+#include "..\..\libs\zlib\src\zlib.h"
#define MS_SYSTEM_GET_MD5I "Miranda/System/GetMD5I"
@@ -372,6 +373,47 @@ bool ProcessFileDrop(HDROP hDrop, MCONTACT hContact)
/////////////////////////////////////////////////////////////////////////////////////////
+MIR_APP_DLL(MBinBuffer) Utils_Unzip(const void *pData, size_t cbLen)
+{
+ MBinBuffer res;
+ if (pData == nullptr || cbLen == 0)
+ return res;
+
+ z_stream strm = {};
+ inflateInit(&strm);
+
+ strm.avail_in = (uInt)cbLen;
+ strm.next_in = (Bytef *)pData;
+
+ Bytef buf[2048];
+
+ while (strm.avail_in > 0) {
+ strm.avail_out = sizeof(buf);
+ strm.next_out = buf;
+
+ int ret = inflate(&strm, Z_NO_FLUSH);
+ switch (ret) {
+ case Z_NEED_DICT:
+ ret = Z_DATA_ERROR;
+ __fallthrough;
+
+ case Z_DATA_ERROR:
+ case Z_MEM_ERROR:
+ inflateEnd(&strm);
+ return res;
+ }
+
+ res.append(buf, sizeof(buf) - strm.avail_out);
+ if (ret == Z_STREAM_END)
+ break;
+ }
+
+ inflateEnd(&strm);
+ return res;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
int LoadUtilsModule(void)
{
CreateServiceFunction(MS_UTILS_GETCOUNTRYBYNUMBER, GetCountryByNumber);