mirror of
https://github.com/moparisthebest/curl
synced 2025-03-11 15:50:48 -04:00
made a nicer output for the decode test, as it served as a nice tool for me ;-)
This commit is contained in:
parent
5ea04a852e
commit
52c5b57200
24
lib/base64.c
24
lib/base64.c
@ -220,6 +220,8 @@ int main(int argc, char **argv, char **envp)
|
|||||||
#ifdef TEST_DECODE
|
#ifdef TEST_DECODE
|
||||||
/* decoding test harness. Read in a base64 string from stdin and write out the
|
/* decoding test harness. Read in a base64 string from stdin and write out the
|
||||||
* length returned by Curl_base64_decode, followed by the decoded data itself
|
* length returned by Curl_base64_decode, followed by the decoded data itself
|
||||||
|
*
|
||||||
|
* gcc -DTEST_DECODE base64.c -o base64 mprintf.o memdebug.o
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@ -232,7 +234,7 @@ int main(int argc, char **argv, char **envp)
|
|||||||
int base64Len;
|
int base64Len;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
int dataLen;
|
int dataLen;
|
||||||
int i;
|
int i, j;
|
||||||
|
|
||||||
base64 = (char *)suck(&base64Len);
|
base64 = (char *)suck(&base64Len);
|
||||||
data = (unsigned char *)malloc(base64Len * 3/4 + 8);
|
data = (unsigned char *)malloc(base64Len * 3/4 + 8);
|
||||||
@ -240,9 +242,23 @@ int main(int argc, char **argv, char **envp)
|
|||||||
|
|
||||||
fprintf(stderr, "%d\n", dataLen);
|
fprintf(stderr, "%d\n", dataLen);
|
||||||
|
|
||||||
for(i=0; i < dataLen; i++)
|
for(i=0; i < dataLen; i+=0x10) {
|
||||||
printf("%02x ", data[i]);
|
printf("0x%02x: ", i);
|
||||||
puts("");
|
for(j=0; j < 0x10; j++)
|
||||||
|
if((j+i) < dataLen)
|
||||||
|
printf("%02x ", data[i+j]);
|
||||||
|
else
|
||||||
|
printf(" ");
|
||||||
|
|
||||||
|
printf(" | ");
|
||||||
|
|
||||||
|
for(j=0; j < 0x10; j++)
|
||||||
|
if((j+i) < dataLen)
|
||||||
|
printf("%c", isgraph(data[i+j])?data[i+j]:'.');
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
puts("");
|
||||||
|
}
|
||||||
|
|
||||||
free(base64); free(data);
|
free(base64); free(data);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user