Provided by: libgetdata-doc_0.11.0-3ubuntu1_all bug

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 gd_add(3) or gd_add_spec(3) functions to
       add a new field of the indicated type to the dirfile specified by dirfile.

       In  all  of these calls, field_name indicates the name of the field to be added.  Further,
       fragment_index 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 gd_fragmentname(3).)
       The meaning and allowed types of other arguments may be obtained from the gd_entry(3)  and
       dirfile-format(5) manual pages.

       The  gd_add_clincom() and gd_add_cpolynom() functions are identical to gd_add_lincom() and
       gd_add_polynom(), except they take complex  scalar  parameters,  instead  of  purely  real
       values.

       The  gd_add_lincom()  and  gd_add_clincom()  functions  takes  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_add_polynom() and gd_add_cpolynom() take an
       array of length poly_ord + 1 containing the polynomial co-efficients (a or ca).

       The gd_add_carray(), gd_add_const(), gd_add_sarray(), and  gd_add_string()  functions  add
       the   field   and   set  the  value  of  the  field  to  value.   For  gd_add_const()  and
       gd_add_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.  For gd_add_sarray(),
       value should be an array of array_len 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 gd_entry(3) for details.

       A  metafield may be added to the dirfile either by calling these functions with field_name
       containing the fully formed "<parent-field>/<meta-field>" field code, or else by using the
       corresponding  gd_madd_...()  function  (see  gd_madd_bit(3), &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 gd_add(3) or gd_add_spec(3).

       See  NOTES  below  for  information  on  using  gd_add_clincom(),  gd_add_cpolynom(),  and
       gd_add_crecip() 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:

       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  contained  invalid  characters;  or  it or an input field did not
               contain the affected fragment's prefix or suffix.

       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_INDEX
               The fragment_index argument was out of range.

       GD_E_BAD_TYPE
               The data_type or const_type argument provided to  gd_add_raw()  or  gd_add_const()
               was invalid.

       GD_E_DUPLICATE
               The field_name provided duplicated that of an already existing field.

       GD_E_INTERNAL_ERROR
               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_E_IO (gd_add_raw()  only)  An I/O error occurred while creating an empty binary file to
               be associated with a newly added RAW field.

       GD_E_PROTECTED
               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_E_UNKNOWN_ENCODING
               (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_E_UNSUPPORTED
               (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 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_add_clincom(), gd_add_cpolynom(),
       and gd_add_crecip():

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

HISTORY

       The    functions     dirfile_add_bit(),     dirfile_add_const(),     dirfile_add_lincom(),
       dirfile_add_linterp(), dirfile_add_multiply(), dirfile_add_phase(), dirfile_add_raw(), and
       dirfile_add_string() appeared in GetData-0.4.0.

       The functions dirfile_add_clincom(),  dirfile_add_cpolynom(),  dirfile_add_polynom(),  and
       dirfile_add_sbit() appeared in GetData-0.6.0.

       In   GetData-0.7.0,   the   functions  were  renamed  to  gd_add_bit(),  gd_add_clincom(),
       gd_add_const(), gd_add_cpolynom(), gd_add_lincom(),  gd_add_linterp(),  gd_add_multiply(),
       gd_add_phase(),  gd_add_polynom(),  gd_add_raw(), gd_add_sbit(), and gd_add_string().  The
       functions  gd_add_carray(),  gd_add_crecip(),  gd_add_divide(),  and  gd_add_recip()  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 gd_add_mplex() and gd_add_window() 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  gd_add_indir(),  gd_add_sarray(),  and  gd_add_sindir()
       also appeared in this version.

SEE ALSO

       gd_add(3), gd_add_spec(3), gd_entry(3), gd_error(3), gd_error_string(3), the corresponding
       gd_madd_<entry-type>  functions  (e.g.   gd_madd_bit(3)),   gd_metaflush(3),   gd_open(3),
       dirfile-format(5)