#include "wx/wxprec.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
#if wxUSE_BASE64
#include "wx/base64.h"
size_t
wxBase64Encode(char *dst, size_t dstLen, const void *src_, size_t srcLen)
{
- wxCHECK_MSG( src_, wxCONV_FAILED, _T("NULL input buffer") );
+ wxCHECK_MSG( src_, wxCONV_FAILED, wxT("NULL input buffer") );
- const unsigned char *src = wx_static_cast(const unsigned char *, src_);
+ const unsigned char *src = static_cast<const unsigned char *>(src_);
static const char b64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
wxBase64DecodeMode mode,
size_t *posErr)
{
- wxCHECK_MSG( src, wxCONV_FAILED, _T("NULL input buffer") );
+ wxCHECK_MSG( src, wxCONV_FAILED, wxT("NULL input buffer") );
- unsigned char *dst = wx_static_cast(unsigned char *, dst_);
+ unsigned char *dst = static_cast<unsigned char *>(dst_);
size_t decLen = 0;
const char *p;
for ( p = src; srcLen; p++, srcLen-- )
{
- const unsigned char c = decode[wx_static_cast(unsigned char, *p)];
+ const unsigned char c = decode[static_cast<unsigned char>(*p)];
switch ( c )
{
case WSP:
// force the loop to stop and an error to be returned
n = -1;
- srcLen = 0;
+ srcLen = 1;
break;
case PAD:
{
// force the loop terminate with an error
n = -1;
- srcLen = 0;
+ srcLen = 1;
}
break;
{
// nothing is allowed after the end so provoke error return
n = -1;
- srcLen = 0;
+ srcLen = 1;
break;
}
if ( n )
{
if ( posErr )
- *posErr = p - src;
+ {
+ // notice that the error was on a previous position as we did one
+ // extra "p++" in the loop line after it
+ *posErr = p - src - 1;
+ }
return wxCONV_FAILED;
}
size_t *posErr)
{
wxMemoryBuffer buf;
- wxCHECK_MSG( src, buf, _T("NULL input buffer") );
+ wxCHECK_MSG( src, buf, wxT("NULL input buffer") );
if ( srcLen == wxNO_LEN )
srcLen = strlen(src);