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

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Apr 27 23:40:41 MST 2006


Author: rizzo
Date: Fri Apr 28 01:40:40 2006
New Revision: 23067

URL: http://svn.digium.com/view/asterisk?rev=23067&view=rev
Log:
minor cleanup


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=23067&r1=23066&r2=23067&view=diff
==============================================================================
--- trunk/apps/app_directory.c (original)
+++ trunk/apps/app_directory.c Fri Apr 28 01:40:40 2006
@@ -153,19 +153,22 @@
  *           '1' for selected entry from directory
  *           '*' for skipped entry from directory
  */
-static int play_mailbox_owner(struct ast_channel *chan, char *context, char *dialcontext, char *ext, char *name, int readext) {
+static int play_mailbox_owner(struct ast_channel *chan, char *context,
+		char *dialcontext, char *ext, char *name, int readext)
+{
 	int res = 0;
-	int loop = 3;
+	int loop;
 	char fn[256];
-	char fn2[256];
 
 	/* Check for the VoiceMail2 greeting first */
 	snprintf(fn, sizeof(fn), "%s/voicemail/%s/%s/greet",
-		(char *)ast_config_AST_SPOOL_DIR, context, ext);
-
-	/* Otherwise, check for an old-style Voicemail greeting */
-	snprintf(fn2, sizeof(fn2), "%s/vm/%s/greet",
-		(char *)ast_config_AST_SPOOL_DIR, ext);
+		ast_config_AST_SPOOL_DIR, context, ext);
+
+	if (ast_fileexists(fn, NULL, chan->language) <= 0) {
+		/* no file, check for an old-style Voicemail greeting */
+		snprintf(fn, sizeof(fn), "%s/vm/%s/greet",
+			ast_config_AST_SPOOL_DIR, ext);
+	}
 
 	if (ast_fileexists(fn, NULL, chan->language) > 0) {
 		res = ast_stream_and_wait(chan, fn, chan->language, AST_DIGIT_ANY);
@@ -175,14 +178,6 @@
 			ast_stream_and_wait(chan, "vm-extension", chan->language, 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_stream_and_wait(chan, fn2, chan->language, AST_DIGIT_ANY);
-		ast_stopstream(chan);
-		/* If Option 'e' was specified, also read the extension number with the name */
-		if (readext) {
-			ast_stream_and_wait(chan, "vm-extension", chan->language, AST_DIGIT_ANY);
-			res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, chan->language);
-		}
 	} else {
 		res = ast_say_character_str(chan, S_OR(name, ext), AST_DIGIT_ANY, chan->language);
 		if (!ast_strlen_zero(name) && readext) {
@@ -191,44 +186,31 @@
 		}
 	}
 
-	while (loop) {
+	for (loop = 3 ; loop > 0; loop--) {
 		if (!res)
 			res = ast_stream_and_wait(chan, "dir-instr", chan->language, AST_DIGIT_ANY);
 		if (!res)
 			res = ast_waitfordigit(chan, 3000);
 		ast_stopstream(chan);
 	
-		if (res > -1) {
-			switch (res) {
-				case '1':
-					/* Name selected */
-					loop = 0;
-					if (ast_goto_if_exists(chan, dialcontext, ext, 1)) {
-						ast_log(LOG_WARNING,
-							"Can't find extension '%s' in context '%s'.  "
-							"Did you pass the wrong context to Directory?\n",
-							ext, dialcontext);
-						res = -1;
-					}
-					break;
-	
-				case '*':   
-					/* Skip to next match in list */
-					loop = 0;
-					break;
-	
-				default:
-					/* Not '1', or '*', so decrement number of tries */
-					res = 0;
-					loop--;
-					break;
-			} /* end switch */
-		} /* end if */
-		else {
-			/* User hungup, so jump out now */
-			loop = 0;
-		}
-	} /* end while */
+		if (res < 0) /* User hungup, so jump out now */
+			break;
+		if (res == '1') {	/* Name selected */
+			if (ast_goto_if_exists(chan, dialcontext, ext, 1)) {
+				ast_log(LOG_WARNING,
+					"Can't find extension '%s' in context '%s'.  "
+					"Did you pass the wrong context to Directory?\n",
+					ext, dialcontext);
+				res = -1;
+			}
+			break;
+		}
+		if (res == '*') /* Skip to next match in list */
+			break;
+
+		/* Not '1', or '*', so decrement number of tries */
+		res = 0;
+	}
 
 	return(res);
 }



More information about the asterisk-commits mailing list