| 5499 | } |
| 5500 | |
| 5501 | int set_rule_tables_query(modparam_t type, void *_mapping) |
| 5502 | { |
| 5503 | str_list *tokens; |
| 5504 | struct custom_rule_table *crt; |
| 5505 | str input; |
| 5506 | char *mapping; |
| 5507 | |
| 5508 | mapping = pkg_strdup((char *)_mapping); |
| 5509 | if (!mapping) { |
| 5510 | LM_ERR("oom\n"); |
| 5511 | return -1; |
| 5512 | } |
| 5513 | |
| 5514 | init_str(&input, mapping); |
| 5515 | |
| 5516 | if (!q_memchr(mapping, ':', input.len)) { |
| 5517 | LM_ERR("invalid format, must be '<name> : <query>'\n"); |
| 5518 | return -1; |
| 5519 | } |
| 5520 | |
| 5521 | tokens = __parse_csv_record(&input, 0, ':'); |
| 5522 | if (!tokens) { |
| 5523 | LM_ERR("failed to parse input: %.*s\n", input.len, input.s); |
| 5524 | return -1; |
| 5525 | } |
| 5526 | |
| 5527 | crt = pkg_malloc(sizeof *crt); |
| 5528 | if (!crt) { |
| 5529 | LM_ERR("oom\n"); |
| 5530 | return -1; |
| 5531 | } |
| 5532 | memset(crt, 0, sizeof *crt); |
| 5533 | |
| 5534 | crt->id = tokens->s; |
| 5535 | crt->query = tokens->next->s; |
| 5536 | |
| 5537 | add_last(crt, custom_rule_tables); |
| 5538 | free_csv_record(tokens); |
| 5539 | |
| 5540 | return 0; |
| 5541 | } |
nothing calls this directly
no test coverage detected