gd_add, gd_madd
add a field to a dirfile
- Provided by: libgetdata-doc (Version: 0.9.0-2.2)
- Source: libgetdata
- Report a bug
add a field to a dirfile
#include <getdata.h>
int gd_add(DIRFILE *dirfile, const gd_entry_t *entry);
int gd_madd(DIRFILE *dirfile, const gd_entry_t *entry, const char *parent);
The gd_add() function adds the field described by entry to the dirfile specified by dirfile. The gd_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 gd_entry(3) man page. All relevant members of entry for the field type specified must be properly initialised. If entry specifies a CONST or CARRAY field, the field's data will be set to zero. If entry specifies a STRING field, the field data will be set to the empty string.
The only flags in the entry->flags member which are honoured are GD_EN_HIDDEN, which should be set or cleared to set the hiddenness of the entry (see gd_hidden(3)), and GD_EN_COMPSCAL, which indicates whether scalar parameters are initialised from the complex valued or purely real member, which both are present (LINCOM, POLYNOM, RECIP).
A metafield may be added either by calling gd_madd() with entry->field containing only the metafield's name, or else by calling gd_add() with the fully formed <parent-field>/<meta-field> field code in entry->field. Regardless of which interface is used, when adding a metafield the value of entry->fragment_index is ignored and GetData will add the new metafield to the same format specification fragment in which the parent field is defined. If the specified parent field name is an alias, the canonical name of the field will be substituted.
Fields added with this interface may contain either literal parameters or parameters based on scalar 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 scalar 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. If using an element of a CARRAY field, entry->scalar_ind should also be set.
On success, gd_add() and gd_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 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).
gd_add_bit(3), gd_add_carray(3), gd_add_const(3), gd_add_divide(3), gd_add_lincom(3), gd_add_linterp(3), gd_add_multiply(3), gd_add_phase(3), gd_add_polynom(3), gd_add_raw(3), gd_add_recip(3), gd_add_sbit(3), gd_add_spec(3), gd_add_string(3), gd_entry(3), gd_error(3), gd_error_string(3), gd_madd_bit(3), gd_madd_carray(3), gd_madd_const(3), gd_madd_divide(3), gd_madd_lincom(3), gd_madd_linterp(3), gd_madd_multiply(3), gd_madd_phase(3), gd_madd_polynom(3), gd_madd_recip(3), gd_madd_sbit(3), gd_madd_spec(3), gd_madd_string(3), gd_metaflush(3), gd_open(3), dirfile-format(5)