Index: trunk/i386/libsaio/xml.c =================================================================== --- trunk/i386/libsaio/xml.c (revision 2175) +++ trunk/i386/libsaio/xml.c (revision 2176) @@ -806,9 +806,7 @@ //printf("ParseTagData unimplimented\n"); //printf("Data: %s\n", buffer); // getchar(); - - // TODO: base64 decode - + char* string = BASE64Decode(buffer, strlen(buffer), &actuallen); tmpTag->type = kTagTypeData; tmpTag->string = string; Index: trunk/i386/libsaio/base64-decode.c =================================================================== --- trunk/i386/libsaio/base64-decode.c (revision 2175) +++ trunk/i386/libsaio/base64-decode.c (revision 2176) @@ -8,8 +8,8 @@ */ #include -static const char base64_chars[] = -"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +//static const char base64_chars[] = +//"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static const char base64_digits[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -28,6 +28,7 @@ char *BASE64Decode(const char* src, int in_len, int* out_len) { + int endpad = 0; char* dest; char* result; @@ -35,7 +36,8 @@ { /* Wrong base64 string length */ return NULL; - } + + } result = dest = malloc(in_len / 4 * 3 + 1); if (result == NULL) return NULL; /* out of memory */ @@ -46,14 +48,22 @@ char d = base64_digits[(unsigned char)*(src++)]; *(dest++) = (a << 2) | ((b & 0x30) >> 4); if (c == (char)-1) + { + // padding char. + endpad += 2; break; + } *(dest++) = ((b & 0x0f) << 4) | ((c & 0x3c) >> 2); if (d == (char)-1) + { + // padding char. + endpad += 1; break; + } *(dest++) = ((c & 0x03) << 6) | d; } *dest = 0; - *out_len = in_len / 4 * 3; // not including NULL terminator + *out_len = in_len / 4 * 3 - endpad; // not including NULL terminator return result; }