HEX diff dump API

Overview

Functions to format a hex diff dump of two binary memory blocks and log it. More…

// global functions

void te_hex_diff_dump(const void* expected, size_t exp_len, const void* actual, size_t actual_len, size_t offset, te_string* dest);
void te_hex_diff_log(const void* expected, size_t exp_len, const void* actual, size_t actual_len, size_t offset, const char* file, int line, unsigned int level, const char* entity, const char* user);

// macros

#define LOG_HEX_DIFF_DUMP(_lvl, _expected, _actual, _len)
#define LOG_HEX_DIFF_DUMP_AT(_lvl, _expected, _explen, _actual, _actlen, _offset)

Detailed Documentation

Functions to format a hex diff dump of two binary memory blocks and log it.

Global Functions

void te_hex_diff_dump(const void* expected, size_t exp_len, const void* actual, size_t actual_len, size_t offset, te_string* dest)

Format the difference between expected and actual and put the dump into dest.

Parameters:

expected

Buffer with the expected data.

exp_len

Length of the expected buffer.

actual

Buffer with the actual data.

actual_len

Length of the actual buffer.

offset

The offset of the buffers (only affects logging).

dest

Destination string.

void te_hex_diff_log(const void* expected, size_t exp_len, const void* actual, size_t actual_len, size_t offset, const char* file, int line, unsigned int level, const char* entity, const char* user)

Log the difference between expected and actual with the specified log level and user.

The formatting is done by te_hex_diff_dump().

Usually the function shall not be used directly, but through the macro LOG_HEX_DIFF_DUMP_AT() or LOG_HEX_DIFF_DUMP().

Parameters:

expected

Buffer with the expected data.

exp_len

Length of the expected buffer.

actual

Buffer with the actual data.

actual_len

Length of the actual buffer.

offset

The offset of the buffers (only affects logging).

level

Log level

entity

Log entity

user

Log user

Macros

#define LOG_HEX_DIFF_DUMP(_lvl, _expected, _actual, _len)

Log the difference between buffers with a given log level.

The buffers are assumed to be at offset 0 and be of the same length.

Parameters:

_lvl

Log level for the diff.

_expected

Buffer with expected data.

_actual

Buffer with actual data.

_len

Length of buffers.

See also:

LOG_HEX_DIFF_DUMP_AT

#define LOG_HEX_DIFF_DUMP_AT(_lvl, _expected, _explen, _actual, _actlen, _offset)

Log the difference between buffers with a given log level.

Parameters:

_lvl

Log level for the diff.

_expected

Buffer with expected data.

_explen

The length of the expected buffer.

_actual

Buffer with actual data.

_actlen

The length of the actual buffer.

_offset

The offset of the buffers (only affects logging).

See also:

te_hex_diff_log