aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_directory.c
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-14 22:32:13 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-14 22:32:13 +0000
commit03f9214af5fdf05b399b6ece7f112ec1ac8bfd0e (patch)
tree85d9ca19799733180e6efa5304b5be5b79dfe0b5 /apps/app_directory.c
parent8c45c1475f9d6759b0cbb5e4825f8c76de211596 (diff)
code simplifications
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@20168 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_directory.c')
-rw-r--r--apps/app_directory.c39
1 files changed, 12 insertions, 27 deletions
diff --git a/apps/app_directory.c b/apps/app_directory.c
index 316720088..3856bb04c 100644
--- a/apps/app_directory.c
+++ b/apps/app_directory.c
@@ -176,16 +176,14 @@ static int play_mailbox_owner(struct ast_channel *chan, char *context, char *dia
/* 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 @@ static int play_mailbox_owner(struct ast_channel *chan, char *context, char *dia
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 @@ static struct ast_config *realtime_directory(char *context)
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 @@ static struct ast_config *realtime_directory(char *context)
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 @@ static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *
}
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 @@ static int directory_exec(struct ast_channel *chan, void *data)
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 @@ static int directory_exec(struct ast_channel *chan, void *data)
if (res > 0) {
res = ast_waitstream(chan, AST_DIGIT_ANY);
ast_stopstream(chan);
- if (res >= 0) {
+ if (res >= 0)
continue;
- }
}
}
break;