Scroll to navigation

gd_array_len(3) GETDATA gd_array_len(3)

NAME

gd_array_len — returns the length of a CARRAY or SARRAY field in a Dirfile

SYNOPSIS

#include <getdata.h>

size_t gd_array_len(DIRFILE *dirfile, const char *field_code);

DESCRIPTION

The gd_array_len() function queries a dirfile(5) database specified by dirfile and calculates the length of the CARRAY, CONST, STRING, or SARRAY field called field_code. If field_code contains a valid representation suffix, it will be ignored.

The dirfile argument must point to a valid DIRFILE object previously created by a call to gd_open(3).

RETURN VALUE

Upon successful completion, gd_array_len() returns a positive integer indicating the array length of the field specified. (The length of a CONST or a STRING field is always 1.) On error, it returns a negative-valued error code. Possible error codes are:

GD_E_BAD_CODE
The field specified by field_code was not found in the database.
GD_E_BAD_DIRFILE
The supplied dirfile was invalid.
GD_E_BAD_FIELD_TYPE
The field specified by field_code was not of one of the field types listed above.

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

HISTORY

The gd_carray_len() function appeared in GetData-0.7.0. It was restricted to CONST and CARRAY entries.

In GetData-0.9.0, this function was renamed to gd_array_len, and STRING entries were now valid for this function.

Before GetData-0.10.0, this function could also fail with the error code GD_E_ALLOC.

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

SEE ALSO

dirfile(5), gd_open(3), gd_error(3), gd_error_string(3)

25 December 2016 Version 0.10.0