summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/CrashDumper/src/upload.cpp5
-rw-r--r--plugins/FileAsMessage/src/dialog.cpp135
-rw-r--r--plugins/LotusNotify/LotusNotify_10.vcxproj28
-rw-r--r--plugins/LotusNotify/LotusNotify_10.vcxproj.filters87
-rw-r--r--plugins/NewsAggregator/Src/Utils.cpp4
-rw-r--r--plugins/SmileyAdd/src/customsmiley.cpp12
-rw-r--r--plugins/SmileyAdd/src/smileys.cpp28
-rw-r--r--plugins/Watrack/proto/proto.pas37
8 files changed, 46 insertions, 290 deletions
diff --git a/plugins/CrashDumper/src/upload.cpp b/plugins/CrashDumper/src/upload.cpp
index 0097ff80be..2e614923f9 100644
--- a/plugins/CrashDumper/src/upload.cpp
+++ b/plugins/CrashDumper/src/upload.cpp
@@ -88,10 +88,7 @@ void CreateAuthString(char* auth)
char str[110];
int len = mir_snprintf(str, sizeof(str), "%s:%s", user, pass);
-
- strcpy(auth, "Basic ");
- NETLIBBASE64 nlb = { auth+6, 250, (PBYTE)str, len };
- CallService(MS_NETLIB_BASE64ENCODE, 0, LPARAM(&nlb));
+ mir_snprintf(auth, 250, "Basic %s", ptrA( mir_base64_encode((PBYTE)str, len)));
}
diff --git a/plugins/FileAsMessage/src/dialog.cpp b/plugins/FileAsMessage/src/dialog.cpp
index 8add3a7720..b103854565 100644
--- a/plugins/FileAsMessage/src/dialog.cpp
+++ b/plugins/FileAsMessage/src/dialog.cpp
@@ -6,111 +6,6 @@ char *szFEMode[] =
"Send file"
};
-#define USE_BUILDIN_BASE64
-//
-// BASE64 encoding/decoding
-//
-#define Base64_GetDecodedBufferSize(cchEncoded) (((cchEncoded)>>2)*3)
-#define Base64_GetEncodedBufferSize(cbDecoded) (((cbDecoded)*4+11)/12*4+1)
-#ifdef USE_BUILDIN_BASE64
-#define Base64_Encode(nlb64) CallService(MS_NETLIB_BASE64ENCODE, 0, (LPARAM)nlb64)
-#define Base64_Decode(nlb64) CallService(MS_NETLIB_BASE64DECODE, 0, (LPARAM)nlb64)
-#else
-
-static char base64chars[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-#define Base64_Encode(nlb64) NetlibBase64Encode(0, (LPARAM)nlb64)
-#define Base64_Decode(nlb64) NetlibBase64Decode(0, (LPARAM)nlb64)
-
-int NetlibBase64Encode(WPARAM wParam,LPARAM lParam)
-{
- NETLIBBASE64 *nlb64=(NETLIBBASE64*)lParam;
- int iIn;
- char *pszOut;
- PBYTE pbIn;
-
- if(nlb64==NULL || nlb64->pszEncoded==NULL || nlb64->pbDecoded==NULL) {
- SetLastError(ERROR_INVALID_PARAMETER);
- return 0;
- }
- if(nlb64->cchEncoded<Netlib_GetBase64EncodedBufferSize(nlb64->cbDecoded)) {
- SetLastError(ERROR_BUFFER_OVERFLOW);
- return 0;
- }
- nlb64->cchEncoded=Netlib_GetBase64EncodedBufferSize(nlb64->cbDecoded);
- for(iIn=0,pbIn=nlb64->pbDecoded,pszOut=nlb64->pszEncoded;iIn<nlb64->cbDecoded;iIn+=3,pbIn+=3,pszOut+=4) {
- pszOut[0]=base64chars[pbIn[0]>>2];
- if(nlb64->cbDecoded-iIn==1) {
- pszOut[1]=base64chars[(pbIn[0]&3)<<4];
- pszOut[2]='=';
- pszOut[3]='=';
- pszOut+=4;
- break;
- }
- pszOut[1]=base64chars[((pbIn[0]&3)<<4)|(pbIn[1]>>4)];
- if(nlb64->cbDecoded-iIn==2) {
- pszOut[2]=base64chars[(pbIn[1]&0xF)<<2];
- pszOut[3]='=';
- pszOut+=4;
- break;
- }
- pszOut[2]=base64chars[((pbIn[1]&0xF)<<2)|(pbIn[2]>>6)];
- pszOut[3]=base64chars[pbIn[2]&0x3F];
- }
- pszOut[0]='\0';
- return 1;
-}
-
-static BYTE Base64CharToInt(char c)
-{
- if(c>='A' && c<='Z') return c-'A';
- if(c>='a' && c<='z') return c-'a'+26;
- if(c>='0' && c<='9') return c-'0'+52;
- if(c=='+') return 62;
- if(c=='/') return 63;
- if(c=='=') return 64;
- return 255;
-}
-
-int NetlibBase64Decode(WPARAM wParam,LPARAM lParam)
-{
- NETLIBBASE64 *nlb64=(NETLIBBASE64*)lParam;
- char *pszIn;
- PBYTE pbOut;
- BYTE b1,b2,b3,b4;
- int iIn;
-
- if(nlb64==NULL || nlb64->pszEncoded==NULL || nlb64->pbDecoded==NULL) {
- SetLastError(ERROR_INVALID_PARAMETER);
- return 0;
- }
- if(nlb64->cchEncoded&3) {
- SetLastError(ERROR_INVALID_DATA);
- return 0;
- }
- if(nlb64->cbDecoded<Netlib_GetBase64DecodedBufferSize(nlb64->cchEncoded)) {
- SetLastError(ERROR_BUFFER_OVERFLOW);
- return 0;
- }
- nlb64->cbDecoded=Netlib_GetBase64DecodedBufferSize(nlb64->cchEncoded);
- for(iIn=0,pszIn=nlb64->pszEncoded,pbOut=nlb64->pbDecoded;iIn<nlb64->cchEncoded;iIn+=4,pszIn+=4,pbOut+=3) {
- b1=Base64CharToInt(pszIn[0]);
- b2=Base64CharToInt(pszIn[1]);
- b3=Base64CharToInt(pszIn[2]);
- b4=Base64CharToInt(pszIn[3]);
- if(b1==255 || b1==64 || b2==255 || b2==64 || b3==255 || b4==255) {
- SetLastError(ERROR_INVALID_DATA);
- return 0;
- }
- pbOut[0]=(b1<<2)|(b2>>4);
- if(b3==64) {nlb64->cbDecoded-=2; break;}
- pbOut[1]=(b2<<4)|(b3>>2);
- if(b4==64) {nlb64->cbDecoded--; break;}
- pbOut[2]=b4|(b3<<6);
- }
- return 1;
-}
-#endif
-
char* ltoax(char* s, DWORD value)
{
if(value == 0)
@@ -472,8 +367,8 @@ int FILEECHO::createTransfer()
}
else
{
- int EncodedMaxLen = Base64_GetEncodedBufferSize(Base64_GetDecodedBufferSize(chunkMaxLen));
- int DecodedMaxLen = Base64_GetDecodedBufferSize(EncodedMaxLen);
+ int EncodedMaxLen = Netlib_GetBase64EncodedBufferSize(Netlib_GetBase64DecodedBufferSize(chunkMaxLen));
+ int DecodedMaxLen = Netlib_GetBase64DecodedBufferSize(EncodedMaxLen);
codeSymb = '-';
chunkCount = (fileSize + DecodedMaxLen - 1) / DecodedMaxLen;
@@ -735,14 +630,8 @@ void FILEECHO::onSendTimer()
}
else
{
- NETLIBBASE64 nlb;
-
- nlb.pbDecoded = data;
- nlb.cbDecoded = data_end - data;
- nlb.pszEncoded = (char*)buffer;
- nlb.cchEncoded = chunkMaxLen*2;
-
- Base64_Encode(&nlb);
+ ptrA enc( mir_base64_encode(data, data_end - data));
+ strncpy((char*)buffer, enc, chunkMaxLen*2);
}
char prefix[128];
@@ -810,18 +699,10 @@ void FILEECHO::cmdDATA(char *param)
}
else
{
- NETLIBBASE64 nlb;
- uchar *temp_buffer;
-
- nlb.pszEncoded = param;
- nlb.cchEncoded = (int)_tcslen(param);
- temp_buffer = (uchar*)malloc(nlb.cchEncoded);
- nlb.pbDecoded = temp_buffer;
- nlb.cbDecoded = nlb.cchEncoded;
-
- Base64_Decode(&nlb);
- memcpy(data, temp_buffer, min(nlb.cbDecoded, data_end - data));
- data += nlb.cbDecoded;
+ unsigned bufLen;
+ mir_ptr<BYTE> buf((BYTE*)mir_base64_decode(param, &bufLen));
+ memcpy(data, buf, min(bufLen, data_end - data));
+ data += bufLen;
}
//
// let's check it up
diff --git a/plugins/LotusNotify/LotusNotify_10.vcxproj b/plugins/LotusNotify/LotusNotify_10.vcxproj
index 1d11e42c2d..44ce191ae1 100644
--- a/plugins/LotusNotify/LotusNotify_10.vcxproj
+++ b/plugins/LotusNotify/LotusNotify_10.vcxproj
@@ -184,34 +184,6 @@
<ClInclude Include="src\debug.h" />
<ClInclude Include="src\lotusnotes.h" />
<ClInclude Include="src\LotusNotify.h" />
- <ClInclude Include="src\notesapi\include\bsafe.h" />
- <ClInclude Include="src\notesapi\include\bsafeerr.h" />
- <ClInclude Include="src\notesapi\include\darray.h" />
- <ClInclude Include="src\notesapi\include\dname.h" />
- <ClInclude Include="src\notesapi\include\extmgr.h" />
- <ClInclude Include="src\notesapi\include\global.h" />
- <ClInclude Include="src\notesapi\include\globerr.h" />
- <ClInclude Include="src\notesapi\include\idtable.h" />
- <ClInclude Include="src\notesapi\include\kfm.h" />
- <ClInclude Include="src\notesapi\include\mailserv.h" />
- <ClInclude Include="src\notesapi\include\misc.h" />
- <ClInclude Include="src\notesapi\include\nadtypes.h" />
- <ClInclude Include="src\notesapi\include\names.h" />
- <ClInclude Include="src\notesapi\include\nif.h" />
- <ClInclude Include="src\notesapi\include\nls.h" />
- <ClInclude Include="src\notesapi\include\ns.h" />
- <ClInclude Include="src\notesapi\include\nsfdata.h" />
- <ClInclude Include="src\notesapi\include\nsfdb.h" />
- <ClInclude Include="src\notesapi\include\nsferr.h" />
- <ClInclude Include="src\notesapi\include\nsfnote.h" />
- <ClInclude Include="src\notesapi\include\nsfsearc.h" />
- <ClInclude Include="src\notesapi\include\osenv.h" />
- <ClInclude Include="src\notesapi\include\osfile.h" />
- <ClInclude Include="src\notesapi\include\osmem.h" />
- <ClInclude Include="src\notesapi\include\osmisc.h" />
- <ClInclude Include="src\notesapi\include\ossignal.h" />
- <ClInclude Include="src\notesapi\include\pool.h" />
- <ClInclude Include="src\notesapi\include\stdnames.h" />
<ClInclude Include="src\resource.h" />
<ClInclude Include="src\stdafx.h" />
<ClInclude Include="src\version.h" />
diff --git a/plugins/LotusNotify/LotusNotify_10.vcxproj.filters b/plugins/LotusNotify/LotusNotify_10.vcxproj.filters
index 5bc066e5c4..a132330333 100644
--- a/plugins/LotusNotify/LotusNotify_10.vcxproj.filters
+++ b/plugins/LotusNotify/LotusNotify_10.vcxproj.filters
@@ -13,9 +13,6 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions>
</Filter>
- <Filter Include="notesapi">
- <UniqueIdentifier>{df00f0a3-e7f1-4ece-8f78-92cd020c62d1}</UniqueIdentifier>
- </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\debug.cpp">
@@ -44,90 +41,6 @@
<ClInclude Include="src\resource.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\notesapi\include\stdnames.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\bsafe.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\bsafeerr.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\darray.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\dname.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\extmgr.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\global.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\globerr.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\idtable.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\kfm.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\mailserv.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\misc.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\nadtypes.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\names.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\nif.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\nls.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\ns.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\nsfdata.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\nsfdb.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\nsferr.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\nsfnote.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\nsfsearc.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\osenv.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\osfile.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\osmem.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\osmisc.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\ossignal.h">
- <Filter>notesapi</Filter>
- </ClInclude>
- <ClInclude Include="src\notesapi\include\pool.h">
- <Filter>notesapi</Filter>
- </ClInclude>
<ClInclude Include="src\version.h">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp
index 18bec6d18f..a1508e304c 100644
--- a/plugins/NewsAggregator/Src/Utils.cpp
+++ b/plugins/NewsAggregator/Src/Utils.cpp
@@ -115,9 +115,7 @@ void CreateAuthString(char *auth, HANDLE hContact, HWND hwndDlg)
mir_free(tlogin);
mir_free(tpass);
- strcpy(auth, "Basic ");
- NETLIBBASE64 nlb = { auth+6, 250, (PBYTE)str, len };
- CallService(MS_NETLIB_BASE64ENCODE, 0, LPARAM(&nlb));
+ mir_snprintf(auth, 250, "Basic %s", ptrA(mir_base64_encode((PBYTE)str, len)));
}
VOID GetNewsData(TCHAR *tszUrl, char **szData, HANDLE hContact, HWND hwndDlg)
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;
}
diff --git a/plugins/Watrack/proto/proto.pas b/plugins/Watrack/proto/proto.pas
index 416a610a31..5befc5e2d8 100644
--- a/plugins/Watrack/proto/proto.pas
+++ b/plugins/Watrack/proto/proto.pas
@@ -213,7 +213,9 @@ var
ccs:PCCSDATA;
s:pWideChar;
buf:PWideChar;
- base64:TNETLIBBASE64;
+ data:PByte;
+ dataSize:int;
+ encodedStr:PAnsiChar;
// pos_artist,pos_title,pos_album:PwideChar;
pos_template:pWideChar;
curpos:pWideChar;
@@ -290,22 +292,22 @@ begin
begin
if curpos<>nil then
begin
- base64.pbDecoded:=PByte(buf);
- base64.cbDecoded:=PAnsiChar(curpos)-PAnsiChar(buf);
+ data:=PByte(buf);
+ dataSize:=PAnsiChar(curpos)-PAnsiChar(buf);
end
else
begin
- base64.pbDecoded:=PByte(s);
- base64.cbDecoded:=(StrLenW(textpos)+3+1)*SizeOf(PWideChar);
+ data:=PByte(s);
+ dataSize:=(StrLenW(textpos)+3+1)*SizeOf(PWideChar);
end;
- base64.cchEncoded:=Netlib_GetBase64EncodedBufferSize(base64.cbDecoded);
- mGetMem(encbuf,base64.cchEncoded+1+Length(wpAnswer));
- base64.pszEncoded:=PAnsiChar(encbuf)+Length(wpAnswer);
+ encodedStr:=mir_base64_encode(data,dataSize);
+ mGetMem(encbuf,Length(encodedStr)+1+Length(wpAnswer));
StrCopy(PAnsiChar(encbuf),wpAnswer);
- CallService(MS_NETLIB_BASE64ENCODE,0,tlparam(@base64));
+ StrCopy(PAnsiChar(encbuf)+Length(wpAnswer),encodedStr);
+ mFreeMem(encodedStr);
+
if (HistMask and hmOutInfo)<>0 then
- AddEvent(ccs^.hContact,EVENTTYPE_WAT_ANSWER,DBEF_SENT,
- base64.pbDecoded,base64.cbDecoded);
+ AddEvent(ccs^.hContact,EVENTTYPE_WAT_ANSWER,DBEF_SENT,data,dataSize);
CallContactService(ccs^.hContact,PSS_MESSAGE,0,tlparam(encbuf));
end
else
@@ -348,14 +350,9 @@ begin
else if StrCmp(PPROTORECVEVENT(ccs^.lParam)^.szMessage.a,wpAnswer,Length(wpAnswer))=0 then
begin
// decode
- base64.pszEncoded:=PPROTORECVEVENT(ccs^.lParam)^.szMessage.a+Length(wpAnswer);
- base64.cchEncoded:=StrLen(base64.pszEncoded);
- base64.cbDecoded :=Netlib_GetBase64DecodedBufferSize(base64.cchEncoded);
- mGetMem(base64.pbDecoded,base64.cbDecoded);
-
- CallService(MS_NETLIB_BASE64DECODE,0,tlparam(@base64));
+ data:=mir_base64_decode(PPROTORECVEVENT(ccs^.lParam)^.szMessage.a+Length(wpAnswer),dataSize);
- curpos:=pWideChar(base64.pbDecoded); // pos_artist:=curpos;
+ curpos:=pWideChar(data); // pos_artist:=curpos;
while curpos^<>#0 do inc(curpos); inc(curpos); // pos_title :=curpos;
while curpos^<>#0 do inc(curpos); inc(curpos); // pos_album :=curpos;
while curpos^<>#0 do inc(curpos); inc(curpos);
@@ -363,7 +360,7 @@ begin
if (HistMask and hmInInfo)<>0 then
AddEvent(ccs^.hContact,EVENTTYPE_WAT_ANSWER,DBEF_READ,
- base64.pbDecoded,base64.cbDecoded,
+ data,dataSize,
PPROTORECVEVENT(ccs^.lParam)^.Timestamp);
// Action
@@ -372,7 +369,7 @@ begin
MessageBoxW(0,TranslateW(pos_template),buf,MB_ICONINFORMATION);
- mFreeMem(base64.pbDecoded);
+ mFreeMem(data);
end
else if StrCmp(PPROTORECVEVENT(ccs^.lParam)^.szMessage.a,wpError,Length(wpError))=0 then
begin