git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12439 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Brian West 2009-03-05 04:08:31 +00:00
parent f996890d1c
commit db90b8270d
1 changed files with 11 additions and 11 deletions

View File

@ -326,14 +326,14 @@ static char *format_custom_sql(const char *custom_sql, callback_t *cb_struct, co
switch_channel_t *channel; switch_channel_t *channel;
/* first replace %s with digits to maintain backward compat */ /* first replace %s with digits to maintain backward compat */
if(cb_struct->profile->custom_sql_has_percent == SWITCH_TRUE) { if (cb_struct->profile->custom_sql_has_percent == SWITCH_TRUE) {
tmpSQL = switch_string_replace(custom_sql, "%q", digits); tmpSQL = switch_string_replace(custom_sql, "%q", digits);
newSQL = tmpSQL; newSQL = tmpSQL;
} }
/* expand the vars */ /* expand the vars */
if(cb_struct->profile->custom_sql_has_vars == SWITCH_TRUE) { if (cb_struct->profile->custom_sql_has_vars == SWITCH_TRUE) {
if(cb_struct->session) { if (cb_struct->session) {
channel = switch_core_session_get_channel(cb_struct->session); channel = switch_core_session_get_channel(cb_struct->session);
switch_assert(channel); switch_assert(channel);
/* /*
@ -349,11 +349,11 @@ static char *format_custom_sql(const char *custom_sql, callback_t *cb_struct, co
} }
} }
if(tmpSQL != newSQL) { if (tmpSQL != newSQL) {
switch_safe_free(tmpSQL); switch_safe_free(tmpSQL);
} }
if(newSQL == NULL) { if (newSQL == NULL) {
return (char *) custom_sql; return (char *) custom_sql;
} else { } else {
return newSQL; return newSQL;
@ -519,8 +519,8 @@ switch_status_t lcr_do_lookup(callback_t *cb_struct, char *digits)
digits_expanded = expand_digits(cb_struct->pool, digits_copy); digits_expanded = expand_digits(cb_struct->pool, digits_copy);
/* set some channel vars if we have a session */ /* set some channel vars if we have a session */
if(cb_struct->session) { if (cb_struct->session) {
if((channel = switch_core_session_get_channel(cb_struct->session))) { if ((channel = switch_core_session_get_channel(cb_struct->session))) {
switch_channel_set_variable_var_check(channel, "lcr_query_digits", digits_copy, SWITCH_FALSE); switch_channel_set_variable_var_check(channel, "lcr_query_digits", digits_copy, SWITCH_FALSE);
id_str = switch_core_sprintf(cb_struct->pool, "%d", cb_struct->profile->id); id_str = switch_core_sprintf(cb_struct->pool, "%d", cb_struct->profile->id);
switch_channel_set_variable_var_check(channel, "lcr_query_profile", id_str, SWITCH_FALSE); switch_channel_set_variable_var_check(channel, "lcr_query_profile", id_str, SWITCH_FALSE);
@ -555,11 +555,11 @@ switch_status_t lcr_do_lookup(callback_t *cb_struct, char *digits)
/* format the custom_sql */ /* format the custom_sql */
safe_sql = format_custom_sql(profile->custom_sql, cb_struct, digits_copy); safe_sql = format_custom_sql(profile->custom_sql, cb_struct, digits_copy);
if(!safe_sql) { if (!safe_sql) {
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
} }
sql_stream.write_function(&sql_stream, safe_sql); sql_stream.write_function(&sql_stream, safe_sql);
if(safe_sql != profile->custom_sql) { if (safe_sql != profile->custom_sql) {
/* channel_expand_variables returned the same string to us, no need to free */ /* channel_expand_variables returned the same string to us, no need to free */
switch_safe_free(safe_sql); switch_safe_free(safe_sql);
} }
@ -727,10 +727,10 @@ static switch_status_t lcr_load_config()
} }
if (!switch_strlen_zero(custom_sql)) { if (!switch_strlen_zero(custom_sql)) {
if(switch_string_var_check_const(custom_sql)) { if (switch_string_var_check_const(custom_sql)) {
profile->custom_sql_has_vars = SWITCH_TRUE; profile->custom_sql_has_vars = SWITCH_TRUE;
} }
if(strstr(custom_sql, "%")) { if (strstr(custom_sql, "%")) {
profile->custom_sql_has_percent = SWITCH_TRUE; profile->custom_sql_has_percent = SWITCH_TRUE;
} }
profile->custom_sql = switch_core_strdup(globals.pool, (char *)custom_sql); profile->custom_sql = switch_core_strdup(globals.pool, (char *)custom_sql);