You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
3.5 KiB
130 lines
3.5 KiB
13 years ago
|
/*
|
||
|
* Copyright © 2008 Kristian Høgsberg
|
||
|
*
|
||
10 years ago
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||
|
* a copy of this software and associated documentation files (the
|
||
|
* "Software"), to deal in the Software without restriction, including
|
||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||
|
* the following conditions:
|
||
13 years ago
|
*
|
||
10 years ago
|
* The above copyright notice and this permission notice (including the
|
||
|
* next paragraph) shall be included in all copies or substantial
|
||
|
* portions of the Software.
|
||
|
*
|
||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||
|
* SOFTWARE.
|
||
13 years ago
|
*/
|
||
|
|
||
|
#ifndef CONFIGPARSER_H
|
||
|
#define CONFIGPARSER_H
|
||
|
|
||
12 years ago
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
8 years ago
|
#include <stdint.h>
|
||
|
|
||
10 years ago
|
#define WESTON_CONFIG_FILE_ENV_VAR "WESTON_CONFIG_FILE"
|
||
|
|
||
13 years ago
|
enum config_key_type {
|
||
13 years ago
|
CONFIG_KEY_INTEGER, /* typeof data = int */
|
||
|
CONFIG_KEY_UNSIGNED_INTEGER, /* typeof data = unsigned int */
|
||
|
CONFIG_KEY_STRING, /* typeof data = char* */
|
||
|
CONFIG_KEY_BOOLEAN /* typeof data = int */
|
||
13 years ago
|
};
|
||
|
|
||
|
struct config_key {
|
||
|
const char *name;
|
||
13 years ago
|
enum config_key_type type;
|
||
13 years ago
|
void *data;
|
||
|
};
|
||
|
|
||
|
struct config_section {
|
||
|
const char *name;
|
||
|
const struct config_key *keys;
|
||
|
int num_keys;
|
||
|
void (*done)(void *data);
|
||
|
};
|
||
|
|
||
13 years ago
|
enum weston_option_type {
|
||
|
WESTON_OPTION_INTEGER,
|
||
|
WESTON_OPTION_UNSIGNED_INTEGER,
|
||
|
WESTON_OPTION_STRING,
|
||
13 years ago
|
WESTON_OPTION_BOOLEAN
|
||
13 years ago
|
};
|
||
|
|
||
|
struct weston_option {
|
||
|
enum weston_option_type type;
|
||
|
const char *name;
|
||
8 years ago
|
char short_name;
|
||
13 years ago
|
void *data;
|
||
|
};
|
||
|
|
||
|
int
|
||
|
parse_options(const struct weston_option *options,
|
||
12 years ago
|
int count, int *argc, char *argv[]);
|
||
13 years ago
|
|
||
12 years ago
|
struct weston_config_section;
|
||
|
struct weston_config;
|
||
|
|
||
|
struct weston_config_section *
|
||
|
weston_config_get_section(struct weston_config *config, const char *section,
|
||
|
const char *key, const char *value);
|
||
|
int
|
||
|
weston_config_section_get_int(struct weston_config_section *section,
|
||
|
const char *key,
|
||
|
int32_t *value, int32_t default_value);
|
||
|
int
|
||
|
weston_config_section_get_uint(struct weston_config_section *section,
|
||
|
const char *key,
|
||
|
uint32_t *value, uint32_t default_value);
|
||
|
int
|
||
9 years ago
|
weston_config_section_get_color(struct weston_config_section *section,
|
||
|
const char *key,
|
||
|
uint32_t *color, uint32_t default_color);
|
||
|
int
|
||
12 years ago
|
weston_config_section_get_double(struct weston_config_section *section,
|
||
|
const char *key,
|
||
|
double *value, double default_value);
|
||
|
int
|
||
12 years ago
|
weston_config_section_get_string(struct weston_config_section *section,
|
||
|
const char *key,
|
||
|
char **value,
|
||
|
const char *default_value);
|
||
|
int
|
||
|
weston_config_section_get_bool(struct weston_config_section *section,
|
||
|
const char *key,
|
||
|
int *value, int default_value);
|
||
10 years ago
|
|
||
10 years ago
|
const char *
|
||
|
weston_config_get_name_from_env(void);
|
||
|
|
||
12 years ago
|
struct weston_config *
|
||
11 years ago
|
weston_config_parse(const char *name);
|
||
12 years ago
|
|
||
11 years ago
|
const char *
|
||
|
weston_config_get_full_path(struct weston_config *config);
|
||
|
|
||
12 years ago
|
void
|
||
|
weston_config_destroy(struct weston_config *config);
|
||
|
|
||
12 years ago
|
int weston_config_next_section(struct weston_config *config,
|
||
|
struct weston_config_section **section,
|
||
|
const char **name);
|
||
|
|
||
|
|
||
12 years ago
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
|
||
13 years ago
|
#endif /* CONFIGPARSER_H */
|
||
|
|