2 * Copyright © 2008 Kristian Høgsberg
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial
14 * portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 #ifndef CONFIGPARSER_H
27 #define CONFIGPARSER_H
35 #define WESTON_CONFIG_FILE_ENV_VAR "WESTON_CONFIG_FILE"
37 enum config_key_type {
38 CONFIG_KEY_INTEGER, /* typeof data = int */
39 CONFIG_KEY_UNSIGNED_INTEGER, /* typeof data = unsigned int */
40 CONFIG_KEY_STRING, /* typeof data = char* */
41 CONFIG_KEY_BOOLEAN /* typeof data = int */
46 enum config_key_type type;
50 struct config_section {
52 const struct config_key *keys;
54 void (*done)(void *data);
57 enum weston_option_type {
58 WESTON_OPTION_INTEGER,
59 WESTON_OPTION_UNSIGNED_INTEGER,
64 struct weston_option {
65 enum weston_option_type type;
72 parse_options(const struct weston_option *options,
73 int count, int *argc, char *argv[]);
75 struct weston_config_section;
78 struct weston_config_section *
79 weston_config_get_section(struct weston_config *config, const char *section,
80 const char *key, const char *value);
82 weston_config_section_get_int(struct weston_config_section *section,
84 int32_t *value, int32_t default_value);
86 weston_config_section_get_uint(struct weston_config_section *section,
88 uint32_t *value, uint32_t default_value);
90 weston_config_section_get_color(struct weston_config_section *section,
92 uint32_t *color, uint32_t default_color);
94 weston_config_section_get_double(struct weston_config_section *section,
96 double *value, double default_value);
98 weston_config_section_get_string(struct weston_config_section *section,
101 const char *default_value);
103 weston_config_section_get_bool(struct weston_config_section *section,
105 int *value, int default_value);
108 weston_config_get_name_from_env(void);
110 struct weston_config *
111 weston_config_parse(const char *name);
114 weston_config_get_full_path(struct weston_config *config);
117 weston_config_destroy(struct weston_config *config);
119 int weston_config_next_section(struct weston_config *config,
120 struct weston_config_section **section,
128 #endif /* CONFIGPARSER_H */