Manpage logo

econf_getValueDef - evaluate value for a given group and key, returning a default if not found

NAME  SYNOPSIS  DESCRIPTION  RETURN VALUE  ERRORS  SEE ALSO 

NAME

econf_get<type>ValueDef − evaluate value for a given group and key, returning a default if not found

SYNOPSIS

#include <libeconf.h>

econf_err econf_getBoolValueDef(econf_file *kf, const char *group, const char *key, bool *result, bool def);

econf_err econf_getDoubleValueDef(econf_file *kf, const char *group, const char *key, double *result, double def);

econf_err econf_getFloatValueDef(econf_file *kf, const char *group, const char *key, float *result, float def);

econf_err econf_getIntValueDef(econf_file *kf, const char *group, const char *key, int32_t *result, int32_t def);

econf_err econf_getInt64ValueDef(econf_file *kf, const char *group, const char *key, int64_t *result, int64_t def);

econf_err econf_getStringValueDef(econf_file *kf, const char *group, const char *key, char **result, const char *def);

econf_err econf_getUInt64ValueDef(econf_file *kf, const char *group, const char *key, uint64_t *result, uint64_t def);

econf_err econf_getUIntValueDef(econf_file *kf, const char *group, const char *key, uint32_t *result, uint32_t def);

DESCRIPTION

These functions evaluate the value for a specific group and key in the given econf_file structure kf. If the key exists, the value is parsed and stored in result. If the key is not found, the default value specified by def is stored in result.

The group parameter specifies the section name in the configuration file. If group is NULL, the key is looked up in the upper part of the file without any group declaration. The key parameter specifies the name of the entry to retrieve.

For econf_getStringValueDef, memory is allocated for the result string (even if the default value is used). This memory should be freed by the caller using free(3).

For econf_getBoolValue(), the function parses common boolean strings (such as "true", "yes", "1", "false", "no", "0") irrespective of case.

These functions are essentially wrappers around the standard econf_get*Value functions, providing a convenient way to handle missing keys without checking return codes manually for ECONF_NOKEY.

RETURN VALUE

If the key is found and parsed successfully, the function returns ECONF_SUCCESS.

If the key is not found, the function sets result to def and returns ECONF_NOKEY.

If an error occurs (e.g., the value cannot be parsed, or invalid arguments), an error code is returned. See econf_errString(3) for converting error codes to strings.

ERRORS

ECONF_KEY_HAS_NULL_VALUE

Given key has NULL value.

ECONF_NOMEM

Memory allocation failed (specifically applicable to econf_getStringValueDef).

ECONF_VALUE_CONVERSION_ERROR

Value cannot be converted.

ECONF_NOKEY

The specified key could not be found within the group.

ECONF_ARGUMENT_IS_NULL_VALUE

Given argument is NULL.

ECONF_PARSE_ERROR

Parse error. (specifically applicable to econf_getBooleanValueDef).

ECONF_ERROR

General error.

SEE ALSO

libeconf(3), econf_getValue(3), econf_setValue(3), econf_errString(3).


Updated 2026-06-01 - jenkler.se | uex.se