summaryrefslogtreecommitdiffstats
path: root/backend/conf.h
blob: 8e9be5d9b546ad6ec3ebc3853c27f82652469d25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef CONFIG_FILE_H_
#define CONFIG_FILE_H_


#define CONF_HASHTAB_BITS	5
#define CONF_HASHTAB_SIZE	(1 << CONF_HASHTAB_BITS)
#define CONF_HASHTAB_MASK	(CONF_HASHTAB_SIZE - 1)


struct config_item;
struct config_section;
struct config_file;

struct config_item {
	struct config_section *section;
	char *name;
	char *value;

	struct config_item *next;
};

struct config_section {
	struct config_file *file;
	char *name;

	struct config_item *item_hashtab[CONF_HASHTAB_SIZE];

	struct config_section *next;
};

struct config_file {
	struct config_section *section_hashtab[CONF_HASHTAB_SIZE];
};

const char * config_get(struct config_file *f,
			const char *section,
			const char *item,
			const char *_default);

int config_get_int(struct config_file *f,
		   const char *section,
		   const char *item,
		   int _default);

int config_get_bool(struct config_file *f,
		    const char *section,
		    const char *item,
		    int _default);

struct config_file * config_file_parse(const char *path);
void config_file_free(struct config_file *f);

#endif /* CONFIG_FILE_H_ */
bues.ch cgit interface