Scroll to navigation

gd_fragment_index(3) GETDATA gd_fragment_index(3)


gd_fragment_index — retrieve the fragment containing a Dirfile field


#include <getdata.h>

int gd_fragment_index(const DIRFILE *dirfile, const char *entry_name);


The gd_fragment_index() function queries a dirfile(5) database specified by dirfile and returns the index number of the fragment defining the field or alias named entry_name.

This is one of the few GetData functions which does not resolve aliases: supplying the name of an alias as entry_name will return the index of the fragment containing the alias itself and not that of its target.


Upon successful completion, gd_fragment_index() returns the requested fragment index, which is never negative. On error, gd_fragment_index() returns a negative-valued error code. Possible error codes are:

The entry specified by entry_name was not found in the database.
The supplied dirfile was invalid.

The error code is also stored in the DIRFILE object and may be retrieved after this function returns by calling gd_error(3). A descriptive error string for the error may be obtained by calling gd_error_string(3).


The get_fragment_index() function appeared in GetData-0.5.0.

In GetData-0.7.0, this function was renamed to gd_fragment_index().

In GetData-0.10.0, the error return from this function changed from -1 to a negative-valued error code.


gd_open(3), gd_entry(3), gd_error(3), gd_error_string(3), gd_fragmentname(3), gd_parent_fragment(3), dirfile(5)

25 December 2016 Version 0.10.0