MCPcopy Create free account
hub / github.com/corosync/corosync / cmap_get

Function cmap_get

lib/cmap.c:553–636  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

551}
552
553cs_error_t cmap_get(
554 cmap_handle_t handle,
555 const char *key_name,
556 void *value,
557 size_t *value_len,
558 cmap_value_types_t *type)
559{
560 cs_error_t error;
561 struct cmap_inst *cmap_inst;
562 struct iovec iov;
563 struct req_lib_cmap_get req_lib_cmap_get;
564 struct res_lib_cmap_get *res_lib_cmap_get;
565 size_t res_size;
566
567 if (key_name == NULL) {
568 return (CS_ERR_INVALID_PARAM);
569 }
570 if (strlen(key_name) >= CS_MAX_NAME_LENGTH) {
571 return (CS_ERR_NAME_TOO_LONG);
572 }
573
574 if (value != NULL && value_len == NULL) {
575 return (CS_ERR_INVALID_PARAM);
576 }
577
578 error = hdb_error_to_cs(hdb_handle_get (&cmap_handle_t_db, handle, (void *)&cmap_inst));
579 if (error != CS_OK) {
580 return (error);
581 }
582
583 memset(&req_lib_cmap_get, 0, sizeof(req_lib_cmap_get));
584 req_lib_cmap_get.header.size = sizeof(req_lib_cmap_get);
585 req_lib_cmap_get.header.id = MESSAGE_REQ_CMAP_GET;
586
587 memcpy(req_lib_cmap_get.key_name.value, key_name, strlen(key_name));
588 req_lib_cmap_get.key_name.length = strlen(key_name);
589
590 if (value != NULL && value_len != NULL) {
591 req_lib_cmap_get.value_len = *value_len;
592 } else {
593 req_lib_cmap_get.value_len = 0;
594 }
595
596 iov.iov_base = (char *)&req_lib_cmap_get;
597 iov.iov_len = sizeof(req_lib_cmap_get);
598
599 res_size = sizeof(struct res_lib_cmap_get) + req_lib_cmap_get.value_len;
600
601 res_lib_cmap_get = malloc(res_size);
602 if (res_lib_cmap_get == NULL) {
603 return (CS_ERR_NO_MEMORY);
604 }
605
606 error = qb_to_cs_error(qb_ipcc_sendv_recv(
607 cmap_inst->c,
608 &iov,
609 1,
610 res_lib_cmap_get,

Callers 6

print_keyFunction · 0.85
mainFunction · 0.85
cmap_get_intFunction · 0.85
cmap_get_stringFunction · 0.85
getFunction · 0.85
nextMethod · 0.85

Calls 4

hdb_error_to_csFunction · 0.85
hdb_handle_getFunction · 0.85
qb_to_cs_errorFunction · 0.85
hdb_handle_putFunction · 0.85

Tested by

no test coverage detected