Langue: en

Autres versions - même langue

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

Section: 3 (Bibliothèques de fonctions)


dirfile_add, dirfile_madd --- add a field to a dirfile


#include <getdata.h>
int dirfile_add(DIRFILE *dirfile, const gd_entry_t *entry);
int dirfile_madd(DIRFILE *dirfile, const gd_entry_t *entry, const char *parent);


The dirfile_add() function adds the field described by entry to the dirfile specified by dirfile. The dirfile_madd() function behaves similarly, but adds the field as a metafield under the field indicated by the field code parent.

The form of entry is described in detail on the get_entry(3) man page. All relevant members of entry for the field type specified must be properly initialised.

When adding a metafield, the entry->field member should contain just the metafield's name, not the fully formed <parent-field>/<meta-field> field code. Also, dirfile_madd() ignores the value of entry->fragment_index, and instead adds the new meta field to the same format file fragment in which the parent field is defined.

Fields added with this interface may contain either numerical parameters or parameters based on CONST fields. If an element of the entry->scalar array defined for the specified field type is non-NULL, this element will be used as the CONST field code, and the corresponding numerical member will be ignored, and need not be initialised. Conversely, if numerical parameters are intended, the corresponding entry->scalar elements should be set to NULL.


On success, dirfile_add() and dirfile_madd() 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 field name provided in entry->field contained invalid characters. Alternately, the parent field code was not found, or was already a metafield.
The supplied dirfile was invalid.
There was an error in the specification of the field described by entry, or the caller attempted to add a field of type RAW as a metafield.
The entry->fragment_index parameter was out of range.
The entry->data_type parameter provided with a RAW entry, or the entry->const_type parameter provided with a CONST entry, was invalid.
The field name provided in entry->field duplicated that of an already existing field.
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_bit(3), dirfile_add_clincom(3), dirfile_add_const(3), dirfile_add_cpolynom(3), dirfile_add_lincom(3), dirfile_add_linterp(3), dirfile_add_multiply(3), dirfile_add_phase(3), dirfile_add_polynom(3), dirfile_add_raw(3), dirfile_add_sbit(3), dirfile_add_spec(3), dirfile_add_string(3), dirfile_madd_bit(3), dirfile_madd_clincom(3), dirfile_madd_const(3), dirfile_madd_cpolynom(3), dirfile_madd_lincom(3), dirfile_madd_linterp(3), dirfile_madd_multiply(3), dirfile_madd_phase(3), dirfile_madd_polynom(3), dirfile_madd_sbit(3), dirfile_madd_spec(3), dirfile_madd_string(3), dirfile_metaflush(3), dirfile_open(3), get_entry(3), get_error(3), get_error_string(3), dirfile-format(5)