Index: app_voicemail.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_voicemail.c,v retrieving revision 1.56 diff -u -r1.56 app_voicemail.c --- app_voicemail.c 11 Feb 2004 03:54:28 -0000 1.56 +++ app_voicemail.c 23 Feb 2004 21:38:58 -0000 @@ -450,11 +450,14 @@ FILE *configin; FILE *configout; + int linenum=0; char inbuf[256]; char orig[256]; + char szCurrContext[256] =""; char tmpin[AST_CONFIG_MAX_PATH]; char tmpout[AST_CONFIG_MAX_PATH]; - char *user, *pass, *rest, *trim; + char *user, *pass, *rest, *trim, *pszContext; + pszContext = NULL; snprintf((char *)tmpin, sizeof(tmpin)-1, "%s/voicemail.conf",(char *)ast_config_AST_CONFIG_DIR); snprintf((char *)tmpout, sizeof(tmpout)-1, "%s/voicemail.conf.new",(char *)ast_config_AST_CONFIG_DIR); configin = fopen((char *)tmpin,"r"); @@ -477,6 +480,7 @@ while (!feof(configin)) { /* Read in the line */ fgets(inbuf, sizeof(inbuf), configin); + linenum++; if (!feof(configin)) { /* Make a backup of it */ memcpy(orig, inbuf, sizeof(orig)); @@ -488,6 +492,18 @@ user=inbuf; while(*user < 33) user++; + /* check for '[' (opening of context name ) */ + pszContext = strchr(user, '['); + if (pszContext) { + strncpy(szCurrContext, pszContext +1, + sizeof(szCurrContext) - 1); + /* now check for ']' */ + pszContext = strchr(szCurrContext, ']'); + if (pszContext) + *pszContext = '\0'; + else + szCurrContext[0] = '\0'; + } pass = strchr(user, '='); if (pass > user) { trim = pass - 1; @@ -512,7 +528,11 @@ } } else rest = NULL; - if (user && pass && *user && *pass && !strcmp(user, vmu->mailbox) && !strcmp(pass, vmu->password)) { + + /* Compare user, pass AND context */ + if (user && *user && !strcmp(user, vmu->mailbox) && + pass && *pass && !strcmp(pass, vmu->password) && + szCurrContext && *szCurrContext && !strcmp(szCurrContext, vmu->context)) { /* This is the line */ if (rest) { fprintf(configout, "%s => %s,%s\n", vmu->mailbox,newpassword,rest);