secureswitools/swisistools/source/common/util.cpp
branchRCL_3
changeset 66 8b7f4e561641
parent 65 7333d7932ef7
child 81 42552535c1ac
--- a/secureswitools/swisistools/source/common/util.cpp	Tue Aug 31 15:21:33 2010 +0300
+++ b/secureswitools/swisistools/source/common/util.cpp	Wed Sep 01 12:22:02 2010 +0100
@@ -31,13 +31,10 @@
 #include <openssl/bio.h>
 #include <openssl/evp.h>
 #include <openssl/buffer.h>
-
 #ifdef _WIN32
 #include <windows.h>
 #endif // _WIN32
-
-
-#include "utf8_wrapper.h"
+#include "utf8.h"
 
 static const TUint32 CrcTab32[256] =
      {
@@ -215,10 +212,9 @@
 
 TInt64 Util::WideCharToInt64(const wchar_t* aWideChar)
 	{
-	TInt64 value=0;
-	std::wstringstream str(aWideChar);
-	str >> value;
-	return value;
+	TInt64 i64 = 0;
+	swscanf(aWideChar, L"%I64d", &i64);
+	return i64;
 	}
 
 DllExport const std::wstring Util::IntegerToWideString(int aInt)
@@ -247,30 +243,22 @@
 
 std::string Util::Base64Decode( const std::string& aEncodedData )
 	{
-	unsigned char* pIn = aEncodedData.c_str();
-	int inLen = aEncodedData.length();
-	unsigned char* pOut = new unsigned char[inLen];
+	BIO *mem = BIO_new(BIO_s_mem());
+	BIO_write(mem, aEncodedData.c_str(), aEncodedData.length());
 
-	int outLen;
-	std::string aDecodeData;
-		
-    // create a memory buffer containing base64 encoded data
-    BIO* bmem = BIO_new_mem_buf((void*)pIn, inLen);
+	BIO* b64 = BIO_new(BIO_f_base64());
+	mem = BIO_push(b64, mem);
+	int inlen = 0;
+	char inbuf[40]={0};
 
-    // push a Base64 filter so that reading from buffer decodes it
-    BIO *bioCmd = BIO_new(BIO_f_base64());
-    // we don't want newlines
-    BIO_set_flags(bioCmd, BIO_FLAGS_BASE64_NO_NL);
-    bmem = BIO_push(bioCmd, bmem);
+	inlen = BIO_read(b64, inbuf, aEncodedData.length());
+    BIO_write(mem, inbuf, inlen);
+	std::string decodedData = inbuf;
+	
+	BIO_free_all(mem);
+	return decodedData;
+	}
 
-    int finalLen = BIO_read(bmem, (void*)pOut, outLen);
-
-	aDecodeData.assign(pOut, pOut+finalLen);
-	delete pOut;
-    BIO_free_all(bmem);
-
-	return aDecodeData;
-	}
 
 TUint32 Util::Crc32(const void* aPtr, TInt aLength)
 	{
@@ -281,7 +269,3 @@
 	 crc = (crc >> 8) ^ CrcTab32[(crc ^ *p++) & 0xff];
 	return crc;
 	}
-
-
-
-