aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_hasnewvoicemail.c
diff options
context:
space:
mode:
authorcitats <citats@f38db490-d61c-443f-a65b-d21fe96a405b>2004-10-03 05:38:27 +0000
committercitats <citats@f38db490-d61c-443f-a65b-d21fe96a405b>2004-10-03 05:38:27 +0000
commit38c6530b2a7cd4eb11726565df392090c0370bd1 (patch)
treefd9b429eab37470448e0d416a1b5375eab30d3ba /apps/app_hasnewvoicemail.c
parentab56710ca7d4bd898fc10691aa0bb1caa6215b58 (diff)
Fix HasVoicemail so it can parse all arguments correctly (bug 2559)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3890 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_hasnewvoicemail.c')
-rwxr-xr-xapps/app_hasnewvoicemail.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/apps/app_hasnewvoicemail.c b/apps/app_hasnewvoicemail.c
index ab6fbad1d..5891e6764 100755
--- a/apps/app_hasnewvoicemail.c
+++ b/apps/app_hasnewvoicemail.c
@@ -38,6 +38,7 @@
#include <asterisk/pbx.h>
#include <asterisk/module.h>
#include <asterisk/lock.h>
+#include <asterisk/utils.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
@@ -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))) {