diff options
author | Daniel Stenberg <daniel@haxx.se> | 2003-06-11 15:31:06 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2003-06-11 15:31:06 +0000 |
commit | 52c5b572005662803ced51f4008bc175e8b59eca (patch) | |
tree | 5a5909825979ae25d6eb86474460bf5f70959519 /lib/base64.c | |
parent | 5ea04a852e04047ac500f2882c78402f6f3ff875 (diff) | |
download | curl-52c5b572005662803ced51f4008bc175e8b59eca.tar.gz |
made a nicer output for the decode test, as it served as a nice tool for me ;-)
Diffstat (limited to 'lib/base64.c')
-rw-r--r-- | lib/base64.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/base64.c b/lib/base64.c index ee533189f..3b36fd0b9 100644 --- a/lib/base64.c +++ b/lib/base64.c @@ -220,6 +220,8 @@ int main(int argc, char **argv, char **envp) #ifdef TEST_DECODE /* 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 + * + * gcc -DTEST_DECODE base64.c -o base64 mprintf.o memdebug.o */ #include <stdio.h> @@ -232,7 +234,7 @@ int main(int argc, char **argv, char **envp) int base64Len; unsigned char *data; int dataLen; - int i; + int i, j; base64 = (char *)suck(&base64Len); 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); - for(i=0; i < dataLen; i++) - printf("%02x ", data[i]); - puts(""); + for(i=0; i < dataLen; i+=0x10) { + printf("0x%02x: ", i); + 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); return 0; |