SYNOPSIS
#include <getdata.h>-
int gd_madd_bit(DIRFILE *dirfile,
const char *parent, const char *field_name,
const char *in_field, int bitnum, int numbits);
- int gd_madd_carray(DIRFILE *dirfile, const char *parent, const char *field_name, gd_type_t const_type, size_t array_len, gd_type_t data_type, void *value);
- int gd_madd_clincom(DIRFILE *dirfile, const char *parent, const char *field_name, int n_fields, const char **in_fields, const double complex *cm, const double complex *cb);
- int gd_madd_const(DIRFILE *dirfile, const char *parent, const char *field_name, gd_type_t const_type, gd_type_t data_type, void *value);
- int gd_madd_cpolynom(DIRFILE *dirfile, const char *parent, const char *field_name, int poly_ord, const char *in_field, const double complex *ca);
- int gd_madd_crecip(DIRFILE *dirfile, const char *parent, const char *field_name, const char *in_field, double complex cdividend, int fragment_index);
- int gd_madd_divide(DIRFILE *dirfile, const char *parent, const char *field_name, const char *in_field1, const char *in_field2);
- int gd_madd_lincom(DIRFILE *dirfile, const char *parent, const char *field_name, int n_fields, const char **in_fields, const double *m, const double *b);
- int gd_madd_linterp(DIRFILE *dirfile, const char *parent, const char *field_name, const char *in_field, const char *table);
- int gd_madd_mplex(DIRFILE *dirfile, const char *parent, const char *field_name, const char *in_field, const char *count_field, int count_val, int period);
- int gd_madd_multiply(DIRFILE *dirfile, const char *parent, const char *field_name, const char *in_field1, const char *in_field2);
- int gd_madd_polynom(DIRFILE *dirfile, const char *parent, const char *field_name, int poly_ord, const char *in_field, const double *a);
- int gd_madd_phase(DIRFILE *dirfile, const char *parent, const char *field_name, const char *in_field, gd_shift_t shift);
- int gd_madd_recip(DIRFILE *dirfile, const char *parent, const char *field_name, const char *in_field, double dividend, int fragment_index);
- int gd_madd_sbit(DIRFILE *dirfile, const char *parent, const char *field_name, const char *in_field, int bitnum, int numbits);
- int gd_madd_string(DIRFILE *dirfile, const char *parent, const char *field_name, const char *value);
- int gd_madd_window(DIRFILE *dirfile, const char *parent, const char *field_name, const char *in_field, const char *check_field, gd_windop_t windop, gd_triplet_t threshold);
- int gd_madd_carray(DIRFILE *dirfile, const char *parent, const char *field_name, gd_type_t const_type, size_t array_len, gd_type_t data_type, void *value);
DESCRIPTION
In all of these calls, field_name indicates the name of the field to be added. It should not be the full <parent-field>/<meta-field> field code. The meaning and valid types of other arguments may be obtained from the gd_entry(3) and dirfile-format(5) manual pages.
The gd_madd_clincom() and gd_madd_cpolynom() functions are identical to gd_madd_lincom() and gd_madd_polynom(), except they take complex scalar parameters, instead of purely real values.
The gd_madd_lincom() and gd_madd_clincom() functions take pointers to three arrays of length n_fields containing the input field names (in_fields), the gain factors (m or cm), and the offset terms (b or cb). Similarly, gd_madd_polynom() and gd_madd_cpolynom() take an array of length poly_ord + 1 containing the polynomial co-efficients (a or ca).
The gd_madd_string(),~gd_madd_carray, and gd_madd_const() functions both add the field and set the value of the field to value. For gd_madd_const() and gd_madd_carray(), the const_type argument specifies the storage type for the const, while data_type specifies the data type of the value pointed to by value.
The gd_shift_t type is a signed 64-bit integer type. The gd_triplet_t type is defined as:
typedef union { gd_int64_t i; gd_uint64_t u; double r; } gd_triplet_t;
Which element of this gd_triplet_t union to set depends on the operator selected for the WINDOW field. See gd_entry(3) for details.
All fields added with this interface must contain numerical parameters. Fields with scalar fields as parameters cannot be added with these functions. Those fields must be added with gd_madd(3) or gd_madd_spec(3). See gd_add_bit(3), &c. for an alternate way of adding metafields with explicit parameters.
See NOTES below for information on using gd_madd_clincom(), gd_madd_cpolynom(), and gd_madd_crecip() in the C89 GetData API.
RETURN VALUE
On success, any of these functions returns zero. On error, -1 is returned and the dirfile error is set to a non-zero error value. Possible error values are:- GD_E_ACCMODE
- The specified dirfile was opened read-only.
- GD_E_ALLOC
- The library was unable to allocate memory.
- GD_E_BAD_CODE
- The field_name argument contained invalid characters. Alternately, the parent field code was not found, or was already a metafield.
- GD_E_BAD_DIRFILE
- The supplied dirfile was invalid.
- GD_E_BAD_ENTRY
- One or more of the field parameters specified was invalid.
- GD_E_BAD_TYPE
- The data_type or const_type argument provided to gd_madd_const() or gd_madd_carray() was invalid.
- GD_E_DUPLICATE
- The field_name provided duplicated that of an already existing field.
- GD_E_PROTECTED
- The metadata of the fragment was protected from change.
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).
NOTES
The C89 GetData API provides different prototypes for gd_madd_clincom(),~gd_madd_cpolynom(), and gd_madd_crecip():
#define GD_C89_API
#include <getdata.h>
-
int gd_madd_clincom(DIRFILE *dirfile, const char *parent,
const char *field_name, int n_fields, const char **in_fields,
const double *cm, const double *cb);
- int gd_madd_cpolynom(DIRFILE *dirfile, const char *parent, const char *field_name, int poly_ord, const char *in_field, const double *ca);
- int gd_madd_crecip(DIRFILE *dirfile, const char *parent, const char *field_name, const char *in_field, double cdividend[2], int fragment_index);
- int gd_madd_cpolynom(DIRFILE *dirfile, const char *parent, const char *field_name, int poly_ord, const char *in_field, const double *ca);
For gd_madd_clincom() and gd_madd_cpolynom(), these are simply different (but equivalent) declarations of the C99 function entry point. For gd_madd_crecip(), however, a different entry point is needed (since the cdividend parameter is passed by reference instead of by value). In the interests of portability, the C89 version of gd_madd_crecip() is always available, and may be accessed as gd_madd_crecip89(), with the C89 prototype, in both the C99 and C89 APIs.