提交 e33b0151 authored 作者: Raymond Chandler's avatar Raymond Chandler

FS-5845 --resolve

上级 bdc788f3
......@@ -244,14 +244,14 @@ static const char *do_cid(switch_memory_pool_t *pool, const char *cid, const cha
done:
switch_regex_safe_free(re);
switch_safe_free(tmp_regex);
return number;
}
static char *get_bridge_data(switch_memory_pool_t *pool, char *dialed_number, char *caller_id, lcr_route cur_route, profile_t *profile, switch_core_session_t *session)
static char *get_bridge_data(switch_memory_pool_t *pool, char *dialed_number, char *caller_id, lcr_route cur_route, profile_t *profile, switch_core_session_t *session, char *data)
{
size_t lstrip;
size_t tstrip;
char *data = NULL;
char *destination_number = NULL;
char *codec = NULL;
char *cid = NULL;
......@@ -340,6 +340,7 @@ static char *get_bridge_data(switch_memory_pool_t *pool, char *dialed_number, ch
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Returning Dialstring %s\n", data);
return data;
}
......@@ -548,14 +549,12 @@ static char *expand_digits(switch_memory_pool_t *pool, char *digits, switch_bool
/* format the custom sql */
static char *format_custom_sql(const char *custom_sql, callback_t *cb_struct, const char *digits)
{
char * tmpSQL = NULL;
char * newSQL = NULL;
switch_channel_t *channel;
/* first replace %s with digits to maintain backward compat */
if (cb_struct->profile->custom_sql_has_percent == SWITCH_TRUE) {
tmpSQL = switch_string_replace(custom_sql, "%q", digits);
newSQL = tmpSQL;
newSQL = switch_string_replace(custom_sql, "%q", digits);
}
/* expand the vars */
......@@ -563,32 +562,22 @@ static char *format_custom_sql(const char *custom_sql, callback_t *cb_struct, co
if (cb_struct->session) {
channel = switch_core_session_get_channel(cb_struct->session);
switch_assert(channel);
/*
newSQL = switch_channel_expand_variables_escape(channel,
tmpSQL ? tmpSQL : custom_sql,
escape_sql);
*/
newSQL = switch_channel_expand_variables(channel,
tmpSQL ? tmpSQL : custom_sql);
newSQL = switch_channel_expand_variables(channel, newSQL ? newSQL : custom_sql);
custom_sql = newSQL;
} else if (cb_struct->event) {
/* use event system to expand vars */
newSQL = switch_event_expand_headers(cb_struct->event, tmpSQL ? tmpSQL : custom_sql);
newSQL = switch_event_expand_headers(cb_struct->event, newSQL ? newSQL : custom_sql);
custom_sql = newSQL;
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_CRIT,
"mod_lcr called without a valid session while using a custom_sql that has channel variables.\n");
}
}
if (tmpSQL != newSQL) {
switch_safe_free(tmpSQL);
}
if (newSQL == NULL) {
return (char *) custom_sql;
} else {
return newSQL;
switch_safe_free(newSQL);
}
return (char *) custom_sql;
}
static switch_bool_t lcr_execute_sql_callback(char *sql, switch_core_db_callback_func_t callback, void *pdata)
......@@ -619,6 +608,7 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
char *key2 = NULL;
int i = 0;
int r = 0;
char *data = NULL;
switch_bool_t lcr_skipped = SWITCH_TRUE; /* assume we'll throw it away, paranoid about leak */
switch_memory_pool_t *pool = cbt->pool;
......@@ -675,7 +665,7 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
cbt->matches++;
additional->dialstring = get_bridge_data(pool, cbt->lookup_number, cbt->cid, additional, cbt->profile, cbt->session);
additional->dialstring = get_bridge_data(pool, cbt->lookup_number, cbt->cid, additional, cbt->profile, cbt->session, data);
if (cbt->head == NULL) {
if (cbt->max_rate && (cbt->max_rate < additional->rate)) {
......@@ -815,6 +805,8 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
lcr_destroy(additional);
}
switch_safe_free(data);
return r;
}
......@@ -1823,6 +1815,7 @@ SWITCH_STANDARD_API(dialplan_lcr_function)
char *event_str = NULL;
switch_xml_t event_xml = NULL;
int rowcount = 0;
char *data = NULL;
if (zstr(cmd)) {
goto usage;
......@@ -1942,16 +1935,16 @@ SWITCH_STANDARD_API(dialplan_lcr_function)
while (current) {
//dialstring =
get_bridge_data(pool, cb_struct.lookup_number, cb_struct.cid, current, cb_struct.profile, cb_struct.session);
get_bridge_data(pool, cb_struct.lookup_number, cb_struct.cid, current, cb_struct.profile, cb_struct.session, data);
rowcount++;
if (as_xml) {
stream->write_function(stream, " <row id=\"%d\">\n", rowcount);
}
write_data(stream, as_xml, "prefix", current->digit_str, 2, maximum_lengths.digit_str);
write_data(stream, as_xml, "carrier_name", current->carrier_name, 2, maximum_lengths.carrier_name);
write_data(stream, as_xml, "rate", current->rate_str, 2, maximum_lengths.rate);
write_data(stream, as_xml, "prefix", current->digit_str, 2, (int)maximum_lengths.digit_str);
write_data(stream, as_xml, "carrier_name", current->carrier_name, 2, (int)maximum_lengths.carrier_name);
write_data(stream, as_xml, "rate", current->rate_str, 2, (int)maximum_lengths.rate);
if (current->codec) {
write_data(stream, as_xml, "codec", current->codec, 2, maximum_lengths.codec);
} else {
......@@ -1967,13 +1960,12 @@ SWITCH_STANDARD_API(dialplan_lcr_function)
if (current->limit_realm && current->limit_id) {
char *str = NULL;
str = switch_core_sprintf(pool, "%s %s %d", current->limit_realm, current->limit_id, current->limit_max);
write_data(stream, as_xml, "limit", str, 2, maximum_lengths.limit);
write_data(stream, as_xml, "limit", str, 2, (int)maximum_lengths.limit);
} else {
write_data(stream, as_xml, "limit", "", 2, maximum_lengths.limit);
}
write_data(stream, as_xml, "dialstring", current->dialstring, 2, maximum_lengths.dialstring);
write_data(stream, as_xml, "dialstring", current->dialstring, 2, (int)maximum_lengths.dialstring);
if (as_xml) {
event_xml = switch_event_xmlize(current->fields, SWITCH_VA_NONE);
event_str = switch_xml_toxml(event_xml, SWITCH_FALSE);
......@@ -2006,6 +1998,7 @@ SWITCH_STANDARD_API(dialplan_lcr_function)
}
end:
switch_safe_free(data);
lcr_destroy(cb_struct.head);
if (!session) {
if (pool) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论