econf_newKeyFile_with_options - Man Page

create a new econf_file object with special options

Synopsis

#include <libeconf​.h>

econf_err econf_newKeyFile_with_options(econf_file **result, const char *options);

Description

The econf_newKeyFile_with_options() function creates a new, empty econf_file object and stores it in *result​.

options is a string of <key>=<value> pairs separated by ';', e​.g​. "JOIN_SAME_ENTRIES=1"​. If options is NULL or an empty string, the new econf_file object is created with the default settings described below​.

The following options are supported:

JOIN_SAME_ENTRIES (default 0)

         Parsed entries with the same name will not be replaced but will be joined to one entry​.

PYTHON_STYLE (default 0)

         Indentations will be handled like multiline entries​.

DEFAULT_QUOTES (default 0)

         Entries which are newly created (e​.g​. via econf_setStringValue()) and not read from a file will have their value enclosed by quotes when the econf_file is written to a file​. This default can be overridden per entry with econf_setQuotes()​.

PARSING_DIRS (default /usr/etc/:/run:/etc)

         List of directories from which the configuration files have to be parsed​. The list is a string, divided by ':'​. The last entry has the highest priority​. E​.g​.: "PARSING_DIRS=/usr/etc/:/run:/etc"​.

CONFIG_DIRS (default empty)

         List of directory structures (with order) which describes the directories in which the files have to be parsed​. The list is a string, divided by ':'​. The last entry has the highest priority​. E​.g​. with the given list "CONFIG_DIRS=.conf.d:.d" files in the following directories will be parsed:

<default_dirs>/<config_name>​.conf​.d/
<default_dirs>/<config_name>​.d/
<default_dirs>/<config_name>/

ROOT_PREFIX (default empty)

         Directory prefix used for all search directories if specified​.

Return Value

Upon successful completion, this function returns ECONF_SUCCESS and stores the newly created econf_file object in *result​.

On error, a non-zero error code is returned (see the section called “Errors”), and *result may be set to NULL​.

Errors

ECONF_NOMEM

         Insufficient memory to allocate the new econf_file object or one of its internal lists​.

ECONF_OPTION_NOT_FOUND

options contains a key that is not a known option​.

Examples

#include <libeconf​.h>

econf_file *key_file = NULL;
econf_err error;

if ((error = econf_newKeyFile_with_options(&key_file, "PYTHON_STYLE=1")))
{
  fprintf (stderr, "ERROR: couldn't create new key file: %s\n",
           econf_errString(error));
  return 1;
}

error = econf_readConfig (&key_file,
                          "foo",
                          "/usr/lib",
                          "example",
                          "conf",
                          "=", "#");

econf_free (key_file);
key_file = NULL;

See Also

libeconf(3), econf_newKeyFile(3), econf_newIniFile(3), econf_setQuotes(3), econf_freeFile(3), econf_errString(3)​

Info

2026-10-15 libeconf Manual