]> Pileus Git - ~andy/lamechat/blob - conf.h
Make logfile optional.
[~andy/lamechat] / conf.h
1 /*
2  * Copyright (C) 2013 Andy Spencer <andy753421@gmail.com>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 /* Handlers */
19 typedef void (*parser_t)(const char *group, const char *name,
20                          const char *key, const char *value);
21
22 /* Getters */
23 #define get_map(value, map) \
24         get_enum(value, map, 1, N_ELEMENTS(map))
25 #define get_mapv(value, map) \
26         get_enum(value, *map, N_ELEMENTS(*map), N_ELEMENTS(map))
27
28 int get_enum(const char *value, const char **map, int s, int n);
29 int get_bool(const char *value);
30 int get_number(const char *value);
31 char *get_string(const char *value);
32 char *get_name(const char *name);
33 const char *get_const(const char *name);
34
35 /* Setters */
36 void set_enum(const char *group, const char *name,
37                 const char *key, int value,
38                 const char **map, int n);
39 void set_bool(const char *group, const char *name,
40                 const char *key, int value);
41 void set_number(const char *group, const char *name,
42                 const char *key, int value);
43 void set_string(const char *group, const char *name,
44                 const char *key, const char *value);
45 void set_name(const char *group, const char *name,
46                 const char *value);
47
48 /* Functions */
49 void conf_setup(const char *name, parser_t parser);
50 void conf_sync(void);