[asterisk-commits] branch murf/AEL2 r16475 - in /team/murf/AEL2: ./ channels/ include/asterisk/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Mar 29 23:10:39 MST 2006


Author: murf
Date: Thu Mar 30 00:10:35 2006
New Revision: 16475

URL: http://svn.digium.com/view/asterisk?rev=16475&view=rev
Log:
Merged revisions 13280-13281 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r13280 | russell | 2006-03-16 13:11:05 -0700 (Thu, 16 Mar 2006) | 2 lines

fix compiler warning on mac (issue #6737)

................
r13281 | tilghman | 2006-03-16 13:16:56 -0700 (Thu, 16 Mar 2006) | 10 lines

Merged revisions 13279 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r13279 | tilghman | 2006-03-16 14:05:00 -0600 (Thu, 16 Mar 2006) | 2 lines

Bug 6737 - Fix compile warning on OS X

........

................

Modified:
    team/murf/AEL2/   (props changed)
    team/murf/AEL2/callerid.c
    team/murf/AEL2/channels/chan_sip.c
    team/murf/AEL2/include/asterisk/callerid.h

Propchange: team/murf/AEL2/
------------------------------------------------------------------------------
    automerge = 1

Propchange: team/murf/AEL2/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Mar 30 00:10:35 2006
@@ -1,1 +1,1 @@
-/trunk:1-16401
+/trunk:1-16471

Modified: team/murf/AEL2/callerid.c
URL: http://svn.digium.com/view/asterisk/team/murf/AEL2/callerid.c?rev=16475&r1=16474&r2=16475&view=diff
==============================================================================
--- team/murf/AEL2/callerid.c (original)
+++ team/murf/AEL2/callerid.c Thu Mar 30 00:10:35 2006
@@ -905,19 +905,40 @@
 	n[y] = '\0';
 }
 
+/*! \brief Checks if phone number consists of valid characters 
+	\param exten	String that needs to be checked
+	\param valid	Valid characters in string
+	\return 1 if valid string, 0 if string contains invalid characters
+*/
+static int ast_is_valid_string(const char *exten, const char *valid)
+{
+	int x;
+
+	if (ast_strlen_zero(exten))
+		return 0;
+	for (x=0; exten[x]; x++)
+		if (!strchr(valid, exten[x]))
+			return 0;
+	return 1;
+}
+
 /*! \brief checks if string consists only of digits and * \# and + 
 	\return 1 if string is valid AST phone number
 	\return 0 if not
 */
-int ast_isphonenumber(char *n)
-{
-	int x;
-	if (ast_strlen_zero(n))
-		return 0;
-	for (x=0;n[x];x++)
-		if (!strchr("0123456789*#+", n[x]))
-			return 0;
-	return 1;
+int ast_isphonenumber(const char *n)
+{
+	return ast_is_valid_string(n, "0123456789*#+");
+}
+
+/*! \brief checks if string consists only of digits and ( ) - * \# and + 
+	Pre-qualifies the string for ast_shrink_phone_number()
+	\return 1 if string is valid AST shrinkable phone number
+	\return 0 if not
+*/
+int ast_is_shrinkable_phonenumber(const char *exten)
+{
+	return ast_is_valid_string(exten, "0123456789*#+()-.");
 }
 
 /*! \brief parse string for caller id information 

Modified: team/murf/AEL2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/murf/AEL2/channels/chan_sip.c?rev=16475&r1=16474&r2=16475&view=diff
==============================================================================
--- team/murf/AEL2/channels/chan_sip.c (original)
+++ team/murf/AEL2/channels/chan_sip.c Thu Mar 30 00:10:35 2006
@@ -1975,9 +1975,12 @@
 		char *tmpcall;
 		char *c;
 		tmpcall = ast_strdupa(r->callid);
-		if ((c = strchr(tmpcall, '@'))) {
-			*c = '\0';
-			ast_string_field_build(r, callid, "%s@%s", tmpcall, peer->fromdomain);
+		if (tmpcall) {
+			c = strchr(tmpcall, '@');
+			if (c) {
+				*c = '\0';
+				ast_string_field_build(r, callid, "%s@%s", tmpcall, peer->fromdomain);
+			}
 		}
 	}
 	if (ast_strlen_zero(r->tohost)) {
@@ -7230,8 +7233,13 @@
 		if ((c = strchr(of, ':')))
 			*c = '\0';
 		tmp = ast_strdupa(of);
-		ast_shrink_phone_number(tmp);
-		ast_string_field_set(p, cid_num, tmp);
+		if (tmp) {
+			if (ast_is_shrinkable_phonenumber(tmp))
+				ast_shrink_phone_number(tmp);
+			ast_string_field_set(p, cid_num, tmp);
+		} else {
+			ast_string_field_set(p, cid_num, of);
+		}
 	}
 	if (ast_strlen_zero(of))
 		return 0;
@@ -7257,8 +7265,13 @@
 			if (*calleridname)
 				ast_string_field_set(p, cid_name, calleridname);
 			tmp = ast_strdupa(rpid_num);
-			ast_shrink_phone_number(tmp);
-			ast_string_field_set(p, cid_num, tmp);
+			if (tmp) {
+				if (ast_is_shrinkable_phonenumber(tmp))
+					ast_shrink_phone_number(tmp);
+				ast_string_field_set(p, cid_num, tmp);
+			} else {
+				ast_string_field_set(p, cid_num, rpid_num);
+			}
 		}
 
 		
@@ -7289,8 +7302,13 @@
 				ast_string_field_set(p, context, user->context);
 			if (!ast_strlen_zero(user->cid_num) && !ast_strlen_zero(p->cid_num)) {
 				char *tmp = ast_strdupa(user->cid_num);
-				ast_shrink_phone_number(tmp);
-				ast_string_field_set(p, cid_num, tmp);
+				if (tmp) {
+					if (ast_is_shrinkable_phonenumber(tmp))
+						ast_shrink_phone_number(tmp);
+					ast_string_field_set(p, cid_num, tmp);
+				} else {
+					ast_string_field_set(p, cid_num, user->cid_num);
+				}
 			}
 			if (!ast_strlen_zero(user->cid_name) && !ast_strlen_zero(p->cid_num))
 				ast_string_field_set(p, cid_name, user->cid_name);
@@ -7360,8 +7378,13 @@
 				char *tmp = ast_strdupa(rpid_num);
 				if (*calleridname)
 					ast_string_field_set(p, cid_name, calleridname);
-				ast_shrink_phone_number(tmp);
-				ast_string_field_set(p, cid_num, tmp);
+				if (tmp) {
+					if (ast_is_shrinkable_phonenumber(tmp))
+						ast_shrink_phone_number(tmp);
+					ast_string_field_set(p, cid_num, tmp);
+				} else {
+					ast_string_field_set(p, cid_num, rpid_num);
+				}
 			}
 			usenatroute = ast_test_flag(&p->flags[0], SIP_NAT_ROUTE);
 			if (p->rtp) {
@@ -7410,8 +7433,13 @@
 				}
 				if (!ast_strlen_zero(peer->cid_num) && !ast_strlen_zero(p->cid_num)) {
 					char *tmp = ast_strdupa(peer->cid_num);
-					ast_shrink_phone_number(tmp);
-					ast_string_field_set(p, cid_num, tmp);
+					if (tmp) {
+						if (ast_is_shrinkable_phonenumber(tmp))
+							ast_shrink_phone_number(tmp);
+						ast_string_field_set(p, cid_num, tmp);
+					} else {
+						ast_string_field_set(p, cid_num, peer->cid_num);
+					}
 				}
 				if (!ast_strlen_zero(peer->cid_name) && !ast_strlen_zero(p->cid_name)) 
 					ast_string_field_set(p, cid_name, peer->cid_name);
@@ -12237,7 +12265,7 @@
 			ast_copy_string(user->subscribecontext, v->value, sizeof(user->subscribecontext));
 		} else if (!strcasecmp(v->name, "setvar")) {
 			varname = ast_strdupa(v->value);
-			if ((varval = strchr(varname,'='))) {
+			if (varname && (varval = strchr(varname,'='))) {
 				*varval = '\0';
 				varval++;
 				if ((tmpvar = ast_variable_new(varname, varval))) {
@@ -12546,7 +12574,7 @@
 		} else if (!strcasecmp(v->name, "setvar")) {
 			/* Set peer channel variable */
 			varname = ast_strdupa(v->value);
-			if ((varval = strchr(varname,'='))) {
+			if (varname && (varval = strchr(varname,'='))) {
 				*varval = '\0';
 				varval++;
 				if ((tmpvar = ast_variable_new(varname, varval))) {
@@ -13252,11 +13280,13 @@
 			return 0;
 		}
 		if ((localtmp = strstr(tmp, "sip:")) && (localtmp = strchr(localtmp, '@'))) {
-			char lhost[80] = "", lport[80] = "";
+			char lhost[80], lport[80];
+			memset(lhost, 0, sizeof(lhost));
+			memset(lport, 0, sizeof(lport));
 			localtmp++;
 			/* This is okey because lhost and lport are as big as tmp */
 			sscanf(localtmp, "%[^<>:; ]:%[^<>:; ]", lhost, lport);
-			if (ast_strlen_zero(lhost)) {
+			if (!strlen(lhost)) {
 				ast_log(LOG_ERROR, "Can't find the host address\n");
 				return 0;
 			}

Modified: team/murf/AEL2/include/asterisk/callerid.h
URL: http://svn.digium.com/view/asterisk/team/murf/AEL2/include/asterisk/callerid.h?rev=16475&r1=16474&r2=16475&view=diff
==============================================================================
--- team/murf/AEL2/include/asterisk/callerid.h (original)
+++ team/murf/AEL2/include/asterisk/callerid.h Thu Mar 30 00:10:35 2006
@@ -193,11 +193,18 @@
  */
 extern void ast_shrink_phone_number(char *n);
 
-/*! \brief Check if a string consists only of digits.   
+/*! \brief Check if a string consists only of digits and + \#
     \param n number to be checked.
     \return Returns 0 if n is a number, 1 if it's not.
  */
-extern int ast_isphonenumber(char *n);
+extern int ast_isphonenumber(const char *n);
+
+/*! \brief Check if a string consists only of digits and and + \# ( ) - .
+	(meaning it can be cleaned with ast_shrink_phone_number)
+    \param exten The extension (or URI) to be checked.
+    \return Returns 0 if n is a number, 1 if it's not.
+ */
+extern int ast_is_shrinkable_phonenumber(const char *exten);
 
 extern int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen);
 



More information about the asterisk-commits mailing list