switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR,"Called with null user!\n");
returnNULL;
}
if(host){
switch_snprintf(sql,sizeof(sql),"select contact,expires from sip_registrations where sip_user='%s' and (sip_host='%s' or presence_hosts like '%%%s%%')",
user,host,host);
}else{
switch_snprintf(sql,sizeof(sql),"select contact,expires from sip_registrations where sip_user='%s'",user);