.\" gd_alter_bit.3. The gd_alter_bit man page. .\" .\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" .\" This file is part of the GetData project. .\" .\" Permission is granted to copy, distribute and/or modify this document .\" under the terms of the GNU Free Documentation License, Version 1.2 or .\" any later version published by the Free Software Foundation; with no .\" Invariant Sections, with no Front-Cover Texts, and with no Back-Cover .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" .TH gd_alter_bit 3 "3 November 2010" "Version 0.7.0" "GETDATA" .SH NAME gd_alter_bit, gd_alter_carray, gd_alter_clincom, gd_alter_const, gd_alter_cpolynom, gd_alter_crecip, gd_alter_divide, gd_alter_lincom, gd_alter_linterp, gd_alter_multiply, gd_alter_phase, gd_alter_polynom, gd_alter_raw, gd_alter_recip, gd_alter_sbit \(em modify a field in a dirfile .SH SYNOPSIS .B #include .HP .nh .ad l .BI "int gd_alter_bit(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field ", gd_bit_t " bitnum ", gd_bit_t " numbits ); .HP .BI "int gd_alter_carray(DIRFILE *" dirfile ", const char *" field_code , .BI "gd_type_t " const_type ", size_t " array_len ); .HP .BI "int gd_alter_clincom(DIRFILE *" dirfile ", const char *" field_code , .BI "int " n_fields ", const char **" in_fields ", const double complex *" cm , .BI "const double complex *" cb ); .HP .BI "int gd_alter_const(DIRFILE *" dirfile ", const char *" field_code , .BI "gd_type_t " const_type ); .HP .BI "int gd_alter_cpolynom(DIRFILE *" dirfile ", const char *" field_code , .BI "int " poly_ord ", const char *" in_field ", const double complex *" ca ); .HP .BI "int gd_alter_crecip(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field ", complex double " cdividend ); .HP .BI "int gd_alter_divide(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field1 ", const char *" in_field2 ); .HP .BI "int gd_alter_lincom(DIRFILE *" dirfile ", const char *" field_code , .BI "int " n_fields ", const char **" in_fields ", const double *" m , .BI "const double *" b ); .HP .BI "int gd_alter_linterp(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field ", const char *" table ", int " rename_table ); .HP .BI "int gd_alter_multiply(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field1 ", const char *" in_field2 ); .HP .BI "int gd_alter_phase(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field ", gd_shift_t " shift ); .HP .BI "int gd_alter_polynom(DIRFILE *" dirfile ", const char *" field_code , .BI "int " poly_ord ", const char *" in_field ", const double *" ca ); .HP .BI "int gd_alter_raw(DIRFILE *" dirfile ", const char *" field_code , .BI "gd_type_t " data_type ", gd_spf_t " spf ", int " recode ); .HP .BI "int gd_alter_recip(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field ", double " dividend ); .HP .BI "int gd_alter_sbit(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field ", gd_bit_t " bitnum ", gd_bit_t " numbits ); .hy .ad n .SH DESCRIPTION These functions provide alternatives to using the .BR gd_alter_entry (3) function to modify a field of the indicated type in the dirfile specified by .IR dirfile . .PP In all of these calls, .I field_code indicates the the field to be modified, which may be a regular field, or a metafield specified by its full (slashed) field code, but should not contain a representation suffix. The meaning and valid types of other arguments may be obtained from the .BR get_entry (3) and .BR dirfile-format (5) manual pages. The .B gd_bit_t type is a signed 16-bit integer type. The .B gd_shift_t type is a signed 64-bit integer type. The .B gd_spf_t type is an unsigned 16-bit integer type. The .BR gd_alter_clincom () and .BR gd_alter_cpolynom () functions are identical to .BR gd_alter_lincom () and .BR gd_alter_polynom (), except they take complex scalar parameters, instead of purely real values. This only matters for the input of .I new parameters; if the scalar parameters are not changed (by passing NULL instead of a list of scalars), the functions can be used interchangeably, regardless of whether the altered field has complex scalar parameters or not. If the corresponding parameters are to be changed, the .BR gd_alter_lincom () and .BR gd_alter_clincom () functions take pointers to three arrays of length .I n_fields containing the input field names .RI ( in_fields ), the gain factors .RI ( m " or " cm ), and the offset terms .RI ( b " or " cb ). Similarly, .BR gd_alter_polynom () and .BR gd_alter_cpolynom () take an array of length .I poly_ord + 1 containing the polynomial co-efficients .RI ( a " or " ca ). Some field parameters have special values which indicate no change should be made to the parameter. Specifically, if any of the string parameters or .IR m ,\~ b ", or " a .RI ( cm ,\~ cb ", or " ca ) are NULL, the old values will be retained. Similarly, if .IR spf ,\~ n_fields ,\~ numbits ,\~ cdividend , or .I dividend is zero, or if .IR bitnum is -1, or if .IR data_type ", or " const_type are equal to .BR GD_NULL , these parameters will not be modified. All field parameters introduced with this interface must contain literal parameters. Field parameters which are scalar fields cannot be introduced with these functions. To do that, use .BR gd_alter_entry (3), .BR gd_alter_spec (3) or .BR gd_malter_spec (3), as appropriate. If .I rename_table is non-zero, the look-up table referenced by the .B LINTERP field will be renamed to the path given by .IR table . If .I recode is non-zero, the binary file associated with the .B RAW field will be re-encoded to reflect the new field parameters. See .B NOTES below for information on using .BR gd_alter_clincom (),\~ gd_alter_crecip (), and .BR gd_alter_cpolynom () in the C89 GetData API. .SH 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: .TP 8 .B GD_E_ACCMODE The specified dirfile was opened read-only. .TP .B GD_E_ALLOC The library was unable to allocate memory. .TP .B GD_E_BAD_CODE The field specified by .I field_code was not found. .TP .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. .TP .B GD_E_BAD_ENTRY One or more of the field parameters specified was invalid. .TP .B GD_E_BAD_FIELD_TYPE The field specified by .I field_code was of the wrong type for the function called. .TP .B GD_E_BAD_TYPE The .IR data_type " or " const_type argument was invalid. .TP .B GD_E_PROTECTED The metadata of the fragment was protected from change. Or, a request to translate the binary file associated with a .B RAW field was attempted, but the data of the fragment was protected. .TP .B GD_E_RAW_IO An I/O error occurred while translating the binary file associated with a modified .B RAW field, or an I/O error occurred while attempting to rename a .B LINTERP table file. .TP .B GD_E_UNKNOWN_ENCODING The encoding scheme of the indicated format specification fragment is not known to the library. As a result, the library was unable to translate the binary file be associated with a modified .B RAW field. .TP .B GD_E_UNSUPPORTED The encoding scheme of the indicated format specification fragment does not support translating the binary file associated with a modified .B RAW field. .PP The dirfile error may be retrieved by calling .BR gd_error (3). A descriptive error string for the last error encountered can be obtained from a call to .BR gd_error_string (3). .SH NOTES The C89 GetData API provides different prototypes for .BR gd_alter_clincom (),\~ gd_alter_cpolynom (), and .BR gd_alter_crecip (): .PP .nf .B #define GD_C89_API .B #include .HP .nh .ad l .BI "int gd_alter_clincom(DIRFILE *" dirfile ", const char *" field_code , .BI "int " n_fields ", const char **" in_fields ", const double *" cm , .BI "const double *" cb ); .HP .BI "int gd_alter_cpolynom(DIRFILE *" dirfile ", const char *" field_code , .BI "int " poly_ord ", const char *" in_fields ", const double *" ca ); .HP .BI "int gd_alter_crecip(DIRFILE *" dirfile ", const char *" field_code , .BI "const char *" in_field ", double " cdividend [2]); .hy .ad n .fi .PP In this case, the array pointers passed as .IR cm ,\~ cb or .IR ca should have twice as many (purely real) elements, consisting of alternating real and imaginary parts for the complex data. For example, .IR ca [0] should be the real part of the first co-efficient, .IR ca [1] the imaginary part of the first co-efficient, .IR ca [2] the real part of the second co-efficient, .IR ca [3] the imaginary part of the second co-efficient, and so on. Similarly, the .I cdividend parameter becomes a double precision array of length two. .SH SEE ALSO .BR gd_alter_entry (3), .BR gd_alter_spec (3), .BR gd_error (3), .BR gd_error_string (3), .BR gd_malter_spec (3), .BR gd_metaflush (3), .BR gd_open (3), .BR dirfile-format (5)