ECONF_NEWKEY..._WITH_OPTIONS(3)

πŸ“¦ version 0.8.6, in nixpkgs unstable

πŸ’… ECONF_NEWKEY..._WITH_OPTIONS(3) πŸ’…

okay bestie, pull up a chair β€” this one's from the libeconf Manual and it's literally the glow-up version of making a fresh key file. πŸŽ€


✨ NAME ✨

econf_newKeyFile_with_options β€” creates a brand-new econf_file object, but like… with options. main character energy fr fr πŸ’–


🌸 SYNOPSIS 🌸

#include <libeconf.h>

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

πŸ¦‹ DESCRIPTION πŸ¦‹

so the econf_newKeyFile_with_options() function does the thing: it makes a new, empty econf_file object and tucks it safely into *result. ✨

options is a string of <key>=<value> pairs, separated by ';' β€” like "JOIN_SAME_ENTRIES=1". if options is NULL or just an empty string, no stress: the new econf_file object gets created with the default settings described down below. 🫢

these are the options that are supported:

  • JOIN_SAME_ENTRIES (default 0) β€” parsed entries that have the same name won't get replaced; instead they get joined into one entry. no cap, they're bonding. 🀝
  • PYTHON_STYLE (default 0) β€” indentations get handled like multiline entries. very python-coded of them. 🐍
  • DEFAULT_QUOTES (default 0) β€” entries that are newly created (think: via econf_setStringValue()) and not read from a file will have their value wrapped in quotes when the econf_file gets written out to a file. and this default can be overridden per entry with econf_setQuotes(). πŸ’…
  • PARSING_DIRS (default /usr/etc/:/run:/etc) β€” the list of directories that the configuration files have to be parsed from. the list is one string, divided by ':'. the last entry has the highest priority. e.g.: "PARSING_DIRS=/usr/etc/:/run:/etc". πŸ‘‘
  • CONFIG_DIRS (default empty) β€” the list of directory structures (with order) that describes the directories where the files have to be parsed. the list is one string, divided by ':'. the last entry has the highest priority. so like, with the list "CONFIG_DIRS=.conf.d:.d", files in these directories get parsed: ⬇️
<default_dirs>/<config_name>.conf.d/
<default_dirs>/<config_name>.d/
<default_dirs>/<config_name>/
  • ROOT_PREFIX (default empty) β€” a directory prefix used for all search directories, if specified. 🌈

πŸŽ€ RETURN VALUE πŸŽ€

if everything slays, this function returns ECONF_SUCCESS and stores the newly created econf_file object in *result. πŸ’–

but if there's an error, a non-zero error code comes back (peep the β€œERRORS” section below πŸ‘€), and *result may be set to NULL. 😭


πŸ’€ ERRORS πŸ’€

  • ECONF_NOMEM β€” not enough memory to allocate the new econf_file object, or one of its internal lists. the malloc said nope. πŸ™ˆ
  • ECONF_OPTION_NOT_FOUND β€” options contains a key that isn't a known option. bestie, that flag doesn't exist. 🚫

⭐ 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)


okay that's the whole page, go forth and make key files 🌸 β€” this was libeconf, dated 2026-10-15, version libeconf (yes the source and the version are the same word, iconic honestly). mwah, bye bestie πŸ’œπŸ«Ά

πŸ“¦ where this page comes from