summaryrefslogtreecommitdiff
path: root/channels
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 /channels
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
Diffstat (limited to 'channels')
-rwxr-xr-xchannels/chan_iax2.c27
-rwxr-xr-xchannels/chan_sip.c16
2 files changed, 26 insertions, 17 deletions
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 : (");