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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#ifndef COMET_CONFIG_H
#define COMET_CONFIG_H
#include <stdio.h>
#include <stdint.h>
#include "util.h"
#include "log.h"
typedef struct block block_t;
typedef struct action action_t;
typedef enum {
CONFIG_STRING,
CONFIG_INT,
CONFIG_UINT,
CONFIG_DOUBLE,
CONFIG_BOOL,
CONFIG_COLOR,
CONFIG_GRADIENT,
CONFIG_ENUM,
CONFIG_TIME,
CONFIG_LIST,
} config_type_t;
typedef enum {
CHECK_NONE,
CHECK_POSITIVE,
CHECK_IN_RANGE,
CHECK_GT_OTHER,
CHECK_EQ_OTHER,
} config_check_type_t;
typedef struct {
config_check_type_t type;
union {
struct {
double min;
double max;
} range;
struct {
size_t offset;
config_type_t type;
} compare;
};
} config_check_t;
typedef struct {
const char *key;
config_type_t type;
const void *data;
const config_check_t *checks;
size_t offset;
} config_entry_t;
typedef enum {
CONFIG_SUCCESS,
CONFIG_INVALID,
CONFIG_UNKNOWN,
} config_status_t;
typedef struct {
size_t n_blocks;
block_t **blocks;
size_t n_actions;
action_t *actions;
bool override_redirect;
bool action_strict_run;
bool action_strict_set;
bool action_failfast;
bool wm_struts;
char *wm_name;
gradient_t background;
char *font;
char *monitor;
unsigned int width;
unsigned int height;
unsigned int x_offset;
unsigned int y_offset;
double scale;
} config_t;
typedef struct {
const char *label;
int value;
} config_enum_t;
extern const any_log_formatter_t config_formatters[];
const char *config_type_to_string(config_type_t type);
void config_init(config_t *config);
config_status_t config_read_entry(const config_entry_t *entries, void *result, const config_entry_t **found,
const char *key, const char *value);
int config_read(config_t *config, FILE *file);
int config_validate(config_t *config);
bool config_resolve_action(config_t *config, const char *label, action_t **action);
bool config_resolve(config_t *config, block_t **block);
void config_free(config_t *config);
#endif
|