GENDLIB(3)

✨ GENDLIB ✨

okay so bestie, welcome to gendlib β€” it's the perl library for querying the genders file, and yes the name is giving "gender studies elective" but it's actually about clusters, i promise πŸŽ€ (the manual page lives in section 3, hence the (3), iykyk)


πŸ’– SYNOPSIS πŸ’–

require "/usr/lib/genders/gendlib.pl";

that's it. that's the whole vibe. one require and you're in 🫢


🌸 DESCRIPTION 🌸

so this package is a lil bundle of common functions for manipulating the genders file. and like β€” previously this code existed only in the nodeattr command, which was lowkey tragic, because apps that have to call nodeattr over and over and over again would spend a genuinely upsetting amount of time just reading and parsing the genders file every single time. exhausting. not the vibe.

these functions fix that: on the first call they build an in-memory cache of genders, and then every call after that just references the in-memory copy. so it's fast. it's giving ✨optimized✨. slay.


πŸ”§ Initialization

  • Genders::init([$path_genders]) β€” this one is normally called internally for initialization, but you can call it externally with a non-default genders file path, and then all subsequent operations will use that non-default data instead. you can also call it more than once if you want to switch up which genders file you're working with. iconic, flexible, we love her πŸ’…

πŸ” Simple Queries

  • Genders::hasattr($attribute, [$node]) β€” returns 1 if the node has that attribute, 0 if it doesn't. if you don't specify a node, it just uses the local node. easy peasy.
  • Genders::getattrval($attribute, [$node]) β€” returns the value of the attribute held by the node, or an empty string if there's no value, or if the node doesn't even have that attribute. no node specified? local node. default behavior, we move.
  • Genders::getnode([$attribute]) β€” returns a list of nodes that have the attribute you asked for. and if you also give a value, like "attr=val", then only nodes with that exact attribute and value come back. if you pass no attribute at all, getnode literally returns every node listed in the genders file. the whole roster. periodt.
  • Genders::getattr([$node]) β€” returns a list of attributes held by the node. guess what happens if you don't specify a node. yeah. local node. you know the drill 😌

🧠 Complex Queries

  • Genders::getallattr() β€” returns a list of all attributes in the genders file (one cluster only, bestie β€” just the one).
  • Genders::get_node_hash(\%node) β€” grabs you a copy of a hash of attributes to node lists for the current cluster, aka a "hash of lists". and it makes sure keys exist for all possible attributes across clusters, even if they point to empty lists. no missing keys, no sad undef warnings. we're thorough like that πŸ¦‹
  • Genders::get_clusters() β€” returns a list where the local cluster name is the first and only element. and yes it returns a list instead of a scalar purely for backwards compatibility β€” don't @ me, it's legacy behavior and we respect her. if the local cluster name isn't known, you get null. that's the whole story.
  • Genders::gendexp($exp, [$node]) β€” evaluates an expression involving genders attributes and hands you back the result. any legal perl expression is fair game here, as long as it uses numeric constants, genders attributes (which get converted into $variables), and these operators: !, ||, &&, *, +, -, /. if $node isn't specified, it assumes the local host. go off, math queen πŸ”₯

πŸ”„ Conversion

  • Genders::to_altnames() β€” give it a list of hostnames as they appear in the genders file, and it gives you back a list of alternate names. on the SP, genders names are assumed to be the initial_hostnames, and it uses the SDR to convert to reliable_hostnames. on other systems, it goes looking for the value of the altname attribute in the genders file instead. and if an input hostname just can't be converted? it's preserved in the output. no hostname left behind 🫢
  • Genders::to_gendnames() β€” this is the inverse of the to_altnames() function, bestie. performs the reverse operation. and just like to_altnames(), if an input hostname can't be converted, it's preserved in the output. same energy, opposite direction πŸ’œ

πŸ‘€ SEE ALSO


lowkey important reminder: libgenders(3) and Libgenders(3) are two different pages. capitalization matters. i don't make the rules, i just read them πŸ’…

and that's the whole page, bestie!! this one came from LLNL, dated 10/10/97, and it's GENDLIB(3) β€” go query those genders files, you absolute main character πŸŒˆβ­πŸ’–