3#define __DCL_INCLUDED_CTYPE_H
7#if __DCL_HAVE_ALLOC_DEBUG
8#undef __DCL_ALLOC_LEVEL
9#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
14#if __DCL_HAVE_THIS_FILE__
30#define MAX_LINE_LENGTH 76
37 static const char aHex[] =
"0123456789ABCDEF";
39 size_t len = _str.length();
41 ByteBuffer* buf = ByteBuffer::create(
47 if ((c ==
CR) && (*src ==
LF) && len) {
61 || ((c ==
' ') && (*src ==
CR))
73 *dest++ = aHex[c >> 4];
74 *dest++ = aHex[c & 0x0f];
94 buf->__dataLength = (
char*) dest - buf->data();
106 else if ((
'A' <= c) && (c <=
'F'))
108 else if ((
'a' <= c) && (c <=
'f'))
121 ByteBuffer* buf = ByteBuffer::create(_str.length());
129 if (src[i + 1] && src[i + 2]
130 && isxdigit(src[i + 1]) && isxdigit(src[i + 2])
132 dest[j++] = (
hex2int(src[i + 1]) << 4)
140 ((src[i + k] ==
' ') || (src[i + k] ==
TAB))
148 else if ((src[i + k] ==
CR) && (src[i + k + 1] ==
LF))
150 else if ((src[i + k] ==
CR) || (src[i + k] ==
LF))
153 dest[j++] = src[i++];
158 dest[j++] = src[i++];
164 buf->__dataLength = j;
171#define BASE64_PADDING_CHAR '='
173static const char __base64Table__[] =
175 'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
176 'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
177 'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
178 'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
179 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'+',
'/',
'\0'
186 size_t nAllocLength = ((_str.length() + 2) / 3) * 4;
189 ByteBuffer* buf = ByteBuffer::create(nAllocLength);
193 size_t len = _str.length();
194 for(
size_t i = 1; len >= 3; len -= 3, src += 3) {
195 *dest++ = __base64Table__[src[0] >> 2];
196 *dest++ = __base64Table__[((src[0] & 0x03) << 4) + (src[1] >> 4)];
197 *dest++ = __base64Table__[((src[1] & 0x0f) << 2) + (src[2] >> 6)];
198 *dest++ = __base64Table__[src[2] & 0x3f];
208 *dest++ = __base64Table__[src[0] >> 2];
210 *dest++ = __base64Table__[((src[0] & 0x03) << 4) + (src[1] >> 4)];
211 *dest++ = __base64Table__[((src[1] & 0x0f) << 2)];
215 *dest++ = __base64Table__[((src[0] & 0x03) << 4)];
226 buf->__dataLength = (
char*) dest - buf->data();
234static const char __reverseBase64__[256] =
236 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
237 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
238 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
239 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
240 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
241 '\xff',
'\xff',
'\xff', 62,
'\xff',
'\xff',
'\xff', 63,
242 52, 53, 54, 55, 56, 57, 58, 59,
243 60, 61,
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
244 '\xff', 0, 1, 2, 3, 4, 5, 6,
245 7, 8, 9, 10, 11, 12, 13, 14,
246 15, 16, 17, 18, 19, 20, 21, 22,
247 23, 24, 25,
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
248 '\xff', 26, 27, 28, 29, 30, 31, 32,
249 33, 34, 35, 36, 37, 38, 39, 40,
250 41, 42, 43, 44, 45, 46, 47, 48,
251 49, 50, 51,
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
252 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
253 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
254 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
255 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
256 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
257 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
258 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
259 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
260 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
261 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
262 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
263 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
264 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
265 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
266 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
267 '\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff',
'\xff'
270ByteString Base64Decoder::decode(
const ByteString& _str)
274 ByteBuffer* buf = ByteBuffer::create(_str.length());
277 size_t len = _str.length();
286 ch = __reverseBase64__[ch];
310 size_t nNewLength = (
char*) dest - buf->data();
327 buf->__dataLength = nNewLength;
329 *(buf->data() + buf->__dataLength) =
__T(
'\0');
#define __DCL_ASSERT(expr)
#define BASE64_PADDING_CHAR
static ByteString encode(const ByteString &_str)
static ByteString decode(const ByteString &_str)
static ByteString encode(const ByteString &_str)