[commit] r3885 - freeswitch/branches/outcast/src/mod/xml_int/mod_xml_mysql
Author: outcast Date: Mon Jan 1 16:26:05 2007 New Revision: 3885 Modified: freeswitch/branches/outcast/src/mod/xml_int/mod_xml_mysql/mod_xml_mysql.c Log: corrected if statement to check if mysql_xml is null. Also added a check for the section type. Modified: freeswitch/branches/outcast/src/mod/xml_int/mod_xml_mysql/mod_xml_mysql.c ============================================================================== --- freeswitch/branches/outcast/src/mod/xml_int/mod_xml_mysql/mod_xml_mysql.c (original) +++ freeswitch/branches/outcast/src/mod/xml_int/mod_xml_mysql/mod_xml_mysql.c Mon Jan 1 16:26:05 2007 @@ -79,38 +79,41 @@ return NULL; } - snprintf(mysql_query, sizeof(mysql_query), "SELECT data FROM xml_templates WHERE section = \"%s\" and name = \"%s\"", mysql_section, mysql_key_value); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Built query: %s\nSize: %d\n", mysql_query, sizeof(mysql_query)); + if(!(strcmp(mysql_section, "configuration"))) { + snprintf(mysql_query, sizeof(mysql_query), "SELECT data FROM xml_templates WHERE section = \"%s\" and name = \"%s\"", mysql_section, mysql_key_value); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Built query: %s\nSize: %d\n", mysql_query, sizeof(mysql_query)); - if(mysql_real_query(&globals.mysql, mysql_query, strlen(mysql_query)) == 0){ + if(mysql_real_query(&globals.mysql, mysql_query, strlen(mysql_query)) == 0){ - result = mysql_store_result(&globals.mysql); - if(result){ + result = mysql_store_result(&globals.mysql); + if(result){ - if(mysql_num_fields(result) == 1) { - if(!(row = mysql_fetch_row(result))) { + if(mysql_num_fields(result) == 1) { + if(!(row = mysql_fetch_row(result))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Database returned an empty result\n"); - return NULL; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Database returned an empty result\n"); + return NULL; + } else { + + mysql_xml = strdup(row[0]); + } } else { - mysql_xml = strdup(row[0]); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Incorrect amount of fields retrived please check MySQL query.\n"); + return NULL; } } else { - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Incorrect amount of fields retrived please check MySQL query.\n"); - return NULL; - } - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No records found for %s in database\n", mysql_key_value); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No records found for %s in database\n", mysql_key_value); + return NULL; + } + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Mysql Error: %s\n", mysql_error(&globals.mysql)); return NULL; - } + } } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Mysql Error: %s\n", mysql_error(&globals.mysql)); - return NULL; - } - - if(mysql_query == NULL) { + return NULL; + } + if(mysql_xml == NULL) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Database returned a null value\n"); return NULL; }
participants (1)
-
Freeswitch SVN