diff options
Diffstat (limited to 'src/base64.cc')
-rw-r--r-- | src/base64.cc | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/base64.cc b/src/base64.cc index 367a3e4..5b182b2 100644 --- a/src/base64.cc +++ b/src/base64.cc @@ -2,20 +2,21 @@ * @file base64.cc * @brief Implementation of base64 Utilities * @author Andreas Aardal Hanssen - * @date 2002-2005 + * @date 2002-2005 * ----------------------------------------------------------------- **/ #include "base64.h" -#include <string> + #include <iostream> +#include <string> using namespace ::std; -typedef unsigned char bbyte; /* Byte type */ +typedef unsigned char bbyte; /* Byte type */ #define TRUE 1 #define FALSE 0 -#define LINELEN 72 /* Encoded line length (max 76) */ +#define LINELEN 72 /* Encoded line length (max 76) */ static bbyte dtable[256]; @@ -38,14 +39,13 @@ string Binc::base64encode(const string &s_in) string::const_iterator s_i = s_in.begin(); while (s_i != s_in.end()) { - bbyte igroup[3], ogroup[4]; int c, n; igroup[0] = igroup[1] = igroup[2] = 0; for (n = 0; n < 3 && s_i != s_in.end(); n++) { c = *s_i++; - igroup[n] = (bbyte) c; + igroup[n] = (bbyte)c; } if (n > 0) { ogroup[0] = dtable[igroup[0] >> 2]; @@ -53,9 +53,9 @@ string Binc::base64encode(const string &s_in) ogroup[2] = dtable[((igroup[1] & 0xF) << 2) | (igroup[2] >> 6)]; ogroup[3] = dtable[igroup[2] & 0x3F]; - /* Replace characters in output stream with "=" pad - characters if fewer than three characters were - read from the end of the input stream. */ + /* Replace characters in output stream with "=" pad + characters if fewer than three characters were + read from the end of the input stream. */ if (n < 3) { ogroup[3] = '='; @@ -89,9 +89,9 @@ string Binc::base64decode(const string &s_in) for (i = '0'; i <= '9'; i++) { dtable[i] = 52 + (i - '0'); } - dtable[(int) '+'] = 62; - dtable[(int) '/'] = 63; - dtable[(int) '='] = 0; + dtable[(int)'+'] = 62; + dtable[(int)'/'] = 63; + dtable[(int)'='] = 0; /*CONSTANTCONDITION*/ string::const_iterator s_i = s_in.begin(); @@ -101,8 +101,8 @@ string Binc::base64decode(const string &s_in) for (i = 0; i < 4 && s_i != s_in.end(); i++) { int c = *s_i++; if (dtable[c] & 0x80) return result; - a[i] = (bbyte) c; - b[i] = (bbyte) dtable[c]; + a[i] = (bbyte)c; + b[i] = (bbyte)dtable[c]; } o[0] = (b[0] << 2) | (b[1] >> 4); |