Scroll to navigation

ECONF_GETVALUE(3) libeconf Manual ECONF_GETVALUE(3)

NAME

econf_get<type>Value - retrieve a value from an econf configuration file

SYNOPSIS

#include <libeconf.h>

econf_err econf_getIntValue(econf_file *kf, const char *group, const char *key, int *result);

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

econf_err econf_getUIntValue(econf_file *kf, const char *group, const char *key, unsigned int *result);

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

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

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

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

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

DESCRIPTION

These functions retrieve a value associated with a specific group and key from the parsed configuration file object pointed to by kf.

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.

Upon success, the retrieved value is converted to the appropriate data type and stored in the memory location pointed to by result.

For econf_getStringValue(), memory is dynamically allocated for the stored string. It is the responsibility of the caller to free this memory using free(3) when it is no longer needed.

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

RETURN VALUE

If the function succeeds, it returns ECONF_SUCCESS.

On failure, a non-zero error code of type econf_err is returned.

ERRORS

ECONF_KEY_HAS_NULL_VALUE


Given key has NULL value.

ECONF_NOMEM


Memory allocation failed (specifically applicable to econf_getStringValue).

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

ECONF_ERROR


General error.

SEE ALSO

libeconf(3), econf_free(3), econf_errString(3).

2023-12-01 libeconf