Langue: en

Autres versions - même langue

Version: 4 October 2009 (fedora - 01/12/10)

Section: 3 (Bibliothèques de fonctions)


dirfile_add_spec, dirfile_madd_spec --- add a field to a dirfile


#include <getdata.h>
int dirfile_add_spec(DIRFILE *dirfile, const char *line, int fragment_index);
int dirfile_madd_spec(DIRFILE *dirfile, const char *line, const char *parent);


The dirfile_add_spec() function adds the field described by the field specification line in line to the dirfile specified by dirfile. The dirfile_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, dirfile_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 dirfile_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, dirfile_add_spec() and dirfile_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.
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.
An I/O error occurred while creating an empty binary file to be associated with a newly added RAW field.
The encoding scheme of the specified format file 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 specified format file 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 get_error(3). A descriptive error string for the last error encountered can be obtained from a call to get_error_string(3).


dirfile_add(3), dirfile_add_bit(3), dirfile_add_const(3), dirfile_add_lincom(3), dirfile_add_linterp(3), dirfile_add_multiply(3), dirfile_add_phase(3), dirfile_add_raw(3), dirfile_madd(3), dirfile_madd_bit(3), dirfile_madd_const(3), dirfile_madd_lincom(3), dirfile_madd_linterp(3), dirfile_madd_multiply(3), dirfile_madd_phase(3), dirfile_madd_string(3), dirfile_metaflush(3), dirfile_open(3), get_error(3), get_error_string(3), dirfile-format(5)