---
name: "cmap_get"
section: "3"
platform: "linux"
package: "libcmap-dev"
version: "3.1.9-2+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/cmap_get"
---

# cmap\_get(3)

Retrieve value from CMAP

## 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)](/cmap_set/3.md)** function. The *handle* argument is connection to CMAP database obtained by calling **[cmap\_initialize(3)](/cmap_initialize/3.md)** 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)](/cmap_set/3.md)** 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_set/3.md), [**cmap\_initialize**(3)](/cmap_initialize/3.md), [**cmap\_overview**(3)](/cmap_overview/3.md)

**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
