CMAP_ITER_NEXT(3)

πŸ’– CMAP_ITER_NEXT πŸ’–

okay bestie, welcome to the CMAP_ITER_NEXT(3) page β€” that's section 3 of the Corosync Cluster Engine Programmer's Manual, and yes she's a whole legend. sit down, grab a boba, let's go πŸ§‹βœ¨


✨ NAME ✨

cmap_iter_next β€” returns the next item in an iteration in CMAP πŸ¦‹


🌸 SYNOPSIS 🌸

#include <corosync/cmap.h>

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);

πŸ’… DESCRIPTION πŸ’…

so cmap_iter_next is literally the function you call to get the next value in an iteration. it's giving "walk the whole CMAP database one key at a time" energy, and honestly? iconic. πŸ‘‘

quick vibe check on the args:

  • handle β€” this is your connection to the CMAP database, and you get it by calling cmap_initialize(3). no handle, no party. 🫢
  • iter_handle β€” the iterator handle, which you snagged from cmap_iter_init(3). this is your backstage pass to the iteration.
  • key_name β€” the following key name gets stored in here. ⚠️ important: you (the caller) have to preallocate this buffer. the guaranteed maximum size is CMAP_KEYNAME_MAXLEN (currently 255), so plan accordingly bestie, no cutting it close. πŸ’€
  • value_len β€” a pointer to where the length of the value gets stored. this one can be NULL if you're feeling minimal, no judgement. πŸ™ˆ
  • type β€” also optional (yep, can be NULL too!) and this is where the type of the value gets stored. the type is one of the types described over in the cmap_get(3) function, so go peek there if you need the full roster. ⭐

πŸ”₯ RETURN VALUE πŸ”₯

this call returns the CS_OK value when it succeeds. slay. ✨

but if there are no more items to iterate, it returns the CS_NO_SECTION error code instead β€” that's your "we're done here, the end, periodt" signal. πŸŽ€


πŸ¦‹ SEE ALSO πŸ¦‹

go read these too, they're all in the same friend group:

and here's the full error-code lineup, because knowing your errors is highkey main character energy πŸ‘‘:

  • 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 is not supported πŸ™ˆ
  • CS_ERR_MESSAGE_ERROR β€” incorrect auth message received πŸ•΅οΈ
  • CS_ERR_NO_MEMORY β€” not enough memory to complete the requested task 😡

and that's the whole page, bestie!! this one came straight out of the corosync Man Page, dated 06/02/2012 β€” oldie but a goodie, fr fr. now go iterate some keys and be amazing πŸ’œπŸŒˆπŸ«Ά

πŸ“¦ where this page comes from