[svn-commits] tilghman: branch 1.6.1 r262658 - in /branches/1.6.1: ./ apps/app_privacy.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed May 12 11:29:09 CDT 2010


Author: tilghman
Date: Wed May 12 11:29:04 2010
New Revision: 262658

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=262658
Log:
Merged revisions 262656 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r262656 | tilghman | 2010-05-12 11:23:26 -0500 (Wed, 12 May 2010) | 8 lines
  
  Ensure the arguments are initialized.  Also miscellaneous CG cleanup.
  
  (closes issue #16576)
   Reported by: uxbod
   Patches: 
         20100505__issue16576.diff.txt uploaded by tilghman (license 14)
   Tested by: uxbod
........

Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/apps/app_privacy.c

Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.1/apps/app_privacy.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.1/apps/app_privacy.c?view=diff&rev=262658&r1=262657&r2=262658
==============================================================================
--- branches/1.6.1/apps/app_privacy.c (original)
+++ branches/1.6.1/apps/app_privacy.c Wed May 12 11:29:04 2010
@@ -21,7 +21,7 @@
  * \brief Block all calls without Caller*ID, require phone # to be entered
  *
  * \author Mark Spencer <markster at digium.com>
- * 
+ *
  * \ingroup applications
  */
 
@@ -82,48 +82,55 @@
 	} else {
 		/*Answer the channel if it is not already*/
 		if (chan->_state != AST_STATE_UP) {
-			if ((res = ast_answer(chan)))
+			if ((res = ast_answer(chan))) {
 				return -1;
+			}
 		}
 
-		if (!ast_strlen_zero(data)) {
-			parse = ast_strdupa(data);
-			
-			AST_STANDARD_APP_ARGS(args, parse);
+		parse = ast_strdupa(S_OR(data, ""));
 
-			if (args.maxretries) {
-				if (sscanf(args.maxretries, "%30d", &x) == 1)
-					maxretries = x;
-				else
-					ast_log(LOG_WARNING, "Invalid max retries argument\n");
+		AST_STANDARD_APP_ARGS(args, parse);
+
+		if (!ast_strlen_zero(args.maxretries)) {
+			if (sscanf(args.maxretries, "%30d", &x) == 1 && x > 0) {
+				maxretries = x;
+			} else {
+				ast_log(LOG_WARNING, "Invalid max retries argument: '%s'\n", args.maxretries);
 			}
-			if (args.minlength) {
-				if (sscanf(args.minlength, "%30d", &x) == 1)
-					minlength = x;
-				else
-					ast_log(LOG_WARNING, "Invalid min length argument\n");
+		}
+		if (!ast_strlen_zero(args.minlength)) {
+			if (sscanf(args.minlength, "%30d", &x) == 1 && x > 0) {
+				minlength = x;
+			} else {
+				ast_log(LOG_WARNING, "Invalid min length argument: '%s'\n", args.minlength);
 			}
-		}		
+		}
 
 		/* Play unidentified call */
 		res = ast_safe_sleep(chan, 1000);
-		if (!res)
+		if (!res) {
 			res = ast_streamfile(chan, "privacy-unident", chan->language);
-		if (!res)
+		}
+		if (!res) {
 			res = ast_waitstream(chan, "");
+		}
 
 		/* Ask for 10 digit number, give 3 attempts */
 		for (retries = 0; retries < maxretries; retries++) {
-			if (!res)
+			if (!res) {
 				res = ast_streamfile(chan, "privacy-prompt", chan->language);
-			if (!res)
+			}
+			if (!res) {
 				res = ast_waitstream(chan, "");
+			}
 
-			if (!res ) 
+			if (!res) {
 				res = ast_readstring(chan, phone, sizeof(phone) - 1, /* digit timeout ms */ 3200, /* first digit timeout */ 5000, "#");
+			}
 
-			if (res < 0)
+			if (res < 0) {
 				break;
+			}
 
 			/* Make sure we get at least digits */
 			if (strlen(phone) >= minlength ) {
@@ -142,25 +149,27 @@
 				}
 			} else {
 				res = ast_streamfile(chan, "privacy-incorrect", chan->language);
-				if (!res)
+				if (!res) {
 					res = ast_waitstream(chan, "");
+				}
 			}
 		}
-		
+
 		/* Got a number, play sounds and send them on their way */
-		if ((retries < maxretries) && res >= 0 ) {
+		if ((retries < maxretries) && res >= 0) {
 			res = ast_streamfile(chan, "privacy-thankyou", chan->language);
-			if (!res)
+			if (!res) {
 				res = ast_waitstream(chan, "");
+			}
 
-			ast_set_callerid (chan, phone, "Privacy Manager", NULL); 
+			ast_set_callerid(chan, phone, "Privacy Manager", NULL);
 
 			/* Clear the unavailable presence bit so if it came in on PRI
 			 * the caller id will now be passed out to other channels
 			 */
 			chan->cid.cid_pres &= (AST_PRES_UNAVAILABLE ^ 0xFF);
 
-			ast_verb(3, "Changed Caller*ID to %s, callerpres to %d\n",phone,chan->cid.cid_pres);
+			ast_verb(3, "Changed Caller*ID to '%s', callerpres to %d\n", phone, chan->cid.cid_pres);
 
 			pbx_builtin_setvar_helper(chan, "PRIVACYMGRSTATUS", "SUCCESS");
 		} else {
@@ -173,7 +182,7 @@
 
 static int unload_module(void)
 {
-	return ast_unregister_application (app);
+	return ast_unregister_application(app);
 }
 
 static int load_module(void)




More information about the svn-commits mailing list