GENDERS_GETNODES(3)

✨ GENDERS_GETNODES ✨

okay bestie, listen up β€” this is the genders_getnodes page from section 3 of the LIBGENDERS manual, and it's genuinely one of the most useful little functions in the whole library. Let's get into it πŸ’…


🌸 NAME 🌸

genders_getnodes β€” literally just: get nodes from the genders file πŸ¦‹


✨ SYNOPSIS ✨

#include <genders.h>

int genders_getnodes(genders_t handle, char *nodes[], int len, const
char *attr, const char *val);

πŸ’– DESCRIPTION πŸ’–

So here's the tea, bestie πŸ«–: genders_getnodes() grabs the names of the nodes in the genders file that have the attribute specified by attr and the value specified by val.

Those node names get stashed in the list pointed to by nodes. And len? That's how many nodes you can actually fit in that list. Like, the capacity. Don't be out here lying about it πŸ”₯

Couple of special cases, and they're iconic:

  • If attr is NULL, genders_getnodes() returns all the nodes listed in the genders file. Every single one. The whole roster πŸ‘‘
  • If val is NULL, attribute values are ignored. So it's like "idc what the value is, just gimme the nodes that have this attribute."
🫢 Pro tip from someone who cares about you: to avoid passing in a list that is NOT large enough to store all the nodes (the classic oopsie), you should use genders_getnumnodes(3) to figure out the minimum number of elements nodes needs to be able to store. Or β€” even cuter β€” genders_nodelist_create(3) can be used to create a list that's guaranteed to be large enough to store all of the nodes. No math, no panic. Slay πŸ’…

🌈 RETURN VALUES 🌈

On success: you get back the number of nodes stored in nodes. Yay! ✨

On error: -1 comes back, and an error code gets returned in handle. You can retrieve that error code with genders_errnum(3), and a description of the error code with genders_strerror(3). The error codes themselves are defined in genders.h πŸ“–


πŸ’€ ERRORS πŸ’€

Not me listing every single one, but like… every single one matters, bestie. Here we go:

  • GENDERS_ERR_NULLHANDLE β€” the handle parameter is NULL. The genders handle must be created with genders_handle_create(3). You cannot skip this step, I'm so serious 😭
  • GENDERS_ERR_NOTLOADED β€” genders_load_data(3) has not been called to load genders data. No data, no nodes, no vibes.
  • GENDERS_ERR_OVERFLOW β€” the list pointed to by nodes is not large enough to store all the nodes. She's giving "I brought a tote bag to a Costco run" πŸ›οΈ
  • GENDERS_ERR_PARAMETERS β€” an incorrect parameter has been passed in. Wrong input, wrong energy πŸ™ˆ
  • GENDERS_ERR_NULLPTR β€” a null pointer has been found in the list passed in.
  • GENDERS_ERR_MAGIC β€” handle has an incorrect magic number. Which means: handle does not point to a genders handle, or handle has been destroyed by genders_handle_destroy(3). Rude of you, honestly πŸ’€

πŸŽ€ FILES πŸŽ€

  • /usr/include/genders.h

πŸ¦‹ SEE ALSO πŸ¦‹

libgenders(3), genders_handle_create(3), genders_load_data(3), genders_getnumnodes(3), genders_nodelist_create(3), genders_errnum(3), genders_strerror(3)


And that's the whole page, bestie!! This one came straight outta LLNL, dated August 2003 β€” yes she's an elder icon and yes she still eats πŸ’–βœ¨πŸ‘‘