gd_add_bit(3)

NAME
gd_add_bit, gd_add_carray gd_add_clincom, gd_add_const, gd_add_cpolynom, gd_add_crecip, gd_add_divide, gd_add_indir, gd_add_lincom, gd_add_linterp, gd_add_multiply, gd_add_phase, gd_add_polynom, gd_add_raw, gd_add_recip, gd_add_sarray, gd_add_sbit, gd_add_sindir, gd_add_string — add a field to a Dirfile

SYNOPSIS
#include <getdata.h>

int gd_add_bit(DIRFILE *dirfile, const char *field_name, const char *in_field, int bitnum, int numbits, int fragment_index);

int gd_add_carray(DIRFILE *dirfile, const char *field_name, gd_type_t const_type, size_t array_len, gd_type_t data_type, void *value, int fragment_index);

int gd_add_clincom(DIRFILE *dirfile, const char *field_name, int n_fields, const char **in_fields, const double complex *cm, const double complex *cb, int fragment_index);

int gd_add_const(DIRFILE *dirfile, const char *field_name, gd_type_t const_type, gd_type_t data_type, void *value, int fragment_index);

int gd_add_cpolynom(DIRFILE *dirfile, const char *field_name, int poly_ord, const char *in_fields, const double complex *ca, int fragment_index);

int gd_add_crecip(DIRFILE *dirfile, const char *field_name, const char *in_field, double complex cdividend, int fragment_index);

int gd_add_divide(DIRFILE *dirfile, const char *field_name, const char *in_field1, const char *in_field2, int fragment_index);

int gd_add_indir(DIRFILE *dirfile, const char *field_name, const char *index_field, const char *carray_field, int fragment_index);

int gd_add_lincom(DIRFILE *dirfile, const char *field_name, int n_fields, const char **in_fields, const double *m, const double *b, int fragment_index);

int gd_add_linterp(DIRFILE *dirfile, const char *field_name, const char *in_field, const char *table, int fragment_index);

int gd_add_mplex(DIRFILE *dirfile, const char *field_name, const char *in_field, const char *count_field, int count_val, int period, int fragment_index);

int gd_add_multiply(DIRFILE *dirfile, const char *field_name, const char *in_field1, const char *in_field2, int fragment_index);

int gd_add_phase(DIRFILE *dirfile, const char *field_name, const char *in_field, gd_int64_t shift, int fragment_index);

int gd_add_polynom(DIRFILE *dirfile, const char *field_name, int poly_ord, const char *in_fields, const double *a, int fragment_index );

int gd_add_raw(DIRFILE *dirfile, const char *field_name, gd_type_t data_type, unsigned int spf, int fragment_index);

int gd_add_recip(DIRFILE *dirfile, const char *field_name, const char *in_field, double dividend, int fragment_index);

int gd_add_sarray(DIRFILE *dirfile, const char *field_name, size_t array_len, const char **values,int fragment_index);

int gd_add_sbit(DIRFILE *dirfile, const char *field_name, const char *in_field, int bitnum, int numbits, int fragment_index);

int gd_add_sindir(DIRFILE *dirfile, const char *field_name, const char *index_field, const char *sarray_field, int fragment_index);

int gd_add_string(DIRFILE *dirfile, const char *field_name, const char *value, int fragment_index);

int gd_add_window(DIRFILE *dirfile, const char *field_name, const char *in_field, const char *check_field, gd_windop_t windop, gd_triplet_t threshold, int fragment_index);

DESCRIPTION
These functions provide alternatives to using the or functions to add a new field of the indicated type to the dirfile specified by

In all of these calls, indicates the name of the field to be added. Further, is the index of the format specification fragment into which the field should be added. (To convert a fragment index to its file name, see The meaning and allowed types of other arguments may be obtained from the and dirfile-format(5) manual pages. The and functions are identical to and except they take complex scalar parameters, instead of purely real values. The and functions takes pointers to three arrays of length containing the input field names (in_fields), the gain factors (m or cm), and the offset terms (b or cb). Similarly, and take an array of length + 1 containing the polynomial co-efficients (a or ca). The and functions add the field and set the value of the field to For and the argument specifies the storage type for the const, while specifies the data type of the value pointed to by For should be an array of string pointers. The gd_int64_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 for details.

A metafield may be added to the dirfile either by calling these functions with containing the fully formed "<parent-field>/<meta-field>" field code, or else by using the corresponding gd_madd_...() function (see &c.) When adding a metafield with these functions, 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. All fields added with this interface must contain literal parameters. Fields with scalar fields as parameters cannot be added with these functions. Those fields must be added with or See NOTES below for information on using and in the C89 GetData API.

RETURN VALUE
On success, any of these functions returns zero. On error, a negative-valued error value is returned. Possible error values are: The specified dirfile was opened read-only. The library was unable to allocate memory. The field_name contained invalid characters; or it or an input field did not contain the affected fragment's prefix or suffix. The supplied dirfile was invalid. One or more of the field parameters specified was invalid. The fragment_index argument was out of range. The data_type or const_type argument provided to or was invalid. The field_name provided duplicated that of an already existing field. An internal error occurred in the library while trying to perform the task. This indicates a bug in the library. Please report the incident to the GetData developers. (gd_add_raw() only) An I/O error occurred while creating an empty binary file to be associated with a newly added RAW 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. (gd_add_raw() only) 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. (gd_add_raw() only) 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 also be retrieved by calling A descriptive error string for the last error encountered can be obtained from a call to

NOTES
The C89 GetData API provides different prototypes for and

#define GD_C89_API
#include <getdata.h>

int gd_add_clincom(DIRFILE *dirfile, const char *field_name, int n_fields, const char **in_fields, const double *cm, const double *cb, int fragment_index);

int gd_add_cpolynom(DIRFILE *dirfile, const char *field_name, int poly_ord, const char *in_fields, const double *ca, int fragment_index);

int gd_add_crecip(DIRFILE *dirfile, const char *field_name, const char *in_field, const double cdividend[2], int fragment_index);

In this case, the array pointers passed as cm, cb or ca should have twice as many (purely real) elements, consisting of alternating real and imaginary parts for the complex data. That is, for example, ca[0] should be the real part of the first co-efficient, ca[1] the imaginary part of the first co-efficient, ca[2] the real part of the second co-efficient, ca[3] the imaginary part of the second co-efficient, and so on. Similarly, the cdividend parameter becomes a double precision array of length two.

For and these are simply different (but equivalent) declarations of the C99 function entry point. For 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 is always available, and may be accessed as with the C89 prototype, in both the C99 and C89 APIs.

HISTORY
The functions and appeared in GetData-0.4.0. The functions and appeared in GetData-0.6.0. In GetData-0.7.0, the functions were renamed to and The functions and also appeared in this version. In GetData-0.8.0, these functions first allowed adding metafields by providing the full (slashed) field name. The functions and also appeared in this version. In GetData-0.10.0, the error return from these functions changed from -1 to a negative-valued error code. The functions and also appeared in this version.

SEE ALSO
the corresponding gd_madd_<entry-type> functions (e.g. dirfile-format(5)