set DP_REGEX_MATCH_1 .. DP_REGEX_MATCH_N to preserve captures into arrays
This commit is contained in:
parent
0ea936ba9e
commit
c285db5473
|
@ -271,6 +271,8 @@ SWITCH_DECLARE(const char *) switch_channel_get_variable_partner(switch_channel_
|
|||
SWITCH_DECLARE(const char *) switch_channel_get_hold_music(switch_channel_t *channel);
|
||||
SWITCH_DECLARE(const char *) switch_channel_get_hold_music_partner(switch_channel_t *channel);
|
||||
|
||||
SWITCH_DECLARE(uint32_t) switch_channel_del_variable_prefix(switch_channel_t *channel, const char *prefix);
|
||||
|
||||
#define switch_channel_set_variable(_channel, _var, _val) switch_channel_set_variable_var_check(_channel, _var, _val, SWITCH_TRUE)
|
||||
#define switch_channel_set_variable_partner(_channel, _var, _val) switch_channel_set_variable_partner_var_check(_channel, _var, _val, SWITCH_TRUE)
|
||||
|
||||
|
|
|
@ -149,6 +149,8 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
|
|||
int fail = 0;
|
||||
int total = 0;
|
||||
|
||||
switch_channel_del_variable_prefix(channel, "DP_REGEX_MATCH");
|
||||
|
||||
for (xregex = switch_xml_child(xcond, "regex"); xregex; xregex = xregex->next) {
|
||||
time_match = switch_xml_std_datetime_check(xregex);
|
||||
|
||||
|
@ -219,6 +221,11 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
|
|||
}
|
||||
|
||||
if (field && strchr(expression, '(')) {
|
||||
char var[256];
|
||||
switch_snprintf(var, sizeof(var), "DP_REGEX_MATCH_%d", total);
|
||||
|
||||
switch_channel_set_variable(channel, var, NULL);
|
||||
switch_capture_regex(re, proceed, field_data, ovector, var, switch_regex_set_var_callback, session);
|
||||
|
||||
switch_safe_free(save_expression);
|
||||
switch_safe_free(save_field_data);
|
||||
|
|
|
@ -1127,6 +1127,28 @@ SWITCH_DECLARE(switch_status_t) switch_channel_export_variable_printf(switch_cha
|
|||
return status;
|
||||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(uint32_t) switch_channel_del_variable_prefix(switch_channel_t *channel, const char *prefix)
|
||||
{
|
||||
switch_event_t *event;
|
||||
switch_event_header_t *hp;
|
||||
uint32_t r = 0;
|
||||
|
||||
switch_channel_get_variables(channel, &event);
|
||||
|
||||
if (event) {
|
||||
for (hp = event->headers; hp; hp = hp->next) {
|
||||
if (zstr(prefix) || !strncasecmp(hp->name, prefix, strlen(prefix))) {
|
||||
switch_channel_set_variable(channel, hp->name, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch_event_destroy(&event);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_var_check(switch_channel_t *channel,
|
||||
const char *varname, const char *value, switch_bool_t var_check)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue