summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2005-10-17 22:26:33 +0000
committerMark Spencer <markster@digium.com>2005-10-17 22:26:33 +0000
commit4e919f337ce523e555d3bdfa94ba22614318a6d7 (patch)
tree3a8d21864533fd0345e3bf2ac373e18f7f3b7476
parenta863d2b280b517e176dbe3de2015f98509be1104 (diff)
Fix queue, iax and sip formatting issues (bug #5449)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6811 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rwxr-xr-xapps/app_queue.c35
-rwxr-xr-xchannels/chan_iax2.c27
-rwxr-xr-xchannels/chan_sip.c16
3 files changed, 44 insertions, 34 deletions
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 071f9b57d..e1d7373c4 100755
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -3181,7 +3181,7 @@ static void reload_queues(void)
ast_mutex_unlock(&qlock);
}
-static int __queues_show(int fd, int argc, char **argv, int queue_show)
+static int __queues_show(int manager, int fd, int argc, char **argv, int queue_show)
{
struct ast_call_queue *q;
struct queue_ent *qe;
@@ -3192,6 +3192,7 @@ static int __queues_show(int fd, int argc, char **argv, int queue_show)
char *max;
size_t max_left;
float sl = 0;
+ char *term = manager ? "\r\n" : "\n";
time(&now);
if ((!queue_show && argc != 2) || (queue_show && argc != 3))
@@ -3201,9 +3202,9 @@ static int __queues_show(int fd, int argc, char **argv, int queue_show)
if (!q) {
ast_mutex_unlock(&qlock);
if (queue_show)
- ast_cli(fd, "No such queue: %s.\n",argv[2]);
+ ast_cli(fd, "No such queue: %s.%s",argv[2], term);
else
- ast_cli(fd, "No queues.\n");
+ ast_cli(fd, "No queues.%s", term);
return RESULT_SUCCESS;
}
while (q) {
@@ -3213,7 +3214,7 @@ static int __queues_show(int fd, int argc, char **argv, int queue_show)
ast_mutex_unlock(&q->lock);
q = q->next;
if (!q) {
- ast_cli(fd, "No such queue: %s.\n",argv[2]);
+ ast_cli(fd, "No such queue: %s.%s",argv[2], term);
break;
}
continue;
@@ -3229,10 +3230,10 @@ static int __queues_show(int fd, int argc, char **argv, int queue_show)
sl = 0;
if(q->callscompleted > 0)
sl = 100*((float)q->callscompletedinsl/(float)q->callscompleted);
- ast_cli(fd, "%-12.12s has %d calls (max %s) in '%s' strategy (%ds holdtime), W:%d, C:%d, A:%d, SL:%2.1f%% within %ds\n",
- q->name, q->count, max_buf, int2strat(q->strategy), q->holdtime, q->weight, q->callscompleted, q->callsabandoned,sl,q->servicelevel);
+ ast_cli(fd, "%-12.12s has %d calls (max %s) in '%s' strategy (%ds holdtime), W:%d, C:%d, A:%d, SL:%2.1f%% within %ds%s",
+ q->name, q->count, max_buf, int2strat(q->strategy), q->holdtime, q->weight, q->callscompleted, q->callsabandoned,sl,q->servicelevel, term);
if (q->members) {
- ast_cli(fd, " Members: \n");
+ ast_cli(fd, " Members: %s", term);
for (mem = q->members; mem; mem = mem->next) {
max_buf[0] = '\0';
max = max_buf;
@@ -3249,19 +3250,19 @@ static int __queues_show(int fd, int argc, char **argv, int queue_show)
mem->calls, (long)(time(NULL) - mem->lastcall));
} else
ast_build_string(&max, &max_left, " has taken no calls yet");
- ast_cli(fd, " %s%s\n", mem->interface, max_buf);
+ ast_cli(fd, " %s%s%s", mem->interface, max_buf, term);
}
} else
- ast_cli(fd, " No Members\n");
+ ast_cli(fd, " No Members%s", term);
if (q->head) {
pos = 1;
- ast_cli(fd, " Callers: \n");
+ ast_cli(fd, " Callers: %s", term);
for (qe = q->head; qe; qe = qe->next)
- ast_cli(fd, " %d. %s (wait: %ld:%2.2ld, prio: %d)\n", pos++, qe->chan->name,
- (long)(now - qe->start) / 60, (long)(now - qe->start) % 60, qe->prio);
+ ast_cli(fd, " %d. %s (wait: %ld:%2.2ld, prio: %d)%s", pos++, qe->chan->name,
+ (long)(now - qe->start) / 60, (long)(now - qe->start) % 60, qe->prio, term);
} else
- ast_cli(fd, " No Callers\n");
- ast_cli(fd, "\n");
+ ast_cli(fd, " No Callers%s", term);
+ ast_cli(fd, "%s", term);
ast_mutex_unlock(&q->lock);
q = q->next;
if (queue_show)
@@ -3273,12 +3274,12 @@ static int __queues_show(int fd, int argc, char **argv, int queue_show)
static int queues_show(int fd, int argc, char **argv)
{
- return __queues_show(fd, argc, argv, 0);
+ return __queues_show(0, fd, argc, argv, 0);
}
static int queue_show(int fd, int argc, char **argv)
{
- return __queues_show(fd, argc, argv, 1);
+ return __queues_show(0, fd, argc, argv, 1);
}
static char *complete_queue(char *line, char *word, int pos, int state)
@@ -3301,7 +3302,7 @@ static char *complete_queue(char *line, char *word, int pos, int state)
static int manager_queues_show( struct mansession *s, struct message *m )
{
char *a[] = { "show", "queues" };
- queues_show(s->fd, 2, a);
+ __queues_show(1, s->fd, 2, a, 0);
ast_cli(s->fd, "\r\n\r\n"); /* Properly terminate Manager output */
return RESULT_SUCCESS;
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 4633f80d6..6bd6ea566 100755
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -4114,7 +4114,7 @@ static int iax2_show_users(int fd, int argc, char *argv[])
#undef FORMAT2
}
-static int iax2_show_peers(int fd, int argc, char *argv[])
+static int __iax2_show_peers(int manager, int fd, int argc, char *argv[])
{
regex_t regexbuf;
int havepattern = 0;
@@ -4123,13 +4123,14 @@ static int iax2_show_peers(int fd, int argc, char *argv[])
int offline_peers = 0;
int unmonitored_peers = 0;
-#define FORMAT2 "%-15.15s %-15.15s %s %-15.15s %-8s %s %-10s\n"
-#define FORMAT "%-15.15s %-15.15s %s %-15.15s %-5d%s %s %-10s\n"
+#define FORMAT2 "%-15.15s %-15.15s %s %-15.15s %-8s %s %-10s%s"
+#define FORMAT "%-15.15s %-15.15s %s %-15.15s %-5d%s %s %-10s%s"
struct iax2_peer *peer;
char name[256];
char iabuf[INET_ADDRSTRLEN];
int registeredonly=0;
+ char *term = manager ? "\r\n" : "\n";
switch (argc) {
case 6:
@@ -4165,7 +4166,7 @@ static int iax2_show_peers(int fd, int argc, char *argv[])
}
ast_mutex_lock(&peerl.lock);
- ast_cli(fd, FORMAT2, "Name/Username", "Host", " ", "Mask", "Port", " ", "Status");
+ ast_cli(fd, FORMAT2, "Name/Username", "Host", " ", "Mask", "Port", " ", "Status", term);
for (peer = peerl.peers;peer;peer = peer->next) {
char nm[20];
char status[20];
@@ -4208,19 +4209,19 @@ static int iax2_show_peers(int fd, int argc, char *argv[])
ast_test_flag(peer, IAX_DYNAMIC) ? "(D)" : "(S)",
nm,
ntohs(peer->addr.sin_port), ast_test_flag(peer, IAX_TRUNK) ? "(T)" : " ",
- peer->encmethods ? "(E)" : " ", status);
+ peer->encmethods ? "(E)" : " ", status, term);
ast_cli(fd, FORMAT, name,
peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "(Unspecified)",
ast_test_flag(peer, IAX_DYNAMIC) ? "(D)" : "(S)",
nm,
ntohs(peer->addr.sin_port), ast_test_flag(peer, IAX_TRUNK) ? "(T)" : " ",
- peer->encmethods ? "(E)" : " ", status);
+ peer->encmethods ? "(E)" : " ", status, term);
total_peers++;
}
ast_mutex_unlock(&peerl.lock);
- ast_cli(fd,"%d iax2 peers [%d online, %d offline, %d unmonitored]\n", total_peers, online_peers, offline_peers, unmonitored_peers);
+ ast_cli(fd,"%d iax2 peers [%d online, %d offline, %d unmonitored]%s", total_peers, online_peers, offline_peers, unmonitored_peers, term);
if (havepattern)
regfree(&regexbuf);
@@ -4230,6 +4231,10 @@ static int iax2_show_peers(int fd, int argc, char *argv[])
#undef FORMAT2
}
+static int iax2_show_peers(int fd, int argc, char *argv[])
+{
+ return __iax2_show_peers(0, fd, argc, argv);
+}
static int manager_iax2_show_netstats( struct mansession *s, struct message *m )
{
ast_cli_netstats(s->fd, 0);
@@ -4267,8 +4272,12 @@ static int manager_iax2_show_peers( struct mansession *s, struct message *m )
{
char *a[] = { "iax2", "show", "users" };
int ret;
- ret = iax2_show_peers( s->fd, 3, a );
- ast_cli( s->fd, "\r\n\r\n" );
+ char *id;
+ id = astman_get_header(m,"ActionID");
+ if (id && !ast_strlen_zero(id))
+ ast_cli(s->fd, "ActionID: %s\r\n",id);
+ ret = __iax2_show_peers(1, s->fd, 3, a );
+ ast_cli(s->fd, "\r\n\r\n" );
return ret;
} /* /JDG */
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 3f338cfc5..f0eba567d 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -7541,10 +7541,10 @@ static int sip_show_objects(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
/*--- print_group: Print call group and pickup group ---*/
-static void print_group(int fd, unsigned int group)
+static void print_group(int fd, unsigned int group, int crlf)
{
char buf[256];
- ast_cli(fd, "%s\n", ast_print_group(buf, sizeof(buf), group) );
+ ast_cli(fd, crlf ? "%s\r\n" : "%s\n", ast_print_group(buf, sizeof(buf), group) );
}
/*--- dtmfmode2str: Convert DTMF mode to printable string ---*/
@@ -7865,9 +7865,9 @@ static int _sip_show_peer(int type, int fd, struct mansession *s, struct message
if (!ast_strlen_zero(peer->fromdomain))
ast_cli(fd, " FromDomain : %s\n", peer->fromdomain);
ast_cli(fd, " Callgroup : ");
- print_group(fd, peer->callgroup);
+ print_group(fd, peer->callgroup, 0);
ast_cli(fd, " Pickupgroup : ");
- print_group(fd, peer->pickupgroup);
+ print_group(fd, peer->pickupgroup, 0);
ast_cli(fd, " Mailbox : %s\n", peer->mailbox);
ast_cli(fd, " VM Extension : %s\n", peer->vmexten);
ast_cli(fd, " LastMsgsSent : %d\n", peer->lastmsgssent);
@@ -7942,9 +7942,9 @@ static int _sip_show_peer(int type, int fd, struct mansession *s, struct message
if (!ast_strlen_zero(peer->fromdomain))
ast_cli(fd, "SIP-FromDomain: %s\r\n", peer->fromdomain);
ast_cli(fd, "Callgroup: ");
- print_group(fd, peer->callgroup);
+ print_group(fd, peer->callgroup, 1);
ast_cli(fd, "Pickupgroup: ");
- print_group(fd, peer->pickupgroup);
+ print_group(fd, peer->pickupgroup, 1);
ast_cli(fd, "VoiceMailbox: %s\r\n", peer->mailbox);
ast_cli(fd, "LastMsgsSent: %d\r\n", peer->lastmsgssent);
ast_cli(fd, "Call limit: %d\r\n", peer->call_limit);
@@ -8031,9 +8031,9 @@ static int sip_show_user(int fd, int argc, char *argv[])
ast_cli(fd, " CallingPres : %s\n", ast_describe_caller_presentation(user->callingpres));
ast_cli(fd, " Call limit : %d\n", user->call_limit);
ast_cli(fd, " Callgroup : ");
- print_group(fd, user->callgroup);
+ print_group(fd, user->callgroup, 0);
ast_cli(fd, " Pickupgroup : ");
- print_group(fd, user->pickupgroup);
+ print_group(fd, user->pickupgroup, 0);
ast_cli(fd, " Callerid : %s\n", ast_callerid_merge(cbuf, sizeof(cbuf), user->cid_name, user->cid_num, "<unspecified>"));
ast_cli(fd, " ACL : %s\n", (user->ha?"Yes":"No"));
ast_cli(fd, " Codec Order : (");