<!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-&gt;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-&gt;xml_in_cur-&gt;child; xml_in_tmp; xml_in_tmp = xml_in_tmp-&gt;ordered) {
</span><span class="cx"> // only continue if helper-&gt;next_template_name is NOT set !
</span><span class="cx">                 helper-&gt;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-&gt;xml_in, &quot;value&quot;);
-        char *new_value = switch_event_expand_headers(helper-&gt;event, value);
</del><ins>+        char *value = (char *) switch_xml_attr_soft(helper-&gt;xml_in_cur, &quot;value&quot;);
+        char *new_value = switch_event_expand_headers_by_pool(helper-&gt;pool, helper-&gt;event, value);
</ins><span class="cx"> 
</span><del>-        helper-&gt;next_template_name = switch_core_strdup(helper-&gt;pool, new_value);
</del><ins>+        helper-&gt;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-&gt;xml_in_cur, &quot;name&quot;);
+        char *if_name = (char *) switch_xml_attr_soft(helper-&gt;xml_in_cur, &quot;if-name&quot;);
+        char *if_value = (char *) switch_xml_attr_soft(helper-&gt;xml_in_cur, &quot;if-value&quot;);
+        char *tmp_value;
+        switch_xml_t xml_in_tmp;
+
+        if (switch_strlen_zero(if_name)) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Ignoring xml-odbc-do name=[%s] because no if-name is given\n&quot;, name);
+                goto done;
+        }
+
+        if ((tmp_value = switch_event_get_header(helper-&gt;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-&gt;xml_in_cur-&gt;child; xml_in_tmp; xml_in_tmp = xml_in_tmp-&gt;ordered) {
+                                        helper-&gt;xml_in_cur = xml_in_tmp;
+                                        xml_odbc_render_tag(helper);
+
+                                        if (!switch_strlen_zero(helper-&gt;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-&gt;xml_in_cur, &quot;name&quot;);
</span><span class="cx">         char *if_name = (char *) switch_xml_attr_soft(helper-&gt;xml_in_cur, &quot;if-name&quot;);
</span><span class="cx">         char *if_value = (char *) switch_xml_attr_soft(helper-&gt;xml_in_cur, &quot;if-value&quot;);
</span><del>-        char *value = (char *) switch_xml_attr_soft(helper-&gt;xml_in_cur, &quot;value&quot;);
</del><span class="cx">         char *old_value = NULL;
</span><del>-        char *new_value = switch_event_expand_headers_by_pool(helper-&gt;pool, helper-&gt;event, value);
-
</del><ins>+        char *to_value = (char *) switch_xml_attr_soft(helper-&gt;xml_in_cur, &quot;to-value&quot;);
+        char *new_to_value = switch_event_expand_headers_by_pool(helper-&gt;pool, helper-&gt;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, &quot;Ignoring xml-odbc-do name=[%s] because no value is given\n&quot;, name);
</del><ins>+        if (switch_strlen_zero(to_value)) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Ignoring xml-odbc-do name=[%s] because no to-value is given\n&quot;, 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-&gt;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-&gt;event, if_name);
</span><del>-                        switch_event_add_header_string(helper-&gt;event, SWITCH_STACK_BOTTOM, if_name, new_value);
</del><ins>+                        switch_event_add_header_string(helper-&gt;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-&gt;xml_in_cur, &quot;value&quot;);
</span><span class="cx">         char *empty_result_break_to = (char *) switch_xml_attr_soft(helper-&gt;xml_in_cur, &quot;on-empty-result-break-to&quot;);
</span><del>-        char *new_value = switch_event_expand_headers(helper-&gt;event, value);
</del><ins>+        char *new_value = switch_event_expand_headers_by_pool(helper-&gt;pool, helper-&gt;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-&gt;xml_in_cur-&gt;attr[i]; i+=2) {
</span><del>-                char *tmp_attr = switch_event_expand_headers_by_pool(helper-&gt;pool, helper-&gt;event, helper-&gt;xml_in_cur-&gt;attr[i+1]);
-                switch_xml_set_attr(helper-&gt;xml_in_cur, helper-&gt;xml_in_cur-&gt;attr[i], tmp_attr);
</del><ins>+                char *tmp_value = switch_event_expand_headers_by_pool(helper-&gt;pool, helper-&gt;event, helper-&gt;xml_in_cur-&gt;attr[i+1]);
+                switch_xml_set_attr(helper-&gt;xml_out_cur, helper-&gt;xml_in_cur-&gt;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, &quot;DEBUG GOING TO RENDER TEMPLATE [%s]\n&quot;, helper-&gt;next_template_name);
+        }
+
</ins><span class="cx">         /* free helper -&gt; xml_out */
</span><span class="cx">         switch_xml_free(helper-&gt;xml_out);
</span><span class="cx"> 
</span><span class="lines">@@ -305,20 +325,21 @@
</span><span class="cx">         /* reset helper-&gt;xml_out_cur_off */
</span><span class="cx">         helper-&gt;xml_out_cur_off = 0;
</span><span class="cx"> 
</span><del>-        /* render child tag */
</del><ins>+        /* render children */
</ins><span class="cx">         if ((helper-&gt;xml_in = helper-&gt;xml_in_cur = switch_xml_find_child(globals.templates_tag, &quot;template&quot;, &quot;name&quot;, helper-&gt;next_template_name))) {
</span><del>-                helper-&gt;xml_in_cur = helper-&gt;xml_in_cur-&gt;child;
-                helper-&gt;next_template_name = &quot;&quot;;
-                if (xml_odbc_render_tag(helper) != SWITCH_STATUS_SUCCESS) {
-                        goto done;
-                }
</del><ins>+                for (xml_tmp = helper-&gt;xml_in_cur-&gt;child; xml_tmp; xml_tmp = xml_tmp-&gt;ordered) {
+                        helper-&gt;xml_in_cur = xml_tmp;
+                        helper-&gt;next_template_name = &quot;&quot;;
+                        if (xml_odbc_render_tag(helper) != SWITCH_STATUS_SUCCESS) {
+                                goto done;
+                        }
</ins><span class="cx"> 
</span><del>-                if (!switch_strlen_zero(helper-&gt;next_template_name)) {
-                        goto reset;
</del><ins>+                        if (!switch_strlen_zero(helper-&gt;next_template_name)) {
+                                goto reset;
+                        }
</ins><span class="cx">                 }
</span><del>-
</del><span class="cx">         } else {
</span><del>-                helper-&gt;next_template_name = &quot;not_found&quot;;
</del><ins>+                helper-&gt;next_template_name = &quot;not-found&quot;;
</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] = &quot;&quot;;                        /* added as header to switch_event_t event */
</del><span class="cx">         char filename[512] = &quot;&quot;;                        /* 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 = &quot;default&quot;;
</span><span class="cx"> 
</span><del>-        /* find out what template to render, and put it in helper.next_template_name */
-/*
-        if (!strcmp(section, &quot;configuration&quot;)) {
-                helper.next_template_name = switch_core_strdup(pool, globals.configuration_template_name);
-        } else if (!strcmp(section, &quot;directory&quot;)) {
-                helper.next_template_name = switch_core_strdup(pool, globals.directory_template_name);
-        } else if (!strcmp(section, &quot;dialplan&quot;)) {
-                helper.next_template_name = switch_core_strdup(pool, globals.dialplan_template_name);
-        } else if (!strcmp(section, &quot;phrases&quot;)) {
-                helper.next_template_name = switch_core_strdup(pool, globals.phrases_template_name);
-        } else {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid section\n&quot;);
-                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, &quot;hostname&quot;, hostname); // IS THIS ALWAYS PASSED AS FreeSWITCH-Hostname ??
</del><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_TOP, &quot;section&quot;, switch_str_nil(section));
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_TOP, &quot;tag_name&quot;, switch_str_nil(tag_name));
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_TOP, &quot;key_name&quot;, switch_str_nil(key_name));
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_TOP, &quot;key_value&quot;, 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(&amp;uuid);
-        switch_uuid_format(uuid_str, &amp;uuid);
-
-        /* generate a temporary filename to store the generated xml in */
-        // use switch_core_sprintf here ?!?!
-        switch_snprintf(filename, sizeof(filename), &quot;%s%s.tmp.xml&quot;, 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-&gt;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(&amp;helper) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Something went horribly wrong while generating an XML template!\n&quot;);
</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, &quot;Debug dump of generated XML:\n%s&quot;, xml_char);
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        /* generate a new uuid */
+        switch_uuid_get(&amp;uuid);
+        switch_uuid_format(uuid_str, &amp;uuid);
+
+        /* generate a temporary filename to store the generated xml in */
+        // use switch_core_sprintf here ?!?!
+        switch_snprintf(filename, sizeof(filename), &quot;%s%s.tmp.xml&quot;, 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)) &lt; 0) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error opening temp file [%s]!\n&quot;, 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 = &quot;xml_odbc.conf&quot;;
</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, &quot;bindings&quot;))) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Missing &lt;bindings&gt; tag!\n&quot;);
-                goto done;
-        }
-
</del><span class="cx">         if (!(templates_tag = switch_xml_child(cfg, &quot;templates&quot;))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Missing &lt;templates&gt; tag!\n&quot;);
</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, &quot;name&quot;);
</span><span class="cx">                 val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);
</span><span class="cx"> 
</span><del>-                /* set globals.odbc_dsn */
-                if (!strcasecmp(var, &quot;odbc-dsn&quot;) &amp;&amp; !switch_strlen_zero(val)) {
</del><ins>+                if (!strcasecmp(var, &quot;binding&quot;) &amp;&amp; !switch_strlen_zero(val)) {
+                        if (!(binding = malloc(sizeof(*binding)))) {
+                                goto done;
+                        }
+                        memset(binding, 0, sizeof(*binding));
+                        binding-&gt;bindings = strdup(val); // use switch_core_strdup globals.pool for this ?
+
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Binding XML Search Function [%s]\n&quot;, val);
+
+                        switch_xml_bind_search_function(xml_odbc_search, switch_xml_parse_section_string(binding-&gt;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, &quot;odbc-dsn&quot;) &amp;&amp; !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, &quot;keep_files_around&quot;) &amp;&amp; !switch_strlen_zero(val)) {
</del><ins>+                } else if (!strcasecmp(var, &quot;keep-files-around&quot;) &amp;&amp; !switch_strlen_zero(val)) {
</ins><span class="cx">                         if (!strcasecmp(val, &quot;true&quot;) || !strcasecmp(val, &quot;on&quot;)) {
</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, &quot;No bindings are set, is this really what you want?\n&quot;);
+        }
+
</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, &quot;No odbc-dsn setting is set!\n&quot;);
</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, &quot;binding&quot;); binding_tag; binding_tag = binding_tag-&gt;next) {
-                char *bname = (char*) switch_xml_attr_soft(binding_tag, &quot;name&quot;);
-
-                for (param = switch_xml_child(binding_tag, &quot;param&quot;); param; param = param-&gt;next) {
-                        char *var = NULL;
-                        char *val = NULL;
-
-                        var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);
-                        val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);
-
-                        if (!strcasecmp(var, &quot;template&quot;) &amp;&amp; !switch_strlen_zero(val)) {
-                                if (!strcmp(bname, &quot;configuration&quot;)) {
-                                        globals.configuration_template_name = switch_core_strdup(globals.pool, val);
-                                } else if (!strcmp(bname, &quot;directory&quot;)) {
-                                        globals.directory_template_name = switch_core_strdup(globals.pool, val);
-                                } else if (!strcmp(bname, &quot;dialplan&quot;)) {
-                                        globals.dialplan_template_name = switch_core_strdup(globals.pool, val);
-                                } else if (!strcmp(bname, &quot;phrases&quot;)) {
-                                        globals.phrases_template_name = switch_core_strdup(globals.pool, val);
-                                } else {
-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid binding name [%s]\n&quot;, 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-&gt;bindings = strdup(bname);
-
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Binding [%s] XML ODBC Fetch Function [%s]\n&quot;,
-                        switch_strlen_zero(bname) ? &quot;N/A&quot; : bname, binding-&gt;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, &quot;No binding is set, is this really what you want?\n&quot;);
-        }
-
</del><span class="cx">         /* make odbc connection */
</span><span class="cx">         if (switch_odbc_available() &amp;&amp; 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"> &lt;configuration name=&quot;xml_odbc.conf&quot; description=&quot;XML ODBC Configuration&quot;&gt;
</span><span class="cx"> 
</span><span class="cx">   &lt;settings&gt;
</span><ins>+    &lt;param name=&quot;binding&quot; value=&quot;directory&quot;/&gt;
</ins><span class="cx">     &lt;param name=&quot;odbc-dsn&quot; value=&quot;freeswitch:freeswitch:secret&quot;/&gt;
</span><span class="cx">     &lt;param name=&quot;debug&quot; value=&quot;true&quot;/&gt;
</span><span class="cx">     &lt;param name=&quot;keep_files_around&quot; value=&quot;true&quot;/&gt;
</span><span class="cx">   &lt;/settings&gt;
</span><span class="cx"> 
</span><del>-  &lt;bindings&gt;
-&lt;!--
-    &lt;binding name=&quot;configuration&quot;&gt;
-      &lt;param name=&quot;template&quot; value=&quot;configuration&quot;/&gt;
-    &lt;/binding&gt;
---&gt;
-    &lt;binding name=&quot;directory&quot;&gt;
-      &lt;!-- &lt;param name=&quot;template&quot; value=&quot;directory_swk&quot;/&gt; --&gt;
-      &lt;param name=&quot;template&quot; value=&quot;directory&quot;/&gt;
-    &lt;/binding&gt;
-&lt;!--
-    &lt;binding name=&quot;dialplan&quot;&gt;
-      &lt;param name=&quot;template&quot; value=&quot;dialplan&quot;/&gt;
-    &lt;/binding&gt;
</del><ins>+  &lt;templates&gt;
</ins><span class="cx"> 
</span><del>-    &lt;binding name=&quot;phrases&quot;&gt;
-      &lt;param name=&quot;template&quot; value=&quot;phrases&quot;/&gt;
-    &lt;/binding&gt;
---&gt;
-  &lt;/bindings&gt;
</del><ins>+    &lt;template name=&quot;default&quot;&gt;
+      &lt;xml-odbc-do name=&quot;break-to&quot; value=&quot;${section}&quot;/&gt;
+    &lt;/template&gt;
</ins><span class="cx"> 
</span><del>-  &lt;templates&gt;
</del><ins>+    &lt;template name=&quot;directory&quot;&gt; --&gt;
+      &lt;xml-odbc-do name=&quot;check-event-header&quot; if-name=&quot;purpose&quot;&gt; 
+        &lt;!-- catches purpose gateways and network-list (any more?) --&gt;
+        &lt;xml-odbc-do name=&quot;break-to&quot; value=&quot;directory-${purpose}&quot;/&gt; 
+      &lt;/xml-odbc-do&gt; 
+      &lt;xml-odbc-do name=&quot;break-to&quot; value=&quot;directory-user&quot;/&gt;
+    &lt;/template&gt; 
</ins><span class="cx"> 
</span><span class="cx">     &lt;template name=&quot;configuration&quot;&gt;
</span><span class="cx">       &lt;xml-odbc-do name=&quot;break-to&quot; value=&quot;${section}&quot; on-no-template-break-to=&quot;simple_configuration&quot;/&gt;
</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}';&quot;&gt;
</span><span class="cx">               &lt;param name=&quot;${name}&quot; value=&quot;${value}&quot;/&gt;
</span><span class="cx">             &lt;/xml-odbc-do&gt;
</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>+&lt;include&gt;
+  &lt;template name=&quot;directory-user&quot;&gt;
+    &lt;document type=&quot;freeswitch/xml&quot;&gt;
+      &lt;xml-odbc-do name=&quot;set-event-header&quot; if-name=&quot;key&quot; if-value=&quot;id&quot; to-value=&quot;username&quot;/&gt;
+      &lt;xml-odbc-do name=&quot;query&quot; on-empty-result-break-to=&quot;not-found&quot; value=&quot;
+        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';&quot;/&gt;
+      &lt;section name=&quot;directory&quot;&gt;
+        &lt;domain name=&quot;${domain}&quot;&gt;
+          &lt;params&gt;
+            &lt;xml-odbc-do name=&quot;query&quot; value=&quot;
+              SELECT
+                name, value
+              FROM
+                dir_domain_params
+              WHERE
+                dir_domain_id = '${domain_id}';&quot;&gt;
+              &lt;param name=&quot;${name}&quot; value=&quot;${value}&quot;/&gt;
+            &lt;/xml-odbc-do&gt;
+          &lt;/params&gt;
+          &lt;variables&gt;
+            &lt;xml-odbc-do name=&quot;query&quot; value=&quot;
+              SELECT
+                name, value
+              FROM
+                dir_domain_variables
+              WHERE
+                dir_domain_id = '${domain_id}';&quot;&gt;
+              &lt;variable name=&quot;${name}&quot; value=&quot;${value}&quot;/&gt;
+            &lt;/xml-odbc-do&gt;
+          &lt;/variables&gt;
+          &lt;groups&gt;
+            &lt;group name=&quot;default&quot;&gt;
+              &lt;users&gt;
+                &lt;user id=&quot;${user}&quot; mailbox=&quot;${mailbox}&quot; cidr=&quot;${cidr}&quot; number-alias=&quot;${number-alias}&quot;&gt;
+                  &lt;params&gt;
+                    &lt;xml-odbc-do name=&quot;query&quot; on-empty-result-break-to=&quot;not-found&quot; value=&quot;
+                      SELECT
+                        name, value
+                      FROM
+                        dir_user_params
+                      WHERE
+                        dir_user_id = '${user_id}';&quot;&gt;
+                      &lt;param name=&quot;${name}&quot; value=&quot;${value}&quot;/&gt;
+                    &lt;/xml-odbc-do&gt;
+                  &lt;/params&gt;
+                  &lt;variables&gt;
+                    &lt;xml-odbc-do name=&quot;query&quot; value=&quot;
+                      SELECT
+                        name, value
+                      FROM
+                        dir_user_variables
+                      WHERE
+                        dir_user_id = '${user_id}';&quot;&gt;
+                      &lt;variable name=&quot;${name}&quot; value=&quot;${value}&quot;/&gt;
+                    &lt;/xml-odbc-do&gt;
+                  &lt;/variables&gt;
+                &lt;/user&gt;
+              &lt;/users&gt;
+            &lt;/group&gt;
+            &lt;xml-odbc-do name=&quot;query&quot; value=&quot;
+              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}';&quot;&gt;
+              &lt;group name=&quot;${group_name}&quot;&gt;
+                &lt;user id=&quot;${user}&quot; type=&quot;pointer&quot;/&gt;
+              &lt;/group&gt;
+            &lt;/xml-odbc-do&gt;
+          &lt;/groups&gt;
+        &lt;/domain&gt;
+      &lt;/section&gt;
+    &lt;/document&gt;
+  &lt;/template&gt;
+&lt;/include&gt;
</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>