X-Git-Url: https://git.cryptolib.org/?p=labortage2013badge.git;a=blobdiff_plain;f=hostware%2Fcommandline%2Fhexdump.c;fp=hostware%2Fcommandline%2Fhexdump.c;h=6fb3742855cbabf8cb3850f0ee4f6c9b2be5c828;hp=0000000000000000000000000000000000000000;hb=14a4df0d4392a668439c879c89e135d5ac345688;hpb=2da43c43d4818a4f2e3af7e8ec138c1f98019d9e
diff --git a/hostware/commandline/hexdump.c b/hostware/commandline/hexdump.c
new file mode 100644
index 0000000..6fb3742
--- /dev/null
+++ b/hostware/commandline/hexdump.c
@@ -0,0 +1,74 @@
+/* hexdump.c */
+/*
+ This file is part of the ARM-Crypto-Lib.
+ Copyright (C) 2006-2011 Daniel Otte (daniel.otte@rub.de)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+#include
+#include
+#include
+#include
+
+static
+void int_hexdump_line_buffer(FILE* stream, uint8_t* buffer, unsigned width, unsigned fill){
+ unsigned i;
+ for(i=0; iwidth){
+ memcpy(buffer, block, width);
+ if(print_addr){
+ fprintf(stream, "%8.8x ", (uint32_t)print_addr);
+ print_addr = (uint8_t*)print_addr + width;
+ }
+ fprintf(stream, "<%4.4x>: ", index);
+ int_hexdump_line_buffer(stream, buffer, width, width);
+ fputc('\n', stream);
+ block = (uint8_t*)block + width;
+ length -= width;
+ index += width;
+ }
+ memcpy(buffer, block, length);
+ if(print_addr){
+ fprintf(stream, "%8.8x ", (uint32_t)print_addr);
+ }
+ fprintf(stream, "<%4.4x>: ", index);
+ int_hexdump_line_buffer(stream, buffer, width, length);
+ fputc('\n', stream);
+}