gd_reference(3)
π gd_reference β getdata's little reference-field handler π
okay so bestie, you know how every dirfile has that one field it points at? yeah. this is the function that gets it or sets it. it's gd_reference(3) from the GETDATA manual, and it's lowkey iconic. let's go β¨
π NAME π
gd_reference β retrieve or set the reference field for a Dirfile π
π¦ SYNOPSIS π¦
#include <getdata.h>
const char *gd_reference(DIRFILE *dirfile, const char *field_code);
πΈ DESCRIPTION πΈ
so the way that gd_reference() works is: it sets or retrieves the reference field (peep dirfile(5) for the lore on what that even is) that's associated with the dirfile you handed it in dirfile.
here's the vibe check on field_code:
- if
field_codeis non-NULL π the reference field for the dirfile gets set to the field you specified. - if
field_codeis NULL π nothing happens to the reference field, it just stays as it was. no touchy. π
also important, bestie: the field code should refer to a RAW field, and it may not contain a representation suffix. that's the rule. periodt.
β¨ RETURN VALUE β¨
when it slays: gd_reference() returns the field code of the dirfile's reference field β which will literally be field_code, if field_code is non-NULL. makes sense, it ate.
but wait π«Ά if there are no RAW fields defined in the dirfile, this function returns NULL, and it does that without raising an error. that's not a fail, that's just how it is. no drama.
on error though π NULL is returned and the dirfile error gets set to a non-zero error value. the possible error values are:
GD_E_ACCMODEβ the specified dirfile was opened read-only. can't touch this. πGD_E_ALLOCβ the library was unable to allocate memory. it's giving out of RAM.GD_E_BAD_CODEβ the field specified byfield_codewas not found. nowhere to be found, ghosted. π»GD_E_BAD_DIRFILEβ the supplied dirfile was invalid. invalid dirfile era.GD_E_BAD_FIELD_TYPEβ the field specified byfield_codewas not a RAW field. wrong type, wrong vibe. π«GD_E_PROTECTEDβ the metadata of the primary format specification fragment (the file namedformatin the root dirfile directory) was protected from change. hands off, it's protected. π
you can grab the dirfile error by callinggd_error(3). and if you want a descriptive error string for the last error encountered, that's agd_error_string(3)call, babes. π
π HISTORY π
storytime, because this function has lore:
- the
get_reference()function appeared in GetData-0.4.2. it took only one parameter (theDIRFILE), and returned the current reference field. minimalist queen. - the
dirfile_reference()function appeared in GetData-0.5.0. glow up. - in GetData-0.7.0, the
dirfile_reference()function was renamed togd_reference()and theget_reference()function was removed. rebrand era, and honestly? it was for the best. π
β SEE ALSO β
gd_error(3), gd_error_string(3), gd_metaflush(3), gd_open(3), dirfile(5), dirfile-format(5)
go read them, iykyk π§
okay that's the whole page!! this was Version 0.10.0, dated 25 December 2016, and it's a gd_reference(3) situation from the GETDATA manual. merry christmas to everyone who celebrates πβ¨ mwah, go set your reference field bestie ππ«Ά
π¦ where this page comes from
- debian bookworm: libgetdata-doc 0.11.0-6
- debian trixie: libgetdata-doc 0.11.0-15
- fedora 43: getdata-devel 0.11.0-13.fc43 Β· GPL-2.0-or-later
- fedora 43: getdata-devel 0.11.0-13.fc43 Β· GPL-2.0-or-later
- fedora 44: getdata-devel 0.11.0-14.fc44 Β· GPL-2.0-or-later
- fedora 44: getdata-devel 0.11.0-14.fc44 Β· GPL-2.0-or-later
- nixos 26.05: getdata 0.11.0
- nixpkgs unstable: getdata 0.11.0
- ubuntu jammy: libgetdata-doc 0.11.0-3ubuntu1
- ubuntu noble: libgetdata-doc 0.11.0-13
- ubuntu questing: libgetdata-doc 0.11.0-15
- ubuntu resolute: libgetdata-doc 0.11.0-17build1
- ubuntu stonking: libgetdata-doc 0.11.0-17build2
- Copyright (C) 2016 D. V. Wiebe
- Copyright (C) 2008, 2010, 2016 D.V. Wiebe
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms