ECONF\_GETVALUEDEF(3) libeconf Manual ECONF\_GETVALUEDEF(3)

# [NAME](#NAME)

econf\_get&lt;type&gt;ValueDef - evaluate value for a given group and key, returning a default if not found

# [SYNOPSIS](#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](#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)](/man/os/libeconf/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](#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)](/man/os/libeconf/econf_errString.3) for converting error codes to strings.

# [ERRORS](#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](#SEE_ALSO)

[**libeconf**(3)](/man/os/libeconf/libeconf.3), [**econf\_getValue**(3)](/man/os/libeconf/econf_getValue.3), [**econf\_setValue**(3)](/man/os/libeconf/econf_setValue.3), [**econf\_errString**(3)](/man/os/libeconf/econf_errString.3).

2024-12-14 libeconf

---

Document: econf_getUIntValueDef(3) from libeconf 0.8.4-r3 (Chainguard OS)
Source: https://github.com/openSUSE/libeconf
