summaryrefslogtreecommitdiff
path: root/src/modules/json/JSON_Base64.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-05 22:41:06 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-05 22:41:06 +0000
commite3cefc7b6ca803e3f87dbadae54a110332778490 (patch)
tree0ee41f14f962f946c9e64fae4a11fbcb197af853 /src/modules/json/JSON_Base64.cpp
parentf0fb070eab8f276e66c0154363656045bc0dadb3 (diff)
- first of the /Core standard plugins;
- code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@778 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/json/JSON_Base64.cpp')
-rw-r--r--src/modules/json/JSON_Base64.cpp58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/modules/json/JSON_Base64.cpp b/src/modules/json/JSON_Base64.cpp
index 4759b112bb..07147afadc 100644
--- a/src/modules/json/JSON_Base64.cpp
+++ b/src/modules/json/JSON_Base64.cpp
@@ -1,28 +1,28 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-
-Copyright 2000-2009 Miranda ICQ/IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2009 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "..\..\core\commonheaders.h"
+
#include "JSON_Base64.h"
#include "JSONDefs.h"
@@ -42,7 +42,7 @@ json_string JSONBase64::json_encode64(const unsigned char * binary, size_t bytes
result.reserve((size_t)(((float)bytes) * 1.37f) + 4);
//do all of the ones that are 3 byte aligned
- for (size_t i = 0; i < aligned; ++i){
+ for (size_t i=0; i < aligned; ++i){
result += chars64[(binary[0] & 0xFC) >> 2];
result += chars64[((binary[0] & 0x03) << 4) + ((binary[1] & 0xF0) >> 4)];
result += chars64[((binary[1] & 0x0F) << 2) + ((binary[2] & 0xC0) >> 6)];
@@ -53,7 +53,7 @@ json_string JSONBase64::json_encode64(const unsigned char * binary, size_t bytes
if (misaligned){
//copy the rest into a temporary buffer
unsigned char temp[3];
- for (unsigned int i = 0; i < misaligned; ++i){
+ for (unsigned int i=0; i < misaligned; ++i){
temp[i] = *binary++;
}
for (unsigned int i = (unsigned int)misaligned; i < 3; ++i){
@@ -67,7 +67,7 @@ json_string JSONBase64::json_encode64(const unsigned char * binary, size_t bytes
result += chars64[((temp[1] & 0x0F) << 2) + ((temp[2] & 0xC0) >> 6)];
result += JSON_TEXT('=');
} else {
- result += JSON_TEXT("==");
+ result += JSON_TEXT(" = = ");
}
}
JSON_ASSERT((size_t)(((float)bytes) * 1.37f) + 4 >= result.length(), JSON_TEXT("Didn't reserve enough space for a one-time go"));
@@ -110,7 +110,7 @@ std::string JSONBase64::json_decode64(const json_string & encoded){
result.reserve((size_t)((float)length / 1.37) + 1);
//first do the ones that can not have any padding
- for (unsigned int i = 0; i < aligned; ++i){
+ for (unsigned int i=0; i < aligned; ++i){
const json_char second = toBinary(runner[1]);
const json_char third = toBinary(runner[2]);
result += (toBinary(runner[0]) << 2) + ((second & 0x30) >> 4);