GENDERS_LOAD_DATA(3)

πŸ’– GENDERS_LOAD_DATA β€” the genders_load_data(3) glow-up πŸ’–

okay bestie, welcome to libgenders, section 3 of the manual. today's main character is genders_load_data() β€” the function that literally goes and gets your genders file and reads it. she's the one who opens the door, no cap. πŸšͺ✨


✨ SYNOPSIS ✨

#include <genders.h>

int genders_load_data(genders_t handle, const char *filename);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: genders_load_data() reads and parses the genders file that filename points at. that's it. that's the job. she shows up, she reads it, she parses it, she's done. πŸ’…

and if filename is NULL? no problem, she's not gonna throw a fit. she'll just go for the default genders file, which is defined by GENDERS_DEFAULT_FILE. periodt.

handle is a genders handle β€” and not just any handle, one that was created by genders_handle_create(3). gotta be born legit, yk? πŸ‘‘

now the part that actually matters: once genders_load_data() has been called, all the info about that genders file gets stored inside the genders handle you passed in. and every other genders C API function is gonna reach into that handle and use it. so from that moment on, every future use of handle with any other genders C API function is directly associated with the genders file that filename pointed at β€” or the default genders file, if filename was NULL. she's committed. she's locked in. it's giving relationship. 🫢


🌈 RETURN VALUES 🌈

  • On success? 0 is returned. slay. ✨
  • On error? -1 is returned, and an error code gets dropped into handle.

you can grab that error code with genders_errnum(3), and get a lil description of it with genders_strerror(3). the error codes themselves live in genders.h. πŸ“–


πŸ’€ ERRORS πŸ’€

here's the whole rogues gallery of things that can go wrong. read them, memorize them, respect them:

  • GENDERS_ERR_NULLHANDLE β€” the handle parameter is NULL. bestie. the genders handle has to be created with genders_handle_create(3). you can't just roll up with nothing. 😭
  • GENDERS_ERR_OPEN β€” the genders file that filename points at cannot be opened for reading. door's locked, no key, not today.
  • GENDERS_ERR_READ β€” error reading the genders file that filename points at. it opened, but the reading part went sideways. πŸ™ˆ
  • GENDERS_ERR_PARSE β€” the genders file that filename points at is incorrectly formatted. grammar check failed fr fr.
  • GENDERS_ERR_ISLOADED β€” genders_load_data(3) has already been called with handle. she already did this one, girl. one and done.
  • GENDERS_ERR_OVERFLOW β€” a line in the genders database is longer than the maximum allowed length. too much text, not enough room, tragic. πŸ“
  • GENDERS_ERR_OUTMEM β€” malloc(3) has failed internally, meaning the system is out of memory. she's running on empty, genuinely.
  • GENDERS_ERR_MAGIC β€” handle has an incorrect magic number. that means handle doesn't point to a genders handle at all, OR it's a handle that's already been destroyed by genders_handle_destroy(3). poof. gone. ghost handle. πŸ‘»
  • GENDERS_ERR_INTERNAL β€” an internal system error has occurred. we don't know. the vibes are off. πŸ’€

πŸŽ€ FILES πŸŽ€

  • /usr/include/genders.h

πŸ‘‘ SEE ALSO πŸ‘‘


lowkey important reminder: if you're passing a handle around, make sure it came from genders_handle_create(3) and hasn't been genders_handle_destroy(3)'d, because GENDERS_ERR_NULLHANDLE and GENDERS_ERR_MAGIC are waiting to humble you. 🫢

and that's the whole page, bestie!! brought to you by LLNL, dated August 2003 β€” yes, she's been iconic since 2003 and she's still serving. mwah πŸ’‹βœ¨πŸŽ€πŸ¦‹