[Freeswitch-svn] [commit] r8195 - freeswitch/trunk/src/mod/xml_int/mod_xml_ldap
Freeswitch SVN
anthm at freeswitch.org
Fri Apr 25 14:57:53 EDT 2008
Author: anthm
Date: Fri Apr 25 14:57:52 2008
New Revision: 8195
Modified:
freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c
Log:
fix warnings
Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c
==============================================================================
--- freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c (original)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c Fri Apr 25 14:57:52 2008
@@ -134,7 +134,7 @@
{
struct ldap_c *ldap = ldap_connection;
switch_xml_t asdf = *xml;
- switch_xml_t param, variable, params, variables;
+ switch_xml_t param, variable, params = NULL, variables = NULL;
int i = 0;
int loff = *off;
@@ -217,7 +217,7 @@
xml_binding_t *binding = (xml_binding_t *)user_data;
switch_event_header_t *hi;
- switch_xml_t xml, sub;
+ switch_xml_t xml = NULL, sub = NULL;
struct ldap_c ldap_connection;
struct ldap_c *ldap = &ldap_connection;
@@ -225,7 +225,7 @@
int auth_method = LDAP_AUTH_SIMPLE;
int desired_version = LDAP_VERSION3;
xml_ldap_query_type_t query_type;
- char *dir_exten, *dir_domain;
+ char *dir_exten = NULL, *dir_domain = NULL;
char *filter = "(objectClass=*)";
char *search_base = NULL;
@@ -248,6 +248,9 @@
}
else if (!strcmp(section,"phrases")) {
query_type = XML_LDAP_PHRASE;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid section\n");
+ return NULL;
}
if (params) {
@@ -277,20 +280,24 @@
case XML_LDAP_DIRECTORY:
if (dir_exten && dir_domain) {
- xml = switch_xml_new("directory");
- switch_xml_set_attr_d(xml, "type", "freeswitch/xml");
-
- sub = switch_xml_add_child_d(xml, "section", off++);
- switch_xml_set_attr_d(sub, "name", "directory");
-
- sub = switch_xml_add_child_d(sub, "domain", off++);
- switch_xml_set_attr_d(sub, "name", dir_domain);
+ if ((xml = switch_xml_new("directory"))) {
+ switch_xml_set_attr_d(xml, "type", "freeswitch/xml");
+
+ if ((sub = switch_xml_add_child_d(xml, "section", off++))) {
+ switch_xml_set_attr_d(sub, "name", "directory");
+ }
- sub = switch_xml_add_child_d(sub, "user", off++);
- switch_xml_set_attr_d(sub, "id", dir_exten);
+ if ((sub = switch_xml_add_child_d(sub, "domain", off++))) {
+ switch_xml_set_attr_d(sub, "name", dir_domain);
+ }
+
+ if ((sub = switch_xml_add_child_d(sub, "user", off++))) {
+ switch_xml_set_attr_d(sub, "id", dir_exten);
+ }
+ }
search_base = switch_mprintf(binding->queryfmt, dir_exten, dir_domain, binding->ldap_base);
-
+
free(dir_exten);
dir_exten = NULL;
@@ -303,13 +310,15 @@
break;
case XML_LDAP_DIALPLAN:
- xml = switch_xml_new("document");
- switch_xml_set_attr_d(xml, "type", "freeswitch/xml");
+ if ((xml = switch_xml_new("document"))) {
+ switch_xml_set_attr_d(xml, "type", "freeswitch/xml");
- sub = switch_xml_add_child_d(xml, "section", off++);
- switch_xml_set_attr_d(sub, "name", "dialplan");
+ if ((sub = switch_xml_add_child_d(xml, "section", off++))) {
+ switch_xml_set_attr_d(sub, "name", "dialplan");
+ }
- sub = switch_xml_add_child_d(xml, "context", off++);
+ sub = switch_xml_add_child_d(xml, "context", off++);
+ }
search_base = switch_mprintf(binding->queryfmt, dir_exten, dir_domain, binding->ldap_base);
break;
@@ -323,6 +332,7 @@
}
+
if ((ldap->ld = ldap_init(binding->host, LDAP_PORT)) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to connect to ldap server.%s\n", binding->host);
goto cleanup;
@@ -345,7 +355,7 @@
goto cleanup;
}
- if (xml_ldap_result(&ldap_connection, binding, &sub, &off, query_type) != SWITCH_STATUS_SUCCESS) {
+ if (sub && xml_ldap_result(&ldap_connection, binding, &sub, &off, query_type) != SWITCH_STATUS_SUCCESS) {
goto cleanup;
}
More information about the Freeswitch-svn
mailing list