corosync  2.3.5-dirty
Data Structures | Macros | Typedefs | Enumerations | Functions
Cmap_corosync

Data Structures

struct  cmap_notify_value
 

Macros

#define CMAP_KEYNAME_MAXLEN   255
 
#define CMAP_KEYNAME_MINLEN   3
 
#define CMAP_TRACK_ADD   4
 
#define CMAP_TRACK_DELETE   1
 
#define CMAP_TRACK_MODIFY   2
 
#define CMAP_TRACK_PREFIX   8
 

Typedefs

typedef uint64_t cmap_handle_t
 
typedef uint64_t cmap_iter_handle_t
 
typedef uint64_t cmap_track_handle_t
 
typedef void(* cmap_notify_fn_t) (cmap_handle_t cmap_handle, cmap_track_handle_t cmap_track_handle, int32_t event, const char *key_name, struct cmap_notify_value new_value, struct cmap_notify_value old_value, void *user_data)
 

Enumerations

enum  cmap_value_types_t {
  CMAP_VALUETYPE_INT8 = 1, CMAP_VALUETYPE_UINT8 = 2, CMAP_VALUETYPE_INT16 = 3, CMAP_VALUETYPE_UINT16 = 4,
  CMAP_VALUETYPE_INT32 = 5, CMAP_VALUETYPE_UINT32 = 6, CMAP_VALUETYPE_INT64 = 7, CMAP_VALUETYPE_UINT64 = 8,
  CMAP_VALUETYPE_FLOAT = 9, CMAP_VALUETYPE_DOUBLE = 10, CMAP_VALUETYPE_STRING = 11, CMAP_VALUETYPE_BINARY = 12
}
 

Functions

cs_error_t cmap_initialize (cmap_handle_t *handle)
 Create a new cmap connection. More...
 
cs_error_t cmap_finalize (cmap_handle_t handle)
 Close the cmap handle. More...
 
cs_error_t cmap_fd_get (cmap_handle_t handle, int *fd)
 
cs_error_t cmap_dispatch (cmap_handle_t handle, cs_dispatch_flags_t dispatch_types)
 Dispatch data from service. More...
 
cs_error_t cmap_context_get (cmap_handle_t handle, const void **context)
 
cs_error_t cmap_context_set (cmap_handle_t handle, const void *context)
 
cs_error_t cmap_set (cmap_handle_t handle, const char *key_name, const void *value, size_t value_len, cmap_value_types_t type)
 Store value in cmap. More...
 
cs_error_t cmap_set_int8 (cmap_handle_t handle, const char *key_name, int8_t value)
 
cs_error_t cmap_set_uint8 (cmap_handle_t handle, const char *key_name, uint8_t value)
 
cs_error_t cmap_set_int16 (cmap_handle_t handle, const char *key_name, int16_t value)
 
cs_error_t cmap_set_uint16 (cmap_handle_t handle, const char *key_name, uint16_t value)
 
cs_error_t cmap_set_int32 (cmap_handle_t handle, const char *key_name, int32_t value)
 
cs_error_t cmap_set_uint32 (cmap_handle_t handle, const char *key_name, uint32_t value)
 
cs_error_t cmap_set_int64 (cmap_handle_t handle, const char *key_name, int64_t value)
 
cs_error_t cmap_set_uint64 (cmap_handle_t handle, const char *key_name, uint64_t value)
 
cs_error_t cmap_set_float (cmap_handle_t handle, const char *key_name, float value)
 
cs_error_t cmap_set_double (cmap_handle_t handle, const char *key_name, double value)
 
cs_error_t cmap_set_string (cmap_handle_t handle, const char *key_name, const char *value)
 
cs_error_t cmap_delete (cmap_handle_t handle, const char *key_name)
 Deletes key from cmap database. More...
 
cs_error_t cmap_get (cmap_handle_t handle, const char *key_name, void *value, size_t *value_len, cmap_value_types_t *type)
 Retrieve value of key key_name and store it in user preallocated value pointer. More...
 
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)
 Shortcut for cmap_get for string type. More...
 
cs_error_t cmap_inc (cmap_handle_t handle, const char *key_name)
 Increment value of key_name if it is [u]int* type. More...
 
cs_error_t cmap_dec (cmap_handle_t handle, const char *key_name)
 Decrement value of key_name if it is [u]int* type. More...
 
cs_error_t cmap_iter_init (cmap_handle_t handle, const char *prefix, cmap_iter_handle_t *cmap_iter_handle)
 Initialize iterator with given prefix. More...
 
cs_error_t cmap_iter_next (cmap_handle_t handle, cmap_iter_handle_t iter_handle, char key_name[], size_t *value_len, cmap_value_types_t *type)
 Return next item in iterator iter. More...
 
cs_error_t cmap_iter_finalize (cmap_handle_t handle, cmap_iter_handle_t iter_handle)
 Finalize iterator. More...
 
cs_error_t cmap_track_add (cmap_handle_t handle, const char *key_name, int32_t track_type, cmap_notify_fn_t notify_fn, void *user_data, cmap_track_handle_t *cmap_track_handle)
 
cs_error_t cmap_track_delete (cmap_handle_t handle, cmap_track_handle_t track_handle)
 Delete track created previously by cmap_track_add. More...
 

Detailed Description

Macro Definition Documentation

#define CMAP_KEYNAME_MAXLEN   255

Definition at line 69 of file cmap.h.

Referenced by cmap_iter_next().

#define CMAP_KEYNAME_MINLEN   3

Definition at line 73 of file cmap.h.

#define CMAP_TRACK_ADD   4

Definition at line 78 of file cmap.h.

#define CMAP_TRACK_DELETE   1

Definition at line 79 of file cmap.h.

#define CMAP_TRACK_MODIFY   2

Definition at line 80 of file cmap.h.

#define CMAP_TRACK_PREFIX   8

Definition at line 86 of file cmap.h.

Typedef Documentation

typedef uint64_t cmap_handle_t

Definition at line 54 of file cmap.h.

typedef uint64_t cmap_iter_handle_t

Definition at line 59 of file cmap.h.

typedef void(* cmap_notify_fn_t) (cmap_handle_t cmap_handle, cmap_track_handle_t cmap_track_handle, int32_t event, const char *key_name, struct cmap_notify_value new_value, struct cmap_notify_value old_value, void *user_data)

Definition at line 122 of file cmap.h.

typedef uint64_t cmap_track_handle_t

Definition at line 64 of file cmap.h.

Enumeration Type Documentation

Enumerator
CMAP_VALUETYPE_INT8 
CMAP_VALUETYPE_UINT8 
CMAP_VALUETYPE_INT16 
CMAP_VALUETYPE_UINT16 
CMAP_VALUETYPE_INT32 
CMAP_VALUETYPE_UINT32 
CMAP_VALUETYPE_INT64 
CMAP_VALUETYPE_UINT64 
CMAP_VALUETYPE_FLOAT 
CMAP_VALUETYPE_DOUBLE 
CMAP_VALUETYPE_STRING 
CMAP_VALUETYPE_BINARY 

Definition at line 91 of file cmap.h.

Function Documentation

cs_error_t cmap_context_get ( cmap_handle_t  handle,
const void **  context 
)

Definition at line 310 of file lib/cmap.c.

References cmap_inst::context, CS_OK, and hdb_error_to_cs().

cs_error_t cmap_context_set ( cmap_handle_t  handle,
const void *  context 
)

Definition at line 329 of file lib/cmap.c.

References cmap_inst::context, CS_OK, and hdb_error_to_cs().

cs_error_t cmap_dec ( cmap_handle_t  handle,
const char *  key_name 
)

Decrement value of key_name if it is [u]int* type.

Parameters
handlecmap handle
key_namekey name

Definition at line 775 of file lib/cmap.c.

cs_error_t cmap_delete ( cmap_handle_t  handle,
const char *  key_name 
)

Deletes key from cmap database.

Parameters
handlecmap handle
key_namename of key to delete

Definition at line 465 of file lib/cmap.c.

References cmap_inst::c, CS_ERR_INVALID_PARAM, CS_ERR_NAME_TOO_LONG, CS_IPC_TIMEOUT_MS, CS_MAX_NAME_LENGTH, CS_OK, hdb_error_to_cs(), MESSAGE_REQ_CMAP_DELETE, and qb_to_cs_error().

cs_error_t cmap_dispatch ( cmap_handle_t  handle,
cs_dispatch_flags_t  dispatch_types 
)
cs_error_t cmap_fd_get ( cmap_handle_t  handle,
int *  fd 
)

Definition at line 170 of file lib/cmap.c.

References cmap_inst::c, CS_OK, hdb_error_to_cs(), and qb_to_cs_error().

cs_error_t cmap_finalize ( cmap_handle_t  handle)

Close the cmap handle.

Parameters
handlecmap handle

Definition at line 131 of file lib/cmap.c.

References cmap_inst::c, cmap_track_inst::c, CS_ERR_BAD_HANDLE, CS_OK, cmap_inst::finalize, and hdb_error_to_cs().

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

Retrieve value of key key_name and store it in user preallocated value pointer.

value can be NULL, and then only value_len and/or type is returned (both of them can also be NULL). 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.

Parameters
handlecmap handle
key_namename of key where to get value
valuepointer to store data (or NULL)
value_lenpointer with length of value (value != NULL), or pointer where value length will be returned (value == NULL) or NULL.
typetype of value in cmap

Definition at line 511 of file lib/cmap.c.

References cmap_inst::c, CS_ERR_INVALID_PARAM, CS_ERR_NAME_TOO_LONG, CS_ERR_NO_MEMORY, CS_IPC_TIMEOUT_MS, CS_MAX_NAME_LENGTH, CS_OK, hdb_error_to_cs(), MESSAGE_REQ_CMAP_GET, and qb_to_cs_error().

Referenced by cmap_get_string().

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

Definition at line 679 of file lib/cmap.c.

References CMAP_VALUETYPE_DOUBLE.

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

Definition at line 673 of file lib/cmap.c.

References CMAP_VALUETYPE_FLOAT.

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

Definition at line 637 of file lib/cmap.c.

References CMAP_VALUETYPE_INT16.

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

Definition at line 649 of file lib/cmap.c.

References CMAP_VALUETYPE_INT32.

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

Definition at line 661 of file lib/cmap.c.

References CMAP_VALUETYPE_INT64.

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

Definition at line 625 of file lib/cmap.c.

References CMAP_VALUETYPE_INT8.

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

Shortcut for cmap_get for string type.

Returned string is newly allocated and caller is responsible for freeing memory

Parameters
handlecmap handle
key_namename of key to get value from
strpointer where char pointer will be stored

Definition at line 685 of file lib/cmap.c.

References cmap_get(), CMAP_VALUETYPE_STRING, CS_ERR_INVALID_PARAM, CS_ERR_NO_MEMORY, CS_OK, and type.

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

Definition at line 643 of file lib/cmap.c.

References CMAP_VALUETYPE_UINT16.

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

Definition at line 655 of file lib/cmap.c.

References CMAP_VALUETYPE_UINT32.

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

Definition at line 667 of file lib/cmap.c.

References CMAP_VALUETYPE_UINT64.

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

Definition at line 631 of file lib/cmap.c.

References CMAP_VALUETYPE_UINT8.

cs_error_t cmap_inc ( cmap_handle_t  handle,
const char *  key_name 
)

Increment value of key_name if it is [u]int* type.

Parameters
handlecmap handle
key_namekey name

Definition at line 769 of file lib/cmap.c.

cs_error_t cmap_initialize ( cmap_handle_t handle)

Create a new cmap connection.

Parameters
handlewill be filled with handle to be used for all following operations with cht.

Definition at line 90 of file lib/cmap.c.

References cmap_inst::c, CS_OK, cmap_inst::finalize, hdb_error_to_cs(), IPC_REQUEST_SIZE, and qb_to_cs_error().

cs_error_t cmap_iter_finalize ( cmap_handle_t  handle,
cmap_iter_handle_t  iter_handle 
)

Finalize iterator.

Definition at line 894 of file lib/cmap.c.

References cmap_inst::c, CS_IPC_TIMEOUT_MS, CS_OK, hdb_error_to_cs(), MESSAGE_REQ_CMAP_ITER_FINALIZE, and qb_to_cs_error().

cs_error_t cmap_iter_init ( cmap_handle_t  handle,
const char *  prefix,
cmap_iter_handle_t cmap_iter_handle 
)

Initialize iterator with given prefix.

Parameters
handlecmap handle
prefixprefix to iterate on
cmap_iter_handlevalue used for getting next value of iterator and/or deleting iteration

Definition at line 781 of file lib/cmap.c.

References cmap_inst::c, CS_ERR_INVALID_PARAM, CS_ERR_NAME_TOO_LONG, CS_IPC_TIMEOUT_MS, CS_MAX_NAME_LENGTH, CS_OK, hdb_error_to_cs(), MESSAGE_REQ_CMAP_ITER_INIT, and qb_to_cs_error().

cs_error_t cmap_iter_next ( cmap_handle_t  handle,
cmap_iter_handle_t  iter_handle,
char  key_name[],
size_t *  value_len,
cmap_value_types_t type 
)

Return next item in iterator iter.

value_len and type are optional (= can be NULL), but if set, length of returned value and/or type is returned.

Parameters
handlecmap handle
iter_handlehandle of iteration returned by cmap_iter_init
key_nameplace to store name of key. Maximum length is CMAP_KEYNAME_MAXLEN
value_lenlength of value
typetype of value
Returns
CS_NO_SECTION if there are no more sections to iterate

Definition at line 836 of file lib/cmap.c.

References cmap_inst::c, CMAP_KEYNAME_MAXLEN, CS_ERR_INVALID_PARAM, CS_IPC_TIMEOUT_MS, CS_OK, hdb_error_to_cs(), MESSAGE_REQ_CMAP_ITER_NEXT, and qb_to_cs_error().

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

Store value in cmap.

Parameters
handlecmap handle
key_namename of key where to store value
valuevalue to store
value_lenlength of value to store
typetype to store

Definition at line 348 of file lib/cmap.c.

References cmap_inst::c, CS_ERR_INVALID_PARAM, CS_ERR_NAME_TOO_LONG, CS_IPC_TIMEOUT_MS, CS_MAX_NAME_LENGTH, CS_OK, hdb_error_to_cs(), MESSAGE_REQ_CMAP_SET, qb_to_cs_error(), and type.

Referenced by cmap_set_double(), cmap_set_float(), cmap_set_int16(), cmap_set_int32(), cmap_set_int64(), cmap_set_int8(), cmap_set_string(), cmap_set_uint16(), cmap_set_uint32(), cmap_set_uint64(), and cmap_set_uint8().

cs_error_t cmap_set_double ( cmap_handle_t  handle,
const char *  key_name,
double  value 
)

Definition at line 450 of file lib/cmap.c.

References cmap_set(), and CMAP_VALUETYPE_DOUBLE.

cs_error_t cmap_set_float ( cmap_handle_t  handle,
const char *  key_name,
float  value 
)

Definition at line 445 of file lib/cmap.c.

References cmap_set(), and CMAP_VALUETYPE_FLOAT.

cs_error_t cmap_set_int16 ( cmap_handle_t  handle,
const char *  key_name,
int16_t  value 
)

Definition at line 415 of file lib/cmap.c.

References cmap_set(), and CMAP_VALUETYPE_INT16.

cs_error_t cmap_set_int32 ( cmap_handle_t  handle,
const char *  key_name,
int32_t  value 
)

Definition at line 425 of file lib/cmap.c.

References cmap_set(), and CMAP_VALUETYPE_INT32.

cs_error_t cmap_set_int64 ( cmap_handle_t  handle,
const char *  key_name,
int64_t  value 
)

Definition at line 435 of file lib/cmap.c.

References cmap_set(), and CMAP_VALUETYPE_INT64.

cs_error_t cmap_set_int8 ( cmap_handle_t  handle,
const char *  key_name,
int8_t  value 
)

Definition at line 405 of file lib/cmap.c.

References cmap_set(), and CMAP_VALUETYPE_INT8.

cs_error_t cmap_set_string ( cmap_handle_t  handle,
const char *  key_name,
const char *  value 
)

Definition at line 455 of file lib/cmap.c.

References cmap_set(), CMAP_VALUETYPE_STRING, and CS_ERR_INVALID_PARAM.

cs_error_t cmap_set_uint16 ( cmap_handle_t  handle,
const char *  key_name,
uint16_t  value 
)

Definition at line 420 of file lib/cmap.c.

References cmap_set(), and CMAP_VALUETYPE_UINT16.

cs_error_t cmap_set_uint32 ( cmap_handle_t  handle,
const char *  key_name,
uint32_t  value 
)

Definition at line 430 of file lib/cmap.c.

References cmap_set(), and CMAP_VALUETYPE_UINT32.

cs_error_t cmap_set_uint64 ( cmap_handle_t  handle,
const char *  key_name,
uint64_t  value 
)

Definition at line 440 of file lib/cmap.c.

References cmap_set(), and CMAP_VALUETYPE_UINT64.

cs_error_t cmap_set_uint8 ( cmap_handle_t  handle,
const char *  key_name,
uint8_t  value 
)

Definition at line 410 of file lib/cmap.c.

References cmap_set(), and CMAP_VALUETYPE_UINT8.

cs_error_t cmap_track_add ( cmap_handle_t  handle,
const char *  key_name,
int32_t  track_type,
cmap_notify_fn_t  notify_fn,
void *  user_data,
cmap_track_handle_t cmap_track_handle 
)
cs_error_t cmap_track_delete ( cmap_handle_t  handle,
cmap_track_handle_t  track_handle 
)

Delete track created previously by cmap_track_add.

Parameters
handlecmap handle
track_handleTrack handle

Definition at line 1024 of file lib/cmap.c.

References cmap_inst::c, CS_IPC_TIMEOUT_MS, CS_OK, hdb_error_to_cs(), MESSAGE_REQ_CMAP_TRACK_DELETE, and qb_to_cs_error().