<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][14131] </title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=14131">14131</a></dd>
<dt>Author</dt> <dd>ledr</dd>
<dt>Date</dt> <dd>2009-07-04 08:57:40 -0500 (Sat, 04 Jul 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>another update, conf structure has changed a bit, am documenting a bit now</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunkcontribmodxml_intmod_xml_odbcmod_xml_odbcc">freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/mod_xml_odbc.c</a></li>
<li><a href="#freeswitchtrunkcontribmodxml_intmod_xml_odbcxml_odbcconfxml">freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/xml_odbc.conf.xml</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#freeswitchtrunkcontribmodxml_intmod_xml_odbcxml_odbc_templatesdirectoryuserxml">freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/xml_odbc_templates/directory-user.xml</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#freeswitchtrunkcontribmodxml_intmod_xml_odbcxml_odbc_templatesdirectoryxml">freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/xml_odbc_templates/directory.xml</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunkcontribmodxml_intmod_xml_odbcmod_xml_odbcc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/mod_xml_odbc.c (14130 => 14131)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/mod_xml_odbc.c        2009-07-04 09:58:37 UTC (rev 14130)
+++ freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/mod_xml_odbc.c        2009-07-04 13:57:40 UTC (rev 14131)
</span><span class="lines">@@ -49,10 +49,6 @@
</span><span class="cx">
</span><span class="cx"> static struct {
</span><span class="cx">         char *odbc_dsn;
</span><del>-//        char *configuration_template_name;
-//        char *directory_template_name;
-//        char *dialplan_template_name;
-//        char *phrases_template_name;
</del><span class="cx">         switch_xml_t templates_tag;
</span><span class="cx">         switch_mutex_t *mutex;
</span><span class="cx">         switch_memory_pool_t *pool;
</span><span class="lines">@@ -137,7 +133,7 @@
</span><span class="cx">                 switch_event_add_header_string(helper->event, SWITCH_STACK_BOTTOM, columnName[i], argv[i]);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        /* render all children of xml_in */
</del><ins>+        /* render all children of xml_in_cur */
</ins><span class="cx">         for (xml_in_tmp = helper->xml_in_cur->child; xml_in_tmp; xml_in_tmp = xml_in_tmp->ordered) {
</span><span class="cx"> // only continue if helper->next_template_name is NOT set !
</span><span class="cx">                 helper->xml_in_cur = xml_in_tmp;
</span><span class="lines">@@ -149,16 +145,41 @@
</span><span class="cx">
</span><span class="cx"> static switch_status_t xml_odbc_do_break_to(xml_odbc_session_helper_t *helper)
</span><span class="cx"> {
</span><del>-        char *value = (char *) switch_xml_attr_soft(helper->xml_in, "value");
-        char *new_value = switch_event_expand_headers(helper->event, value);
</del><ins>+        char *value = (char *) switch_xml_attr_soft(helper->xml_in_cur, "value");
+        char *new_value = switch_event_expand_headers_by_pool(helper->pool, helper->event, value);
</ins><span class="cx">
</span><del>-        helper->next_template_name = switch_core_strdup(helper->pool, new_value);
</del><ins>+        helper->next_template_name = new_value;
</ins><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t xml_odbc_do_check_event_header(xml_odbc_session_helper_t *helper)
</span><span class="cx"> {
</span><ins>+        char *name = (char *) switch_xml_attr_soft(helper->xml_in_cur, "name");
+        char *if_name = (char *) switch_xml_attr_soft(helper->xml_in_cur, "if-name");
+        char *if_value = (char *) switch_xml_attr_soft(helper->xml_in_cur, "if-value");
+        char *tmp_value;
+        switch_xml_t xml_in_tmp;
+
+        if (switch_strlen_zero(if_name)) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Ignoring xml-odbc-do name=[%s] because no if-name is given\n", name);
+                goto done;
+        }
+
+        if ((tmp_value = switch_event_get_header(helper->event, if_name))) {
+                if (!switch_strlen_zero(tmp_value)) {
+                        if (switch_strlen_zero(if_value) || !strcasecmp(if_value, tmp_value)) {
+                                for (xml_in_tmp = helper->xml_in_cur->child; xml_in_tmp; xml_in_tmp = xml_in_tmp->ordered) {
+                                        helper->xml_in_cur = xml_in_tmp;
+                                        xml_odbc_render_tag(helper);
+
+                                        if (!switch_strlen_zero(helper->next_template_name)) goto done;
+                                }
+                        }
+                }
+        }
+
+ done:
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -167,21 +188,20 @@
</span><span class="cx">         char *name = (char *) switch_xml_attr_soft(helper->xml_in_cur, "name");
</span><span class="cx">         char *if_name = (char *) switch_xml_attr_soft(helper->xml_in_cur, "if-name");
</span><span class="cx">         char *if_value = (char *) switch_xml_attr_soft(helper->xml_in_cur, "if-value");
</span><del>-        char *value = (char *) switch_xml_attr_soft(helper->xml_in_cur, "value");
</del><span class="cx">         char *old_value = NULL;
</span><del>-        char *new_value = switch_event_expand_headers_by_pool(helper->pool, helper->event, value);
-
</del><ins>+        char *to_value = (char *) switch_xml_attr_soft(helper->xml_in_cur, "to-value");
+        char *new_to_value = switch_event_expand_headers_by_pool(helper->pool, helper->event, to_value);
</ins><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><del>-        if (switch_strlen_zero(value)) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Ignoring xml-odbc-do name=[%s] because no value is given\n", name);
</del><ins>+        if (switch_strlen_zero(to_value)) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Ignoring xml-odbc-do name=[%s] because no to-value is given\n", name);
</ins><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ((old_value = switch_event_get_header(helper->event, if_name))) {
</span><span class="cx">                 if (switch_strlen_zero(if_value) || !strcasecmp(if_value, old_value)) {
</span><span class="cx">                         switch_event_del_header(helper->event, if_name);
</span><del>-                        switch_event_add_header_string(helper->event, SWITCH_STACK_BOTTOM, if_name, new_value);
</del><ins>+                        switch_event_add_header_string(helper->event, SWITCH_STACK_BOTTOM, if_name, new_to_value);
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -195,7 +215,7 @@
</span><span class="cx"> {
</span><span class="cx">         char *value = (char *) switch_xml_attr_soft(helper->xml_in_cur, "value");
</span><span class="cx">         char *empty_result_break_to = (char *) switch_xml_attr_soft(helper->xml_in_cur, "on-empty-result-break-to");
</span><del>-        char *new_value = switch_event_expand_headers(helper->event, value);
</del><ins>+        char *new_value = switch_event_expand_headers_by_pool(helper->pool, helper->event, value);
</ins><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><span class="cx">         if (globals.debug == SWITCH_TRUE) {
</span><span class="lines">@@ -214,11 +234,6 @@
</span><span class="cx">         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span><span class="cx"> done:
</span><del>-
-        if (new_value != value) {
-                switch_safe_free(new_value);
-        }
-
</del><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -262,8 +277,8 @@
</span><span class="cx">
</span><span class="cx">         /* copy all expanded attrs */
</span><span class="cx">         for (i=0; helper->xml_in_cur->attr[i]; i+=2) {
</span><del>-                char *tmp_attr = switch_event_expand_headers_by_pool(helper->pool, helper->event, helper->xml_in_cur->attr[i+1]);
-                switch_xml_set_attr(helper->xml_in_cur, helper->xml_in_cur->attr[i], tmp_attr);
</del><ins>+                char *tmp_value = switch_event_expand_headers_by_pool(helper->pool, helper->event, helper->xml_in_cur->attr[i+1]);
+                switch_xml_set_attr(helper->xml_out_cur, helper->xml_in_cur->attr[i], tmp_value);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* render all children */
</span><span class="lines">@@ -291,7 +306,12 @@
</span><span class="cx"> static switch_status_t xml_odbc_render_template(xml_odbc_session_helper_t *helper)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><ins>+        switch_xml_t xml_tmp;
</ins><span class="cx">
</span><ins>+        if (globals.debug == SWITCH_TRUE) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "DEBUG GOING TO RENDER TEMPLATE [%s]\n", helper->next_template_name);
+        }
+
</ins><span class="cx">         /* free helper -> xml_out */
</span><span class="cx">         switch_xml_free(helper->xml_out);
</span><span class="cx">
</span><span class="lines">@@ -305,20 +325,21 @@
</span><span class="cx">         /* reset helper->xml_out_cur_off */
</span><span class="cx">         helper->xml_out_cur_off = 0;
</span><span class="cx">
</span><del>-        /* render child tag */
</del><ins>+        /* render children */
</ins><span class="cx">         if ((helper->xml_in = helper->xml_in_cur = switch_xml_find_child(globals.templates_tag, "template", "name", helper->next_template_name))) {
</span><del>-                helper->xml_in_cur = helper->xml_in_cur->child;
-                helper->next_template_name = "";
-                if (xml_odbc_render_tag(helper) != SWITCH_STATUS_SUCCESS) {
-                        goto done;
-                }
</del><ins>+                for (xml_tmp = helper->xml_in_cur->child; xml_tmp; xml_tmp = xml_tmp->ordered) {
+                        helper->xml_in_cur = xml_tmp;
+                        helper->next_template_name = "";
+                        if (xml_odbc_render_tag(helper) != SWITCH_STATUS_SUCCESS) {
+                                goto done;
+                        }
</ins><span class="cx">
</span><del>-                if (!switch_strlen_zero(helper->next_template_name)) {
-                        goto reset;
</del><ins>+                        if (!switch_strlen_zero(helper->next_template_name)) {
+                                goto reset;
+                        }
</ins><span class="cx">                 }
</span><del>-
</del><span class="cx">         } else {
</span><del>-                helper->next_template_name = "not_found";
</del><ins>+                helper->next_template_name = "not-found";
</ins><span class="cx">                 goto reset;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -343,7 +364,6 @@
</span><span class="cx">         switch_memory_pool_t *pool;                        /* for easy memory cleanup */
</span><span class="cx">         xml_odbc_session_helper_t helper;        /* this helper is sent through all other functions to generate the xml */
</span><span class="cx">         switch_xml_t xml_out = NULL;                /* the xml that will be returned by this function */
</span><del>-        char hostname[256] = "";                        /* added as header to switch_event_t event */
</del><span class="cx">         char filename[512] = "";                        /* the temporary, uuid-based filename */
</span><span class="cx">         int fd;
</span><span class="cx">
</span><span class="lines">@@ -359,39 +379,13 @@
</span><span class="cx">         /* set the default template to render */
</span><span class="cx">         helper.next_template_name = "default";
</span><span class="cx">
</span><del>-        /* find out what template to render, and put it in helper.next_template_name */
-/*
-        if (!strcmp(section, "configuration")) {
-                helper.next_template_name = switch_core_strdup(pool, globals.configuration_template_name);
-        } else if (!strcmp(section, "directory")) {
-                helper.next_template_name = switch_core_strdup(pool, globals.directory_template_name);
-        } else if (!strcmp(section, "dialplan")) {
-                helper.next_template_name = switch_core_strdup(pool, globals.dialplan_template_name);
-        } else if (!strcmp(section, "phrases")) {
-                helper.next_template_name = switch_core_strdup(pool, globals.phrases_template_name);
-        } else {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid section\n");
-                goto cleanup;
-        }
-*/
-
</del><span class="cx">         /* add some headers to event and put it in the helper */
</span><del>-        gethostname(hostname, sizeof(hostname));
-//        switch_event_add_header_string(event, SWITCH_STACK_TOP, "hostname", hostname); // IS THIS ALWAYS PASSED AS FreeSWITCH-Hostname ??
</del><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_TOP, "section", switch_str_nil(section));
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_TOP, "tag_name", switch_str_nil(tag_name));
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_TOP, "key_name", switch_str_nil(key_name));
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_TOP, "key_value", switch_str_nil(key_value));
</span><span class="cx">         helper.event = event;
</span><span class="cx">
</span><del>-        /* generate a new uuid */
-        switch_uuid_get(&uuid);
-        switch_uuid_format(uuid_str, &uuid);
-
-        /* generate a temporary filename to store the generated xml in */
-        // use switch_core_sprintf here ?!?!
-        switch_snprintf(filename, sizeof(filename), "%s%s.tmp.xml", SWITCH_GLOBAL_dirs.temp_dir, uuid_str);
-
</del><span class="cx">         /* debug print all switch_event_t event headers */
</span><span class="cx">         if (globals.debug == SWITCH_TRUE) {
</span><span class="cx">                 if ((hi = event->headers)) {
</span><span class="lines">@@ -401,7 +395,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        /* render xml from template */
</del><ins>+        /* render xml to helper.xml_out */
</ins><span class="cx">         if (xml_odbc_render_template(&helper) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Something went horribly wrong while generating an XML template!\n");
</span><span class="cx">                 goto cleanup;
</span><span class="lines">@@ -415,6 +409,14 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Debug dump of generated XML:\n%s", xml_char);
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        /* generate a new uuid */
+        switch_uuid_get(&uuid);
+        switch_uuid_format(uuid_str, &uuid);
+
+        /* generate a temporary filename to store the generated xml in */
+        // use switch_core_sprintf here ?!?!
+        switch_snprintf(filename, sizeof(filename), "%s%s.tmp.xml", SWITCH_GLOBAL_dirs.temp_dir, uuid_str);
+
</ins><span class="cx">         /* open (temporary) file */
</span><span class="cx">         if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR| S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) < 0) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening temp file [%s]!\n", filename);
</span><span class="lines">@@ -465,7 +467,7 @@
</span><span class="cx"> static switch_status_t do_config()
</span><span class="cx"> {
</span><span class="cx">         char *cf = "xml_odbc.conf";
</span><del>-        switch_xml_t cfg, xml, settings_tag, bindings_tag, binding_tag, templates_tag, param;
</del><ins>+        switch_xml_t cfg, xml, settings_tag, templates_tag, param;
</ins><span class="cx">         xml_binding_t *binding = NULL;
</span><span class="cx">
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -484,17 +486,12 @@
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (!(bindings_tag = switch_xml_child(cfg, "bindings"))) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing <bindings> tag!\n");
-                goto done;
-        }
-
</del><span class="cx">         if (!(templates_tag = switch_xml_child(cfg, "templates"))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing <templates> tag!\n");
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-// is this allowed ? or should I copy the entire tree ?
</del><ins>+// is this allowed ? or should I copy the entire tree ? can I register a callback function that is called when reloadxml is done ?
</ins><span class="cx">         globals.templates_tag = templates_tag;
</span><span class="cx">
</span><span class="cx">         /* get all the settings */
</span><span class="lines">@@ -505,8 +502,24 @@
</span><span class="cx">                 var = (char *) switch_xml_attr_soft(param, "name");
</span><span class="cx">                 val = (char *) switch_xml_attr_soft(param, "value");
</span><span class="cx">
</span><del>-                /* set globals.odbc_dsn */
-                if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) {
</del><ins>+                if (!strcasecmp(var, "binding") && !switch_strlen_zero(val)) {
+                        if (!(binding = malloc(sizeof(*binding)))) {
+                                goto done;
+                        }
+                        memset(binding, 0, sizeof(*binding));
+                        binding->bindings = strdup(val); // use switch_core_strdup globals.pool for this ?
+
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding XML Search Function [%s]\n", val);
+
+                        switch_xml_bind_search_function(xml_odbc_search, switch_xml_parse_section_string(binding->bindings), binding);
+
+                        binding_count++;
+                        binding = NULL;
+
+                // change odbc-dsn to something like odbc-handle with name=default and dsn=a:b:c
+                // so a linked list or something is created with multiple handles that can be
+                // selected from xml-odbc-do name=query !!! that would be COOL !!!
+                } else if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) {
</ins><span class="cx">                         globals.odbc_dsn = switch_core_strdup(globals.pool, val);
</span><span class="cx">                         if ((odbc_user = strchr(globals.odbc_dsn, ':'))) {
</span><span class="cx">                                 *odbc_user++ = '\0';
</span><span class="lines">@@ -520,7 +533,7 @@
</span><span class="cx">                         } else {
</span><span class="cx">                                 globals.debug = SWITCH_FALSE;
</span><span class="cx">                         }
</span><del>-                } else if (!strcasecmp(var, "keep_files_around") && !switch_strlen_zero(val)) {
</del><ins>+                } else if (!strcasecmp(var, "keep-files-around") && !switch_strlen_zero(val)) {
</ins><span class="cx">                         if (!strcasecmp(val, "true") || !strcasecmp(val, "on")) {
</span><span class="cx">                                 globals.keep_files_around = SWITCH_TRUE;
</span><span class="cx">                         } else {
</span><span class="lines">@@ -529,62 +542,17 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        /* check if any bindings were done */
+        if (binding_count == 0) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No bindings are set, is this really what you want?\n");
+        }
+
</ins><span class="cx">         /* check if odbc_dsn is set */
</span><span class="cx">         if (!globals.odbc_dsn) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No odbc-dsn setting is set!\n");
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        /* get all bindings */
-        for (binding_tag = switch_xml_child(bindings_tag, "binding"); binding_tag; binding_tag = binding_tag->next) {
-                char *bname = (char*) switch_xml_attr_soft(binding_tag, "name");
-
-                for (param = switch_xml_child(binding_tag, "param"); param; param = param->next) {
-                        char *var = NULL;
-                        char *val = NULL;
-
-                        var = (char *) switch_xml_attr_soft(param, "name");
-                        val = (char *) switch_xml_attr_soft(param, "value");
-
-                        if (!strcasecmp(var, "template") && !switch_strlen_zero(val)) {
-                                if (!strcmp(bname, "configuration")) {
-                                        globals.configuration_template_name = switch_core_strdup(globals.pool, val);
-                                } else if (!strcmp(bname, "directory")) {
-                                        globals.directory_template_name = switch_core_strdup(globals.pool, val);
-                                } else if (!strcmp(bname, "dialplan")) {
-                                        globals.dialplan_template_name = switch_core_strdup(globals.pool, val);
-                                } else if (!strcmp(bname, "phrases")) {
-                                        globals.phrases_template_name = switch_core_strdup(globals.pool, val);
-                                } else {
-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid binding name [%s]\n", bname);
-                                        goto done;
-                                }
-                        }
-                }
-
-                binding_count++;
-
-                if (!(binding = malloc(sizeof(*binding)))) {
-                        goto done;
-                }
-                memset(binding, 0, sizeof(*binding));
-
-                // use switch_core_strdup on globals.pool here as well ?
-                binding->bindings = strdup(bname);
-
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding [%s] XML ODBC Fetch Function [%s]\n",
-                        switch_strlen_zero(bname) ? "N/A" : bname, binding->bindings);
-
-                switch_xml_bind_search_function(xml_odbc_search, switch_xml_parse_section_string(bname), binding);
-
-                binding = NULL;
-        }
-
-        /* check if a binding is set */
-        if (binding_count == 0) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No binding is set, is this really what you want?\n");
-        }
-
</del><span class="cx">         /* make odbc connection */
</span><span class="cx">         if (switch_odbc_available() && globals.odbc_dsn) {
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunkcontribmodxml_intmod_xml_odbcxml_odbcconfxml"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/xml_odbc.conf.xml (14130 => 14131)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/xml_odbc.conf.xml        2009-07-04 09:58:37 UTC (rev 14130)
+++ freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/xml_odbc.conf.xml        2009-07-04 13:57:40 UTC (rev 14131)
</span><span class="lines">@@ -1,33 +1,25 @@
</span><span class="cx"> <configuration name="xml_odbc.conf" description="XML ODBC Configuration">
</span><span class="cx">
</span><span class="cx"> <settings>
</span><ins>+ <param name="binding" value="directory"/>
</ins><span class="cx"> <param name="odbc-dsn" value="freeswitch:freeswitch:secret"/>
</span><span class="cx"> <param name="debug" value="true"/>
</span><span class="cx"> <param name="keep_files_around" value="true"/>
</span><span class="cx"> </settings>
</span><span class="cx">
</span><del>- <bindings>
-<!--
- <binding name="configuration">
- <param name="template" value="configuration"/>
- </binding>
--->
- <binding name="directory">
- <!-- <param name="template" value="directory_swk"/> -->
- <param name="template" value="directory"/>
- </binding>
-<!--
- <binding name="dialplan">
- <param name="template" value="dialplan"/>
- </binding>
</del><ins>+ <templates>
</ins><span class="cx">
</span><del>- <binding name="phrases">
- <param name="template" value="phrases"/>
- </binding>
--->
- </bindings>
</del><ins>+ <template name="default">
+ <xml-odbc-do name="break-to" value="${section}"/>
+ </template>
</ins><span class="cx">
</span><del>- <templates>
</del><ins>+ <template name="directory"> -->
+ <xml-odbc-do name="check-event-header" if-name="purpose">
+ <!-- catches purpose gateways and network-list (any more?) -->
+ <xml-odbc-do name="break-to" value="directory-${purpose}"/>
+ </xml-odbc-do>
+ <xml-odbc-do name="break-to" value="directory-user"/>
+ </template>
</ins><span class="cx">
</span><span class="cx"> <template name="configuration">
</span><span class="cx"> <xml-odbc-do name="break-to" value="${section}" on-no-template-break-to="simple_configuration"/>
</span><span class="lines">@@ -43,7 +35,7 @@
</span><span class="cx"> FROM
</span><span class="cx"> cnf_settings
</span><span class="cx"> WHERE
</span><del>- hostname = '${hostname}' AND
</del><ins>+ hostname = '${FreeSWITCH-Hostname}' AND
</ins><span class="cx"> section = '${section}';">
</span><span class="cx"> <param name="${name}" value="${value}"/>
</span><span class="cx"> </xml-odbc-do>
</span></span></pre></div>
<a id="freeswitchtrunkcontribmodxml_intmod_xml_odbcxml_odbc_templatesdirectoryuserxmlfromrev14126freeswitchtrunkcontribmodxml_intmod_xml_odbcxml_odbc_templatesdirectoryxml"></a>
<div class="copfile"><h4>Copied: freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/xml_odbc_templates/directory-user.xml (from rev 14126, freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/xml_odbc_templates/directory.xml) (0 => 14131)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/xml_odbc_templates/directory-user.xml         (rev 0)
+++ freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/xml_odbc_templates/directory-user.xml        2009-07-04 13:57:40 UTC (rev 14131)
</span><span class="lines">@@ -0,0 +1,91 @@
</span><ins>+<include>
+ <template name="directory-user">
+ <document type="freeswitch/xml">
+ <xml-odbc-do name="set-event-header" if-name="key" if-value="id" to-value="username"/>
+ <xml-odbc-do name="query" on-empty-result-break-to="not-found" value="
+ SELECT
+ dir_domains.id AS domain_id,
+ dir_users.id AS user_id,
+ dir_users.cidr,
+ dir_users.mailbox,
+ dir_users.`number-alias`
+ FROM
+ dir_domains,
+ dir_users
+ WHERE
+ dir_users.${key} = '${user}' AND
+ dir_domains.name = '${domain}' AND
+ dir_users.dir_domain_id = dir_domains.id AND
+ dir_users.enabled = '1';"/>
+ <section name="directory">
+ <domain name="${domain}">
+ <params>
+ <xml-odbc-do name="query" value="
+ SELECT
+ name, value
+ FROM
+ dir_domain_params
+ WHERE
+ dir_domain_id = '${domain_id}';">
+ <param name="${name}" value="${value}"/>
+ </xml-odbc-do>
+ </params>
+ <variables>
+ <xml-odbc-do name="query" value="
+ SELECT
+ name, value
+ FROM
+ dir_domain_variables
+ WHERE
+ dir_domain_id = '${domain_id}';">
+ <variable name="${name}" value="${value}"/>
+ </xml-odbc-do>
+ </variables>
+ <groups>
+ <group name="default">
+ <users>
+ <user id="${user}" mailbox="${mailbox}" cidr="${cidr}" number-alias="${number-alias}">
+ <params>
+ <xml-odbc-do name="query" on-empty-result-break-to="not-found" value="
+ SELECT
+ name, value
+ FROM
+ dir_user_params
+ WHERE
+ dir_user_id = '${user_id}';">
+ <param name="${name}" value="${value}"/>
+ </xml-odbc-do>
+ </params>
+ <variables>
+ <xml-odbc-do name="query" value="
+ SELECT
+ name, value
+ FROM
+ dir_user_variables
+ WHERE
+ dir_user_id = '${user_id}';">
+ <variable name="${name}" value="${value}"/>
+ </xml-odbc-do>
+ </variables>
+ </user>
+ </users>
+ </group>
+ <xml-odbc-do name="query" value="
+ SELECT
+ name AS group_name
+ FROM
+ dir_groups,
+ dir_groups_users
+ WHERE
+ dir_groups_users.dir_group_id = dir_groups.id AND
+ dir_user_id = '${user_id}';">
+ <group name="${group_name}">
+ <user id="${user}" type="pointer"/>
+ </group>
+ </xml-odbc-do>
+ </groups>
+ </domain>
+ </section>
+ </document>
+ </template>
+</include>
</ins></span></pre></div>
<a id="freeswitchtrunkcontribmodxml_intmod_xml_odbcxml_odbc_templatesdirectoryuserxml"></a>
<div class="propset"><h4>Property changes: freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/xml_odbc_templates/directory-user.xml</h4>
<pre class="diff"><span>
<span class="cx">Name: svn:mergeinfo
</span><span class="cx"> +
</span></span></pre></div>
<a id="freeswitchtrunkcontribmodxml_intmod_xml_odbcxml_odbc_templatesdirectoryxml"></a>
<div class="delfile"><h4>Deleted: freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/xml_odbc_templates/directory.xml</h4></div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>