gd_add_alias(3) add a field to a dirfile

Other Alias

gd_madd_alias

SYNOPSIS

#include <getdata.h>
int gd_add_alias(DIRFILE *dirfile, const char *alias_name, const char *target_code, int fragment_index);
int gd_madd_alias(DIRFILE *dirfile, const char *parent, const char *alias_name, const char *target_code);

DESCRIPTION

The gd_add_alias() function adds the alias named alias_name pointing to target_code to the fragment indexed by fragment_index in the dirfile specified by dirfile. The gd_madd_alias() function behaves similarly, but adds the field as a meta-entry under the field indicated by the field code parent.

RETURN VALUE

On success, gd_add_alias() and gd_madd_alias() return 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 alias_name contained invalid characters; or it or an input field did not contain the affected fragment's prefix or suffix. 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_INDEX
The fragment_index specified was out of range.
GD_E_DUPLICATE
The alias_name parameter duplicated that of an already existing entry.
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.

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).