more error checking.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6935 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-12-21 05:36:52 +00:00
parent be360558cc
commit 98f285781c
1 changed files with 14 additions and 6 deletions

View File

@ -154,18 +154,18 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt)
}
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_assert(channel != NULL);
if (!caller_profile) {
caller_profile = switch_channel_get_caller_profile(channel);
}
if (caller_profile && !switch_strlen_zero(caller_profile->destination_number)) {
context = caller_profile->context ? caller_profile->context : "default";
} else {
if (!caller_profile || switch_strlen_zero(caller_profile->destination_number)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Obtaining Profile!\n");
return NULL;
}
context = caller_profile->context ? caller_profile->context : "default";
if (!switch_config_open_file(&cfg, cf)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
@ -188,7 +188,7 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt)
char *argument = NULL;
char *expression = NULL, expression_buf[1024] = "";
char substituted[2048] = "";
char *field_data = caller_profile->destination_number;
const char *field_data = caller_profile->destination_number;
int proceed = 0;
switch_regex_t *re = NULL;
int ovector[30] = {0};
@ -220,7 +220,7 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt)
field_data = field_expanded;
}
} else {
field_data = (char *)switch_caller_get_field_by_name(caller_profile, var);
field_data = switch_caller_get_field_by_name(caller_profile, var);
}
}
@ -236,6 +236,10 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt)
expression = pattern;
}
if (!field_data) {
field_data = "";
}
if (!(proceed = switch_regex_perform(field_data, expression, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
switch_regex_safe_free(re);
switch_safe_free(field_expanded);
@ -275,6 +279,10 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt)
argument = "";
}
if (!field_data) {
field_data = "";
}
if (strchr(expression, '(')) {
switch_perform_substitution(re, proceed, argument, field_data, substituted, sizeof(substituted), ovector);
argument = substituted;