diff -Naur asterisk-1.0.5/apps/app_voicemail.c asterisk-1.0.5-new/apps/app_voicemail.c --- asterisk-1.0.5/apps/app_voicemail.c 2005-01-17 01:12:30.000000000 +0100 +++ asterisk-1.0.5-new/apps/app_voicemail.c 2005-04-12 11:49:09.000000000 +0200 @@ -190,13 +190,16 @@ "Leave a voicemail message"; static char *descrip_vm = -" VoiceMail([s|u|b]extension[@context][&extension[@context]][...]): Leaves" +" VoiceMail([s|u|b]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 options parameter is not set, then if the extension is preceded 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" "* 'b' then the the busy message will be played (that is, busy instead of unavail).\n" +"The options parameter can have one of the following values: 's', 'u', 'b'." +"The meaning of these values is the same as the meaning of extension prefix." +"The options parameter was added in order to enable non-numeric voicemail box names that can start with letters 's', 'u' or 'b'." "If the caller presses '0' (zero) during the prompt, the call jumps to\n" "extension 'o' in the current context.\n" "If the caller presses '*' during the prompt, the call jumps to\n" @@ -212,7 +215,7 @@ "Enter voicemail system"; static char *descrip_vmain = -" VoiceMailMain([[s]mailbox][@context]): Enters the main voicemail system\n" +" VoiceMailMain([[s|p]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" @@ -220,6 +223,8 @@ "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" +"Another way of specifying the 's' and 'p' options is using the 'options' parameter." +"If this parameter is specified 'mailbox' is not checked for the prefix." "Returns -1 if the user hangs up or 0 otherwise.\n"; static char *synopsis_vm_box_exists = @@ -3284,6 +3289,7 @@ int silentexit = 0; char cid[256]=""; char *passptr; + char *options; LOCAL_USER_ADD(u); memset(&vms, 0, sizeof(vms)); @@ -3295,19 +3301,34 @@ if (data && !ast_strlen_zero(data)) { strncpy(tmp, data, sizeof(tmp) - 1); ext = tmp; - - switch (*ext) { - case 's': - /* We should skip the user's password */ - valid++; - ext++; - break; - case 'p': - /* We should prefix the mailbox with the supplied data */ - prefix++; - ext++; - break; + + /* 'options' parameter added [start] */ + /* Search for 'options' parameter and look for values [s|p] */ + options = strchr(ext, '|'); + if (options) { + *options = '\0'; + ++options; + if (*options == 's') + ++valid; + else if (*options == 'p') + ++prefix; + } else { + /* We have kept this processing, if 'options' parameter is not set */ + /* This way we have backward compatibility - suggested by markster */ + switch (*ext) { + case 's': + /* We should skip the user's password */ + valid++; + ext++; + break; + case 'p': + /* We should prefix the mailbox with the supplied data */ + prefix++; + ext++; + break; + } } + /* 'options' parameter added [end] */ context = strchr(ext, '@'); if (context) { @@ -3704,6 +3725,7 @@ int res=0, silent=0, busy=0, unavail=0; struct localuser *u; char tmp[256], *ext; + char *options; LOCAL_USER_ADD(u); if (chan->_state != AST_STATE_UP) @@ -3717,20 +3739,40 @@ if (ast_strlen_zero(tmp)) return 0; } + ext = tmp; - while(*ext) { - if (*ext == 's') { + + /* 'options' parameter added [start] */ + /* Search for 'options' parameter and look for values [s|b|u] */ + options = strchr(ext, '|'); + if (options) { + *options = '\0'; + ++options; + if (*options == 's') silent = 2; - ext++; - } else if (*ext == 'b') { + else if (*options == 'b') busy=1; - ext++; - } else if (*ext == 'u') { + else if (*options == 'u') unavail=1; - ext++; - } else - break; + } else { + /* We have kept this processing, if 'options' parameter is not set */ + /* This way we have backward compatibility - suggested by markster */ + while(*ext) { + if (*ext == 's') { + silent = 2; + ext++; + } else if (*ext == 'b') { + busy=1; + ext++; + } else if (*ext == 'u') { + unavail=1; + ext++; + } else + break; + } } + /* 'options' parameter added [end] */ + res = leave_voicemail(chan, ext, silent, busy, unavail); LOCAL_USER_REMOVE(u); return res; @@ -3786,12 +3828,18 @@ LOCAL_USER_ADD(u); box = tmp; + + /* We have put this under the comment since method description does not + say anything about prefixes. + It also doesn't make sense to check for MailboxExists(b100) */ + /* while(*box) { if ((*box == 's') || (*box == 'b') || (*box == 'u')) { box++; } else break; } + */ context = strchr(tmp, '@'); if (context) {