Next: , Previous: , Up: Top   [Contents][Index]


20 Useful global variables

The following global variables and constants are available:

Variable: gdbm_error gdbm_errno

This variable contains error code from the last failed GDBM call. See Error codes, for a list of available error codes and their descriptions.

Use gdbm_strerror (see Errors) to convert it to a descriptive text.

Variable: const char * gdbm_errlist[]

This variable is an array of error descriptions, which is used by gdbm_strerror to convert error codes to human-readable text (see Errors). You can access it directly, if you wish so. It contains _GDBM_MAX_ERRNO + 1 elements and can be directly indexed by the error code to obtain a corresponding descriptive text.

Variable: int const gdbm_syserr[]

Array of boolean values indicating, for each GDBM error code, whether the value of errno(3) variable is meaningful for this error code. See gdbm_check_syserr.

Constant: _GDBM_MIN_ERRNO

The minimum error code used by GDBM.

Constant: _GDBM_MAX_ERRNO

The maximum error code used by GDBM.

Variable: const char * gdbm_version

A string containing the version information.

Variable: int const gdbm_version_number[3]

This variable contains the GDBM version numbers:

IndexMeaning
0Major number
1Minor number
2Patchlevel number

Additionally, the following constants are defined in the gdbm.h file:

GDBM_VERSION_MAJOR

Major number.

GDBM_VERSION_MINOR

Minor number.

GDBM_VERSION_PATCH

Patchlevel number.

These can be used to verify whether the header file matches the library.

To compare two split-out version numbers, use the following function:

gdbm interface: int gdbm_version_cmp (int const a[3], int const b[3])

Compare two version numbers. Return -1 if a is less than b, 1 if a is greater than b and 0 if they are equal.

Comparison is done from left to right, so that:

a = { 1, 8, 3 };
b = { 1, 8, 3 };
gdbm_version_cmp (a, b) ⇒ 0

a = { 1, 8, 3 };
b = { 1, 8, 2 };
gdbm_version_cmp (a, b) ⇒ 1

a = { 1, 8, 3 };
b = { 1, 9. 0 };
gdbm_version_cmp (a, b) ⇒ -1

Next: , Previous: , Up: Top   [Contents][Index]