Module: kamailio
Branch: master
Commit: 421ba0adde21ebc9f1e7a2289901a9574cc37259
URL:
https://github.com/kamailio/kamailio/commit/421ba0adde21ebc9f1e7a2289901a95…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-09-27T12:31:59+02:00
core: fixup helper for igp and regexp params
---
Modified: src/core/mod_fix.c
Modified: src/core/mod_fix.h
---
Diff:
https://github.com/kamailio/kamailio/commit/421ba0adde21ebc9f1e7a2289901a95…
Patch:
https://github.com/kamailio/kamailio/commit/421ba0adde21ebc9f1e7a2289901a95…
---
diff --git a/src/core/mod_fix.c b/src/core/mod_fix.c
index 49dbb44f1f..148ba50227 100644
--- a/src/core/mod_fix.c
+++ b/src/core/mod_fix.c
@@ -251,6 +251,50 @@ int fixup_free_regexp_regexp(void** param, int param_no)
return fixup_free_regexp_null(param, 1);
}
+int fixup_igp_regexp(void** param, int param_no)
+{
+ struct regex_fixup* re;
+
+ if (param_no == 1) {
+ return fixup_igp_null(param, param_no);
+ }
+ if (param_no == 2) {
+ if ((re=pkg_malloc(sizeof(*re))) ==0) {
+ PKG_MEM_ERROR;
+ goto error;
+ }
+ if (regcomp(&re->regex, *param,
+ REG_EXTENDED|REG_ICASE|REG_NEWLINE))
+ goto error;
+ re->orig = *param;
+ *param = re;
+ }
+ return 0;
+error:
+ if (re)
+ pkg_free(re);
+ return E_UNSPEC;
+}
+
+int fixup_free_igp_regexp(void** param, int param_no)
+{
+ struct regex_fixup* re;
+
+ if (param_no == 1) {
+ return fixup_free_igp_null(param, param_no);
+ }
+ if (param_no == 2) {
+ if (*param) {
+ re = *param;
+ *param = re->orig;
+ regfree(&re->regex);
+ pkg_free(re);
+ }
+ }
+ return 0;
+}
+
+
/* fixup_pvar_*() has to be written "by hand", since
it needs to save the original pointer (the fixup users expects
a pointer to the pv_spec_t in *param and hence the original value
diff --git a/src/core/mod_fix.h b/src/core/mod_fix.h
index 29d937a261..f91e489f68 100644
--- a/src/core/mod_fix.h
+++ b/src/core/mod_fix.h
@@ -159,4 +159,7 @@ free_fixup_function mod_fix_get_fixup_free(fixup_function f);
int fixup_vstr_all(void** param, int param_no);
int fixup_free_vstr_all(void** param, int param_no);
int fixup_get_vstr_buf(sip_msg_t *msg, pv_elem_t *p, char *buf, int blen);
+
+int fixup_igp_regexp(void** param, int param_no);
+int fixup_free_igp_regexp(void** param, int param_no);
#endif