static gboolean ReadLDIFText(const char *Buffer, const char *Start, char *Value) { unsigned char Buffer2[1000],buff[200]; int i; Value[0] = 0x00; strcpy(buff,Start); strcat(buff,":: "); if (!strncmp(Buffer,buff,strlen(buff))) { i = DecodeBASE64(Buffer+strlen(Start)+3, Buffer2, strlen(Buffer)-(strlen(Start)+3)); dbgprintf(NULL, "Text after DecodeBASE64 is \"%s\"\n",Buffer2); DecodeUTF8(Value, Buffer2, i); dbgprintf(NULL, "Text after DecodeUTF8 is \"%s\"\n",DecodeUnicodeString(Value)); return TRUE; } strcpy(buff,Start); strcat(buff,": "); if (!strncmp(Buffer,buff,strlen(buff))) { EncodeUnicode(Value,Buffer+strlen(Start)+2,strlen(Buffer)-(strlen(Start)+2)); dbgprintf(NULL, "Text after EncodeUnicode is \"%s\"\n",DecodeUnicodeString(Value)); return TRUE; } return FALSE; }
"ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="; static const char text[] = "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."; int main(int argc UNUSED, char **argv UNUSED) { char *decoded; char *encoded; size_t len; decoded = malloc(sizeof(base64)); encoded = malloc(sizeof(base64)); len = DecodeBASE64(base64, decoded, strlen(base64)); decoded[len] = 0; test_result(len == strlen(text)); test_result(strcmp(decoded, text) == 0); EncodeBASE64(text, encoded, strlen(text)); test_result(strcmp(base64, encoded) == 0); free(encoded); free(decoded); return 0; }