PRInt32 nsEudoraAddress::CountComment( const char *pLine, PRInt32 len) { if (!len) return( 0); PRInt32 cCnt; PRInt32 cnt = 1; pLine++; len--; while (len && (*pLine != ')')) { if (*pLine == '(') { cCnt = CountComment( pLine, len); cnt += cCnt; pLine += cCnt; len -= cCnt; } else { cnt++; len--; pLine++; } } if (len) cnt++; return( cnt); }
int32_t nsEudoraAddress::CountComment(const char *pLine, int32_t len) { if (!len) return 0; int32_t cCnt; int32_t cnt = 1; pLine++; len--; while (len && (*pLine != ')')) { if (*pLine == '(') { cCnt = CountComment(pLine, len); cnt += cCnt; pLine += cCnt; len -= cCnt; } else { cnt++; len--; pLine++; } } if (len) cnt++; return cnt; }
CAliasEntry *nsEudoraAddress::ProcessAlias( const char *pLine, PRInt32 len, nsString& errors) { nsCString name; PRInt32 cnt = GetAliasName( pLine, len, name); pLine += cnt; len -= cnt; // we have 3 known forms of addresses in Eudora // 1) real name <email@address> // 2) email@address // 3) <email@address> // 4) real name email@address // 5) <email@address> (Real name) CAliasEntry *pEntry = new CAliasEntry( name); if (!cnt || !len) return(pEntry); // Theoretically, an alias is just an RFC822 email adress, but it may contain // an alias to another alias as the email! I general, it appears close // but unfortunately not exact so we can't use the nsIMsgHeaderParser to do // the work for us! // Very big bummer! const char *pStart; PRInt32 tLen; nsCString alias; while ( len) { pStart = pLine; cnt = 0; while (len && (*pLine != ',')) { if (*pLine == '"') { tLen = CountQuote( pLine, len); pLine += tLen; len -= tLen; cnt += tLen; } else if (*pLine == '(') { tLen = CountComment( pLine, len); pLine += tLen; len -= tLen; cnt += tLen; } else if (*pLine == '<') { tLen = CountAngle( pLine, len); pLine += tLen; len -= tLen; cnt += tLen; } else { cnt++; pLine++; len--; } } if (cnt) { CAliasData *pData = new CAliasData(); if (pData->Process( pStart, cnt)) { pEntry->m_list.AppendElement( pData); } else delete pData; } if (len && (*pLine == ',')) { pLine++; len--; } } // Always return the entry even if there's no other attribute associated with the contact. return( pEntry); }