58 qb_ipcc_connection_t *
c;
65 qb_ipcc_connection_t *
c;
69static void cmap_inst_free (
void *inst);
96 goto error_no_destroy;
100 if (error !=
CS_OK) {
109 goto error_put_destroy;
112 (void)hdb_handle_put(&cmap_handle_t_db, *handle);
117 (void)hdb_handle_put(&cmap_handle_t_db, *handle);
119 (void)hdb_handle_destroy(&cmap_handle_t_db, *handle);
131 struct qb_ipc_response_header res_lib_cmap_set_current_map;
135 if (error ==
CS_OK) {
137 if (error !=
CS_OK) {
153 &res_lib_cmap_set_current_map,
156 if (error ==
CS_OK) {
157 error = res_lib_cmap_set_current_map.error;
160 (void)hdb_handle_put (&cmap_handle_t_db, *handle);
167static void cmap_inst_free (
void *inst)
181 if (error !=
CS_OK) {
186 (void)hdb_handle_put (&cmap_handle_t_db, handle);
194 hdb_iterator_reset(&cmap_track_handle_t_db);
195 while (hdb_iterator_next(&cmap_track_handle_t_db,
199 (void)hdb_handle_destroy(&cmap_track_handle_t_db, track_inst_handle);
202 (void)hdb_handle_put (&cmap_track_handle_t_db, track_inst_handle);
205 (void)hdb_handle_destroy(&cmap_handle_t_db, handle);
207 (void)hdb_handle_put(&cmap_handle_t_db, handle);
218 if (error !=
CS_OK) {
224 (void)hdb_handle_put (&cmap_handle_t_db, handle);
237 struct qb_ipc_response_header *dispatch_data;
245 if (error !=
CS_OK) {
257 dispatch_data = (
struct qb_ipc_response_header *)dispatch_buf;
284 if (error !=
CS_OK) {
291 switch (dispatch_data->id) {
304 if (error !=
CS_OK) {
347 (void)hdb_handle_put (&cmap_handle_t_db, handle);
354 const void **context)
360 if (error !=
CS_OK) {
366 (void)hdb_handle_put (&cmap_handle_t_db, handle);
379 if (error !=
CS_OK) {
385 (void)hdb_handle_put (&cmap_handle_t_db, handle);
392 const char *key_name,
403 if (key_name == NULL ||
value == NULL) {
412 if (error !=
CS_OK) {
428 iov[1].iov_base = (
void *)
value;
429 iov[1].iov_len = value_len;
438 if (error ==
CS_OK) {
442 (void)hdb_handle_put (&cmap_handle_t_db, handle);
515 if (key_name == NULL) {
523 if (error !=
CS_OK) {
544 if (error ==
CS_OK) {
548 (void)hdb_handle_put (&cmap_handle_t_db, handle);
555 const char *key_name,
567 if (key_name == NULL) {
574 if (
value != NULL && value_len == NULL) {
579 if (error !=
CS_OK) {
590 if (
value != NULL && value_len != NULL) {
613 if (error ==
CS_OK) {
617 if (error ==
CS_OK) {
622 if (value_len != NULL) {
626 if (
value != NULL && value_len != NULL) {
633 (void)hdb_handle_put (&cmap_handle_t_db, handle);
640 const char *key_name,
651 key_size =
sizeof(key_value);
652 memset(key_value, 0, key_size);
654 err =
cmap_get(handle, key_name, key_value, &key_size, &key_type);
658 if (key_type !=
type) {
662 memcpy(
value, key_value, value_size);
733 res =
cmap_get(handle, key_name, NULL, &str_len, &
type);
743 *str = malloc(str_len);
750 res =
cmap_get(handle, key_name, *str, &str_len, &
type);
771 if (key_name == NULL) {
779 if (error !=
CS_OK) {
802 if (error ==
CS_OK) {
806 (void)hdb_handle_put (&cmap_handle_t_db, handle);
814 return (cmap_adjust_int(handle, key_name, 1));
820 return (cmap_adjust_int(handle, key_name, -1));
834 if (cmap_iter_handle == NULL) {
839 if (error !=
CS_OK) {
865 if (error ==
CS_OK) {
869 if (error ==
CS_OK) {
873 (void)hdb_handle_put (&cmap_handle_t_db, handle);
891 if (key_name == NULL) {
896 if (error !=
CS_OK) {
915 if (error ==
CS_OK) {
919 if (error ==
CS_OK) {
924 if (value_len != NULL) {
933 (void)hdb_handle_put (&cmap_handle_t_db, handle);
949 if (error !=
CS_OK) {
968 if (error ==
CS_OK) {
972 (void)hdb_handle_put (&cmap_handle_t_db, handle);
979 const char *key_name,
993 if (cmap_track_handle == NULL ||
notify_fn == NULL) {
998 if (error !=
CS_OK) {
1004 if (error !=
CS_OK) {
1010 if (error !=
CS_OK) {
1011 goto error_put_destroy;
1043 if (error ==
CS_OK) {
1047 if (error ==
CS_OK) {
1052 (void)hdb_handle_put (&cmap_track_handle_t_db, cmap_track_inst_handle);
1054 (void)hdb_handle_put (&cmap_handle_t_db, handle);
1059 (void)hdb_handle_put (&cmap_track_handle_t_db, cmap_track_inst_handle);
1060 (void)hdb_handle_destroy (&cmap_track_handle_t_db, cmap_track_inst_handle);
1063 (void)hdb_handle_put (&cmap_handle_t_db, handle);
1080 if (error !=
CS_OK) {
1099 if (error ==
CS_OK) {
1103 if (error ==
CS_OK) {
1107 if (error !=
CS_OK) {
1116 (void)hdb_handle_put (&cmap_handle_t_db, handle);
cs_dispatch_flags_t
The cs_dispatch_flags_t enum.
@ CS_DISPATCH_ONE_NONBLOCKING
cs_error_t qb_to_cs_error(int result)
qb_to_cs_error
#define CS_MAX_NAME_LENGTH
cs_error_t
The cs_error_t enum.
#define CS_IPC_TIMEOUT_MS
cs_error_t cmap_context_set(cmap_handle_t handle, const void *context)
cmap_context_set
cmap_value_types_t
Possible types of value.
uint64_t cmap_iter_handle_t
cs_error_t cmap_set_int8(cmap_handle_t handle, const char *key_name, int8_t value)
cs_error_t cmap_get_double(cmap_handle_t handle, const char *key_name, double *dbl)
cs_error_t cmap_get_int64(cmap_handle_t handle, const char *key_name, int64_t *i64)
cs_error_t cmap_finalize(cmap_handle_t handle)
Close the cmap handle.
cs_error_t cmap_set_uint32(cmap_handle_t handle, const char *key_name, uint32_t value)
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.
cs_error_t cmap_inc(cmap_handle_t handle, const char *key_name)
Increment value of key_name if it is [u]int* type.
cs_error_t cmap_set_uint8(cmap_handle_t handle, const char *key_name, uint8_t value)
cs_error_t cmap_get_float(cmap_handle_t handle, const char *key_name, float *flt)
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)
Add tracking function for given key_name.
uint64_t cmap_track_handle_t
cs_error_t cmap_context_get(cmap_handle_t handle, const void **context)
cmap_context_get
cs_error_t cmap_dec(cmap_handle_t handle, const char *key_name)
Decrement value of key_name if it is [u]int* type.
cs_error_t cmap_get_uint64(cmap_handle_t handle, const char *key_name, uint64_t *u64)
cs_error_t cmap_delete(cmap_handle_t handle, const char *key_name)
Deletes key from cmap database.
cs_error_t cmap_get_int16(cmap_handle_t handle, const char *key_name, int16_t *i16)
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.
cs_error_t cmap_fd_get(cmap_handle_t handle, int *fd)
Get a file descriptor on which to poll.
cs_error_t cmap_initialize(cmap_handle_t *handle)
Create a new cmap connection.
cs_error_t cmap_set_int32(cmap_handle_t handle, const char *key_name, int32_t value)
cs_error_t cmap_get_uint32(cmap_handle_t handle, const char *key_name, uint32_t *u32)
cs_error_t cmap_get_uint8(cmap_handle_t handle, const char *key_name, uint8_t *u8)
cs_error_t cmap_dispatch(cmap_handle_t handle, cs_dispatch_flags_t dispatch_types)
Dispatch data from service.
cs_error_t cmap_set_uint16(cmap_handle_t handle, const char *key_name, uint16_t value)
cs_error_t cmap_set_int16(cmap_handle_t handle, const char *key_name, int16_t value)
cs_error_t cmap_track_delete(cmap_handle_t handle, cmap_track_handle_t track_handle)
Delete track created previously by cmap_track_add.
cs_error_t cmap_get_string(cmap_handle_t handle, const char *key_name, char **str)
Shortcut for cmap_get for string type.
cs_error_t cmap_iter_finalize(cmap_handle_t handle, cmap_iter_handle_t iter_handle)
Finalize iterator.
cs_error_t cmap_initialize_map(cmap_handle_t *handle, cmap_map_t map)
Create a new cmap connection on a specified map.
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.
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)
Prototype for notify callback function.
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.
cs_error_t cmap_set_string(cmap_handle_t handle, const char *key_name, const char *value)
cs_error_t cmap_get_uint16(cmap_handle_t handle, const char *key_name, uint16_t *u16)
cs_error_t cmap_get_int8(cmap_handle_t handle, const char *key_name, int8_t *i8)
cs_error_t cmap_set_int64(cmap_handle_t handle, const char *key_name, int64_t value)
cs_error_t cmap_set_double(cmap_handle_t handle, const char *key_name, double value)
cs_error_t cmap_set_float(cmap_handle_t handle, const char *key_name, float value)
cs_error_t cmap_get_int32(cmap_handle_t handle, const char *key_name, int32_t *i32)
cs_error_t cmap_set_uint64(cmap_handle_t handle, const char *key_name, uint64_t value)
@ MESSAGE_REQ_CMAP_ITER_NEXT
@ MESSAGE_REQ_CMAP_ITER_INIT
@ MESSAGE_REQ_CMAP_TRACK_DELETE
@ MESSAGE_REQ_CMAP_ADJUST_INT
@ MESSAGE_REQ_CMAP_SET_CURRENT_MAP
@ MESSAGE_REQ_CMAP_ITER_FINALIZE
@ MESSAGE_REQ_CMAP_TRACK_ADD
@ MESSAGE_REQ_CMAP_DELETE
@ MESSAGE_RES_CMAP_NOTIFY_CALLBACK
DECLARE_HDB_DATABASE(cmap_handle_t_db, cmap_inst_free)
cs_error_t hdb_error_to_cs(int res)
#define IPC_DISPATCH_SIZE
Structure passed as new_value and old_value in change callback.
cmap_notify_fn_t notify_fn
cmap_track_handle_t track_handle
The req_lib_cmap_adjust_int struct.
The req_lib_cmap_delete struct.
The req_lib_cmap_get struct.
The req_lib_cmap_iter_finalize struct.
The req_lib_cmap_iter_init struct.
The req_lib_cmap_iter_next struct.
The req_lib_cmap_set_current_map struct used by cmap_initialize_map()
The req_lib_cmap_set struct.
The req_lib_cmap_track_add struct.
The req_lib_cmap_track_delete struct.
The res_lib_cmap_adjust_int struct.
The res_lib_cmap_delete struct.
The res_lib_cmap_get struct.
The res_lib_cmap_iter_finalize struct.
The res_lib_cmap_iter_init struct.
The res_lib_cmap_iter_next struct.
The res_lib_cmap_notify_callback struct.
The res_lib_cmap_set struct.
The res_lib_cmap_track_add struct.
The res_lib_cmap_track_delete struct.