[asterisk-commits] trunk r31842 - /trunk/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Jun 3 15:29:38 MST 2006


Author: rizzo
Date: Sat Jun  3 17:29:37 2006
New Revision: 31842

URL: http://svn.digium.com/view/asterisk?rev=31842&view=rev
Log:
simplify logic in a small block of code


Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=31842&r1=31841&r2=31842&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Sat Jun  3 17:29:37 2006
@@ -10034,15 +10034,11 @@
 	} else  if (!strcasecmp(colname, "codecs")) {
 		ast_getformatname_multiple(buf, len -1, peer->capability);
 	} else  if (!strncasecmp(colname, "codec[", 6)) {
-		char *codecnum, *ptr;
+		char *codecnum;
 		int index = 0, codec = 0;
 		
-		codecnum = strchr(colname, '[');
-		*codecnum = '\0';
-		codecnum++;
-		if ((ptr = strchr(codecnum, ']')))
-			*ptr = '\0';
-
+		codecnum = colname + 6;	/* move past the '[' */
+		codecnum = strsep(&codecnum, "]"); /* trim trailing ']' if any */
 		index = atoi(codecnum);
 		if((codec = ast_codec_pref_index(&peer->prefs, index))) {
 			ast_copy_string(buf, ast_getformatname(codec), len);



More information about the asterisk-commits mailing list