summaryrefslogtreecommitdiffstats
path: root/librazer/config.h
blob: c0c93499022b86b1fb1a5a1b67ee42587ecd9f96 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef CONFIG_FILE_H_
#define CONFIG_FILE_H_

#include "razer_private.h"


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_section *next;
	struct config_item *items;
};

struct config_file {
	char *path;
	struct config_section *sections;
};

enum {
	CONF_SECT_NOCASE	= (1 << 0), /* Ignore case on section names. */
	CONF_ITEM_NOCASE	= (1 << 1), /* Ignore case on item names. */
	CONF_VALUE_NOCASE	= (1 << 2), /* Ignore case on item values (only for bool). */

	CONF_NOCASE		= CONF_SECT_NOCASE | CONF_ITEM_NOCASE | CONF_VALUE_NOCASE,
};

void config_for_each_item(struct config_file *f,
			  void *context, void *data,
			  const char *section,
			  bool (*func)(struct config_file *f,
			    	       void *context, void *data,
				       const char *section,
			     	       const char *item,
				       const char *value));

void config_for_each_section(struct config_file *f,
			     void *context, void *data,
			     bool (*func)(struct config_file *f,
			     		  void *context, void *data,
			     		  const char *section));

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

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

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

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

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