CMAP_GET(3)
π CMAP_GET(3) π
okay bestie, so this is a page from the Corosync Cluster Engine Programmer's Manual (yes, the entire programmer's manual, and it's iconic), and today's main character is cmap_get β the function that goes and fetches a value out of CMAP for you. β¨
πΈ 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);
like look at her. a whole little squad of typed shortcuts. π
β¨ DESCRIPTION β¨
so the cmap_get function is what you call to retrieve a key from cmap that was previously set by cmap_set(3). that's the whole vibe. π«Ά
- the
handleargument is your connection to the CMAP database, and you get it by callingcmap_initialize(3)β no handle, no service, periodt. key_nameis the name of the key you wanna get the value from.valueis a pointer to preallocated data that's used as storage for the data, but lowkey it can also beNULLβ and in that case onlyvalue_lenand/ortypeget returned. (both of those can beNULLtoo, which means the function is basically just doing a vibe check on whether the key even exists. iconic.)- if
valueis notNULL, the actual length of the value in the map gets checked against*value_len. if*value_lenis shorter than the length of the value in the map, you get errorCS_ERR_INVALID_PARAM. π¨ - after a successful copy of the value,
*value_lenis set to the actual length of the value in the map. - the
typeparameter is a pointer to memory where the type of the value gets stored after a successful return. this pointer can also beNULL, and then nothing is stored. no notes. π
Type can be one of:
CMAP_VALUETYPE_INT8β 8-bit signed integerCMAP_VALUETYPE_UINT8β 8-bit unsigned integerCMAP_VALUETYPE_INT16β 16-bit signed integerCMAP_VALUETYPE_UINT16β 16-bit unsigned integerCMAP_VALUETYPE_INT32β 32-bit signed integerCMAP_VALUETYPE_UINT32β 32-bit unsigned integerCMAP_VALUETYPE_INT64β 64-bit signed integerCMAP_VALUETYPE_UINT64β 64-bit unsigned integerCMAP_VALUETYPE_FLOATβ Float valueCMAP_VALUETYPE_DOUBLEβ Double valueCMAP_VALUETYPE_STRINGβ C-style stringCMAP_VALUETYPE_BINARYβ Binary data, byte with zero value has no special meaning
Shortcut functions test the cmap type against their own type. if the type didn't match, you get the CS_ERR_INVALID_PARAM error back. no conversions are done, so for example cmap_get_int16 is not able to return a value with the CMAP_VALUETYPE_INT8 type. she said "know your type or know your place." π
and heads up bestie β the string shortcut function returns newly allocated memory and the caller is responsible for freeing that. don't leave her hanging, free your strings. π§
π₯ RETURN VALUE π₯
This call returns the CS_OK value if successful. slay.
If value or key_name are unspecified, CS_ERR_INVALID_PARAM is returned. same error also comes back if value is specified and *value_len is too short for storing the data. and if the key doesn't exist (like, it was never set by calling cmap_set(3) first), you get the CS_ERR_NOT_EXIST error. π
For the helper functions, CS_ERR_INVALID_PARAM is returned if the type stored in cmap doesn't match with the type of the helper function.
π SEE ALSO π
cmap_set(3), cmap_initialize(3), cmap_overview(3)
CS_ERR_TRY_AGAINβ Resource temporarily unavailableCS_ERR_INVALID_PARAMβ Invalid argumentCS_ERR_ACCESSβ Permission deniedCS_ERR_LIBRARYβ The connection failedCS_ERR_INTERRUPTβ System call interrupted by a signalCS_ERR_NOT_SUPPORTEDβ The requested protocol/functionality not supportedCS_ERR_MESSAGE_ERRORβ Incorrect auth message receivedCS_ERR_NO_MEMORYβ Not enough memory to complete the requested task
okay and that's the whole page, bestie. this was the corosync Man Page, dated 03/02/2012, and she's still serving CMAP_GET(3) realness to this day. go forth and retrieve your values. πβ¨
π¦ where this page comes from
- debian bookworm: libcmap-dev 3.1.7-1+deb12u2 Β· BSD-3-Clause
- debian trixie: libcmap-dev 3.1.9-2+deb13u1 Β· BSD-3-Clause
- epel 9: corosynclib-devel 3.1.10-0.2.el9.1 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.10-3.fc43 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.10-3.fc43 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.9-5.fc43 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.9-5.fc43 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-4.fc44 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-4.fc44 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-6.fc44 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-6.fc44 Β· BSD-3-Clause
- nixos 26.05: corosync 3.1.9
- nixpkgs unstable: corosync 3.1.9
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- ubuntu jammy: libcmap-dev 3.1.6-1ubuntu1 Β· BSD-3-Clause
- ubuntu jammy: libcmap-dev 3.1.6-1ubuntu1.2 Β· BSD-3-Clause
- ubuntu noble: libcmap-dev 3.1.7-1ubuntu3 Β· BSD-3-Clause
- ubuntu noble: libcmap-dev 3.1.7-1ubuntu3.2 Β· BSD-3-Clause
- ubuntu questing: libcmap-dev 3.1.9-2ubuntu1
- ubuntu questing: libcmap-dev 3.1.9-2ubuntu1.1
- ubuntu resolute: libcmap-dev 3.1.9-2ubuntu3 Β· BSD-3-Clause
- ubuntu stonking: libcmap-dev 3.1.10-3ubuntu1 Β· BSD-3-Clause
- Copyright (c) 2012 Red Hat, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms