summaryrefslogtreecommitdiff
path: root/plugins/SmileyAdd
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-06-04 07:55:00 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-06-04 07:55:00 +0000
commit8751885ea79df4b666b65bb2b6900617785e0da7 (patch)
tree676db28129ece760d7ad354b2d39ba371453db8c /plugins/SmileyAdd
parent09476981eccbcae37ef4526f3fbcb18fca686ffa (diff)
end of base64* zoo
git-svn-id: http://svn.miranda-ng.org/main/trunk@4879 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SmileyAdd')
-rw-r--r--plugins/SmileyAdd/src/customsmiley.cpp12
-rw-r--r--plugins/SmileyAdd/src/smileys.cpp28
2 files changed, 19 insertions, 21 deletions
diff --git a/plugins/SmileyAdd/src/customsmiley.cpp b/plugins/SmileyAdd/src/customsmiley.cpp
index 4c0a75a11a..a41920d140 100644
--- a/plugins/SmileyAdd/src/customsmiley.cpp
+++ b/plugins/SmileyAdd/src/customsmiley.cpp
@@ -77,14 +77,14 @@ bool SmileyCType::CreateTriggerText(char* text)
int len = (int)strlen(text);
if (len == 0) return false;
- int reslen = Netlib_GetBase64DecodedBufferSize(len)+1;
- char* res = (char*)alloca(reslen);
-
- NETLIBBASE64 nlb = { text, len, ( PBYTE )res, reslen };
- if (!CallService(MS_NETLIB_BASE64DECODE, 0, LPARAM( &nlb ))) return false;
- res[nlb.cbDecoded] = 0;
+ unsigned reslen;
+ char* res = (char*)mir_base64_decode(text, &reslen);
+ if (res == NULL)
+ return false;
+ char save = res[reslen]; res[reslen] = 0; // safe because of mir_alloc
TCHAR *txt = mir_utf8decodeT(res);
+ res[reslen] = save;
if (txt == NULL) return false;
diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp
index b63cbf4223..e81bc18c28 100644
--- a/plugins/SmileyAdd/src/smileys.cpp
+++ b/plugins/SmileyAdd/src/smileys.cpp
@@ -511,26 +511,24 @@ static void DecodeHTML(bkstring& str)
}
-static IStream* DecodeBase64Data(const char* data)
+static IStream* DecodeBase64Data(const char* pData)
{
- NETLIBBASE64 nlb64;
- nlb64.pszEncoded = (char*)data;
- nlb64.cchEncoded = (int)strlen(data);
- nlb64.cbDecoded = Netlib_GetBase64DecodedBufferSize(nlb64.cchEncoded);
-
- IStream* pStream = NULL;
+ unsigned dataLen;
+ ptrA data((char*)mir_base64_decode(pData, &dataLen));
+ if (data == NULL)
+ return NULL;
// Read image list
- HGLOBAL hBuffer = GlobalAlloc(GMEM_MOVEABLE, nlb64.cbDecoded);
- if (hBuffer)
- {
- nlb64.pbDecoded = (PBYTE)GlobalLock(hBuffer);
- CallService(MS_NETLIB_BASE64DECODE, 0, (LPARAM)&nlb64);
- GlobalUnlock(hBuffer);
+ HGLOBAL hBuffer = GlobalAlloc(GMEM_MOVEABLE, dataLen);
+ if (!hBuffer)
+ return NULL;
- CreateStreamOnHGlobal(hBuffer, TRUE, &pStream);
- }
+ void *dst = GlobalLock(hBuffer);
+ memcpy(dst, data, dataLen);
+ GlobalUnlock(hBuffer);
+ IStream *pStream = NULL;
+ CreateStreamOnHGlobal(hBuffer, TRUE, &pStream);
return pStream;
}