gd_array_len - Man Page

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)

Referenced By

gd_get_carray_slice(3), gd_get_sarray_slice(3), gd_put_carray_slice(3), gd_put_sarray_slice(3).

The man page gd_carray_len(3) is an alias of gd_array_len(3).

25 December 2016 Version 0.10.0 GETDATA