swallows: value needs to be loaded as regular expression

This commit is contained in:
Michael Stapelberg 2013-12-14 10:41:44 +01:00
parent ce480dcc74
commit 0302912b64

View File

@ -153,10 +153,13 @@ static int json_string(void *ctx, const unsigned char *val, unsigned int len) {
if (parsing_swallows) { if (parsing_swallows) {
/* TODO: the other swallowing keys */ /* TODO: the other swallowing keys */
if (strcasecmp(last_key, "class") == 0) { if (strcasecmp(last_key, "class") == 0) {
current_swallow->class = scalloc((len+1) * sizeof(char)); char *sval;
memcpy(current_swallow->class, val, len); sasprintf(&sval, "%.*s", len, val);
current_swallow->class = regex_new(sval);
free(sval);
} else {
ELOG("swallow key %s unknown\n", last_key);
} }
LOG("unhandled yet: swallow\n");
} else { } else {
if (strcasecmp(last_key, "name") == 0) { if (strcasecmp(last_key, "name") == 0) {
json_node->name = scalloc((len+1) * sizeof(char)); json_node->name = scalloc((len+1) * sizeof(char));