dirfile_alter_entry

Langue: en

Autres versions - même langue

Version: 14 December 2008 (fedora - 05/07/09)

Section: 3 (Bibliothèques de fonctions)

NAME

dirfile_alter_entry --- modify the metadata of a dirfile field

SYNOPSIS

#include <getdata.h>
int dirfile_alter_entry(DIRFILE *dirfile, const char *field_code, const gd_entry_t *entry, int recode);

DESCRIPTION

The dirfile_alter_entry() function modifies the field described by field_code in the dirfile specified by dirfile to correspond to the new parameters specified by entry. In addition to specifying a regular field, field_code may also refer to a metafield by specifying it using its full (slashed) field code.

If field_code specifies a RAW field and the recode argument is non-zero, the binary file associated with the field will be converted for changes in data type and samples-per-frame. If recode is zero, no binary file conversion will take place.

If field_code specifies a LINTERP field and the recode argument is non-zero, the look-up table file will be moved if entry->table specifies a different path, overwriting an existing file with the new pathname, if present. If the field specified by field_code is of type other than RAW or LINTERP, the recode argument is ignored.

The form of entry is described in detail in the get_entry(3) man page. The entry->field and entry->fragment_index members are ignored by this function and need not be initialised. All other members appropriate to the field type of field_code should be initialised. To change the fragment index of a field, use dirfile_move(3). To change the name of a field, use dirfile_rename(3).

The entry->field_type member must correspond to the field type of field_code. This interface cannot be used to change the type of a given field. To do so, delete the old field first with dirfile_delete(3), and then create a new field of the desired type with dirfile_add(3).

Some field parameters have special values which indicate no change should be made to the parameter. Specifically, if any of the string parameters are NULL, the old value will be retained. Similarly, if entry->spf, entry->n_fields, or entry->numbits is zero, or if entry->bitnum is -1, or if entry->data_type, or entry->const_type are equal to GD_NULL, these parameters will not be modified.

All new values for field parameters modified by this interface must contain numerical parameters. Using CONST fields as parameters cannot be accomplished with this function. To use such CONST field names, the field must be modified with dirfile_alter_spec(3) or dirfile_malter_spec(3).

RETURN VALUE

On success, dirfile_alter_entry() 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 specified by field_code was not found.
GD_E_BAD_DIRFILE
The supplied dirfile was invalid.
GD_E_BAD_ENTRY
One or more of the parameters specified in entry was invalid.
GD_E_BAD_FIELD_TYPE
The entry->field_type parameter did not correspond to the type of the field specified by field_code, or an attempt was made to modify the immutable INDEX field.
GD_E_BAD_TYPE
The entry->data_type parameter provided with a RAW entry, or the entry->const_type parameter provided with a CONST entry, was invalid.
GD_E_PROTECTED
The metadata of the fragment was protected from change. Or, a request to translate the binary file associated with a RAW field was attempted, but the data of the fragment was protected.
GD_E_RAW_IO
An I/O error occurred while translating the binary file associated with a modified RAW field, or an I/O error occurred while attempting to rename a LINTERP table file.
GD_E_UNKNOWN_ENCODING
The encoding scheme of the specified format file fragment is not known to the library. As a result, the library was unable to translate the binary file be associated with a modified RAW field.
GD_E_UNSUPPORTED
The encoding scheme of the specified format file fragment does not support translating the empty binary file associated with a modified RAW field.

The dirfile error may be retrieved by calling get_error(3). A descriptive error string for the last error encountered can be obtained from a call to get_error_string(3).

SEE ALSO

dirfile_alter_bit(3), dirfile_alter_const(3), dirfile_alter_lincom(3), dirfile_alter_linterp(3), dirfile_alter_multiply(3), dirfile_alter_phase(3), dirfile_alter_raw(3), dirfile_alter_spec(3), dirfile_delete(3), dirfile_malter_spec(3), dirfile_metaflush(3), dirfile_move(3), dirfile_open(3), dirfile_rename(3), get_error(3), get_error_string(3), dirfile-format(5)