INT xeml_address_verify(CHAR * lpszMailAddress, MAILADDRDIVPROC saveproc, void *lpvoid, BOOL fOnlyVerifyFirstOne)
{
BYTE * p = (unsigned char*)lpszMailAddress;
INT iNormAddrCount = 0L, iLotusNotesCount = 0L;
if(NULL == lpszMailAddress){
return MAILADDR_ERROR;
}else{
SKIP_SPACE_FORWARD(p);
if('\0' == *p){
return MAILADDR_EMPTY;
}
}
while(*p){
CHAR * alias_begin = NULL; /* first quotation if address includes alias */
CHAR * alias_end = NULL;
CHAR * virgule = NULL; /* first virgule mark in LotusNotes' address */
CHAR * p_start = NULL; /* first character of a real mail address */
CHAR * p_tail = NULL;
CHAR * p_chrAt = 0L; /* position of character '@' in a mail address */
INT iDotCount = 0L;
SKIP_SPACE_FORWARD(p);
if(QUOTATION == *p){ /* seek alias from "alias" <accountname@isp.com.org>, no space between braces */
alias_begin = ++p;
if(NULL == (p_start = strchr(alias_begin, QUOTATION))){
return MAILADDR_ERROR; /* isn't a brace of double-quotation-mark */
}else{
alias_end = p_start++; /* jump to the first character after right double-quotation-mark */
}
SKIP_SPACE_FORWARD(p_start);
if(';' == *p){
++p;
}else if('\0' != *p){
return MAILADDR_ERROR;
}
if(NULL == virgule){ /* It's a normal mail address such as " 'mary'<abc@edu.cn>" */
if(NULL == p_chrAt){
return MAILADDR_ERROR;
}
if(iDotCount <= 0){ /* must include '.' in a mail address ? */
return MAILADDR_ERROR;
}
++iNormAddrCount;
}else{ /* LotusNotes address, but the address like "abcd/bb/cc" is valid ? */
++iLotusNotesCount;
}
if(NULL != saveproc && NULL != lpvoid){
INT iAlias = 0;
INT iAddr = 0;
if(NULL == alias_end){ /* no alias in this address */
alias_begin = p_start; iAlias = (NULL==virgule ? p_chrAt : virgule) - alias_begin;
}else{
iAlias = alias_end - alias_begin;
}
iAddr = p_tail - p_start;