Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
config-interface.c
Go to the documentation of this file.
1 /*
2  Config-interface - Lumiera configuration interface implementation
3 
4  Copyright (C) Lumiera.org
5  2008, Christian Thaeter <ct@pipapo.org>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
23 
33 #include "common/config.h"
34 
35 
36 
38  LUMIERA_INTERFACE_DEFINE (lumieraorg_configuration, 0,
39  lumieraorg_configuration,
40  NULL,
41  NULL,
42  NULL,
43  LUMIERA_INTERFACE_MAP (load,
45  LUMIERA_INTERFACE_MAP (save,
47  LUMIERA_INTERFACE_MAP (purge,
49  LUMIERA_INTERFACE_MAP (dump,
51  LUMIERA_INTERFACE_INLINE (setdefault,
52  int, (const char* line),
53  {return !!lumiera_config_setdefault (line);}
54  ),
55  LUMIERA_INTERFACE_MAP (reset,
57  LUMIERA_INTERFACE_MAP (info,
59 
60  LUMIERA_INTERFACE_MAP (wordlist_get_nth,
62  LUMIERA_INTERFACE_MAP (wordlist_find,
64  LUMIERA_INTERFACE_INLINE (wordlist_replace,
65  int, (const char* key,
66  const char* value,
67  const char* subst1,
68  const char* subst2,
69  const char* delims),
70  {return !!lumiera_config_wordlist_replace (key, value, subst1, subst2, delims);}
71  ),
72  LUMIERA_INTERFACE_INLINE (wordlist_add,
73  int, (const char* key, const char* value, const char* delims),
74  {return !!lumiera_config_wordlist_add (key, value, delims);}
75  ),
76 
77  LUMIERA_INTERFACE_INLINE (link_get,
78  int, (const char* key, const char** value),
79  {return !!lumiera_config_link_get (key, value);}
80  ),
81  LUMIERA_INTERFACE_INLINE (link_set,
82  int, (const char* key, const char** value),
83  {return !!lumiera_config_link_set (key, value);}
84  ),
85 
86  LUMIERA_INTERFACE_INLINE (number_get,
87  int, (const char* key, long long* value),
88  {return !!lumiera_config_number_get (key, value);}
89  ),
90  LUMIERA_INTERFACE_INLINE (number_set,
91  int, (const char* key, long long* value),
92  {return !!lumiera_config_number_set (key, value);}
93  ),
94 
95  LUMIERA_INTERFACE_INLINE (real_get,
96  int, (const char* key, long double* value),
97  {return !!lumiera_config_real_get (key, value);}
98  ),
99  LUMIERA_INTERFACE_INLINE (real_set,
100  int, (const char* key, long double* value),
101  {return !!lumiera_config_real_set (key, value);}
102  ),
103 
104  LUMIERA_INTERFACE_INLINE (string_get,
105  int, (const char* key, const char** value),
106  {return !!lumiera_config_string_get (key, value);}
107  ),
108  LUMIERA_INTERFACE_INLINE (string_set,
109  int, (const char* key, const char** value),
110  {return !!lumiera_config_string_set (key, value);}
111  ),
112 
113  LUMIERA_INTERFACE_INLINE (wordlist_get,
114  int, (const char* key, const char** value),
115  {return !!lumiera_config_wordlist_get (key, value);}
116  ),
117  LUMIERA_INTERFACE_INLINE (wordlist_set,
118  int, (const char* key, const char** value),
119  {return !!lumiera_config_wordlist_set (key, value);}
120  ),
121 
122  LUMIERA_INTERFACE_INLINE (word_get,
123  int, (const char* key, const char** value),
124  {return !!lumiera_config_word_get (key, value);}
125  ),
126  LUMIERA_INTERFACE_INLINE (word_set,
127  int, (const char* key, const char** value),
128  {return !!lumiera_config_word_set (key, value);}
129  ),
130 
131  LUMIERA_INTERFACE_INLINE (bool_get,
132  int, (const char* key, int* value),
133  {return !!lumiera_config_bool_get (key, value);}
134  ),
135  LUMIERA_INTERFACE_INLINE (bool_set,
136  int, (const char* key, int* value),
137  {return !!lumiera_config_bool_set (key, value);}
138  ),
139  )
140  );
141 
142 
143 #ifndef LUMIERA_PLUGIN
144 
146 void
148 {
150 }
151 
152 void
154 {
156 }
157 
158 #endif
159 
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.
LumieraConfigitem lumiera_config_bool_set(const char *key, int *value)
Definition: config-typed.c:365
int lumiera_config_save()
Definition: config.c:143
int lumiera_config_purge(const char *filename)
Definition: config.c:152
int lumiera_config_load(const char *file)
Definition: config.c:133
const char * lumiera_config_string_get(const char *key, const char **value)
Definition: config-typed.c:200
const char * lumiera_config_link_get(const char *key, const char **value)
Definition: config-typed.c:46
LumieraConfigitem lumiera_config_real_set(const char *key, long double *value)
Definition: config-typed.c:127
int lumiera_config_reset(const char *key)
Definition: config.c:331
std::string dump(std::tuple< TYPES...> const &tuple)
convenience function to dump a given tuple's contents.
Interface for a lumiera configuration system (draft).
LumieraConfigitem lumiera_config_wordlist_set(const char *key, const char **value)
Definition: config-typed.c:271
LumieraConfigitem lumiera_config_string_set(const char *key, const char **value)
Definition: config-typed.c:223
const char * lumiera_config_real_get(const char *key, long double *value)
Real floating point number in standard formats (see printf/scanf)
Definition: config-typed.c:118
#define LUMIERA_INTERFACE_REGISTEREXPORTED
Register all exported interfaces when not a plugin This is a no-op when LUMIERA_PLUGIN is defined...
Definition: interface.h:333
const char * lumiera_config_bool_get(const char *key, int *value)
Bool Bool in various formats, (0,1(!1), yes/no, true/false, on/off, set/clear)
Definition: config-typed.c:355
int lumiera_config_wordlist_find(const char *key, const char *value, const char *delims)
Find the index of a word in a wordlist.
return NULL
Definition: llist.h:596
LumieraConfigitem lumiera_config_link_set(const char *key, const char **value)
Definition: config-typed.c:55
void lumiera_config_interface_destroy(void)
LumieraConfigitem lumiera_config_setdefault(const char *line)
Installs a default value for a config key.
Definition: config.c:274
void lumiera_config_interface_init(void)
const char * lumiera_config_wordlist_get_nth(const char *key, unsigned nth, const char *delims)
return nth word of a wordlist
Global registry for interfaces (extension points).
#define LUMIERA_INTERFACE_UNREGISTEREXPORTED
Unregister all exported interfaces when not a plugin This is a no-op when LUMIERA_PLUGIN is defined...
Definition: interface.h:339
LumieraConfigitem lumiera_config_word_set(const char *key, const char **value)
Definition: config-typed.c:334
const char * lumiera_config_wordlist_get(const char *key, const char **value)
Wordlist words delimited by any of " \t,;".
Definition: config-typed.c:245
void lumiera_config_dump(FILE *out)
Does a diagnostic dump of the whole config database.
Definition: config.c:312
const char * lumiera_config_word_get(const char *key, const char **value)
Definition: config-typed.c:311
const char * lumiera_config_number_get(const char *key, long long *value)
Number signed integer numbers, in different formats (decimal, hex, oct, binary(for masks)) ...
Definition: config-typed.c:69
External interface to the lumiera configuration system.
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.
int lumiera_config_info(const char *key, const char **filename, unsigned *line)
Definition: config.c:341
LUMIERA_EXPORT(LUMIERA_INTERFACE_DEFINE(lumieraorg_configuration, 0, lumieraorg_configuration, NULL, NULL, NULL, LUMIERA_INTERFACE_MAP(load, lumiera_config_load), LUMIERA_INTERFACE_MAP(save, lumiera_config_save), LUMIERA_INTERFACE_MAP(purge, lumiera_config_purge), LUMIERA_INTERFACE_MAP(dump, lumiera_config_dump), LUMIERA_INTERFACE_INLINE(setdefault, int,(const char *line),{return!!lumiera_config_setdefault(line);}), LUMIERA_INTERFACE_MAP(reset, lumiera_config_reset), LUMIERA_INTERFACE_MAP(info, lumiera_config_info), LUMIERA_INTERFACE_MAP(wordlist_get_nth, lumiera_config_wordlist_get_nth), LUMIERA_INTERFACE_MAP(wordlist_find, lumiera_config_wordlist_find), LUMIERA_INTERFACE_INLINE(wordlist_replace, int,(const char *key, const char *value, const char *subst1, const char *subst2, const char *delims),{return!!lumiera_config_wordlist_replace(key, value, subst1, subst2, delims);}), LUMIERA_INTERFACE_INLINE(wordlist_add, int,(const char *key, const char *value, const char *delims),{return!!lumiera_config_wordlist_add(key, value, delims);}), LUMIERA_INTERFACE_INLINE(link_get, int,(const char *key, const char **value),{return!!lumiera_config_link_get(key, value);}), LUMIERA_INTERFACE_INLINE(link_set, int,(const char *key, const char **value),{return!!lumiera_config_link_set(key, value);}), LUMIERA_INTERFACE_INLINE(number_get, int,(const char *key, long long *value),{return!!lumiera_config_number_get(key, value);}), LUMIERA_INTERFACE_INLINE(number_set, int,(const char *key, long long *value),{return!!lumiera_config_number_set(key, value);}), LUMIERA_INTERFACE_INLINE(real_get, int,(const char *key, long double *value),{return!!lumiera_config_real_get(key, value);}), LUMIERA_INTERFACE_INLINE(real_set, int,(const char *key, long double *value),{return!!lumiera_config_real_set(key, value);}), LUMIERA_INTERFACE_INLINE(string_get, int,(const char *key, const char **value),{return!!lumiera_config_string_get(key, value);}), LUMIERA_INTERFACE_INLINE(string_set, int,(const char *key, const char **value),{return!!lumiera_config_string_set(key, value);}), LUMIERA_INTERFACE_INLINE(wordlist_get, int,(const char *key, const char **value),{return!!lumiera_config_wordlist_get(key, value);}), LUMIERA_INTERFACE_INLINE(wordlist_set, int,(const char *key, const char **value),{return!!lumiera_config_wordlist_set(key, value);}), LUMIERA_INTERFACE_INLINE(word_get, int,(const char *key, const char **value),{return!!lumiera_config_word_get(key, value);}), LUMIERA_INTERFACE_INLINE(word_set, int,(const char *key, const char **value),{return!!lumiera_config_word_set(key, value);}), LUMIERA_INTERFACE_INLINE(bool_get, int,(const char *key, int *value),{return!!lumiera_config_bool_get(key, value);}), LUMIERA_INTERFACE_INLINE(bool_set, int,(const char *key, int *value),{return!!lumiera_config_bool_set(key, value);}),))
LumieraConfigitem lumiera_config_number_set(const char *key, long long *value)
Definition: config-typed.c:97