[Asterisk-cvs] asterisk/channels chan_iax2.c, 1.357, 1.358 chan_sip.c, 1.893, 1.894

markster markster
Mon Oct 17 18:32:34 CDT 2005


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv713/channels

Modified Files:
	chan_iax2.c chan_sip.c 
Log Message:
Fix queue, iax and sip formatting issues (bug #5449)


Index: chan_iax2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v
retrieving revision 1.357
retrieving revision 1.358
diff -u -d -r1.357 -r1.358
--- chan_iax2.c	14 Oct 2005 17:02:20 -0000	1.357
+++ chan_iax2.c	17 Oct 2005 22:26:33 -0000	1.358
@@ -4114,7 +4114,7 @@
 #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 @@
 	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 @@
 	}
 
 	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 @@
 					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 @@
 #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 @@
 {
 	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 */
 

Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.893
retrieving revision 1.894
diff -u -d -r1.893 -r1.894
--- chan_sip.c	14 Oct 2005 01:14:29 -0000	1.893
+++ chan_sip.c	17 Oct 2005 22:26:33 -0000	1.894
@@ -7541,10 +7541,10 @@
 	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 @@
 		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 @@
 		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 @@
 		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  : (");




More information about the svn-commits mailing list