Mercury
Macros | Typedefs | Functions
mchecksum.h File Reference
#include "mchecksum_config.h"
Include dependency graph for mchecksum.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MCHECKSUM_OBJECT_NULL   ((mchecksum_object_t)0)
 
#define MCHECKSUM_NOFINALIZE   0
 
#define MCHECKSUM_FINALIZE   1
 

Typedefs

typedef void * mchecksum_object_t
 

Functions

MCHECKSUM_EXPORT int mchecksum_init (const char *hash_method, mchecksum_object_t *checksum)
 Initialize the checksum with the specified hash method. More...
 
MCHECKSUM_EXPORT int mchecksum_destroy (mchecksum_object_t checksum)
 Destroy the checksum. More...
 
MCHECKSUM_EXPORT int mchecksum_reset (mchecksum_object_t checksum)
 Reset the checksum. More...
 
MCHECKSUM_EXPORT size_t mchecksum_get_size (mchecksum_object_t checksum)
 Get size of checksum. More...
 
MCHECKSUM_EXPORT int mchecksum_get (mchecksum_object_t checksum, void *buf, size_t size, int finalize)
 Get checksum and copy it into buf. More...
 
MCHECKSUM_EXPORT int mchecksum_update (mchecksum_object_t checksum, const void *data, size_t size)
 Accumulates a partial checksum of the input data. More...
 

Macro Definition Documentation

#define MCHECKSUM_OBJECT_NULL   ((mchecksum_object_t)0)

Definition at line 18 of file mchecksum.h.

#define MCHECKSUM_NOFINALIZE   0

Definition at line 20 of file mchecksum.h.

#define MCHECKSUM_FINALIZE   1

Definition at line 21 of file mchecksum.h.

Typedef Documentation

typedef void* mchecksum_object_t

Definition at line 16 of file mchecksum.h.

Function Documentation

MCHECKSUM_EXPORT int mchecksum_init ( const char *  hash_method,
mchecksum_object_t checksum 
)

Initialize the checksum with the specified hash method.

Parameters
hash_method[IN] hash method string Available methods are: "crc16", "crc64"
checksum[OUT] pointer to abstract checksum
Returns
Non-negative on success or negative on failure
MCHECKSUM_EXPORT int mchecksum_destroy ( mchecksum_object_t  checksum)

Destroy the checksum.

Parameters
checksum[IN/OUT] abstract checksum
Returns
Non-negative on success or negative on failure
MCHECKSUM_EXPORT int mchecksum_reset ( mchecksum_object_t  checksum)

Reset the checksum.

Parameters
checksum[IN/OUT] abstract checksum
Returns
Non-negative on success or negative on failure
MCHECKSUM_EXPORT size_t mchecksum_get_size ( mchecksum_object_t  checksum)

Get size of checksum.

Parameters
checksum[IN] abstract checksum
Returns
Non-negative value
MCHECKSUM_EXPORT int mchecksum_get ( mchecksum_object_t  checksum,
void *  buf,
size_t  size,
int  finalize 
)

Get checksum and copy it into buf.

Parameters
checksum[IN/OUT] abstract checksum
buf[IN] pointer to buffer
size[IN] size of buffer
finalize[IN] one of: MCHECKSUM_FINALIZE no more data will be added to this checksum (only valid call to follow is reset or destroy) MCHECKSUM_NOFINALIZE More data might be added to this checksum later
Returns
Non-negative on success or negative on failure
MCHECKSUM_EXPORT int mchecksum_update ( mchecksum_object_t  checksum,
const void *  data,
size_t  size 
)

Accumulates a partial checksum of the input data.

Parameters
checksum[IN/OUT] abstract checksum
data[IN] pointer to buffer
size[IN] size of buffer
Returns
Non-negative on success or negative on failure