Revision
14589
Author
mrene
Date
2009-08-21 14:27:35 -0500 (Fri, 21 Aug 2009)

Log Message

MODENDP-232 part 2

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (14588 => 14589)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2009-08-21 18:03:30 UTC (rev 14588)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2009-08-21 19:27:35 UTC (rev 14589)
@@ -1777,23 +1777,20 @@
 				cb.profile = profile;
 				cb.stream = stream;
 				
-				if (argv[3]) {
-					if (argv[4]) {
-						if (!strcasecmp(argv[3], "pres")) {
-							sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
-												 "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
-												 "network_ip,network_port,sip_username,sip_realm"
-												 " from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'", 
-												 profile->name, argv[4]);
-						}
-					} else {
-						sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
-											 "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
-											 "network_ip,network_port,sip_username,sip_realm"
-											 " from sip_registrations where profile_name='%q' and contact like '%%%q%%'", 
-											 profile->name, argv[3]);
-					}
+				if (!sql && argv[2] && !strcasecmp(argv[2], "pres") && argv[3]) {
+					sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
+							"rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
+							"network_ip,network_port,sip_username,sip_realm"
+							" from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'", 
+							profile->name, argv[3]);
 				}
+				if (!sql && argv[2] && !strcasecmp(argv[2], "reg") && argv[3]) {
+					sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
+							"rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
+							"network_ip,network_port,sip_username,sip_realm"
+							" from sip_registrations where profile_name='%q' and contact like '%%%q%%'", 
+							profile->name, argv[3]);
+				}
 				if (!sql && argv[2] && !strcasecmp(argv[2], "user") && argv[3]) {
 					char *dup = strdup(argv[3]);
 					char *host = NULL, *user = NULL;
@@ -1834,7 +1831,7 @@
 				}
 
 				sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, show_reg_callback, &cb);
-				free(sql);
+				switch_safe_free(sql);
 
 				stream->write_function(stream, "%s\n", line);
 
@@ -1998,24 +1995,23 @@
 
 				cb.profile = profile;
 				cb.stream = stream;
-				
-				if (argv[3]) {
-					if (argv[4]) {
-						if (!strcasecmp(argv[3], "pres")) {
-							sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
-												 "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
-												 "network_ip,network_port,sip_username,sip_realm"
-												 " from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'", 
-												 profile->name, argv[4]);
-						}
-					} else {
-						sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
-											 "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
-											 "network_ip,network_port,sip_username,sip_realm"
-											 " from sip_registrations where profile_name='%q' and contact like '%%%q%%'", 
-											 profile->name, argv[3]);
-					}
+
+				if (!sql && argv[2] && !strcasecmp(argv[2], "pres") && argv[3]) {
+
+					sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
+							"rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
+							"network_ip,network_port,sip_username,sip_realm"
+							" from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'", 
+							profile->name, argv[3]);
 				}
+				if (!sql && argv[2] && !strcasecmp(argv[2], "reg") && argv[3]) {
+
+					sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
+							"rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
+							"network_ip,network_port,sip_username,sip_realm"
+							" from sip_registrations where profile_name='%q' and contact like '%%%q%%'", 
+							profile->name, argv[3]);
+				}
 				if (!sql && argv[2] && !strcasecmp(argv[2], "user") && argv[3]) {
 					char *dup = strdup(argv[3]);
 					char *host = NULL, *user = NULL;
@@ -2056,7 +2052,7 @@
 				}
 
 				sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, show_reg_callback_xml, &cb);
-				free(sql);
+				switch_safe_free(sql);
 
 				stream->write_function(stream, "  </registrations>\n");
 				stream->write_function(stream, "</profile>\n");