Mercury
Macros | Functions
mercury_proc.h File Reference
#include "mercury_types.h"
#include "mercury_error.h"
#include "mercury_bulk.h"
#include <stdlib.h>
#include <string.h>
Include dependency graph for mercury_proc.h:
This graph shows which files directly or indirectly include this file:

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...
 

Macro Definition Documentation

#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.

Function Documentation

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".

Parameters
size[IN] request buffer size
Returns
Pointer to memory address or NULL if allocation failed
HG_EXPORT hg_return_t hg_proc_buf_free ( void *  mem_ptr)

Free memory which has been previously allocated using hg_proc_buf_alloc.

Parameters
mem_ptr[IN] pointer to memory address
Returns
HG_SUCCESS or corresponding HG error code
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.

Parameters
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
Returns
HG_SUCCESS or corresponding HG error code
HG_EXPORT hg_return_t hg_proc_free ( hg_proc_t  proc)

Free the processor.

Parameters
proc[IN/OUT] abstract processor object
Returns
HG_SUCCESS or corresponding HG error code
HG_EXPORT hg_proc_op_t hg_proc_get_op ( hg_proc_t  proc)

Get the operation type associated to the processor.

Parameters
proc[IN] abstract processor object
Returns
Operation type
HG_EXPORT size_t hg_proc_get_size ( hg_proc_t  proc)

Get buffer size available for processing.

Parameters
proc[IN] abstract processor object
Returns
Non-negative size value
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.

Parameters
proc[IN/OUT] abstract processor object
buf_size[IN] buffer size
Returns
HG_SUCCESS or corresponding HG error code
HG_EXPORT size_t hg_proc_get_size_left ( hg_proc_t  proc)

Get size left for processing.

Parameters
proc[IN] abstract processor object
Returns
Non-negative size value
HG_EXPORT void* hg_proc_get_buf_ptr ( hg_proc_t  proc)

Get pointer to current buffer (for manual encoding).

Parameters
proc[IN] abstract processor object
Returns
Buffer pointer
HG_EXPORT hg_return_t hg_proc_set_buf_ptr ( hg_proc_t  proc,
void *  buf_ptr 
)

Set new buffer pointer (for manual encoding).

Parameters
proc[IN/OUT] abstract processor object
buf_ptr[IN] pointer to buffer used by the processor
Returns
HG_SUCCESS or corresponding HG error code
HG_EXPORT void* hg_proc_get_extra_buf ( hg_proc_t  proc)

Get eventual extra buffer used by processor.

Parameters
proc[IN] abstract processor object
Returns
Pointer to buffer or NULL if no extra buffer has been used
HG_EXPORT size_t hg_proc_get_extra_size ( hg_proc_t  proc)

Get eventual size of the extra buffer used by processor.

Parameters
proc[IN] abstract processor object
Returns
Size of buffer or 0 if no extra buffer has been used
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)

Parameters
proc[IN] abstract processor object
Returns
HG_SUCCESS or corresponding HG error code
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.

Parameters
proc[IN] abstract processor object
Returns
HG_SUCCESS or corresponding HG error code
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.

Parameters
proc[IN/OUT] abstract processor object
data[IN/OUT] pointer to data
data_size[IN] data size
Returns
HG_SUCCESS or corresponding HG error code
static HG_INLINE void* hg_proc_buf_memcpy ( void *  buf,
void *  data,
size_t  data_size,
hg_proc_op_t  op 
)
static

Copy data to buf if HG_ENCODE or buf to data if HG_DECODE and return incremented pointer to buf.

Parameters
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
Returns
incremented pointer to buf

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.

Parameters
proc[IN/OUT] abstract processor object
data[IN/OUT] pointer to data
Returns
HG_SUCCESS or corresponding HG error code

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.

Parameters
proc[IN/OUT] abstract processor object
data[IN/OUT] pointer to data
Returns
HG_SUCCESS or corresponding HG error code

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.

Parameters
proc[IN/OUT] abstract processor object
data[IN/OUT] pointer to data
Returns
HG_SUCCESS or corresponding HG error code

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.

Parameters
proc[IN/OUT] abstract processor object
data[IN/OUT] pointer to data
Returns
HG_SUCCESS or corresponding HG error code

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.

Parameters
proc[IN/OUT] abstract processor object
data[IN/OUT] pointer to data
Returns
HG_SUCCESS or corresponding HG error code

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.

Parameters
proc[IN/OUT] abstract processor object
data[IN/OUT] pointer to data
Returns
HG_SUCCESS or corresponding HG error code

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.

Parameters
proc[IN/OUT] abstract processor object
data[IN/OUT] pointer to data
Returns
HG_SUCCESS or corresponding HG error code

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.

Parameters
proc[IN/OUT] abstract processor object
data[IN/OUT] pointer to data
Returns
HG_SUCCESS or corresponding HG error code

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.

Parameters
proc[IN/OUT] abstract processor object
buf[IN/OUT] pointer to buffer
buf_size[IN] buffer size
Returns
HG_SUCCESS or corresponding HG error code

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.

Parameters
proc[IN/OUT] abstract processor object
handle[IN/OUT] pointer to bulk handle
Returns
HG_SUCCESS or corresponding HG error code

Definition at line 489 of file mercury_proc.h.