CMAP_ITER_INIT(3)

✨ CMAP_ITER_INIT(3) ✨

okay bestie, gather round, because we're cracking open the Corosync Cluster Engine Programmer's Manual and this page is literally the starter pistol for walking through every key in the CMAP database. no cap. πŸ’–


🌸 NAME 🌸

cmap_iter_init β€” get your iterator ready for all the keys chillin' in CMAP


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <corosync/cmap.h>

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

like, that's the whole vibe. three args, one dream. ✨


πŸ’… DESCRIPTION πŸ’…

so cmap_iter_init is the function you call to initialize iteration of all keys with a given prefix. it's giving "set up the tour, we're about to visit every key in the neighborhood." 🏘️

the handle argument is your connection to the CMAP database β€” and you get that by calling cmap_initialize(3). so like, don't show up to the function without it, that's not the move. πŸ™ˆ

prefix is a string, and every returned key must have a name with that given prefix. it's a filter, basically. a little "only the keys with this aesthetic, please." πŸŽ€

and here's the cute part: this variable can also be NULL (or an empty string) β€” and then all keys are iterated. so if you're feeling greedy, go off. πŸ‘‘

cmap_iter_init is used only to initialize the context for future cmap_iter_next(3) calls, and the handle you need for that function gets handed back to you in the cmap_iter_handle variable. that's your ticket. keep it safe. 🎟️

and when you've finished iterating over objects, call cmap_iter_finalize(3) to free up the memory associated with the iteration. do not skip this part. it's the "wash your face before bed" of CMAP. 🧼


πŸ’– RETURN VALUE πŸ’–

this call returns the CS_OK value if it's successful. slay. ✨

but if there are no items with the given prefixes, CS_ERR_NO_SECTIONS is returned. empty house. nobody home. 😭


🌈 SEE ALSO 🌈


πŸ’€ the error codes, bestie (they live right here, iykyk)

  • 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

okay that's the whole page, you ate it, go iterate something iconic. 🫢

this has been the corosync Man Page, dated 03/02/2012 β€” fr fr, a classic, and yes she's still serving. mwah. πŸ’…πŸŽ€

πŸ“¦ where this page comes from