2014-10-27 19:03:04 +01:00
|
|
|
/*
|
2015-02-08 18:51:25 +01:00
|
|
|
* Copyright (C) 2014 Martine Lenders <mlenders@inf.fu-berlin.de>
|
2014-10-27 19:03:04 +01:00
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @{
|
|
|
|
*
|
2015-05-22 07:34:41 +02:00
|
|
|
* @file
|
2014-10-27 19:03:04 +01:00
|
|
|
*/
|
2015-07-14 13:27:21 +02:00
|
|
|
|
2017-01-31 14:53:38 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdint.h>
|
2014-10-27 19:03:04 +01:00
|
|
|
|
2017-01-31 14:53:38 +01:00
|
|
|
#include "fmt.h"
|
2014-10-27 19:03:04 +01:00
|
|
|
|
2017-01-31 14:53:38 +01:00
|
|
|
#include "od.h"
|
2014-10-27 19:03:04 +01:00
|
|
|
|
2017-01-31 14:53:38 +01:00
|
|
|
void od_hex_dump(const void *data, size_t data_len, uint8_t width)
|
2014-10-27 19:03:04 +01:00
|
|
|
{
|
2017-01-31 14:53:38 +01:00
|
|
|
print_str("00000000");
|
2014-10-27 19:03:04 +01:00
|
|
|
|
|
|
|
if (width == 0) {
|
|
|
|
width = OD_WIDTH_DEFAULT;
|
|
|
|
}
|
|
|
|
|
2017-01-31 14:53:38 +01:00
|
|
|
for (unsigned int i = 0; i < data_len; i++) {
|
|
|
|
print_str(" ");
|
|
|
|
print_byte_hex(((uint8_t *)data)[i]);
|
2014-10-27 19:03:04 +01:00
|
|
|
|
|
|
|
if ((((i + 1) % width) == 0) || i == (data_len - 1)) {
|
2017-01-31 14:53:38 +01:00
|
|
|
puts("");
|
2014-10-27 19:03:04 +01:00
|
|
|
|
|
|
|
if (i != (data_len - 1)) {
|
2017-01-31 14:53:38 +01:00
|
|
|
print_u32_hex((uint32_t)(i + 1));
|
2014-10-27 19:03:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @} */
|