2#define __DCL_INCLUDED_CTYPE_H
6#if __DCL_HAVE_ALLOC_DEBUG
7#undef __DCL_ALLOC_LEVEL
8#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
29#define MAX_LINE_LENGTH 76
36 static const char aHex[] =
"0123456789ABCDEF";
38 size_t len = _str.length();
40 ByteBuffer*
buf = ByteBuffer::create(
47 if ((c ==
CR) && (*src ==
LF) &&
len)
63 || ((c ==
' ') && (*src ==
CR)))
76 *dest++ = aHex[c >> 4];
77 *dest++ = aHex[c & 0x0f];
99 buf->__dataLength = (
char*) dest -
buf->data();
111 else if ((
'A' <= c) && (c <=
'F'))
113 else if ((
'a' <= c) && (c <=
'f'))
127 ByteBuffer*
buf = ByteBuffer::create(_str.length());
138 if (src[i + 1] && src[i + 2]
139 && isxdigit(src[i + 1]) && isxdigit(src[i + 2]))
141 dest[j++] = (
hex2int(src[i + 1]) << 4)
150 ((src[i + k] ==
' ') || (src[i + k] ==
TAB)))
158 else if ((src[i + k] ==
CR) && (src[i + k + 1] ==
LF))
160 else if ((src[i + k] ==
CR) || (src[i + k] ==
LF))
163 dest[j++] = src[i++];
169 dest[j++] = src[i++];
175 buf->__dataLength = j;
182#define BASE64_PADDING_CHAR '='
184static const char aBase64Table[] =
186 'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
187 'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
188 'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
189 'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
190 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'+',
'/',
'\0'
197 size_t nAllocLength = ((_str.length() + 2) / 3) * 4;
200 ByteBuffer*
buf = ByteBuffer::create(nAllocLength);
204 size_t len = _str.length();
205 for(
size_t i = 1;
len >= 3;
len -= 3, src += 3)
207 *dest++ = aBase64Table[src[0] >> 2];
208 *dest++ = aBase64Table[((src[0] & 0x03) << 4) + (src[1] >> 4)];
209 *dest++ = aBase64Table[((src[1] & 0x0f) << 2) + (src[2] >> 6)];
210 *dest++ = aBase64Table[src[2] & 0x3f];
221 *dest++ = aBase64Table[src[0] >> 2];
224 *dest++ = aBase64Table[((src[0] & 0x03) << 4) + (src[1] >> 4)];
225 *dest++ = aBase64Table[((src[1] & 0x0f) << 2)];
230 *dest++ = aBase64Table[((src[0] & 0x03) << 4)];
241 buf->__dataLength = (
char*) dest -
buf->data();
249static const char aReverseTable[256] =
251 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
252 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
253 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
254 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
255 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
256 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
257 -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
258 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
259 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
260 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
261 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
262 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
263 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
264 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
265 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
266 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
269ByteString Base64Decoder::decode(
const ByteString& _str)
273 ByteBuffer*
buf = ByteBuffer::create(_str.length());
276 size_t len = _str.length();
286 ch = aReverseTable[ch];
311 size_t nNewLength = (
char*) dest -
buf->data();
330 buf->__dataLength = nNewLength;
332 *(
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)