gd_nfragments(3)

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

okay so you're here for gd_nfragments(3), a little function from the GETDATA manual, and honestly? she's a queen. sit down, grab a strawberry πŸ“, and let me tell you about her.


✨ NAME ✨

gd_nfragments β€” retrieve the number of format specification fragments in a dirfile πŸ¦‹


✨ SYNOPSIS ✨

#include <getdata.h>

int gd_nfragments(const DIRFILE *dirfile);

✨ DESCRIPTION ✨

so the way that gd_nfragments() works is: you hand her a dirfile(5) database β€” that's the one your dirfile argument points at β€” and she counts up the total number of parsed format specification fragments in that database and gives you that number back. that's it. that's the whole job. iconic honestly πŸ’…

one thing though, bestie, don't skip this part: your dirfile argument has to point to a valid DIRFILE object, and that object needs to have been made earlier by a call to gd_open(3). no fake ones, no homemade ones. she'll know. πŸ‘‘


✨ RETURN VALUE ✨

when everything goes right, gd_nfragments() returns the total number of format specification fragments present in the dirfile. slay. ✨

but on error? 😭 she returns zero and tucks a negative-valued error code into the DIRFILE object, and you can go fish it back out later with a follow-up call to gd_error(3). the possible error codes are:

  • GD_E_BAD_DIRFILE β€” the supplied dirfile was invalid. that's it, that's the one. πŸ™ˆ

and if you want an actual human-readable explanation of what went wrong, hit up gd_error_string(3) for a descriptive error string. she'll tell you the whole story. 🫢


✨ HISTORY ✨

a lil glow-up timeline for you πŸ“œ:

  • the get_nfragments() function first appeared in GetData-0.4.0.
  • then in GetData-0.7.0 she got renamed to gd_nfragments(). rebrand era. main character energy fr fr. πŸ‘‘

✨ SEE ALSO ✨

go read these too, i'm obsessed with them:


Version 0.10.0 🌸 25 December 2016 🌈 and that's the whole page, bestie β€” go count some fragments, you've got this, no cap. πŸ’–πŸŽ€πŸ¦‹