gd_add_spec, gd_madd_spec—add a field to a Dirfile
#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);
The gd_add_spec() function adds the field described by the field specification line in line to the dirfile specified by dirfile. The gd_madd_spec() function behaves similarly, but adds the field as a metafield under the field indicated by the field parent. Field specification lines are described in detail in dirfile-format(5). Since Standards Version 7 (see dirfile(5)) permits specifying metafield without the use of the /META directive, gd_add_spec() may also be used to add metafields, by specifying the metafield's full field code. See dirfile-format(5) for full details.
When using gd_madd_spec(), line should only contain a field specification, and not a /META directive.
Passing these functions a directive line instead of a field specification line will result in a syntax error. These functions never call the registered parser callback function, even if line contains a syntax error.
On success, gd_add_spec() and gd_madd_spec() return zero. On error, a negative-valued error code is returned. Possible error codes are:
The error code is also stored in the DIRFILE object and may be retrieved after this function returns by calling gd_error(3). A descriptive error string for the error may be obtained by calling gd_error_string(3).
The functions dirfile_add_spec() and dirfile_madd_spec() appeared in GetData-0.4.0.
In GetData-0.7.0, these functions were renamed to gd_add_spec() and gd_madd_spec().
In GetData-0.10.0, the error return from these functions changed from −1 to a negative-valued error code.
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)