diff --git a/apps/sw_vsc/Makefile b/apps/sw_vsc/Makefile index 3af8d937..2353f23e 100644 --- a/apps/sw_vsc/Makefile +++ b/apps/sw_vsc/Makefile @@ -1,7 +1,7 @@ plug_in_name = sw_vsc -module_ldflags = -lmysqlclient `pcre-config --libs` -lpcrecpp -module_cflags = -I/usr/include/mysql `pcre-config --cflags` +module_ldflags = -lmysqlclient `pkg-config --libs re2` +module_cflags = -I/usr/include/mysql `pkg-config --cflags re2` module_extra_objs = extra_install = $(plug_in_name)_audio diff --git a/apps/sw_vsc/SW_Vsc.cpp b/apps/sw_vsc/SW_Vsc.cpp index d69a5d26..281372f4 100644 --- a/apps/sw_vsc/SW_Vsc.cpp +++ b/apps/sw_vsc/SW_Vsc.cpp @@ -1,5 +1,5 @@ -#include -using namespace pcrecpp; +#include +using namespace re2; #include "SW_Vsc.h" #include "AmConfig.h" @@ -574,7 +574,6 @@ int SW_VscDialog::number2uri(const AmSipRequest &req, MYSQL *my_handler, my_ulonglong num_rows; MYSQL_RES *res; MYSQL_ROW row; - RE *re; if (req.user.compare(0, 1, "*", 1) == 0) { @@ -695,24 +694,21 @@ int SW_VscDialog::number2uri(const AmSipRequest &req, MYSQL *my_handler, return 0; } - re = new RE(row[0]); - if (re == NULL || re->error().length() > 0) + RE2 re(row[0]); + if (re.error().length() > 0) { ERROR("A callee rewrite rule match pattern ('%s') failed to compile: %s\n", - row[0], (re ? re->error().c_str() : "unknown")); - if (re) delete re; + row[0], re.error().c_str()); mysql_free_result(res); return 0; } - if (re->Replace(row[1], &num)) + if (RE2::Replace(&num, re, row[1])) { INFO("The callee rewrite rule pattern ('%s' and '%s') for subscriber id %llu and domain id %llu matched, result is '%s'\n", row[0], row[1], (unsigned long long int)subId, (unsigned long long int)domId, num.c_str()); - delete re; break; } - delete re; } mysql_free_result(res); @@ -731,22 +727,18 @@ int SW_VscDialog::number2uri(const AmSipRequest &req, MYSQL *my_handler, if (!getPreference(my_handler, subId, ccAttId, &foundPref, &ccStr)) return 0; - re = new RE("\\$avp\\(s:caller_ac\\)"); - if (re->GlobalReplace(acStr, &num)) + if (RE2::GlobalReplace(&num, "\\$avp\\(s:caller_ac\\)", acStr)) { INFO("Successfully replaced $avp(s:caller_ac) by preference value '%s' for subscriber id %llu and domain id %llu", acStr.c_str(), (unsigned long long int)subId, (unsigned long long int)domId); } - delete re; - re = new RE("\\$avp\\(s:caller_cc\\)"); - if (re->GlobalReplace(ccStr, &num)) + if (RE2::GlobalReplace(&num, "\\$avp\\(s:caller_cc\\)", ccStr)) { INFO("Successfully replaced $avp(s:caller_cc) by preference value '%s' for subscriber id %llu and domain id %llu", ccStr.c_str(), (unsigned long long int)subId, (unsigned long long int)domId); } - delete re; INFO("Final normalized number is '%s' for subscriber id %llu and domain id %llu", num.c_str(), (unsigned long long int)subId, diff --git a/debian/control b/debian/control index 9fefcc50..8b939a4f 100644 --- a/debian/control +++ b/debian/control @@ -14,12 +14,13 @@ Build-Depends: libhiredis-dev, libmysql++-dev, libopus-dev, - libpcre3-dev, + libre2-dev, libspandsp-dev, libspeex-dev, libssl-dev, libxml2-dev, openssl, + pkgconf, python3, python3-dev,