7 bool parse_bool(char *value, bool *b)
9 if (streq("true", value) || streq("on", value)) {
12 } else if (streq("false", value) || streq("off", value)) {
19 bool parse_split_type(char *s, split_type_t *t)
21 if (streq("horizontal", s)) {
24 } else if (streq("vertical", s)) {
31 bool parse_split_mode(char *s, split_mode_t *m)
33 if (streq("automatic", s)) {
36 } else if (streq("vertical", s)) {
43 bool parse_layout(char *s, layout_t *l)
45 if (streq("monocle", s)) {
48 } else if (streq("tiled", s)) {
55 bool parse_client_state(char *s, client_state_t *t)
57 if (streq("tiled", s)) {
60 } else if (streq("pseudo_tiled", s)) {
61 *t = STATE_PSEUDO_TILED;
63 } else if (streq("floating", s)) {
66 } else if (streq("fullscreen", s)) {
67 *t = STATE_FULLSCREEN;
73 bool parse_stack_layer(char *s, stack_layer_t *l)
75 if (streq("below", s)) {
78 } else if (streq("normal", s)) {
81 } else if (streq("above", s)) {
88 bool parse_direction(char *s, direction_t *d)
90 if (streq("right", s)) {
93 } else if (streq("down", s)) {
96 } else if (streq("left", s)) {
99 } else if (streq("up", s)) {
106 bool parse_cycle_direction(char *s, cycle_dir_t *d)
108 if (streq("next", s)) {
111 } else if (streq("prev", s)) {
118 bool parse_circulate_direction(char *s, circulate_dir_t *d)
120 if (streq("forward", s)) {
121 *d = CIRCULATE_FORWARD;
123 } else if (streq("backward", s)) {
124 *d = CIRCULATE_BACKWARD;
130 bool parse_history_direction(char *s, history_dir_t *d)
132 if (streq("older", s)) {
135 } else if (streq("newer", s)) {
143 bool parse_flip(char *s, flip_t *f)
145 if (streq("horizontal", s)) {
146 *f = FLIP_HORIZONTAL;
148 } else if (streq("vertical", s)) {
155 bool parse_pointer_action(char *s, pointer_action_t *a)
157 if (streq("move", s)) {
160 } else if (streq("resize_corner", s)) {
161 *a = ACTION_RESIZE_CORNER;
163 } else if (streq("resize_side", s)) {
164 *a = ACTION_RESIZE_SIDE;
166 } else if (streq("focus", s)) {
173 bool parse_child_polarity(char *s, child_polarity_t *p)
175 if (streq("first_child", s)) {
178 } else if (streq("second_child", s)) {
185 bool parse_degree(char *s, int *d)
200 bool parse_window_id(char *s, long int *i)
204 long int ret = strtol(s, &end, 0);
205 if (errno != 0 || *end != '\0')
212 bool parse_bool_declaration(char *s, char **key, bool *value, alter_state_t *state)
214 *key = strtok(s, EQL_TOK);
215 char *v = strtok(NULL, EQL_TOK);
217 *state = ALTER_TOGGLE;
220 if (parse_bool(v, value)) {
230 bool parse_index(char *s, int *i)
233 if (sscanf(s, "^%i", &idx) != 1 || idx < 1)