Lumiera  0.pre.03
»edit your freedom«
config.c File Reference

Go to the source code of this file.

Description

Implementation of a draft for application configuration from 2008.

Warning
since 2012 it is unclear if we retain this approach
Todo:
as of 2016 this code is not used and never was

Definition in file config.c.

#include "include/logging.h"
#include "lib/safeclib.h"
#include "lib/tmpbuf.h"
#include "common/config.h"
#include <stdint.h>
#include <stdlib.h>
#include <ctype.h>

Functions

void lumiera_config_destroy ()
 Destroys the configuration subsystem. More...
 
void lumiera_config_dump (FILE *out)
 Does a diagnostic dump of the whole config database.
 
const char * lumiera_config_get (const char *key, const char **value)
 
const char * lumiera_config_get_default (const char *key, const char **value)
 
int lumiera_config_info (const char *key, const char **filename, unsigned *line)
 
int lumiera_config_init (const char *path)
 Initialise the configuration subsystem. More...
 
int lumiera_config_load (const char *file)
 
int lumiera_config_purge (const char *filename)
 
int lumiera_config_reset (const char *key)
 
int lumiera_config_save ()
 
LumieraConfigitem lumiera_config_set (const char *key, const char *delim_value)
 
LumieraConfigitem lumiera_config_setdefault (const char *line)
 Installs a default value for a config key. More...
 
 LUMIERA_ERROR_DEFINE (CONFIG_SYNTAX, "syntax error in configfile")
 
 LUMIERA_ERROR_DEFINE (CONFIG_SYNTAX_KEY, "syntax error in key")
 
 LUMIERA_ERROR_DEFINE (CONFIG_SYNTAX_VALUE, "syntax error in value")
 
 LUMIERA_ERROR_DEFINE (CONFIG_NO_ENTRY, "no configuration entry")
 

Variables

const char * lumiera_config_defaults []
 defaults for the configuration system itself More...
 
LumieraConfig lumiera_global_config = NULL
 

Function Documentation

◆ lumiera_config_init()

int lumiera_config_init ( const char *  path)

Initialise the configuration subsystem.

Parameters
pathsearch path for config files. Must be called only once

Definition at line 77 of file config.c.

◆ lumiera_config_destroy()

void lumiera_config_destroy ( )

Destroys the configuration subsystem.

Subsequent calls are no-ops.

Definition at line 105 of file config.c.

◆ lumiera_config_set()

LumieraConfigitem lumiera_config_set ( const char *  key,
const char *  delim_value 
)
Parameters
key
delim_valuedelimiter (= or <) followed by the value to be set

Definition at line 223 of file config.c.

References lumiera_config_lookup_item_find().

+ Here is the call graph for this function:

◆ lumiera_config_setdefault()

LumieraConfigitem lumiera_config_setdefault ( const char *  line)

Installs a default value for a config key.

Any key might have an associated default value which is used when no other configuration is available, this can be set once. Any subsequent call will be a no-op. This function locks the config system.

Parameters
lineline with key, delimiter and value to store as default value
Returns
NULL in case of an error, else a pointer to the default configitem

Definition at line 265 of file config.c.

Referenced by lumiera_plugin_discover().

+ Here is the caller graph for this function:

Variable Documentation

◆ lumiera_config_defaults

const char* lumiera_config_defaults[]
Initial value:
=
{
"config.formatstr.link = '< %s'",
"config.formatstr.number.dec = '= %lld'",
"config.formatstr.number.hex = '= 0x%llX'",
"config.formatstr.number.oct = '= 0%llo'",
"config.formatstr.real = '= %Lg'",
"config.formatstr.real.dec = '= %Lf'",
"config.formatstr.real.sci = '= %Le'",
"config.formatstr.string = '= %s'",
"config.formatstr.string.dquoted = '= \"%s\"'",
"config.formatstr.string.quoted = '= ''%s'''",
"config.formatstr.word = '= %s'",
"config.formatstr.bool = '= %d'",
"config.formatdef.link < config.formatstr.link",
"config.formatdef.number < config.formatstr.number.dec",
"config.formatdef.real < config.formatstr.real",
"config.formatdef.string < config.formatstr.string",
"config.formatdef.word < config.formatstr.word",
"config.formatdef.bool < config.formatstr.bool",
"config.formatkey ='config.format.%s'",
NULL
}

defaults for the configuration system itself

Definition at line 41 of file config.c.