cgul_hex_dump.h File Reference

hex dump More...

#include "cgul_common.h"
#include "cgul_exception.h"
#include "cgul_string.h"
Include dependency graph for cgul_hex_dump.h:
This graph shows which files directly or indirectly include this file:

Typedefs

typedef typedefCGUL_BEGIN_C struct cgul_hex_dump * cgul_hex_dump_t
 

Functions

CGUL_EXPORT cgul_hex_dump_t cgul_hex_dump__new (cgul_exception_t *cex)
 
CGUL_EXPORT void cgul_hex_dump__delete (cgul_hex_dump_t hd)
 
CGUL_EXPORT void cgul_hex_dump__append (cgul_exception_t *cex, cgul_hex_dump_t hd, const void *buffer, size_t buffer_length)
 
CGUL_EXPORT cgul_string_t cgul_hex_dump__get_value (cgul_exception_t *cex, cgul_hex_dump_t hd)
 
CGUL_EXPORT void cgul_hex_dump__clear (cgul_exception_t *cex, cgul_hex_dump_t hd, int reset_byte_count)
 

Detailed Description

Create a hex dump of arbitrary binary data.

Author
Paul Serice

Typedef Documentation

§ cgul_hex_dump_t

typedef typedefCGUL_BEGIN_C struct cgul_hex_dump* cgul_hex_dump_t

Function Documentation

§ cgul_hex_dump__new()

CGUL_EXPORT cgul_hex_dump_t cgul_hex_dump__new ( cgul_exception_t cex)

Create a new cgul_hex_dump object. The caller is responsible for freeing the object by calling cgul_hex_dump__delete(). If memory cannot be allocated, NULL is returned and an exception is thrown.

Parameters
[in,out]cexc-style exception
Returns
new cgul_hex_dump instance

§ cgul_hex_dump__delete()

CGUL_EXPORT void cgul_hex_dump__delete ( cgul_hex_dump_t  hd)

This method frees all internally allocated memory. Do not try to use hd after calling this method.

Parameters
[in]hdcgul_hex_dump instance

§ cgul_hex_dump__append()

CGUL_EXPORT void cgul_hex_dump__append ( cgul_exception_t cex,
cgul_hex_dump_t  hd,
const void *  buffer,
size_t  buffer_length 
)

Bytes from buffer to buffer + buffer_length will be append to the conversion. You can call this function as often as you like. For efficiency, a new cgul_string is internally allocated for each call you make to cgul_hex_dump__append(). The new cgul_string is then put on a linked list. When you call cgul_hex_dump__get_value(), all the cgul_string objects on the list are concatenated. If this function fails to allocate memory, an exception is thrown.

Parameters
[in,out]cexc-style exception
[in]hdcgul_hex_dump instance
[in]bufferbuffer
[in]buffer_lengthbuffer length

§ cgul_hex_dump__get_value()

CGUL_EXPORT cgul_string_t cgul_hex_dump__get_value ( cgul_exception_t cex,
cgul_hex_dump_t  hd 
)

Call this method at any point to get a copy of all the strings appended together that comprise elements on the internal linked list. The caller is responsible for freeing the copy by calling cgul_string_delete(). If this function fails to allocate memory, an exception is thrown.

Parameters
[in,out]cexc-style exception
[in]hdcgul_hex_dump instance
Returns
copy of current hex dump as a single string

§ cgul_hex_dump__clear()

CGUL_EXPORT void cgul_hex_dump__clear ( cgul_exception_t cex,
cgul_hex_dump_t  hd,
int  reset_byte_count 
)

The method lets you reuse a cgul_hex_dump object. If reset_byte_count is true, the object will be reset to the same state as any new cgul_hex_dump object would have. If reset_byte_count is false, the object will have the same state as any new cgul_hex_dump object except the byte count that runs along the left edge of the output will not be reset.

Parameters
[in]cexc-style exception
[in]hdcgul_hex_dump instance
[in]reset_byte_countwhether to reset the byte count