Assign the hzEmaddr to an email address held in a character string Note: This function will record an E_FORMAT error if the supplied cstr did not amount to an email address
| Return Type | Function name | Arguments |
|---|---|---|
| hzEmaddr& | hzEmaddr::operator= | (const char*,) |
Declared in file: hzEmaddr.h
Defined in file : hzEmaddr.cpp
Function Logic:
Function body:
hzEmaddr& hzEmaddr::operator= (const char* cpStr)
{
// Assign the hzEmaddr to an email address held in a character string
//
// Argument: cpStr A null terminated string assumed to be an email address
//
// Returns: Reference to this email adress instance in all cases.
//
// Note: This function will record an E_FORMAT error if the supplied cstr did not amount to an email address
_hzfunc("hzEmaddr::operator=(cstr)") ;
_ema_space* destCtl ; // This email address space
const char* i ; // Email iterator
char* j ; // Email iterator
uint32_t nLhs = 0; // LHS part of email address
uint32_t nRhs = 0; // RHS part of email address
Clear() ;
if (!cpStr || !cpStr[0])
return *this ;
if (!IsEmaddr(cpStr))
{
hzerr(E_FORMAT, "Cannot assign %s", cpStr) ;
return *this ;
}
for (i = cpStr ; *i && *i != ''@'';nLhs++, i++) ;
if (*i == ''@'')
for (i++ ; *i ; nRhs++, i++) ;
if (nLhs < 1|| nLhs > 192||nRhs< 1|| nRhs > 63)
{
hzerr(E_FORMAT, "Cannot assign %s", cpStr) ;
return *this ;
}
// m_addr = g_ssrInet.Alloc(nLhs + nRhs + 1 + EMA_FACTOR) ;
m_addr = _emaAlloc(nLhs + nRhs + 1);
if (!m_addr)
hzexit(E_MEMORY, "Cannot assign %s", cpStr) ;
destCtl = _emaXlate(m_addr) ;
if (!destCtl)
hzexit(E_CORRUPT, "Invalid address") ;
// Assign the value
destCtl->m_copy = 1;
destCtl->m_lhs = nLhs & 0xff;
destCtl->m_rhs = nRhs & 0xff;
for (j = destCtl->m_data, i = cpStr ; *i ; *j++ = _tolower(*i++)) ;
*j = 0;
return *this ;
}