int gd_add_spec(DIRFILE *dirfile, const char *line,
- int gd_madd_spec(DIRFILE *dirfile, const char *line, const char *parent);
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.
RETURN VALUEOn success, gd_add_spec() and gd_madd_spec() return zero. On error, -1 is returned and the dirfile error is set to a non-zero error value. Possible error values are:
- The specified dirfile was opened read-only.
- The library was unable to allocate memory.
- The parent field code was not found, or was already a metafield.
- The supplied dirfile was invalid.
- The fragment_index argument was out of range.
- A syntax error was encountered in line.
- An I/O error occurred while creating an empty binary file to be associated with a newly added RAW field.
- The supplied line was longer than the parser was able to deal with. Lines are limited by the storage size of ssize_t. On 32-bit systems, this limits line to 2**31 bytes. The limit is larger on 64-bit systems.
- The metadata of the fragment was protected from change. Or, the creation of a RAW field was attempted and the data of the fragment was protected.
- 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 added RAW field.
- The encoding scheme of the indicated format specification fragment does not support creating an empty binary file to be associated with a newly added RAW field.
The dirfile error may be retrieved by calling gd_error(3). A descriptive error string for the last error encountered can be obtained from a call to gd_error_string(3).