APG
… an ABNF Parser Generator
|
A formatting object for displaying binary data in human-readable formats. More...
Go to the source code of this file.
Data Structures | |
struct | fmt_tag |
The context for the format object. More... | |
Macros | |
Private Macros – used internally by the formatting object | |
#define | MAX_INDENT 80 |
#define | LINE_LEN 16 |
#define | LINE_LEN4 4 |
#define | LINE_LEN8 8 |
#define | LINE_LEN12 12 |
#define | FMT_BUFLEN (128+MAX_INDENT) |
#define | FILE_END ((uint64_t)-1) |
Functions | |
void * | vpFmtCtor (exception *spEx) |
The object constructor. More... | |
void | vFmtDtor (void *vpCtx) |
The object destructor. More... | |
abool | bFmtValidate (void *vpCtx) |
Validate a format context pointer. More... | |
void | vFmtIndent (void *vpCtx, int iIndent) |
Set the an indentation for the display. More... | |
const char * | cpFmtFirstBytes (void *vpCtx, const uint8_t *ucpBytes, uint64_t uiLength, int iStyle, uint64_t uiOffset, uint64_t uiLimit) |
Initiate the iterator over an array of 8-bit byte data. More... | |
const char * | cpFmtFirstFile (void *vpCtx, const char *cpFileName, int iStyle, uint64_t uiOffset, uint64_t uiLimit) |
Initiate the iterator over file of 8-bit byte data. More... | |
const char * | cpFmtFirstUnicode (void *vpCtx, const uint32_t *uipChars, uint64_t uiLength, uint64_t uiOffset, uint64_t uiLimit) |
Initiate the iterator over an array of 32-bit Unicode code points. More... | |
const char * | cpFmtNext (void *vpCtx) |
Formats the next line of data. More... | |
A formatting object for displaying binary data in human-readable formats.
Displaying bytes and Unicode code points which often do not have printing ASCII character counterparts are a common problem with many applications. This object provides a common solution to this problem. It is roughly patterned after the Linux hexdump
command. Once the object has been created it can be used as an iterator to display fixed line length displays of the data in several common formats.
Each line is preceded with the 8 hexadecimal digit offset to the first byte of the line. The final line is empty with just the offset to the (empty) byte following the data.
Definition in file format.c.
#define FMT_BUFLEN (128+MAX_INDENT) |
abool bFmtValidate | ( | void * | vpCtx | ) |
Validate a format context pointer.
vpCtx | A pointer to a possibly valid format context previously return from vpFmtCtor(). |
const char* cpFmtFirstBytes | ( | void * | vpCtx, |
const uint8_t * | ucpBytes, | ||
uint64_t | uiLength, | ||
int | iStyle, | ||
uint64_t | uiOffset, | ||
uint64_t | uiLimit | ||
) |
Initiate the iterator over an array of 8-bit byte data.
vpCtx | - Pointer to a valid object context, previously returned from vpFmtCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code. |
ucpBytes | - Pointer to the array of bytes to display. Cannot be NULL. |
uiLength | - The number of bytes in the array. Cannot be 0. |
iStyle | - The display style identifier. Any of these except FMT_UNICODE.
|
uiOffset | - If > 0, this is the offset to the first byte do display. |
uiLimit | - If > 0, this is the maximum number of bytes to display. |
const char* cpFmtFirstFile | ( | void * | vpCtx, |
const char * | cpFileName, | ||
int | iStyle, | ||
uint64_t | uiOffset, | ||
uint64_t | uiLimit | ||
) |
Initiate the iterator over file of 8-bit byte data.
vpCtx | - Pointer to a valid object context, previously returned from vpFmtCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code. |
cpFileName | - Name of the file whose bytes to display. |
iStyle | - The display style identifier. Any of these except FMT_UNICODE.
|
uiOffset | - If > 0, this is the offset to the first byte do display. |
uiLimit | - If > 0, this is the maximum number of bytes to display. |
const char* cpFmtFirstUnicode | ( | void * | vpCtx, |
const uint32_t * | uipChars, | ||
uint64_t | uiLength, | ||
uint64_t | uiOffset, | ||
uint64_t | uiLimit | ||
) |
Initiate the iterator over an array of 32-bit Unicode code points.
Will actually work for any 32-bit unsigned integers. It will display values in the surrogate pair range. However, values outside the range (> 0xFFFFFF) will result in a distorted display.
vpCtx | - Pointer to a valid object context, previously returned from vpFmtCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code. |
uipChars | - Pointer to the 32-bit data array. |
uiLength | - The number of code points in the arry. |
uiOffset | - If > 0, this is the offset to the first code point do display. |
uiLimit | - If > 0, this is the maximum number of code points to display. |
const char* cpFmtNext | ( | void * | vpCtx | ) |
Formats the next line of data.
vpCtx | - Pointer to a valid object context, previously returned from vpFmtCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code. |
void vFmtDtor | ( | void * | vpCtx | ) |
The object destructor.
Closes any open files, frees all memory associated with this object. Clears the context to prevent accidental reuse attempts.
vpCtx | A pointer to a valid format context previously return from vpFmtCtor(). Silently ignored if NULL. However, if non-NULL it must be a valid format context pointer. The application will silently exit with BAD_CONTEXT exit code if vpCtx is invalid. |
void vFmtIndent | ( | void * | vpCtx, |
int | iIndent | ||
) |
Set the an indentation for the display.
vpCtx | A pointer to a valid format context previously return from vpFmtCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code. |
iIndent | - The number of spaces to indent before displaying each line. The value is truncated to the range 0 <= iIndent <= MAX_INDENT. |
void* vpFmtCtor | ( | exception * | spEx | ) |
The object constructor.
spEx | Pointer to a valid exception structure initialized with XCTOR(). If not valid the application will silently exit with a BAD_CONTEXT exit code. |