summaryrefslogtreecommitdiff
path: root/src/sp_config_utils.c
diff options
context:
space:
mode:
authorxXx-caillou-xXx2017-12-20 18:09:53 +0100
committerjvoisin2017-12-20 18:09:53 +0100
commite7f541396715ee2895abcf73044b91ae9b746201 (patch)
treeba0e9765e7f14f04b92585df1f3fcd1830ab4b00 /src/sp_config_utils.c
parent8d6cc4f2b63c3f0dc31fe6cecd34ac023ea1cccb (diff)
Better parsing of the rules
Thanks to this huge commit from @xXx-caillou-xXx, we can now write amazingly flexible rules.
Diffstat (limited to 'src/sp_config_utils.c')
-rw-r--r--src/sp_config_utils.c44
1 files changed, 0 insertions, 44 deletions
diff --git a/src/sp_config_utils.c b/src/sp_config_utils.c
index 1a797e5..ddd2e05 100644
--- a/src/sp_config_utils.c
+++ b/src/sp_config_utils.c
@@ -133,50 +133,6 @@ char *get_param(size_t *consumed, char *restrict line, sp_type type,
133 return NULL; 133 return NULL;
134} 134}
135 135
136// FIXME this is leaking like hell @blotus
137int array_to_list(char **name_ptr, sp_node_t **keys) {
138 int in_key = 0;
139 size_t i = 0;
140 char *name = *name_ptr;
141 char *key_name = ecalloc(strlen(name) + 1, 1); // im way too lazy for
142 // now
143 char *tmp = ecalloc(strlen(name) + 1, 1);
144
145 for (i = 0; name[i] != '['; i++) {
146 tmp[i] = name[i];
147 }
148 tmp[i] = 0;
149
150 for (size_t j = 0; name[i]; i++) {
151 const char c = name[i];
152 if (c == '[') {
153 if (in_key == 0) {
154 in_key = 1;
155 } else {
156 efree(key_name);
157 return -1;
158 }
159 } else if (c == ']') {
160 if (in_key == 0) {
161 efree(key_name);
162 return -1;
163 } else {
164 in_key = 0;
165 j = 0;
166 sp_list_insert(*keys, pestrdup(key_name, 1));
167 memset(key_name, 0, strlen(name) + 1);
168 }
169 } else if (in_key == 1) {
170 key_name[j] = c;
171 j++;
172 }
173 }
174 efree(key_name);
175 *name_ptr = pestrdup(tmp, 1);
176 return in_key;
177}
178
179
180zend_always_inline sp_node_t *parse_functions_list(char *value) { 136zend_always_inline sp_node_t *parse_functions_list(char *value) {
181 const char *sep = ">"; 137 const char *sep = ">";
182 138