CMAP_GET(3)

NAME

cmap_get - Retrieve value from CMAP

SYNOPSIS

#include <corosync/cmap.h>

cs_error_t cmap_get (cmap_handle_t handle, const char *key_name, void *value, size_t *value_len, cmap_value_types_t *type);

Also shortcuts for different types are defined

cs_error_t cmap_get_int8 (cmap_handle_t handle, const char *key_name, int8_t *i8);

cs_error_t cmap_get_uint8 (cmap_handle_t handle, const char *key_name, uint8_t *u8);

cs_error_t cmap_get_int16 (cmap_handle_t handle, const char *key_name, int16_t *i16);

cs_error_t cmap_get_uint16 (cmap_handle_t handle, const char *key_name, uint16_t *u16);

cs_error_t cmap_get_int32 (cmap_handle_t handle, const char *key_name, int32_t *i32);

cs_error_t cmap_get_uint32 (cmap_handle_t handle, const char *key_name, uint32_t *u32);

cs_error_t cmap_get_int64 (cmap_handle_t handle, const char *key_name, int64_t *i64);

cs_error_t cmap_get_uint64 (cmap_handle_t handle, const char *key_name, uint64_t *u64);

cs_error_t cmap_get_float (cmap_handle_t handle, const char *key_name, float *flt);

cs_error_t cmap_get_double (cmap_handle_t handle, const char *key_name, double *dbl);

cs_error_t cmap_get_string (cmap_handle_t handle, const char *key_name, char **str);

DESCRIPTION

The cmap_get function is used to retrieve key from cmap previously set by cmap_set(3) function. The handle argument is connection to CMAP database obtained by calling cmap_initialize(3) function. key_name is name of key to get value from. value is pointer to preallocated data used as storage for data, but can be also NULL, and then only value_len and/or type is returned (both of them can also be NULL, allowing function to be used only for test of existence of key). If value is not NULL, actual length of value in map is checked against *value_len. If *value_len is shorter then length of value in map, error CS_ERR_INVALID_PARAM is returned. After successful copy of value, *value_len is set to actual length of value in map. Parameter type is pointer to memory, where type of value is stored after successful return. Pointer can also be NULL and then nothing is stored. Type can be one of:

CMAP_VALUETYPE_INT8 - 8-bit signed integer

CMAP_VALUETYPE_UINT8 - 8-bit unsigned integer

CMAP_VALUETYPE_INT16 - 16-bit signed integer

CMAP_VALUETYPE_UINT16 - 16-bit unsigned integer

CMAP_VALUETYPE_INT32 - 32-bit signed integer

CMAP_VALUETYPE_UINT32 - 32-bit unsigned integer

CMAP_VALUETYPE_INT64 - 64-bit signed integer

CMAP_VALUETYPE_UINT64 - 64-bit unsigned integer

CMAP_VALUETYPE_FLOAT - Float value

CMAP_VALUETYPE_DOUBLE - Double value

CMAP_VALUETYPE_STRING - C-style string

CMAP_VALUETYPE_BINARY - Binary data, byte with zero value has no special meaning Shortcut functions tests cmap type with it's own type. If type didn't match, CS_ERR_INVALID_PARAM error is returned. No conversions are done, so for example cmap_get_int16 is not able to return value with CMAP_VALUETYPE_INT8 type. String shortcut function returns newly allocated memory and caller is responsible for freeing that.

RETURN VALUE
This call returns the CS_OK value if successful. If value or key_name are unspecified, CS_ERR_INVALID_PARAM is returned. Same error is also returned if value is specified, and *value_len is too short for store of data. If key doesn't exists (it was not set by calling cmap_set(3) function first) CS_ERR_NOT_EXIST error is returned. For helper functions, CS_ERR_INVALID_PARAM is returned if type stored in cmap doesn't match with type of helper function.

SEE ALSO
cmap_set(3), cmap_initialize(3), cmap_overview(8)

CS_ERR_TRY_AGAIN Resource temporarily unavailable CS_ERR_INVALID_PARAM Invalid argument CS_ERR_ACCESS Permission denied CS_ERR_LIBRARY The connection failed CS_ERR_INTERRUPT System call interrupted by a signal CS_ERR_NOT_SUPPORTED The requested protocol/functionality not supported CS_ERR_MESSAGE_ERROR Incorrect auth message received CS_ERR_NO_MEMORY Not enough memory to complete the requested task