From 04bcd2ff236d90354cd68a5ef1e283788d280f85 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Sun, 3 Oct 2004 16:43:29 +0000 Subject: [PATCH] Has(New)VoiceMail does not assume INBOX if no folder specified (bug #2559) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/v1-0@3899 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_hasnewvoicemail.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/apps/app_hasnewvoicemail.c b/apps/app_hasnewvoicemail.c index 733a65ec81..e74739653d 100755 --- a/apps/app_hasnewvoicemail.c +++ b/apps/app_hasnewvoicemail.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -70,7 +71,7 @@ static int hasvoicemail_exec(struct ast_channel *chan, void *data) { int res=0; struct localuser *u; - char vmpath[256], *input, *varname = NULL, *vmbox, *vmfolder = "INBOX", *context = "default"; + char vmpath[256], *temps, *input, *varname = NULL, *vmbox, *vmfolder = "INBOX", *context = "default"; DIR *vmdir; struct dirent *vment; int vmcount = 0; @@ -83,21 +84,22 @@ static int hasvoicemail_exec(struct ast_channel *chan, void *data) input = ast_strdupa((char *)data); if (input) { - if ((vmbox = strsep(&input,":"))) - if ((vmfolder = strsep(&input,"|"))) + temps = input; + if ((temps = strsep(&input, "|"))) { + if (input && !ast_strlen_zero(input)) varname = input; - else + input = temps; + } + if ((temps = strsep(&input, ":"))) { + if (input && !ast_strlen_zero(input)) vmfolder = input; - else - if ((vmbox = strsep(&input,"|"))) - varname = input; - else - vmbox = input; - - if (index(vmbox,'@')) { - context = vmbox; - vmbox = strsep(&context,"@"); + input = temps; } + if ((vmbox = strsep(&input, "@"))) + if (input && !ast_strlen_zero(input)) + context = input; + if (!vmbox) + vmbox = input; snprintf(vmpath,sizeof(vmpath), "%s/voicemail/%s/%s/%s", (char *)ast_config_AST_SPOOL_DIR, context, vmbox, vmfolder); if (!(vmdir = opendir(vmpath))) { -- 2.47.2