Add printing the read base64 code
Signed-off-by: Piotr Nowicki <piotr.nowicki@arm.com>
diff --git a/programs/ssl/ssl_base64_dump.c b/programs/ssl/ssl_base64_dump.c
index 2ee1f11..1ea02d0 100644
--- a/programs/ssl/ssl_base64_dump.c
+++ b/programs/ssl/ssl_base64_dump.c
@@ -146,6 +146,26 @@
}
/*
+ * This function prints base64 code to the stdout
+ */
+void print_b64( const char *b, const size_t len )
+{
+ size_t i = 0;
+ const char *end = b + len;
+ while( b < end )
+ {
+ if( ++i > 70 )
+ {
+ printf( "\n" );
+ i = 0;
+ }
+ printf( "%c", *b++ );
+ }
+ printf( "\n" );
+ fflush( stdout );
+}
+
+/*
* Read next base64 code from the 'b64_file'. The 'b64_file' must be opened
* previously. After each call to this function, the internal file position
* indicator of the global b64_file is advanced.
@@ -229,6 +249,8 @@
{
enum { B64BUF_LEN = 4 * 1024 };
char b64[ B64BUF_LEN ];
+ uint32_t b64_counter = 0;
+
parse_arguments( argc, argv );
while( NULL != b64_file )
@@ -236,8 +258,17 @@
size_t len = read_next_b64_code( b64, B64BUF_LEN );
if( len > 0)
{
+ b64_counter++;
+
+ if( debug )
+ {
+ printf( "%u.\n", b64_counter );
+ print_b64( b64, len );
+ }
/* TODO: deserializing */
+
+ printf( "\n" );
}
else
{
@@ -246,5 +277,7 @@
}
}
+ printf( "Finish. Found %u base64 codes\n", b64_counter );
+
return 0;
}