Index: trunk/i386/libsaio/xml.c =================================================================== --- trunk/i386/libsaio/xml.c (revision 2160) +++ trunk/i386/libsaio/xml.c (revision 2161) @@ -793,6 +793,7 @@ static long ParseTagData( char * buffer, TagPtr * tag ) { + int actuallen = 0; long length; TagPtr tmpTag; @@ -808,11 +809,11 @@ // TODO: base64 decode - char* string = NewSymbol(buffer); + char* string = BASE64Decode(NewSymbol(buffer), length, &actuallen); tmpTag->type = kTagTypeData; tmpTag->string = string; tmpTag->tag = 0; - tmpTag->offset = length; // buffer_start ? buffer - buffer_start: 0; + tmpTag->offset = actuallen; // buffer_start ? buffer - buffer_start: 0; tmpTag->tagNext = 0; *tag = tmpTag; Index: trunk/i386/libsaio/Makefile =================================================================== --- trunk/i386/libsaio/Makefile (revision 2160) +++ trunk/i386/libsaio/Makefile (revision 2161) @@ -38,7 +38,7 @@ fake_efi.o ext2fs.o \ hpet.o dram_controllers.o spd.o usb.o pci_setup.o \ device_inject.o nvidia_helper.o nvidia.o ati.o gma.o pci_root.o \ - convert.o aml_generator.o console.o exfat.o + convert.o aml_generator.o console.o exfat.o base64-decode.o SAIO_OBJS := $(addprefix $(OBJROOT)/, $(SAIO_OBJS)) Index: trunk/i386/libsaio/base64-decode.c =================================================================== --- trunk/i386/libsaio/base64-decode.c (revision 0) +++ trunk/i386/libsaio/base64-decode.c (revision 2161) @@ -0,0 +1,61 @@ +/* + * This code implements the BASE64 algorithm. + * This code is in the public domain; do with it what you wish. + * + * @file base64.c + * @brief This code implements the BASE64 algorithm + * @author Matthieu Speder + */ +#include + +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, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 62, 0, 0, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 0, 0, 0, -1, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + + +char *BASE64Decode(const char* src, int in_len, int* out_len) +{ + char* dest; + char* result; + + if (in_len % 4) + { + /* Wrong base64 string length */ + return NULL; + } + result = dest = malloc(in_len / 4 * 3 + 1); + if (result == NULL) + return NULL; /* out of memory */ + while (*src) { + char a = base64_digits[(unsigned char)*(src++)]; + char b = base64_digits[(unsigned char)*(src++)]; + char c = base64_digits[(unsigned char)*(src++)]; + char d = base64_digits[(unsigned char)*(src++)]; + *(dest++) = (a << 2) | ((b & 0x30) >> 4); + if (c == (char)-1) + break; + *(dest++) = ((b & 0x0f) << 4) | ((c & 0x3c) >> 2); + if (d == (char)-1) + break; + *(dest++) = ((c & 0x03) << 6) | d; + } + *dest = 0; + *out_len = in_len / 4 * 3; // not including NULL terminator + return result; +} + + +/* end of base64.c */ \ No newline at end of file Index: trunk/i386/libsaio/saio_internal.h =================================================================== --- trunk/i386/libsaio/saio_internal.h (revision 2160) +++ trunk/i386/libsaio/saio_internal.h (revision 2161) @@ -218,4 +218,7 @@ unsigned int byteoff, unsigned int byteCount, void * buffer ); +// Base64-decode.c +char *BASE64Decode(const char* src, int in_len, int* out_len); + #endif /* !__LIBSAIO_SAIO_INTERNAL_H */