| 960 | } |
| 961 | |
| 962 | static int prom_labels_param(modparam_t type, void* val) |
| 963 | { |
| 964 | str module; |
| 965 | str regex; |
| 966 | struct prom_label *label; |
| 967 | init_str(®ex, val); |
| 968 | |
| 969 | trim_leading(®ex); |
| 970 | module = regex; |
| 971 | while (regex.len > 0 && *regex.s != ':') { |
| 972 | regex.s++; |
| 973 | regex.len--; |
| 974 | } |
| 975 | module.len = regex.s - module.s; |
| 976 | if (module.len == 0) { |
| 977 | LM_ERR("no type regexined!\n"); |
| 978 | return -1; |
| 979 | } |
| 980 | regex.s++; |
| 981 | regex.len--; |
| 982 | trim_leading(®ex); |
| 983 | if (regex.len <= 0) { |
| 984 | LM_ERR("no regex regexined!\n"); |
| 985 | return -1; |
| 986 | } |
| 987 | label = pkg_malloc(sizeof(*label) + module.len); |
| 988 | if (!label) { |
| 989 | LM_ERR("oom for label!\n"); |
| 990 | return -1; |
| 991 | } |
| 992 | memset(label, 0, sizeof *label); |
| 993 | label->module.s = label->_buf; |
| 994 | memcpy(label->module.s, module.s, module.len); |
| 995 | label->module.len = module.len; |
| 996 | |
| 997 | label->subst = subst_parser(®ex); |
| 998 | if (!label->subst) { |
| 999 | pkg_free(label); |
| 1000 | LM_ERR("could not parse substitution [%.*s]\n", |
| 1001 | regex.len, regex.s); |
| 1002 | return -1; |
| 1003 | } |
| 1004 | list_add_tail(&label->list, &prom_labels); |
| 1005 | |
| 1006 | return 0; |
| 1007 | } |
| 1008 | |
| 1009 | static int w_prom_declare_stat(struct sip_msg *msg, str *name, str *type, str *help) |
| 1010 | { |
nothing calls this directly
no test coverage detected