Rule management added.
[platform/core/security/suspicious-activity-monitor.git] / daemon / base64.cpp
index 7a14e81..03dac96 100644 (file)
@@ -25,7 +25,7 @@
 #include <cctype>
 #include <stdexcept>
 
-namespace NMD
+namespace agent
 {
 
 using std::string;
@@ -36,33 +36,26 @@ string base64_encode(const string& source)
 
     string result;
 
-    for (auto it = source.cbegin(); it != source.cend(); )
-    {
+    for (auto it = source.cbegin(); it != source.cend();) {
         int word = ((int)(unsigned char) * it) << 16;
         int symbols = 2;
 
-        if (++it != source.cend())
-        {
+        if (++it != source.cend()) {
             word |= ((int)(unsigned char) * it) << 8;
             symbols++;
 
-            if (++it != source.cend())
-            {
+            if (++it != source.cend()) {
                 word |= ((int)(unsigned char) * it);
                 symbols++;
                 ++it;
             }
         }
 
-        for (int i = 0; i < 4; i++)
-        {
-            if (i < symbols)
-            {
+        for (int i = 0; i < 4; i++) {
+            if (i < symbols) {
                 int index = (word >> (18 - i * 6)) & 0x3f;
                 result.push_back(list_code[index]);
-            }
-            else
-            {
+            } else {
                 result.push_back('=');
             }
         }
@@ -87,19 +80,18 @@ string base64_decode(const string& source)
 
     string result;
 
-    for (auto i = source.cbegin(); i != source.cend();)
-    {
+    for (auto i = source.cbegin(); i != source.cend();) {
         int bits_collected = 0;
         unsigned int accumulator = 0;
 
-        for (bits_collected = 0; bits_collected < 24 && i != source.cend(); ++i)
-        {
+        for (bits_collected = 0; bits_collected < 24 && i != source.cend(); ++i) {
             const int c = *i;
             // Skip whitespace and padding. Be liberal in what you accept.
-            if (std::isspace(c) || c == '=') continue;
+            if (std::isspace(c) || c == '=') {
+                continue;
+            }
 
-            if ((c > 127) || (c < 0) || (reverse_table[c] > 63))
-            {
+            if ((c > 127) || (c < 0) || (reverse_table[c] > 63)) {
                 throw std::invalid_argument("Source contains characters not legal in a base64 encoded string.");
             }
 
@@ -107,10 +99,11 @@ string base64_decode(const string& source)
             bits_collected += 6;
         }
 
-        if (bits_collected < 8) throw std::invalid_argument("Wrong source length");
+        if (bits_collected < 8) {
+            throw std::invalid_argument("Wrong source length");
+        }
 
-        while (bits_collected >= 8)
-        {
+        while (bits_collected >= 8) {
             bits_collected -= 8;
             result.push_back((char)((accumulator >> bits_collected) & 0xff));
         }
@@ -119,4 +112,4 @@ string base64_decode(const string& source)
     return result;
 }
 
-} // namespace NMD
+} // namespace agent