[asterisk-commits] trunk r20168 - /trunk/apps/app_directory.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Apr 14 15:32:15 MST 2006


Author: rizzo
Date: Fri Apr 14 17:32:13 2006
New Revision: 20168

URL: http://svn.digium.com/view/asterisk?rev=20168&view=rev
Log:
code simplifications


Modified:
    trunk/apps/app_directory.c

Modified: trunk/apps/app_directory.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_directory.c?rev=20168&r1=20167&r2=20168&view=diff
==============================================================================
--- trunk/apps/app_directory.c (original)
+++ trunk/apps/app_directory.c Fri Apr 14 17:32:13 2006
@@ -176,16 +176,14 @@
 		/* If Option 'e' was specified, also read the extension number with the name */
 		if (readext) {
 			res = ast_streamfile(chan, "vm-extension", chan->language);
-			if (!res) {
+			if (!res)
 				res = ast_waitstream(chan, AST_DIGIT_ANY);
-			}
 			res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, chan->language);
 		}
 	} else if (ast_fileexists(fn2, NULL, chan->language) > 0) {
 		res = ast_streamfile(chan, fn2, chan->language);
-		if (!res) {
+		if (!res)
 			res = ast_waitstream(chan, AST_DIGIT_ANY);
-		}
 		ast_stopstream(chan);
 		/* If Option 'e' was specified, also read the extension number with the name */
 		if (readext) {
@@ -200,23 +198,19 @@
 					AST_DIGIT_ANY, chan->language);
 		if (!ast_strlen_zero(name) && readext) {
 			res = ast_streamfile(chan, "vm-extension", chan->language);
-			if (!res) {
+			if (!res)
 				res = ast_waitstream(chan, AST_DIGIT_ANY);
-			}
 			res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, chan->language);
 		}
 	}
 
 	while (loop) {
-		if (!res) {
+		if (!res)
 			res = ast_streamfile(chan, "dir-instr", chan->language);
-		}
-		if (!res) {
+		if (!res)
 			res = ast_waitstream(chan, AST_DIGIT_ANY);
-		}
-		if (!res) {
+		if (!res)
 			res = ast_waitfordigit(chan, 3000);
-		}
 		ast_stopstream(chan);
 	
 		if (res > -1) {
@@ -294,8 +288,8 @@
 		ast_category_append(cfg, cat);
 	}
 
-	mailbox = ast_category_browse(rtdata, NULL);
-	while (mailbox) {
+	mailbox = NULL;
+	while ( (mailbox = ast_category_browse(rtdata, mailbox)) ) {
 		fullname = ast_variable_retrieve(rtdata, mailbox, "fullname");
 		hidefromdir = ast_variable_retrieve(rtdata, mailbox, "hidefromdir");
 		snprintf(tmp, sizeof(tmp), "no-password,%s,hidefromdir=%s",
@@ -306,7 +300,6 @@
 			ast_variable_append(cat, var);
 		else
 			ast_log(LOG_WARNING, "Out of memory adding mailbox '%s'\n", mailbox);
-		mailbox = ast_category_browse(rtdata, mailbox);
 	}
 	ast_config_destroy(rtdata);
 
@@ -420,10 +413,7 @@
 		}
 
 		if (lastuserchoice != '1') {
-			if (found) 
-				res = ast_streamfile(chan, "dir-nomore", chan->language);
-			else
-				res = ast_streamfile(chan, "dir-nomatch", chan->language);
+			res = ast_streamfile(chan, found ? "dir-nomore" : "dir-nomatch", chan->language);
 			if (!res)
 				res = 1;
 			return res;
@@ -481,12 +471,8 @@
 	dirintro = ast_variable_retrieve(cfg, args.vmcontext, "directoryintro");
 	if (ast_strlen_zero(dirintro))
 		dirintro = ast_variable_retrieve(cfg, "general", "directoryintro");
-	if (ast_strlen_zero(dirintro)) {
-		if (last)
-			dirintro = "dir-intro";	
-		else
-			dirintro = "dir-intro-fn";
-	}
+	if (ast_strlen_zero(dirintro))
+		dirintro = last ? "dir-intro" : "dir-intro-fn";
 
 	if (chan->_state != AST_STATE_UP) 
 		res = ast_answer(chan);
@@ -504,9 +490,8 @@
 			if (res > 0) {
 				res = ast_waitstream(chan, AST_DIGIT_ANY);
 				ast_stopstream(chan);
-				if (res >= 0) {
+				if (res >= 0)
 					continue;
-				}
 			}
 		}
 		break;



More information about the asterisk-commits mailing list