GENDERS_TESTATTR(3)

πŸ’– GENDERS_TESTATTR πŸ’–

okay bestie, so this is genders_testattr(3) from LIBGENDERS β€” yes, the library is literally called libgenders, we don't make the rules, we just slay within them 🫢

This whole page is your cheat sheet for asking "hey, does this node have this attribute or not??" and getting an actual answer instead of vibes.


✨ NAME ✨

genders_testattr β€” test if a node has an attribute. That's it, that's the whole job, and honestly? iconic πŸ’…


🌸 SYNOPSIS 🌸

#include <genders.h>

int genders_testattr(genders_t handle, const char *node, const char *attr,
                     char *val, int len);

int genders_testattrval(genders_t handle, const char *node, const char *attr,
                        const char *val);

two functions, one vibe. let's get into it πŸ¦‹


πŸ’œ DESCRIPTION πŸ’œ

genders_testattr()

so this one tests if the node pointed to by node contains the attribute pointed to by attr. simple. clean. gorgeous.

  • if node is NULL, then bestie, we test the current node instead. no node? no problem πŸ’β€β™€οΈ
  • if the attribute is found, its value gets stored in the buffer pointed to by val
  • len should indicate the length of that buffer. don't lie to it. it knows.
  • if you don't actually need the attribute value, you can set val to NULL β€” zero drama, we just check existence πŸ‘‘
okay so, real talk: to avoid passing in an attribute value buffer that is not large enough to store the attribute value, you should use genders_getmaxvallen(3) to determine the minimum buffer size you should be using. do not skip this. do not eyeball it. do not manifest a bigger buffer. it will not work 😭

genders_testattrval()

this one is the overachiever of the two ✨ it tests if the node pointed to by node contains the attribute pointed to by attr and if that attribute is equal to the attribute value pointed to by val.

  • if val is NULL, only the attribute is tested. lowkey just becomes genders_testattr() at that point, and we respect the versatility.

πŸ”₯ RETURN VALUES πŸ”₯

for genders_testattr()

  • if the node contains the attribute, 1 is returned πŸŽ‰
  • 0 is returned if the node does not contain the attribute πŸ’€

for genders_testattrval()

  • if the node contains the attribute and it is equal to the attribute value, 1 is returned πŸ‘‘
  • 0 is returned if the node does not contain the attribute, or if the attribute is not equal to the attribute value 😀

for BOTH genders_testattr() and genders_testattrval()

  • -1 is returned on error, and an error code is returned in handle
  • that error code can be retrieved via genders_errnum(3) β€” go get it, girl
  • a description of the error code can be retrieved via genders_strerror(3)
  • error codes are defined in genders.h

😭 ERRORS 😭

here's the whole roster of ways things can go sideways. memorize them, they're your enemies now πŸ“

  • GENDERS_ERR_NULLHANDLE β€” the handle parameter is NULL. bestie. the genders handle must be created with genders_handle_create(3). you cannot test attributes with nothing. that's not a handle, that's a void πŸ’€
  • GENDERS_ERR_NOTLOADED β€” genders_load_data(3) has not been called to load genders data. the data isn't there. it's giving empty fridge energy πŸ™ˆ
  • GENDERS_ERR_OVERFLOW β€” the buffer pointed to by val is not large enough to store the attribute value. this is the one genders_getmaxvallen(3) was trying to warn you about. should've listened 😭
  • GENDERS_ERR_PARAMETERS β€” an incorrect parameter has been passed in. wrong vibes, wrong input, rejected.
  • GENDERS_ERR_NOTFOUND β€” the node pointed to by node cannot be found in the genders file, or if node=NULL, the machine genders is running on is not listed in the genders database. it's not in the group chat. it was never added. πŸ’”
  • GENDERS_ERR_MAGIC β€” handle has an incorrect magic number. so handle does not point to a genders handle, or handle has been destroyed by genders_handle_destroy(3). the magic is gone, and not in the cute way ✨

πŸŽ€ FILES πŸŽ€

  • /usr/include/genders.h

🌈 SEE ALSO 🌈

libgenders(3), genders_handle_create(3), genders_load_data(3), genders_getmaxvallen(3), genders_errnum(3), genders_strerror(3)

go read those too, they're all part of the same friend group, iykyk πŸ’–


and that's the whole page, bestie!! this one came from LLNL and it's been holding it down since August 2003 β€” yes, this manpage is older than most of us and it still ate 🫢✨ periodt.