Mercury
|
#include "mercury_types.h"
#include "mercury_error.h"
#include "mercury_bulk.h"
#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
Macros | |
#define | HG_PROC_INLINE HG_INLINE |
#define | hg_proc_int8_t hg_proc_hg_int8_t |
For convenience map stdint types to hg types. More... | |
#define | hg_proc_uint8_t hg_proc_hg_uint8_t |
#define | hg_proc_int16_t hg_proc_hg_int16_t |
#define | hg_proc_uint16_t hg_proc_hg_uint16_t |
#define | hg_proc_int32_t hg_proc_hg_int32_t |
#define | hg_proc_uint32_t hg_proc_hg_uint32_t |
#define | hg_proc_int64_t hg_proc_hg_int64_t |
#define | hg_proc_uint64_t hg_proc_hg_uint64_t |
#define | hg_proc_hg_bool_t hg_proc_hg_uint8_t |
#define | hg_proc_hg_ptr_t hg_proc_hg_uint64_t |
#define | hg_proc_hg_id_t hg_proc_hg_uint32_t |
Functions | |
HG_EXPORT void * | hg_proc_buf_alloc (size_t size) |
Can be used to allocate a buffer that will be used by the generic processor. More... | |
HG_EXPORT hg_return_t | hg_proc_buf_free (void *mem_ptr) |
Free memory which has been previously allocated using hg_proc_buf_alloc. More... | |
HG_EXPORT hg_return_t | hg_proc_create (void *buf, size_t buf_size, hg_proc_op_t op, hg_proc_hash_t hash, hg_proc_t *proc) |
Create a new encoding/decoding processor. More... | |
HG_EXPORT hg_return_t | hg_proc_free (hg_proc_t proc) |
Free the processor. More... | |
HG_EXPORT hg_proc_op_t | hg_proc_get_op (hg_proc_t proc) |
Get the operation type associated to the processor. More... | |
HG_EXPORT size_t | hg_proc_get_size (hg_proc_t proc) |
Get buffer size available for processing. More... | |
HG_EXPORT hg_return_t | hg_proc_set_size (hg_proc_t proc, size_t buf_size) |
Request a new buffer size. More... | |
HG_EXPORT size_t | hg_proc_get_size_left (hg_proc_t proc) |
Get size left for processing. More... | |
HG_EXPORT void * | hg_proc_get_buf_ptr (hg_proc_t proc) |
Get pointer to current buffer (for manual encoding). More... | |
HG_EXPORT hg_return_t | hg_proc_set_buf_ptr (hg_proc_t proc, void *buf_ptr) |
Set new buffer pointer (for manual encoding). More... | |
HG_EXPORT void * | hg_proc_get_extra_buf (hg_proc_t proc) |
Get eventual extra buffer used by processor. More... | |
HG_EXPORT size_t | hg_proc_get_extra_size (hg_proc_t proc) |
Get eventual size of the extra buffer used by processor. More... | |
HG_EXPORT hg_return_t | hg_proc_set_extra_buf_is_mine (hg_proc_t proc, hg_bool_t mine) |
Set extra buffer to mine (if other calls mine, buffer is no longer freed after hg_proc_free) More... | |
HG_EXPORT hg_return_t | hg_proc_flush (hg_proc_t proc) |
Flush the proc after data has been encoded or decoded and verify data using base checksum if available. More... | |
HG_EXPORT hg_return_t | hg_proc_memcpy (hg_proc_t proc, void *data, size_t data_size) |
Base proc routine using memcpy. More... | |
static HG_INLINE void * | hg_proc_buf_memcpy (void *buf, void *data, size_t data_size, hg_proc_op_t op) |
Copy data to buf if HG_ENCODE or buf to data if HG_DECODE and return incremented pointer to buf. More... | |
HG_EXPORT HG_PROC_INLINE hg_return_t | hg_proc_hg_int8_t (hg_proc_t proc, hg_int8_t *data) |
Inline prototypes (do not remove) More... | |
HG_EXPORT HG_PROC_INLINE hg_return_t | hg_proc_hg_uint8_t (hg_proc_t proc, hg_uint8_t *data) |
Generic processing routine. More... | |
HG_EXPORT HG_PROC_INLINE hg_return_t | hg_proc_hg_int16_t (hg_proc_t proc, hg_int16_t *data) |
Generic processing routine. More... | |
HG_EXPORT HG_PROC_INLINE hg_return_t | hg_proc_hg_uint16_t (hg_proc_t proc, hg_uint16_t *data) |
Generic processing routine. More... | |
HG_EXPORT HG_PROC_INLINE hg_return_t | hg_proc_hg_int32_t (hg_proc_t proc, hg_int32_t *data) |
Generic processing routine. More... | |
HG_EXPORT HG_PROC_INLINE hg_return_t | hg_proc_hg_uint32_t (hg_proc_t proc, hg_uint32_t *data) |
Generic processing routine. More... | |
HG_EXPORT HG_PROC_INLINE hg_return_t | hg_proc_hg_int64_t (hg_proc_t proc, hg_int64_t *data) |
Generic processing routine. More... | |
HG_EXPORT HG_PROC_INLINE hg_return_t | hg_proc_hg_uint64_t (hg_proc_t proc, hg_uint64_t *data) |
Generic processing routine. More... | |
HG_EXPORT HG_PROC_INLINE hg_return_t | hg_proc_raw (hg_proc_t proc, void *buf, size_t buf_size) |
Generic processing routine. More... | |
HG_EXPORT HG_PROC_INLINE hg_return_t | hg_proc_hg_bulk_t (hg_proc_t proc, hg_bulk_t *handle) |
Generic processing routine. More... | |
#define HG_PROC_INLINE HG_INLINE |
Definition at line 36 of file mercury_proc.h.
#define hg_proc_int8_t hg_proc_hg_int8_t |
For convenience map stdint types to hg types.
Definition at line 279 of file mercury_proc.h.
#define hg_proc_uint8_t hg_proc_hg_uint8_t |
Definition at line 280 of file mercury_proc.h.
#define hg_proc_int16_t hg_proc_hg_int16_t |
Definition at line 281 of file mercury_proc.h.
#define hg_proc_uint16_t hg_proc_hg_uint16_t |
Definition at line 282 of file mercury_proc.h.
#define hg_proc_int32_t hg_proc_hg_int32_t |
Definition at line 283 of file mercury_proc.h.
#define hg_proc_uint32_t hg_proc_hg_uint32_t |
Definition at line 284 of file mercury_proc.h.
#define hg_proc_int64_t hg_proc_hg_int64_t |
Definition at line 285 of file mercury_proc.h.
#define hg_proc_uint64_t hg_proc_hg_uint64_t |
Definition at line 286 of file mercury_proc.h.
#define hg_proc_hg_bool_t hg_proc_hg_uint8_t |
Definition at line 289 of file mercury_proc.h.
#define hg_proc_hg_ptr_t hg_proc_hg_uint64_t |
Definition at line 290 of file mercury_proc.h.
#define hg_proc_hg_id_t hg_proc_hg_uint32_t |
Definition at line 291 of file mercury_proc.h.
HG_EXPORT void* hg_proc_buf_alloc | ( | size_t | size | ) |
Can be used to allocate a buffer that will be used by the generic processor.
Buffer should be freed using "hg_proc_buf_free".
size | [IN] request buffer size |
HG_EXPORT hg_return_t hg_proc_buf_free | ( | void * | mem_ptr | ) |
Free memory which has been previously allocated using hg_proc_buf_alloc.
mem_ptr | [IN] pointer to memory address |
HG_EXPORT hg_return_t hg_proc_create | ( | void * | buf, |
size_t | buf_size, | ||
hg_proc_op_t | op, | ||
hg_proc_hash_t | hash, | ||
hg_proc_t * | proc | ||
) |
Create a new encoding/decoding processor.
buf | [IN] pointer to buffer that will be used for serialization/deserialization |
buf_size | [IN] buffer size |
op | [IN] operation type: HG_ENCODE / HG_DECODE / HG_FREE |
hash | [IN] hash method used for computing checksum (if NULL, checksum is not computed) hash method: HG_CRC16, HG_CRC64, HG_NOHASH |
proc | [OUT] pointer to abstract processor object |
HG_EXPORT hg_return_t hg_proc_free | ( | hg_proc_t | proc | ) |
Free the processor.
proc | [IN/OUT] abstract processor object |
HG_EXPORT hg_proc_op_t hg_proc_get_op | ( | hg_proc_t | proc | ) |
Get the operation type associated to the processor.
proc | [IN] abstract processor object |
HG_EXPORT size_t hg_proc_get_size | ( | hg_proc_t | proc | ) |
Get buffer size available for processing.
proc | [IN] abstract processor object |
HG_EXPORT hg_return_t hg_proc_set_size | ( | hg_proc_t | proc, |
size_t | buf_size | ||
) |
Request a new buffer size.
This will modify the size of the buffer attached to the processor or create an extra processing buffer.
proc | [IN/OUT] abstract processor object |
buf_size | [IN] buffer size |
HG_EXPORT size_t hg_proc_get_size_left | ( | hg_proc_t | proc | ) |
Get size left for processing.
proc | [IN] abstract processor object |
HG_EXPORT void* hg_proc_get_buf_ptr | ( | hg_proc_t | proc | ) |
Get pointer to current buffer (for manual encoding).
proc | [IN] abstract processor object |
HG_EXPORT hg_return_t hg_proc_set_buf_ptr | ( | hg_proc_t | proc, |
void * | buf_ptr | ||
) |
Set new buffer pointer (for manual encoding).
proc | [IN/OUT] abstract processor object |
buf_ptr | [IN] pointer to buffer used by the processor |
HG_EXPORT void* hg_proc_get_extra_buf | ( | hg_proc_t | proc | ) |
Get eventual extra buffer used by processor.
proc | [IN] abstract processor object |
HG_EXPORT size_t hg_proc_get_extra_size | ( | hg_proc_t | proc | ) |
Get eventual size of the extra buffer used by processor.
proc | [IN] abstract processor object |
HG_EXPORT hg_return_t hg_proc_set_extra_buf_is_mine | ( | hg_proc_t | proc, |
hg_bool_t | mine | ||
) |
Set extra buffer to mine (if other calls mine, buffer is no longer freed after hg_proc_free)
proc | [IN] abstract processor object |
HG_EXPORT hg_return_t hg_proc_flush | ( | hg_proc_t | proc | ) |
Flush the proc after data has been encoded or decoded and verify data using base checksum if available.
proc | [IN] abstract processor object |
HG_EXPORT hg_return_t hg_proc_memcpy | ( | hg_proc_t | proc, |
void * | data, | ||
size_t | data_size | ||
) |
Base proc routine using memcpy.
NB. Only uses memcpy / use hg_proc_raw for encoding independent proc routine.
proc | [IN/OUT] abstract processor object |
data | [IN/OUT] pointer to data |
data_size | [IN] data size |
|
static |
Copy data to buf if HG_ENCODE or buf to data if HG_DECODE and return incremented pointer to buf.
buf | [IN/OUT] abstract processor object |
data | [IN/OUT] pointer to data |
data_size | [IN] data size |
op | [IN] operation type: HG_ENCODE / HG_DECODE |
Definition at line 235 of file mercury_proc.h.
HG_PROC_INLINE hg_return_t hg_proc_hg_int8_t | ( | hg_proc_t | proc, |
hg_int8_t * | data | ||
) |
Inline prototypes (do not remove)
Generic processing routine.
proc | [IN/OUT] abstract processor object |
data | [IN/OUT] pointer to data |
Definition at line 302 of file mercury_proc.h.
HG_PROC_INLINE hg_return_t hg_proc_hg_uint8_t | ( | hg_proc_t | proc, |
hg_uint8_t * | data | ||
) |
Generic processing routine.
proc | [IN/OUT] abstract processor object |
data | [IN/OUT] pointer to data |
Definition at line 322 of file mercury_proc.h.
HG_PROC_INLINE hg_return_t hg_proc_hg_int16_t | ( | hg_proc_t | proc, |
hg_int16_t * | data | ||
) |
Generic processing routine.
proc | [IN/OUT] abstract processor object |
data | [IN/OUT] pointer to data |
Definition at line 342 of file mercury_proc.h.
HG_PROC_INLINE hg_return_t hg_proc_hg_uint16_t | ( | hg_proc_t | proc, |
hg_uint16_t * | data | ||
) |
Generic processing routine.
proc | [IN/OUT] abstract processor object |
data | [IN/OUT] pointer to data |
Definition at line 362 of file mercury_proc.h.
HG_PROC_INLINE hg_return_t hg_proc_hg_int32_t | ( | hg_proc_t | proc, |
hg_int32_t * | data | ||
) |
Generic processing routine.
proc | [IN/OUT] abstract processor object |
data | [IN/OUT] pointer to data |
Definition at line 382 of file mercury_proc.h.
HG_PROC_INLINE hg_return_t hg_proc_hg_uint32_t | ( | hg_proc_t | proc, |
hg_uint32_t * | data | ||
) |
Generic processing routine.
proc | [IN/OUT] abstract processor object |
data | [IN/OUT] pointer to data |
Definition at line 402 of file mercury_proc.h.
HG_PROC_INLINE hg_return_t hg_proc_hg_int64_t | ( | hg_proc_t | proc, |
hg_int64_t * | data | ||
) |
Generic processing routine.
proc | [IN/OUT] abstract processor object |
data | [IN/OUT] pointer to data |
Definition at line 422 of file mercury_proc.h.
HG_PROC_INLINE hg_return_t hg_proc_hg_uint64_t | ( | hg_proc_t | proc, |
hg_uint64_t * | data | ||
) |
Generic processing routine.
proc | [IN/OUT] abstract processor object |
data | [IN/OUT] pointer to data |
Definition at line 442 of file mercury_proc.h.
HG_PROC_INLINE hg_return_t hg_proc_raw | ( | hg_proc_t | proc, |
void * | buf, | ||
size_t | buf_size | ||
) |
Generic processing routine.
proc | [IN/OUT] abstract processor object |
buf | [IN/OUT] pointer to buffer |
buf_size | [IN] buffer size |
Definition at line 463 of file mercury_proc.h.
HG_PROC_INLINE hg_return_t hg_proc_hg_bulk_t | ( | hg_proc_t | proc, |
hg_bulk_t * | handle | ||
) |
Generic processing routine.
proc | [IN/OUT] abstract processor object |
handle | [IN/OUT] pointer to bulk handle |
Definition at line 489 of file mercury_proc.h.