"select name, description, syntax, ikey from interfaces where type = '%s' and description != '' and name = '%s' order by type,name",
command,argv[1]);
"select name, description, syntax, ikey from interfaces where hostname='%s' and type = '%s' and description != '' and name = '%s' order by type,name",
hostname,command,argv[1]);
}else{
sprintf(sql,"select name, description, syntax, ikey from interfaces where type = '%s' and description != '' order by type,name",command);
sprintf(sql,"select name, description, syntax, ikey from interfaces where hostname='%s' and type = '%s' and description != '' order by type,name",hostname,command);
}
}elseif(!strcasecmp(command,"calls")){
sprintf(sql,"select * from calls order by call_created_epoch");
sprintf(sql,"select * from calls where hostname='%s' order by call_created_epoch",hostname);
"select * from channels where uuid like '%s' or name like '%s' or cid_name like '%s' or cid_num like '%s' order by created_epoch",
argv[2],argv[2],argv[2],argv[2]);
"select * from channels where hostname='%s' and uuid like '%s' or name like '%s' or cid_name like '%s' or cid_num like '%s' order by created_epoch",
hostname,argv[2],argv[2],argv[2],argv[2]);
}else{
sprintf(sql,
"select * from channels where uuid like '%%%s%%' or name like '%%%s%%' or cid_name like '%%%s%%' or cid_num like '%%%s%%' order by created_epoch",
argv[2],argv[2],argv[2],argv[2]);
"select * from channels where hostname='%s' and uuid like '%%%s%%' or name like '%%%s%%' or cid_name like '%%%s%%' or cid_num like '%%%s%%' order by created_epoch",
sprintf(sql,"select * from channels left join calls on "
"channels.uuid=calls.caller_uuid where channels.uuid not in (select callee_uuid from calls) order by created_epoch");
"channels.uuid=calls.caller_uuid where channels.hostname='%s' channels.uuid not in (select callee_uuid from calls where hostname='%s') order by created_epoch",hostname,hostname);
if(argv[2]&&!strcasecmp(argv[1],"as")){
as=argv[2];
}
}elseif(!strcasecmp(command,"aliases")){
sprintf(sql,"select * from aliases order by alias");
sprintf(sql,"select * from aliases where hostname='%s' order by alias",hostname);
}elseif(!strcasecmp(command,"complete")){
sprintf(sql,"select * from complete order by a1,a2,a3,a4,a5,a6,a7,a8,a9,a10");
sprintf(sql,"select * from complete where hostname='%s' order by a1,a2,a3,a4,a5,a6,a7,a8,a9,a10",hostname);
"select name, syntax, description, ikey from interfaces where type = 'api' and name = '%s' order by name",cmdname);
"select name, syntax, description, ikey from interfaces where hostname='%s' and type = 'api' and name = '%s' order by name",
hostname,cmdname);
}else{
switch_snprintf(sql,sizeof(sql)-1,"select name, syntax, description, ikey from interfaces where type = 'api' order by name");
switch_snprintf(sql,sizeof(sql)-1,"select name, syntax, description, ikey from interfaces where hostname='%s' and type = 'api' order by name",hostname);