]> Pileus Git - ~andy/lamechat/blob - conf.h
Support pre-formatted text.
[~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, N_ELEMENTS(map))
25
26 int get_enum(const char *value, const char **map, int n);
27 int get_bool(const char *value);
28 int get_number(const char *value);
29 char *get_string(const char *value);
30 char *get_name(const char *name);
31 const char *get_const(const char *name);
32
33 /* Setters */
34 void set_enum(const char *group, const char *name,
35                 const char *key, int value,
36                 const char **map, int n);
37 void set_bool(const char *group, const char *name,
38                 const char *key, int value);
39 void set_number(const char *group, const char *name,
40                 const char *key, int value);
41 void set_string(const char *group, const char *name,
42                 const char *key, const char *value);
43 void set_name(const char *group, const char *name,
44                 const char *value);
45
46 /* Functions */
47 void conf_setup(const char *name, parser_t parser);
48 void conf_sync(void);