[SR-Users] How do I make subst_hf() use variables in search (not replacement)?

Alex Villací­s Lasso a_villacis at palosanto.com
Fri Aug 8 23:38:16 CEST 2014


Consider the following snippet:

if (is_present_hf("Contact")) {
         xlog("L_ALERT", "===== reply to SUBSCRIBE has Contact: $ct\n");
         xlog("L_ALERT", "===== want to replace with $td\n");
         xlog("L_ALERT", "===== regexp to use is /$sel(cfg_get.asterisk.bindip):$sel(cfg_get.asterisk.bindport)/$td/\n");
         if (subst_hf("Contact", "/127.0.0.1:5080/$td/", "a")) {
                 xlog("L_ALERT", "===== reply had Contact modified\n");
         }
}

If I use the hardcoded regexp "/127.0.0.1:5080/$td/", subst_hf() replaces the Contact value correctly.

However, if I use "/$sel(cfg_get.asterisk.bindip):$sel(cfg_get.asterisk.bindport)/$td/" (where asterisk.bindip and asterisk.bindport are the supposed values 127.0.0.1 and 5080), subst_hf() fails to replace the Contact value.

How do I make use of the existing configuration variables in order to substitute in the Contact header?



More information about the sr-users mailing list