Lumiera  0.pre.03
»edityourfreedom«
config-wordlist.c File Reference

Go to the source code of this file.

Description

Draft for a configuration system (2008).

Part of this is the implementation of a word list with search and access functions

Todo:
as of 2016 this code is unused and likely to be replaced by a different approach.

Definition in file config-wordlist.c.

#include "include/logging.h"
#include "lib/error.h"
#include "lib/tmpbuf.h"
#include "common/config.h"

Functions

const char * lumiera_config_wordlist_add (const char *key, const char *value, const char *delims)
 Add a word to the end of a wordlist if it doesn't exist already. More...
 
int lumiera_config_wordlist_find (const char *key, const char *value, const char *delims)
 Find the index of a word in a wordlist. More...
 
const char * lumiera_config_wordlist_get_nth (const char *key, unsigned nth, const char *delims)
 return nth word of a wordlist More...
 
const char * lumiera_config_wordlist_replace (const char *key, const char *value, const char *subst1, const char *subst2, const char *delims)
 Universal word replacement function. More...
 

Variables

LumieraConfig lumiera_global_config
 

Function Documentation

◆ lumiera_config_wordlist_get_nth()

const char* lumiera_config_wordlist_get_nth ( const char *  key,
unsigned  nth,
const char *  delims 
)

return nth word of a wordlist

Wordlists Wordlists are lists of single words delimited by any of " \t,;".

Definition at line 47 of file config-wordlist.c.

References lumiera_config_wordlist_get(), lumiera_tmpbuf_strndup(), and NULL.

Referenced by lumiera_plugin_discover(), and TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lumiera_config_wordlist_find()

int lumiera_config_wordlist_find ( const char *  key,
const char *  value,
const char *  delims 
)

Find the index of a word in a wordlist.

Parameters
keykey under which this wordlist is stored
valueword to find
delimsa string literal listing all characters which are treated as delimiters
Returns
index of the first occurrence of the word or -1 in case of failure

Definition at line 74 of file config-wordlist.c.

References lumiera_config_wordlist_get().

Referenced by TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lumiera_config_wordlist_replace()

const char* lumiera_config_wordlist_replace ( const char *  key,
const char *  value,
const char *  subst1,
const char *  subst2,
const char *  delims 
)

Universal word replacement function.

Replaces a word with up to two new words. This can be used to delete a word (no replacements), insert a new word before an existing word (giving the new word as subst1 and the old word as subst2) insert a new word after an existing word (giving the old word as subst1 and the new word as subst2) or simply give 2 new words.

Parameters
keykey under which this wordlist is stored
valueword to be replaced
subst1first replacement word
subst2second replacement word
delimsa string literal listing all characters which are treated as delimiters
Returns
internal representation of the wordlist in a tmpbuf or NULL in case of an error

Definition at line 97 of file config-wordlist.c.

References lumiera_config_get(), lumiera_config_set(), lumiera_global_config, LUMIERA_MUTEX_SECTION, lumiera_tmpbuf_snprintf(), and NULL.

Referenced by TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lumiera_config_wordlist_add()

const char* lumiera_config_wordlist_add ( const char *  key,
const char *  value,
const char *  delims 
)

Add a word to the end of a wordlist if it doesn't exist already.

Parameters
keykey under which this wordlist is stored
valuenew word to add
delimsa string literal listing all characters which are treated as delimiters
Returns
internal representation of the wordlist in a tmpbuf or NULL in case of an error

Definition at line 152 of file config-wordlist.c.

References lumiera_config_get(), lumiera_config_set(), lumiera_global_config, LUMIERA_MUTEX_SECTION, lumiera_tmpbuf_snprintf(), and NULL.

Referenced by TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ lumiera_global_config