From 7820dc0a9439defed116645df99818f6f703435a Mon Sep 17 00:00:00 2001 From: Mathieu Rene Date: Fri, 21 Aug 2009 19:27:35 +0000 Subject: [PATCH] MODENDP-232 part 2 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14589 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/mod_sofia.c | 66 ++++++++++++------------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index e774267b85..a1531775bf 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1777,22 +1777,19 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t 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]); @@ -1834,7 +1831,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t } 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,23 +1995,22 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl 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]); @@ -2056,7 +2052,7 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl } 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, " \n"); stream->write_function(stream, "\n");