Use computed offset instead of hand-built array for access to struct swb_config members
[browser-switch] / config.h
1 /*
2  * config.h -- definitions for Browser Switchboard configuration
3  *
4  * Copyright (C) 2009-2010 Steven Luo
5  * Derived from a Python implementation by Jason Simpson and Steven Luo
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
9  * as published by the Free Software Foundation; either version 2
10  * of 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20  * USA.
21  */
22
23 #ifndef _CONFIG_H
24 #define _CONFIG_H
25
26 #define SWB_CONFIG_INITIALIZED                  0x01
27 #define SWB_CONFIG_CONTINUOUS_MODE_SET          0x02
28 #define SWB_CONFIG_DEFAULT_BROWSER_SET          0x04
29 #define SWB_CONFIG_OTHER_BROWSER_CMD_SET        0x08
30 #define SWB_CONFIG_LOGGING_SET                  0x10
31 #define SWB_CONFIG_AUTOSTART_MICROB_SET         0x20
32
33 struct swb_config {
34         unsigned int flags;
35
36         int continuous_mode;
37         char *default_browser;
38         char *other_browser_cmd;
39         char *logging;
40         int autostart_microb;
41 };
42
43 struct swb_config_option {
44         char *name;
45         enum {
46                 SWB_CONFIG_OPT_STRING,
47                 SWB_CONFIG_OPT_INT
48         } type;
49         int set_mask;
50         size_t offset;
51 };
52
53 inline void swb_config_init(struct swb_config *cfg);
54 void swb_config_free(struct swb_config *cfg);
55
56 int swb_config_load(struct swb_config *cfg);
57
58 #endif /* _CONFIG_H */