gd_get_sarray_slice(3)

NAME
gd_get_sarray, gd_get_sarray_slice — retrieve STRING or SARRAY data from a dirfile database

SYNOPSIS
#include <getdata.h>

int gd_get_sarray_slice(DIRFILE *dirfile, const char *field_code, unsigned int start, size_t len, const char **data_out);

int gd_get_sarray(DIRFILE *dirfile, const char *field_code, const char **data_out);

DESCRIPTION
The function queries a dirfile(5) database specified by for the STRING or SARRAY scalar Pointers to read-only string elements of the specified field are stored in the user-supplied buffer, which must be large enough to hold pointers. The first element of the field stored is given by and the number of elements stored is given by

The function behaves similarly, except it returns the entire field, as if were called with equal to zero and equal to the value returned by

The argument must point to a valid DIRFILE object previously created by a call to The number of elements returned by may be obtained by calling Unlike calling never results in a short read; attempting to read past the end of the field will result in an error, and no data will be returned.

If refers to a STRING field, it is treated as if it were a SARRAY field with only one element. See the manual page for an example of how to replace calls with

RETURN VALUE
On success, and return zero. Storage for the strings returned by this function are managed by GetData and should not be deallocated by the caller. On error, these functions return a negative-valued error code. Possible error codes are: The library was unable to allocate memory. The field specified by was not found in the database. An invalid was supplied. The supplied was not a STRING nor SARRAY. A request for data beyond the end of the field was made. 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 maintainer.

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

HISTORY
The and functions appeared in GetData-0.10.0.

SEE ALSO
dirfile(5)