Index: apps/app_voicemail.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_voicemail.c,v retrieving revision 1.205 diff -u -r1.205 app_voicemail.c --- apps/app_voicemail.c 2 Apr 2005 01:08:55 -0000 1.205 +++ apps/app_voicemail.c 12 Apr 2005 18:01:32 -0000 @@ -219,9 +219,9 @@ "Leave a voicemail message"; static char *descrip_vm = -" VoiceMail([s|u|b]extension[@context][&extension[@context]][...]): Leaves" +" VoiceMail(extension[@context][&extension[@context]][...][|options]): Leaves" "voicemail for a given extension (must be configured in voicemail.conf).\n" -" If the extension is preceded by \n" +" If the extension is followed by \n" "* 's' then instructions for leaving the message will be skipped.\n" "* 'u' then the \"unavailable\" message will be played.\n" " (/var/lib/asterisk/sounds/vm//unavail) if it exists.\n" @@ -241,11 +241,11 @@ "Enter voicemail system"; static char *descrip_vmain = -" VoiceMailMain([[s]mailbox][@context]): Enters the main voicemail system\n" +" VoiceMailMain([mailbox][@context][|options]): Enters the main voicemail system\n" "for the checking of voicemail. The mailbox can be passed as the option,\n" "which will stop the voicemail system from prompting the user for the mailbox.\n" -"If the mailbox is preceded by 's' then the password check will be skipped. If\n" -"the mailbox is preceded by 'p' then the supplied mailbox is prepended to the\n" +"If the mailbox is followed by 's' then the password check will be skipped. If\n" +"the mailbox is followed by 'p' then the supplied mailbox is prepended to the\n" "user's entry and the resulting string is used as the mailbox number. This is\n" "useful for virtual hosting of voicemail boxes. If a context is specified,\n" "logins are considered in that voicemail context only.\n" @@ -4488,6 +4488,7 @@ struct ast_vm_user *vmu = NULL, vmus; char *context=NULL; int silentexit = 0; + char *options; LOCAL_USER_ADD(u); memset(&vms, 0, sizeof(vms)); @@ -4500,17 +4501,27 @@ strncpy(tmp, data, sizeof(tmp) - 1); ext = tmp; - switch (*ext) { + if ((options = strchr(ext, '|'))) { + options = '\0'; + options++; + if (strchr(options, 's')) + valid++; + else if (strchr(options, 'p')) + prefix++; + } else { + switch (*ext) { case 's': - /* We should skip the user's password */ + /* We should skip the user's password */ valid++; ext++; break; case 'p': - /* We should prefix the mailbox with the supplied data */ + /* We should prefix the mailbox with the supplied data */ prefix++; ext++; break; + } + } context = strchr(ext, '@'); @@ -4852,7 +4863,8 @@ { int res=0, silent=0, busy=0, unavail=0; struct localuser *u; - char tmp[256], *ext; + char tmp[256]; + char *ext, *options; LOCAL_USER_ADD(u); if (chan->_state != AST_STATE_UP) @@ -4866,20 +4878,33 @@ if (ast_strlen_zero(tmp)) return 0; } - ext = tmp; - while (*ext) { - if (*ext == 's') { + + ext = tmp; + if ((options = strchr(tmp, '|'))) { + *options = '0'; + options++; + if (strchr(options, 's')) silent = 2; - ext++; - } else if (*ext == 'b') { - busy=1; - ext++; - } else if (*ext == 'u') { - unavail=1; - ext++; - } else - break; - } + else if (strchr(options, 'b')) + busy = 2; + else if (strchr(options, 'u')) + unavail = 2; + } else { + /* old school options parsing */ + while (*ext) { + if (*ext == 's') { + silent = 2; + ext++; + } else if (*ext == 'b') { + busy=1; + ext++; + } else if (*ext == 'u') { + unavail=1; + ext++; + } else + break; + } + } res = leave_voicemail(chan, ext, silent, busy, unavail); LOCAL_USER_REMOVE(u); return res; @@ -4925,26 +4950,15 @@ struct localuser *u; struct ast_vm_user svm; char *context, *box; - char tmp[256]; - if (!data || !strlen(data)) { + if (!data || !(box = ast_strdupa(data))) { ast_log(LOG_ERROR, "MailboxExists requires an argument: (vmbox[@context])\n"); return -1; - } else { - strncpy(tmp, data, sizeof(tmp) - 1); } LOCAL_USER_ADD(u); - box = tmp; - while (*box) { - if ((*box == 's') || (*box == 'b') || (*box == 'u')) { - box++; - } else - break; - } - context = strchr(tmp, '@'); - if (context) { + if ((context = strchr(box, '@'))) { *context = '\0'; context++; }