bufdumplib
|
This library provides a C API for hexadecimal dumps and diffs of binary memory buffers. More...
Go to the source code of this file.
Functions | |
int | bufdumplib_dump (FILE *fp, const void *buf, size_t len, int flags) |
Write a hex dump of a binary memory buffer over the specified length into a file pointer. More... | |
int | bufdumplib_diff (FILE *fp, const void *b0, const void *b1, size_t len, int flags) |
Write a hex diff of two binary memory buffers over the specified length into a file pointer. More... | |
int | bufdumplib_text (FILE *fp, const void *buf, size_t len) |
Write a comma-delimited hex byte array (e.g. for use in C source) into a file pointer. More... | |
This library provides a C API for hexadecimal dumps and diffs of binary memory buffers.
int bufdumplib_dump | ( | FILE * | fp, |
const void * | buf, | ||
size_t | len, | ||
int | flags | ||
) |
Write a hex dump of a binary memory buffer over the specified length into a file pointer.
fp | FILE pointer to which to write output |
buf | Buffer data to dump |
len | Length of buffer |
flags |
|
Examples
Given the following C data buffer:
bufdumplib_dump(stdout, buf, sizeof buf, 0) with flags=0 outputs:
bufdumplib_dump(stdout, buf, sizeof buf, 1) with flags=1 skips the first and second lines since they contain only zeros:
bufdumplib_dump(stdout, buf, sizeof buf, 2) with flags=2 blanks the 4 byte (32 bit) zero groups:
bufdumplib_dump(stdout, buf, sizeof buf, 4) with flags=4 blanks the remaining individual zero bytes in line 4 that the previous example left in numeric form:
bufdumplib_dump(stdout, buf, sizeof buf, 3) with flags=3 blanks lines and groups that are zero, but preserves the individual zero bytes on line 4:
This example can be found in examples/dumpexample.c
int bufdumplib_diff | ( | FILE * | fp, |
const void * | b0, | ||
const void * | b1, | ||
size_t | len, | ||
int | flags | ||
) |
Write a hex diff of two binary memory buffers over the specified length into a file pointer.
fp | FILE pointer to which to write output |
b0 | First buffer to compare (output on left) |
b1 | Second buffer to compare (output on right) |
len | Length of buffer |
flags |
|
Examples
Now consider a new buffer with a few changed bytes:
bufdumplib_diff(stdout, buf, chg, sizeof buf, 0) with flags=0 outputs a straight comparison with everything intact:
bufdumplib_diff(stdout, buf, chg, sizeof buf, 1) with flags=1 skips the second and third lines since they are the same:
bufdumplib_diff(stdout, buf, chg, sizeof buf, 2) with flags=2 blanks the 4 byte (32 bit) groups that are the same in each buffer:
bufdumplib_diff(stdout, buf, chg, sizeof buf, 4) with flags=4 blanks the remaining individual zero bytes in lines 0 and 1 that the previous example left in numeric form:
bufdumplib_diff(stdout, buf, chg, sizeof buf, 7) with flags=7 (or 5) blanks lines and bytes (and groups) that are the same:
This example can be found in examples/diffexample.c
int bufdumplib_text | ( | FILE * | fp, |
const void * | buf, | ||
size_t | len | ||
) |
Write a comma-delimited hex byte array (e.g. for use in C source) into a file pointer.
fp | FILE pointer to which to write output |
buf | Buffer data to dump |
len | Length of buffer |
Example
Given the same C data buffer as above:
bufdumplib_text(stdout, buf, sizeof buf) outputs:
This example can be found in examples/textexample.c