MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / set_rule_tables_query

Function set_rule_tables_query

modules/drouting/drouting.c:5501–5541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5499}
5500
5501int 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}

Callers

nothing calls this directly

Calls 5

pkg_strdupFunction · 0.85
init_strFunction · 0.85
q_memchrFunction · 0.85
__parse_csv_recordFunction · 0.85
free_csv_recordFunction · 0.85

Tested by

no test coverage detected