libeconf 0.7.6
libeconf.h File Reference

Public API for the econf library. More...

#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>

Go to the source code of this file.

Macros

#define econf_setValue(kf, group, key, value)
 Generic macro calls setter function depending on value type.
 
#define econf_free(value)
 Generic macro to free memory allocated by econf_ functions.
 

Typedefs

typedef enum econf_err econf_err
 
typedef struct econf_file econf_file
 

Enumerations

enum  econf_err {
  ECONF_SUCCESS = 0 , ECONF_ERROR = 1 , ECONF_NOMEM = 2 , ECONF_NOFILE = 3 ,
  ECONF_NOGROUP = 4 , ECONF_NOKEY = 5 , ECONF_EMPTYKEY = 6 , ECONF_WRITEERROR = 7 ,
  ECONF_PARSE_ERROR = 8 , ECONF_MISSING_BRACKET = 9 , ECONF_MISSING_DELIMITER = 10 , ECONF_EMPTY_SECTION_NAME = 11 ,
  ECONF_TEXT_AFTER_SECTION = 12 , ECONF_FILE_LIST_IS_NULL = 13 , ECONF_WRONG_BOOLEAN_VALUE = 14 , ECONF_KEY_HAS_NULL_VALUE = 15 ,
  ECONF_WRONG_OWNER = 16 , ECONF_WRONG_GROUP = 17 , ECONF_WRONG_FILE_PERMISSION = 18 , ECONF_WRONG_DIR_PERMISSION = 19 ,
  ECONF_ERROR_FILE_IS_SYM_LINK = 20 , ECONF_PARSING_CALLBACK_FAILED = 21 , ECONF_ARGUMENT_IS_NULL_VALUE = 22 , ECONF_OPTION_NOT_FOUND = 23 ,
  ECONF_VALUE_CONVERSION_ERROR = 24
}
 libeconf error codes More...
 

Functions

econf_err econf_readFile (econf_file **result, const char *file_name, const char *delim, const char *comment)
 Process the file of the given file_name and save its contents into key_file object.
 
econf_err econf_readFileWithCallback (econf_file **result, const char *file_name, const char *delim, const char *comment, bool(*callback)(const char *filename, const void *data), const void *callback_data)
 Process the file of the given file_name and save its contents into key_file object.
 
econf_err econf_mergeFiles (econf_file **merged_file, econf_file *usr_file, econf_file *etc_file)
 Merge the contents of two key_files objects.
 
econf_err econf_readConfig (econf_file **key_file, const char *project, const char *usr_subdir, const char *config_name, const char *config_suffix, const char *delim, const char *comment)
 Evaluating key/values of a given configuration by reading and merging all needed/available files from different directories.
 
econf_err econf_readConfigWithCallback (econf_file **key_file, const char *project, const char *usr_subdir, const char *config_name, const char *config_suffix, const char *delim, const char *comment, bool(*callback)(const char *filename, const void *data), const void *callback_data)
 Evaluating key/values of a given configuration by reading and merging all needed/available files from different directories.
 
econf_err econf_readDirs (econf_file **key_file, const char *usr_conf_dir, const char *etc_conf_dir, const char *config_name, const char *config_suffix, const char *delim, const char *comment)
 Evaluating key/values of a given configuration by reading and merging all needed/available files in two different directories (normally in /usr/etc and /etc).
 
econf_err econf_readDirsWithCallback (econf_file **key_file, const char *usr_conf_dir, const char *etc_conf_dir, const char *config_name, const char *config_suffix, const char *delim, const char *comment, bool(*callback)(const char *filename, const void *data), const void *callback_data)
 Evaluating key/values for every given configuration files in two different directories (normally in /usr/etc and /etc).
 
econf_err econf_readDirsHistory (econf_file ***key_files, size_t *size, const char *usr_conf_dir, const char *etc_conf_dir, const char *config_name, const char *config_suffix, const char *delim, const char *comment)
 Evaluating key/values for every given configuration files in two different directories (normally in /usr/etc and /etc).
 
econf_err econf_readDirsHistoryWithCallback (econf_file ***key_files, size_t *size, const char *usr_conf_dir, const char *etc_conf_dir, const char *config_name, const char *config_suffix, const char *delim, const char *comment, bool(*callback)(const char *filename, const void *data), const void *callback_data)
 Evaluating key/values for every given configuration files in two different directories (normally in /usr/etc and /etc).
 
econf_err econf_newKeyFile (econf_file **result, char delimiter, char comment)
 Create a new econf_file object.
 
econf_err econf_newKeyFile_with_options (econf_file **result, const char *options)
 Create a new econf_file object with special options.
 
econf_err econf_newIniFile (econf_file **result)
 Create a new econf_file object in IniFile format.
 
char econf_comment_tag (econf_file *key_file)
 Returns the comment character tag of the given econf_file object.
 
char econf_delimiter_tag (econf_file *key_file)
 Returns the delimiter character of the given econf_file object.
 
void econf_set_comment_tag (econf_file *key_file, const char comment)
 Set the comment character tag of the given econf_file object.
 
void econf_set_delimiter_tag (econf_file *key_file, const char delimiter)
 Set the delimiter character of the given econf_file object.
 
econf_err econf_writeFile (econf_file *key_file, const char *save_to_dir, const char *file_name)
 Write content of an econf_file struct to specified location.
 
char * econf_getPath (econf_file *kf)
 Evaluating path name.
 
econf_err econf_getGroups (econf_file *kf, size_t *length, char ***groups)
 Evaluating all group entries.
 
econf_err econf_getKeys (econf_file *kf, const char *group, size_t *length, char ***keys)
 Evaluating all keys.
 
econf_err econf_getIntValue (econf_file *kf, const char *group, const char *key, int32_t *result)
 Evaluating int32 value for given group/key.
 
econf_err econf_getInt64Value (econf_file *kf, const char *group, const char *key, int64_t *result)
 Evaluating int64 value for given group/key.
 
econf_err econf_getUIntValue (econf_file *kf, const char *group, const char *key, uint32_t *result)
 Evaluating uint32 value for given group/key.
 
econf_err econf_getUInt64Value (econf_file *kf, const char *group, const char *key, uint64_t *result)
 Evaluating uint64 value for given group/key.
 
econf_err econf_getFloatValue (econf_file *kf, const char *group, const char *key, float *result)
 Evaluating float value for given group/key.
 
econf_err econf_getDoubleValue (econf_file *kf, const char *group, const char *key, double *result)
 Evaluating double value for given group/key.
 
econf_err econf_getStringValue (econf_file *kf, const char *group, const char *key, char **result)
 Evaluating string value for given group/key.
 
econf_err econf_getBoolValue (econf_file *kf, const char *group, const char *key, bool *result)
 Evaluating bool value for given group/key.
 
econf_err econf_getIntValueDef (econf_file *kf, const char *group, const char *key, int32_t *result, int32_t def)
 Evaluating int32 value for given group/key.
 
econf_err econf_getInt64ValueDef (econf_file *kf, const char *group, const char *key, int64_t *result, int64_t def)
 Evaluating int64 value for given group/key.
 
econf_err econf_getUIntValueDef (econf_file *kf, const char *group, const char *key, uint32_t *result, uint32_t def)
 Evaluating uint32 value for given group/key.
 
econf_err econf_getUInt64ValueDef (econf_file *kf, const char *group, const char *key, uint64_t *result, uint64_t def)
 Evaluating uint64 value for given group/key.
 
econf_err econf_getFloatValueDef (econf_file *kf, const char *group, const char *key, float *result, float def)
 Evaluating float value for given group/key.
 
econf_err econf_getDoubleValueDef (econf_file *kf, const char *group, const char *key, double *result, double def)
 Evaluating double value for given group/key.
 
econf_err econf_getStringValueDef (econf_file *kf, const char *group, const char *key, char **result, char *def)
 Evaluating string value for given group/key.
 
econf_err econf_getBoolValueDef (econf_file *kf, const char *group, const char *key, bool *result, bool def)
 Evaluating bool value for given group/key.
 
econf_err econf_setIntValue (econf_file *kf, const char *group, const char *key, int32_t value)
 Set int32 value for given group/key.
 
econf_err econf_setInt64Value (econf_file *kf, const char *group, const char *key, int64_t value)
 Set int64 value for given group/key.
 
econf_err econf_setUIntValue (econf_file *kf, const char *group, const char *key, uint32_t value)
 Set uint32 value for given group/key.
 
econf_err econf_setUInt64Value (econf_file *kf, const char *group, const char *key, uint64_t value)
 Set uint64 value for given group/key.
 
econf_err econf_setFloatValue (econf_file *kf, const char *group, const char *key, float value)
 Set float value for given group/key.
 
econf_err econf_setDoubleValue (econf_file *kf, const char *group, const char *key, double value)
 Set double value for given group/key.
 
econf_err econf_setStringValue (econf_file *kf, const char *group, const char *key, const char *value)
 Set string value for given group/key.
 
econf_err econf_setBoolValue (econf_file *kf, const char *group, const char *key, const char *value)
 Set bool value for given group/key.
 
const char * econf_errString (const econf_err error)
 Convert an econf_err type to a string.
 
void econf_errLocation (char **filename, uint64_t *line_nr)
 Info about where the error has happened.
 
char ** econf_freeArray (char **array)
 Free an array of type char** created by econf_getGroups() or econf_getKeys().
 
static __inline__ void econf_freeArrayp (char ***array)
 
econf_fileeconf_freeFile (econf_file *key_file)
 Free memory allocated and returned by econf_readFile(), econf_readFileWithCallback, econf_readDirs(), econf_readDirsWithCallback, econf_readDirsHistory, econf_readDirsHistoryWithCallback, econf_readConfig, econf_readConfigWithCallback.
 
static __inline__ void econf_freeFilep (econf_file **key_file)
 
void econf_requireOwner (uid_t owner)
 All parsed files require this user permission.
 
void econf_requireGroup (gid_t group)
 All parsed files require this group permission.
 
void econf_requirePermissions (mode_t file_perms, mode_t dir_perms)
 All parsed file have to have these file and directory permissions.
 
void econf_followSymlinks (bool allow)
 Allowing the parser to follow sym links (default: true).
 
void econf_reset_security_settings (void)
 Reset all UID, GID, permissions,... restrictions for parsed files/dirs.
 
econf_err econf_set_conf_dirs (const char **dir_postfix_list)
 Set a list of directory structures (with order) which describes the directories in which the files have to be parsed.
 

Detailed Description

Public API for the econf library.

Definition in file libeconf.h.

Macro Definition Documentation

◆ econf_setValue

#define econf_setValue (   kf,
  group,
  key,
  value 
)
Value:
(( \
_Generic((value), \
unsigned int: econf_setUIntValue, \
unsigned long: econf_setUInt64Value, \
(kf, group, key, value))
econf_err econf_setUInt64Value(econf_file *kf, const char *group, const char *key, uint64_t value)
Set uint64 value for given group/key.
econf_err econf_setDoubleValue(econf_file *kf, const char *group, const char *key, double value)
Set double value for given group/key.
econf_err econf_setInt64Value(econf_file *kf, const char *group, const char *key, int64_t value)
Set int64 value for given group/key.
econf_err econf_setUIntValue(econf_file *kf, const char *group, const char *key, uint32_t value)
Set uint32 value for given group/key.
econf_err econf_setStringValue(econf_file *kf, const char *group, const char *key, const char *value)
Set string value for given group/key.
econf_err econf_setFloatValue(econf_file *kf, const char *group, const char *key, float value)
Set float value for given group/key.
econf_err econf_setIntValue(econf_file *kf, const char *group, const char *key, int32_t value)
Set int32 value for given group/key.

Generic macro calls setter function depending on value type.

Use: econf_setValue(econf_file *key_file, char *group, char *key, generic value);

Replace generic with one of the supported value types. Supported Types: int, long, unsigned int, unsigned long, float, double, string (as *char). Note: Does not detect "yes", "no", 1 and 0 as boolean type. If you want to set a bool value use "true" or "false" or use setBoolValue() directly.

Definition at line 106 of file libeconf.h.

◆ econf_free

#define econf_free (   value)
Value:
(( \
_Generic((value), \
char**: econf_freeArray)) \
(value))
struct econf_file econf_file
Definition libeconf.h:129
econf_file * econf_freeFile(econf_file *key_file)
Free memory allocated and returned by econf_readFile(), econf_readFileWithCallback,...
char ** econf_freeArray(char **array)
Free an array of type char** created by econf_getGroups() or econf_getKeys().

Generic macro to free memory allocated by econf_ functions.

Use: econf_free(generic value);

Replace generic with one of the supported value types. Supported Types: char** and econf_file*.

Definition at line 123 of file libeconf.h.

Typedef Documentation

◆ econf_err

typedef enum econf_err econf_err

Definition at line 94 of file libeconf.h.

◆ econf_file

typedef struct econf_file econf_file

Definition at line 129 of file libeconf.h.

Enumeration Type Documentation

◆ econf_err

enum econf_err

libeconf error codes

Enumerator
ECONF_SUCCESS 

General purpose success code.

ECONF_ERROR 

Generic Error.

ECONF_NOMEM 

Out of memory.

ECONF_NOFILE 

Config file not found.

ECONF_NOGROUP 

Group not found.

ECONF_NOKEY 

Key not found.

ECONF_EMPTYKEY 

Key is NULL or has empty value.

ECONF_WRITEERROR 

Error creating or writing to a file.

ECONF_PARSE_ERROR 

General syntax error in input file.

ECONF_MISSING_BRACKET 

Missing closing section bracket.

ECONF_MISSING_DELIMITER 

Missing delimiter.

ECONF_EMPTY_SECTION_NAME 

Empty section name.

ECONF_TEXT_AFTER_SECTION 

Text after section.

ECONF_FILE_LIST_IS_NULL 

Parsed file list is NULL.

ECONF_WRONG_BOOLEAN_VALUE 

Wrong boolean value (1/0 true/false yes/no)

ECONF_KEY_HAS_NULL_VALUE 

Given key has NULL value.

ECONF_WRONG_OWNER 

File has wrong owner.

ECONF_WRONG_GROUP 

File has wrong group.

ECONF_WRONG_FILE_PERMISSION 

File has wrong file permissions.

ECONF_WRONG_DIR_PERMISSION 

File has wrong dir permission.

ECONF_ERROR_FILE_IS_SYM_LINK 

File is a sym link which is not permitted.

ECONF_PARSING_CALLBACK_FAILED 

User defined parsing callback has failed.

ECONF_ARGUMENT_IS_NULL_VALUE 

Given argument is NULL.

ECONF_OPTION_NOT_FOUND 

Given option not found.

ECONF_VALUE_CONVERSION_ERROR 

Value cannot be converted.

Definition at line 41 of file libeconf.h.

Function Documentation

◆ econf_readFile()

econf_err econf_readFile ( econf_file **  result,
const char *  file_name,
const char *  delim,
const char *  comment 
)
extern

Process the file of the given file_name and save its contents into key_file object.

Parameters
resultcontent of parsed file.
file_nameabsolute path of parsed file
delimdelimiters of key/value e.g. "\t =". If delim contains space characters AND none space characters, multiline values are not parseable.
commentarray of characters which define the start of a comment
Returns
econf_err ECONF_SUCCESS or error code

Usage:

#include "libeconf.h"
econf_file *key_file = NULL;
econf_err error;
error = econf_readFile (&key_file, "/etc/test.conf", "=", "#");
econf_free (key_file);
key_file = NULL;
Public API for the econf library.
#define econf_free(value)
Generic macro to free memory allocated by econf_ functions.
Definition libeconf.h:123
econf_err
libeconf error codes
Definition libeconf.h:41
econf_err econf_readFile(econf_file **result, const char *file_name, const char *delim, const char *comment)
Process the file of the given file_name and save its contents into key_file object.

◆ econf_readFileWithCallback()

econf_err econf_readFileWithCallback ( econf_file **  result,
const char *  file_name,
const char *  delim,
const char *  comment,
bool(*)(const char *filename, const void *data)  callback,
const void *  callback_data 
)
extern

Process the file of the given file_name and save its contents into key_file object.

The user defined function will be called in order e.g. to check the correct file permissions.

Parameters
resultcontent of parsed file.
file_nameabsolute path of parsed file
delimdelimiters of key/value e.g. "\t =". If delim contains space characters AND none space characters, multiline values are not parseable.
commentarray of characters which define the start of a comment
callbackfunction which will be called for the given filename. This user defined function has the pathname as parameter and returns true if this file can be parsed. If not, the parsing will be aborted and ECONF_PARSING_CALLBACK_FAILED will be returned.
callback_datapointer which will be given to the callback function.
Returns
econf_err ECONF_SUCCESS or error code

Usage:

#include "libeconf.h"
bool checkFile(const char *filename, const void *data) {
- checking code which returns true or false -
return true;
}
econf_file *key_file = NULL;
econf_err error;
error = econf_readFileWithCallback (&key_file, "/etc/test.conf", "=", "#", checkFile, NULL);
econf_free (key_file);
key_file = NULL;
econf_err econf_readFileWithCallback(econf_file **result, const char *file_name, const char *delim, const char *comment, bool(*callback)(const char *filename, const void *data), const void *callback_data)
Process the file of the given file_name and save its contents into key_file object.

Default behaviour if entries have the same name in one file: The first hit will be returned. Further entries will be ignored. This can be changed by setting the option JOIN_SAME_ENTRIES (see econf_newKeyFile_with_options). In that case entries with the same name will be joined to one single entry.

◆ econf_mergeFiles()

econf_err econf_mergeFiles ( econf_file **  merged_file,
econf_file usr_file,
econf_file etc_file 
)
extern

Merge the contents of two key_files objects.

Entries in etc_file will be preferred. Comment and delimiter tag will be taken from usr_file. This can be changed by calling the functions econf_set_comment_tag and econf_set_delimiter_tag.

Parameters
merged_filemerged data
usr_fileFirst data block which has to be merged.
etc_fileSecond data block which has to be merged.
Returns
econf_err ECONF_SUCCESS or error code

Usage:

#include "libeconf.h"
econf_file *key_file_1 = NULL, *key_file_2 = NULL, *key_file_ret = NULL
econf_err error;
error = econf_readFile (&key_file1, "/usr/etc/test.conf", "=", "#");
error = econf_readFile (&key_file2, /etc/test.conf", "=", "#");
error = econf_mergeFiles (&key_file_ret, key_file_1, key_file_2);
econf_free (key_file_ret);
econf_free (key_file_1);
econf_free (key_file_2);

◆ econf_readConfig()

econf_err econf_readConfig ( econf_file **  key_file,
const char *  project,
const char *  usr_subdir,
const char *  config_name,
const char *  config_suffix,
const char *  delim,
const char *  comment 
)
extern

Evaluating key/values of a given configuration by reading and merging all needed/available files from different directories.

Order is:

/etc/$project/$config_name.$config_suffix does exist:

  • /etc/$project/$config_name.$config_suffix
  • /run/$project/$config_name.$config_suffix.d/ *.$config_suffix
  • $usr_subdir/$project/$config_name.$config_suffix.d/ *.$config_suffix
  • /etc/$project/$config_name.$config_suffix.d/ *.$config_suffix

/etc/$project/$config_name.$config_suffix does NOT exist:

/run/$project/$config_name.$config_suffix does exist:

  • /run/$project/$config_name.$config_suffix
  • /run/$project/$config_name.$config_suffix.d/ *.$config_suffix
  • $usr_subdir/$project/$config_name.$config_suffix.d/ *.$config_suffix
  • /etc/$project/$config_name.$config_suffix.d/ *.$config_suffix

/run/$project/$config_name.$config_suffix does NOT exist:

  • $usr_subdir/$project/$config_name.$config_suffix
  • /run/$project/$config_name.$config_suffix.d/ *.$config_suffix
  • $usr_subdir/$project/$config_name.$config_suffix.d/ *.$config_suffix
  • /etc/$project/$config_name.$config_suffix.d/ *.$config_suffix

No main $config_name.$config_suffix file is defined or must not be parsed:

  • $usr_subdir/$project.d/ *.$config_suffix
  • /run/$project.d/ *.$config_suffix
  • /etc/$project.d/ *.$config_suffix

This call fulfills all requirements, defined by the Linux Userspace API (UAPI) Group chapter "Configuration Files Specification". See: https://uapi-group.org/specifications/specs/configuration_files_specification/

Parameters
key_filecontent of parsed file(s). MUST be initialized (e.g. with NULL).
projectname of the project used as subdirectory, can be NULL
usr_subdirabsolute path of the first directory (often "/usr/lib")
config_namebasename of the configuration file. If it is NULL, drop-ins without a main configuration file will be parsed only.
config_suffixsuffix of the configuration file. Can also be NULL.
delimdelimiters of key/value e.g. "\t =" If delim contains space characters AND none space characters, multiline values are not parseable.
commentarray of characters which define the start of a comment
Returns
econf_err ECONF_SUCCESS or error code

Example: Reading content in different cases in following order:

/etc/foo/example.conf does exist:

  • /etc/foo/example.conf
  • /usr/lib/foo/example.conf.d/ *.conf
  • /run/foo/example.conf.d/ *.conf
  • /etc/foo/example.conf.d/ *.conf

/etc/foo/example.conf does NOT exist:

/run/foo/example.conf does exist:

  • /run/foo/example.conf
  • /usr/lib/foo/example.conf.d/ *.conf
  • /run/foo/example.conf.d/ *.conf
  • /etc/foo/example.conf.d/ *.conf

/run/foo/example.conf does NOT exist:

  • /usr/lib/foo/example.conf
  • /usr/lib/foo/example.conf.d/ *.conf
  • /run/foo/example.conf.d/ *.conf
  • /etc/foo/example.conf.d/ *.conf
#include "libeconf.h"
econf_file *key_file = NULL;
econf_err error;
error = econf_readConfig (&key_file,
"foo",
"/usr/lib",
"example",
"conf",
"=", "#");
econf_free (key_file);
key_file = NULL;
econf_err econf_readConfig(econf_file **key_file, const char *project, const char *usr_subdir, const char *config_name, const char *config_suffix, const char *delim, const char *comment)
Evaluating key/values of a given configuration by reading and merging all needed/available files from...

It is also possible to set additional options for e.g. parsing config files which has python style format or defining the order how to parse the configuration files. For more information have a look to econf_newKeyFile_with_options.

◆ econf_readConfigWithCallback()

econf_err econf_readConfigWithCallback ( econf_file **  key_file,
const char *  project,
const char *  usr_subdir,
const char *  config_name,
const char *  config_suffix,
const char *  delim,
const char *  comment,
bool(*)(const char *filename, const void *data)  callback,
const void *  callback_data 
)
extern

Evaluating key/values of a given configuration by reading and merging all needed/available files from different directories.

Order is:

/etc/$project/$config_name.$config_suffix does exist:

  • /etc/$project/$config_name.$config_suffix
  • $usr_subdir/$project/$config_name.$config_suffix.d/ *.$config_suffix
  • /run/$project/$config_name.$config_suffix.d/ *.$config_suffix
  • /etc/$project/$config_name.$config_suffix.d/ *.$config_suffix

/etc/$project/$config_name.$config_suffix does NOT exist:

/run/$project/$config_name.$config_suffix does exist:

  • /run/$project/$config_name.$config_suffix
  • $usr_subdir/$project/$config_name.$config_suffix.d/ *.$config_suffix
  • /run/$project/$config_name.$config_suffix.d/ *.$config_suffix
  • /etc/$project/$config_name.$config_suffix.d/ *.$config_suffix

/run/$project/$config_name.$config_suffix does NOT exist:

  • $usr_subdir/$project/$config_name.$config_suffix
  • $usr_subdir/$project/$config_name.$config_suffix.d/ *.$config_suffix
  • /run/$project/$config_name.$config_suffix.d/ *.$config_suffix
  • /etc/$project/$config_name.$config_suffix.d/ *.$config_suffix

No main $config_name.$config_suffix file is defined or must not be parsed:

  • $usr_subdir/$project.d/ *.$config_suffix
  • /run/$project.d/ *.$config_suffix
  • /etc/$project.d/ *.$config_suffix

For each parsed file the user defined function will be called in order e.g. to check the correct file permissions.

This call fulfills all requirements, defined by the Linux Userspace API (UAPI) Group chapter "Configuration Files Specification". See: https://uapi-group.org/specifications/specs/configuration_files_specification/

Parameters
key_filecontent of parsed file(s). MUST be initialized (e.g. with NULL).
projectname of the project used as subdirectory, can be NULL
usr_subdirabsolute path of the first directory (often "/usr/lib")
config_namebasename of the configuration file If it is NULL, drop-ins without a main configuration file will be parsed only.
config_suffixsuffix of the configuration file. Can also be NULL.
delimdelimiters of key/value e.g. "\t =" If delim contains space characters AND none space characters, multiline values are not parseable.
commentarray of characters which define the start of a comment
callbackfunction which will be called for each file. This user defined function has the pathname as parameter and returns true if this file can be parsed. If not, the parsing of all files will be aborted and ECONF_PARSING_CALLBACK_FAILED will be returned.
callback_datapointer which will be given to the callback function.
Returns
econf_err ECONF_SUCCESS or error code

Example: Reading content in different cases in following order:

/etc/foo/example.conf does exist:

  • /etc/foo/example.conf
  • /usr/lib/foo/example.conf.d/ *.conf
  • /run/foo/example.conf.d/ *.conf
  • /etc/foo/example.conf.d/ *.conf

/etc/foo/example.conf does NOT exist:

/run/foo/example.conf does exist:

  • /run/foo/example.conf
  • /usr/lib/foo/example.conf.d/ *.conf
  • /run/foo/example.conf.d/ *.conf
  • /etc/foo/example.conf.d/ *.conf

/run/foo/example.conf does NOT exist:

  • /usr/lib/foo/example.conf
  • /usr/lib/foo/example.conf.d/ *.conf
  • /run/foo/example.conf.d/ *.conf
  • /etc/foo/example.conf.d/ *.conf
#include "libeconf.h"
bool checkFile(const char *filename, const void *data) {
- checking code which returns true or false -
return true;
}
econf_file *key_file = NULL;
econf_err error;
error = econf_readConfigWithCallback (&key_file,
"foo",
"/usr/lib",
"example",
"conf",
"=", "#",
checkFile,
NULL);
econf_free (key_file);
key_file = NULL;
econf_err econf_readConfigWithCallback(econf_file **key_file, const char *project, const char *usr_subdir, const char *config_name, const char *config_suffix, const char *delim, const char *comment, bool(*callback)(const char *filename, const void *data), const void *callback_data)
Evaluating key/values of a given configuration by reading and merging all needed/available files from...

It is also possible to set additional options for e.g. parsing config files which has python style format or defining the order how to parse the configuration files. For more information have a look to econf_newKeyFile_with_options.

◆ econf_readDirs()

econf_err econf_readDirs ( econf_file **  key_file,
const char *  usr_conf_dir,
const char *  etc_conf_dir,
const char *  config_name,
const char *  config_suffix,
const char *  delim,
const char *  comment 
)
extern

Evaluating key/values of a given configuration by reading and merging all needed/available files in two different directories (normally in /usr/etc and /etc).

DEPRECATED: Use the econf_readConfig/econf_readConfigWithCallback instead.

Parameters
key_filecontent of parsed file(s).
usr_conf_dirabsolute path of the first directory (normally "/usr/etc")
etc_conf_dirabsolute path of the second directory (normally "/etc")
config_namebasename of the configuration file
config_suffixsuffix of the configuration file. Can also be NULL.
delimdelimiters of key/value e.g. "\t =" If delim contains space characters AND none space characters, multiline values are not parseable.
commentarray of characters which define the start of a comment
Returns
econf_err ECONF_SUCCESS or error code

Example: Reading content of example.conf in /usr/etc and /etc directory.

#include "libeconf.h"
econf_file *key_file = NULL;
econf_err error;
error = econf_readDirs (&key_file,
"/usr/etc",
"/etc",
"example",
"conf",
"=", "#");
econf_free (key_file);
key_file = NULL;
econf_err econf_readDirs(econf_file **key_file, const char *usr_conf_dir, const char *etc_conf_dir, const char *config_name, const char *config_suffix, const char *delim, const char *comment)
Evaluating key/values of a given configuration by reading and merging all needed/available files in t...

◆ econf_readDirsWithCallback()

econf_err econf_readDirsWithCallback ( econf_file **  key_file,
const char *  usr_conf_dir,
const char *  etc_conf_dir,
const char *  config_name,
const char *  config_suffix,
const char *  delim,
const char *  comment,
bool(*)(const char *filename, const void *data)  callback,
const void *  callback_data 
)
extern

Evaluating key/values for every given configuration files in two different directories (normally in /usr/etc and /etc).

For each parsed file the user defined function will be called in order e.g. to check the correct file permissions. DEPRECATED: Use the econf_readConfig/econf_readConfigWithCallback instead.

Parameters
key_filecontent of parsed file(s).
usr_conf_dirabsolute path of the first directory (normally "/usr/etc")
etc_conf_dirabsolute path of the second directory (normally "/etc")
config_namebasename of the configuration file
config_suffixsuffix of the configuration file. Can also be NULL.
delimdelimiters of key/value e.g. "\t =" If delim contains space characters AND none space characters, multiline values are not parseable.
commentarray of characters which define the start of a comment
callbackfunction which will be called for each file. This user defined function has the pathname as parameter and returns true if this file can be parsed. If not, the parsing of all files will be aborted and ECONF_PARSING_CALLBACK_FAILED will be returned.
callback_datapointer which will be given to the callback function.
Returns
econf_err ECONF_SUCCESS or error code

Example: Reading content of example.conf in /usr/etc and /etc directory.

#include "libeconf.h"
bool checkFile(const char *filename, const void *data) {
- checking code which returns true or false -
return true;
}
econf_file *key_file = NULL;
econf_err error;
error = econf_readDirsWithCallback (&key_file,
"/usr/etc",
"/etc",
"example",
"conf",
"=", "#",
checkFile,
NULL);
econf_free (key_file);
key_file = NULL;
econf_err econf_readDirsWithCallback(econf_file **key_file, const char *usr_conf_dir, const char *etc_conf_dir, const char *config_name, const char *config_suffix, const char *delim, const char *comment, bool(*callback)(const char *filename, const void *data), const void *callback_data)
Evaluating key/values for every given configuration files in two different directories (normally in /...

◆ econf_readDirsHistory()

econf_err econf_readDirsHistory ( econf_file ***  key_files,
size_t *  size,
const char *  usr_conf_dir,
const char *  etc_conf_dir,
const char *  config_name,
const char *  config_suffix,
const char *  delim,
const char *  comment 
)
extern

Evaluating key/values for every given configuration files in two different directories (normally in /usr/etc and /etc).

Returns a list of read configuration files and their values.

Parameters
key_fileslist of parsed file(s). Each entry includes all key/value, path, comments,... information of the regarding file.
sizeSize of the evaluated key_files list.
usr_conf_dirabsolute path of the first directory (normally "/usr/etc")
etc_conf_dirabsolute path of the second directory (normally "/etc")
config_namebasename of the configuration file
config_suffixsuffix of the configuration file. Can also be NULL.
delimdelimiters of key/value e.g. "\t =" If delim contains space characters AND none space characters, multiline values are not parseable.
commentarray of characters which define the start of a comment
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_readDirsHistoryWithCallback()

econf_err econf_readDirsHistoryWithCallback ( econf_file ***  key_files,
size_t *  size,
const char *  usr_conf_dir,
const char *  etc_conf_dir,
const char *  config_name,
const char *  config_suffix,
const char *  delim,
const char *  comment,
bool(*)(const char *filename, const void *data)  callback,
const void *  callback_data 
)
extern

Evaluating key/values for every given configuration files in two different directories (normally in /usr/etc and /etc).

For each parsed file the user defined function will be called in order e.g. to check the correct file permissions. Returns a list of read configuration files and their values.

Parameters
key_fileslist of parsed file(s). Each entry includes all key/value, path, comments,... information of the regarding file.
sizeSize of the evaluated key_files list.
usr_conf_dirabsolute path of the first directory (normally "/usr/etc")
etc_conf_dirabsolute path of the second directory (normally "/etc")
config_namebasename of the configuration file
config_suffixsuffix of the configuration file. Can also be NULL.
delimdelimiters of key/value e.g. "\t =" If delim contains space characters AND none space characters, multiline values are not parseable.
commentarray of characters which define the start of a comment
callbackfunction which will be called for each file. This user defined function has the pathname as parameter and returns true if this file can be parsed. If not, the parsing of all files will be aborted and ECONF_PARSING_CALLBACK_FAILED will be returned.
callback_datapointer which will be given to the callback function.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_newKeyFile()

econf_err econf_newKeyFile ( econf_file **  result,
char  delimiter,
char  comment 
)
extern

Create a new econf_file object.

Parameters
resultPointer to the allocated econf_file object.
delimiterdelimiter of key/value e.g. "="
commentCharacter which defines the start of a comment.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_newKeyFile_with_options()

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

Create a new econf_file object with special options.

Parameters
resultPointer to the allocated econf_file object.
optionsdefined as a string separated by ";" format "<key>=<value>"; e.g. "JOIN_SAME_ENTRIES=1"
Returns
econf_err ECONF_SUCCESS or error code

Following options are supported: JOIN_SAME_ENTRIES (default 0) Parsed entries with the same name will not be replaces but will be joined to one entry. PYTHON_STYLE (default 0) E.G. Identations will be handled like multiline entries. PARSING_DIRS (default /usr/etc/:/run:/etc) List of directories from which the configuration files have to be parsed. The list is a string, divides 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, divides by ":". The last entry has the highest priority. E.g. with the given list: "CONFIG_DIRS=.conf.d:.d" files in 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.

e.g. Parsing configuration files written in python style:

#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;
const char * econf_errString(const econf_err error)
Convert an econf_err type to a string.
econf_err econf_newKeyFile_with_options(econf_file **result, const char *options)
Create a new econf_file object with special options.

◆ econf_newIniFile()

econf_err econf_newIniFile ( econf_file **  result)
extern

Create a new econf_file object in IniFile format.

So the delimiter will be "=" and comments are beginning with "#".

Parameters
resultPointer to the allocated econf_file object.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_comment_tag()

char econf_comment_tag ( econf_file key_file)
extern

Returns the comment character tag of the given econf_file object.

This tag will be taken while writing comments to file.

Parameters
key_fileeconf_file object.
Returns
char comment character tag

◆ econf_delimiter_tag()

char econf_delimiter_tag ( econf_file key_file)
extern

Returns the delimiter character of the given econf_file object.

This delimiter will be taken while writing the data to file.

Parameters
key_fileeconf_file object.
Returns
char delimiter of key/value

◆ econf_set_comment_tag()

void econf_set_comment_tag ( econf_file key_file,
const char  comment 
)
extern

Set the comment character tag of the given econf_file object.

This tag will be taken while writing comments to file.

Parameters
key_fileeconf_file object.
commentcomment tag

◆ econf_set_delimiter_tag()

void econf_set_delimiter_tag ( econf_file key_file,
const char  delimiter 
)
extern

Set the delimiter character of the given econf_file object.

This delimiter will be taken while writing the data to file.

Parameters
key_fileeconf_file object.
delimiterdelimiter of key/value

◆ econf_writeFile()

econf_err econf_writeFile ( econf_file key_file,
const char *  save_to_dir,
const char *  file_name 
)
extern

Write content of an econf_file struct to specified location.

Parameters
key_fileData which has to be written.
save_to_dirDirectory into which the file has to be written.
file_namefilename (with suffix)
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getPath()

char * econf_getPath ( econf_file kf)
extern

Evaluating path name.

Parameters
kfgiven/parsed data
Returns
Absolute path name or an empty string if kf is a result of already merged data (e.G. returned by econf_readDirs).

◆ econf_getGroups()

econf_err econf_getGroups ( econf_file kf,
size_t *  length,
char ***  groups 
)
extern

Evaluating all group entries.

Parameters
kfgiven/parsed data
lengthLength of the returned group array.
groupsString array of evaluated groups.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getKeys()

econf_err econf_getKeys ( econf_file kf,
const char *  group,
size_t *  length,
char ***  keys 
)
extern

Evaluating all keys.

Parameters
kfgiven/parsed data
groupGroup name for which the keys have to be evaluated or NULL for all keys.
lengthLength of the returned key array.
keysString array of evaluated keys.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getIntValue()

econf_err econf_getIntValue ( econf_file kf,
const char *  group,
const char *  key,
int32_t *  result 
)
extern

Evaluating int32 value for given group/key.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value is requested.
resultdetermined value
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getInt64Value()

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

Evaluating int64 value for given group/key.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value is requested.
resultdetermined value
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getUIntValue()

econf_err econf_getUIntValue ( econf_file kf,
const char *  group,
const char *  key,
uint32_t *  result 
)
extern

Evaluating uint32 value for given group/key.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value is requested.
resultdetermined value
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getUInt64Value()

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

Evaluating uint64 value for given group/key.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value is requested.
resultdetermined value
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getFloatValue()

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

Evaluating float value for given group/key.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value is requested.
resultdetermined value
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getDoubleValue()

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

Evaluating double value for given group/key.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value is requested.
resultdetermined value
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getStringValue()

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

Evaluating string value for given group/key.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value is requested.
resultA newly allocated string or NULL in error case.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getBoolValue()

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

Evaluating bool value for given group/key.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value is requested.
resultdetermined value
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getIntValueDef()

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

Evaluating int32 value for given group/key.

If key is not found, the default value is returned and error is ECONF_NOKEY.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value is requested.
resultdetermined value
defDefault value if the value has not been found.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getInt64ValueDef()

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

Evaluating int64 value for given group/key.

If key is not found, the default value is returned and error is ECONF_NOKEY.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value is requested.
resultdetermined value
defDefault value if the value has not been found.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getUIntValueDef()

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

Evaluating uint32 value for given group/key.

If key is not found, the default value is returned and error is ECONF_NOKEY.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value is requested.
resultdetermined value
defDefault value if the value has not been found.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getUInt64ValueDef()

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

Evaluating uint64 value for given group/key.

If key is not found, the default value is returned and error is ECONF_NOKEY.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value is requested.
resultdetermined value
defDefault value if the value has not been found.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getFloatValueDef()

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

Evaluating float value for given group/key.

If key is not found, the default value is returned and error is ECONF_NOKEY.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value is requested.
resultdetermined value
defDefault value if the value has not been found.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getDoubleValueDef()

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

Evaluating double value for given group/key.

If key is not found, the default value is returned and error is ECONF_NOKEY.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value is requested.
resultdetermined value
defDefault value if the value has not been found.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getStringValueDef()

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

Evaluating string value for given group/key.

If key is not found, the default value is returned and error is ECONF_NOKEY.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value is requested.
resultReturns a newly allocated string, even if "default" is returned.
defDefault value if the value has not been found.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_getBoolValueDef()

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

Evaluating bool value for given group/key.

If key is not found, the default value is returned and error is ECONF_NOKEY.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value is requested.
resultdetermined value
defDefault value if the value has not been found.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_setIntValue()

econf_err econf_setIntValue ( econf_file kf,
const char *  group,
const char *  key,
int32_t  value 
)
extern

Set int32 value for given group/key.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value has to be set.
valueValue which has to be set.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_setInt64Value()

econf_err econf_setInt64Value ( econf_file kf,
const char *  group,
const char *  key,
int64_t  value 
)
extern

Set int64 value for given group/key.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value has to be set.
valueValue which has to be set.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_setUIntValue()

econf_err econf_setUIntValue ( econf_file kf,
const char *  group,
const char *  key,
uint32_t  value 
)
extern

Set uint32 value for given group/key.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value has to be set.
valueValue which has to be set.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_setUInt64Value()

econf_err econf_setUInt64Value ( econf_file kf,
const char *  group,
const char *  key,
uint64_t  value 
)
extern

Set uint64 value for given group/key.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value has to be set.
valueValue which has to be set.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_setFloatValue()

econf_err econf_setFloatValue ( econf_file kf,
const char *  group,
const char *  key,
float  value 
)
extern

Set float value for given group/key.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value has to be set.
valueValue which has to be set.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_setDoubleValue()

econf_err econf_setDoubleValue ( econf_file kf,
const char *  group,
const char *  key,
double  value 
)
extern

Set double value for given group/key.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value has to be set.
valueValue which has to be set.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_setStringValue()

econf_err econf_setStringValue ( econf_file kf,
const char *  group,
const char *  key,
const char *  value 
)
extern

Set string value for given group/key.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value has to be set.
valueValue which has to be set.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_setBoolValue()

econf_err econf_setBoolValue ( econf_file kf,
const char *  group,
const char *  key,
const char *  value 
)
extern

Set bool value for given group/key.

Parameters
kfgiven/parsed data
groupDesired group or NULL if there is no group defined.
keyKey for which the value has to be set.
valueValue which has to be set.
Returns
econf_err ECONF_SUCCESS or error code

◆ econf_errString()

const char * econf_errString ( const econf_err  error)
extern

Convert an econf_err type to a string.

Parameters
errorerror enum
Returns
human readable string

◆ econf_errLocation()

void econf_errLocation ( char **  filename,
uint64_t *  line_nr 
)
extern

Info about where the error has happened.

Parameters
filenamePath of the last scanned file.
line_nrNumber of the last handled line.

◆ econf_freeArray()

char ** econf_freeArray ( char **  array)
extern

Free an array of type char** created by econf_getGroups() or econf_getKeys().

Parameters
arrayarray of strings
Returns
void

◆ econf_freeArrayp()

static __inline__ void econf_freeArrayp ( char ***  array)
static

Definition at line 1094 of file libeconf.h.

◆ econf_freeFile()

econf_file * econf_freeFile ( econf_file key_file)
extern

Free memory allocated and returned by econf_readFile(), econf_readFileWithCallback, econf_readDirs(), econf_readDirsWithCallback, econf_readDirsHistory, econf_readDirsHistoryWithCallback, econf_readConfig, econf_readConfigWithCallback.

Parameters
key_fileallocated data
Returns
void

◆ econf_freeFilep()

static __inline__ void econf_freeFilep ( econf_file **  key_file)
static

Definition at line 1112 of file libeconf.h.

◆ econf_requireOwner()

void econf_requireOwner ( uid_t  owner)
extern

All parsed files require this user permission.

DEPRECATED: Use the callback in econf_readFileWithCallback or econf_readConfigWithCallback instead.

Parameters
ownerUser ID
Returns
void

◆ econf_requireGroup()

void econf_requireGroup ( gid_t  group)
extern

All parsed files require this group permission.

DEPRECATED: Use the callback in econf_readFileWithCallback, econf_readDirsWithCallback or econf_readDirsHistoryWithCallback instead.

Parameters
groupGroup ID
Returns
void

◆ econf_requirePermissions()

void econf_requirePermissions ( mode_t  file_perms,
mode_t  dir_perms 
)
extern

All parsed file have to have these file and directory permissions.

DEPRECATED: Use the callback in econf_readFileWithCallback or econf_readConfigWithCallback instead.

Parameters
file_permsfile permissions
dir_permsdir permissions
Returns
void

◆ econf_followSymlinks()

void econf_followSymlinks ( bool  allow)
extern

Allowing the parser to follow sym links (default: true).

DEPRECATED: Use the callback in econf_readFileWithCallback or econf_readConfigWithCallback instead.

Parameters
allowallow to follow sym links.
Returns
void

◆ econf_reset_security_settings()

void econf_reset_security_settings ( void  )
extern

Reset all UID, GID, permissions,... restrictions for parsed files/dirs.

DEPRECATED: Use the callback in econf_readFileWithCallback or econf_readConfigWithCallback instead. instead.

Returns
void

◆ econf_set_conf_dirs()

econf_err econf_set_conf_dirs ( const char **  dir_postfix_list)
extern

Set a list of directory structures (with order) which describes the directories in which the files have to be parsed.

Parameters
dir_postfix_listlist of directory structures. E.G. with the given list: {"conf.d", ".d", "/", NULL} files in following directories will be parsed: "<default_dirs>/<config_name>.conf.d/" "<default_dirs>/<config_name>.d/" "<default_dirs>/<config_name>/"
Returns
econf_err ECONF_SUCCESS or error code

CAUTION: These options are NOT TRHEAD-SAFE because they are set globally in libeconf. Individual setting set with econf_newKeyFile_with_options have higher priority and are trhead-safe.