gd_add_spec(3)
๐ gd_add_spec(3) โ GETDATA manual, but make it cute ๐
okay bestie, sit down, hydrate, because we're learning how to add a field to a Dirfile and honestly? it's giving main character energy. this is gd_add_spec(3) from the GETDATA manual, and by the end of this page you're gonna be obsessed. ๐ฆ
โจ NAME โจ
gd_add_spec, gd_madd_spec โ add a field to a Dirfile
like. that's it. that's the whole job. but the way they do it?? iconic. ๐
โจ SYNOPSIS โจ
#include <getdata.h>
int gd_add_spec(DIRFILE *dirfile, const char *line, int fragment_index);
int gd_madd_spec(DIRFILE *dirfile, const char *line, const char *parent);
โจ DESCRIPTION โจ
so. gd_add_spec() takes the field specification line in line and adds the field it describes to the dirfile you passed as dirfile. slay. ๐
gd_madd_spec() is basically the same vibe, except it adds the field as a metafield under the field you name in parent. metafield under a parent fieldโฆ it's giving nepotism but make it data. ๐
field specification lines are explained in excruciating (affectionate) detail in dirfile-format(5). and here's a fun little glow-up: since Standards Version 7 (peep dirfile(5)) lets you specify a metafield without using the /META directive, you can also use gd_add_spec() to add metafields โ just specify the metafield's full field code. full deets live in dirfile-format(5), go read it, i'll wait. ๐
quick note for thegd_madd_spec()girlies:lineshould contain only a field specification, and not a/METAdirective. don't do it. i'm serious. ๐
if you hand these functions a directive line instead of a field specification line, you get a syntax error. periodt. and these functions never call the registered parser callback function โ not even if line has a syntax error in it. they simply do not care to involve your callback. ๐ญ
โจ RETURN VALUE โจ
on success, gd_add_spec() and gd_madd_spec() return zero. cute, clean, no notes. โจ
on error, you get a negative-valued error code. yes, negative. the vibes are bad. possible error codes are:
GD_E_ACCMODEโ the specified dirfile was opened read-only. you tried to write to something that said "look but don't touch." ๐ซGD_E_ALLOCโ the library was unable to allocate memory. it's not the library's fault, it's just tired. ๐ฎโ๐จGD_E_BAD_CODEโ the parent field code was not found, or was already a metafield. (metafieldยฒ is not a thing, bestie.) ๐GD_E_BAD_DIRFILEโ the supplied dirfile was invalid. rip.GD_E_BAD_INDEXโ thefragment_indexargument was out of range. it wandered off the map. ๐บ๏ธGD_E_FORMATโ a syntax error was encountered inline. grammar police but for data. ๐จGD_E_IOโ an I/O error occurred while creating an empty binary file to be associated with a newly addedRAWfield. ๐ญGD_E_LINE_TOO_LONGโ the supplied line was longer than the parser was able to deal with. line lengths are limited by the storage size ofsize_t. (the parser said "tl;dr" fr fr.) ๐GD_E_PROTECTEDโ the metadata of the fragment was protected from change. or, the creation of aRAWfield was attempted and the data of the fragment was protected. hands off, it's guarded. ๐ก๏ธGD_E_UNKNOWN_ENCODINGโ the encoding scheme of the indicated format specification fragment is not known to the library. as a result, the library was unable to create an empty binary file to be associated with a newly addedRAWfield. it simply doesn't speak that language. ๐ซคGD_E_UNSUPPORTEDโ the encoding scheme of the indicated format specification fragment does not support creating an empty binary file to be associated with a newly addedRAWfield. it knows the language, it just refuses. ๐
the error code is also stored in the DIRFILE object, and you can grab it after this function returns by calling gd_error(3). want a descriptive error string instead of a number? call gd_error_string(3). you're welcome. ๐ซถ
โจ HISTORY โจ
- the functions
dirfile_add_spec()anddirfile_madd_spec()appeared in GetData-0.4.0. the origin story. ๐ฑ - in GetData-0.7.0, these functions were renamed to
gd_add_spec()andgd_madd_spec(). glow-up era. โจ - in GetData-0.10.0, the error return from these functions changed from
-1to a negative-valued error code. character development. ๐ฅ
โจ SEE ALSO โจ
gd_add(3), all the gd_add_<entry-type> functions (e.g., gd_add_bit(3)), gd_error(3), gd_error_string(3), gd_madd(3), all the gd_madd_<entry-type> functions (e.g., gd_madd_bit(3)), gd_metaflush(3), gd_open(3), dirfile-format(5)
go forth and read them all, i believe in you. ๐
that's the whole page bestie!! this was Version 0.10.0, dated 25 December 2016, and honestly it ate. no cap. go add some fields. ๐๐
๐ฆ 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, 2009, 2010, 2014, 2016 D. V. Wiebe
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms