gd_fragment_index(3)

πŸ’– gd_fragment_index β€” bestie edition πŸ’–

okay so this is a page from the GETDATA manual (section 3, the library-functions girlies), and it's all about gd_fragment_index. let's get into it 🫢


✨ NAME ✨

gd_fragment_index β€” go find the fragment that's holding your Dirfile field, queen πŸ‘‘


🌸 SYNOPSIS 🌸

#include <getdata.h>

int gd_fragment_index(const DIRFILE *dirfile, const char *entry_name);

πŸ’… DESCRIPTION πŸ’…

so basically, gd_fragment_index() slides into a dirfile(5) database β€” the one you point at with dirfile β€” and hands you back the index number of the fragment that defines the field (or alias) named entry_name. like, which fragment is this entry living in? that one. there you go. ✨

🚨 okay listen up because this is the plot twist: this is one of the few GetData functions that does not resolve aliases. so if you pass in the name of an alias as entry_name, you get the index of the fragment containing the alias itself, not the index of whatever it's pointing at. no chasing the target, no detective work. just the alias, in its own home. periodt πŸ’…

πŸ”₯ RETURN VALUE πŸ”₯

when it works? gd_fragment_index() returns the fragment index you asked for, and that number is never negative. icon behavior.

when it's not working? it returns a negative-valued error code. the possible ones are:

  • GD_E_BAD_CODE β€” the entry you named in entry_name was not found in the database 😭 she's not here.
  • GD_E_BAD_DIRFILE β€” the dirfile you handed over was invalid πŸ’€

also, that error code gets tucked away in the DIRFILE object too, so you can grab it after the function returns by calling gd_error(3). and if you want a whole descriptive error string β€” like, actual words about what went wrong β€” hit up gd_error_string(3). πŸŽ€


πŸ¦‹ HISTORY πŸ¦‹

  • the get_fragment_index() function first showed up in GetData-0.5.0. a legend was born.
  • in GetData-0.7.0, she got a glow-up and was renamed to gd_fragment_index().
  • in GetData-0.10.0, the error return changed from -1 to a negative-valued error code. glow-up number two ✨

🌈 SEE ALSO 🌈


and that's the whole page bestie, no cap 🧚

this was Version 0.10.0, dated 25 December 2016 β€” so yeah, a lil vintage, but she still ate. mwah πŸ’‹πŸ‘‘