Assign the hzDomain to an domain name held in a character string Note: This function will record an E_FORMAT error if the supplied cstr did not amount to an domain name
| Return Type | Function name | Arguments |
|---|---|---|
| hzDomain& | hzDomain::operator= | (const char*,) |
Declared in file: hzEmaddr.h
Defined in file : hzDomain.cpp
Function Logic:
Function body:
hzDomain& hzDomain::operator= (const char* cpStr)
{
// Assign the hzDomain to an domain name held in a character string
//
// Arguments: 1) cpStr A null terminated string assumed to be an domain name
//
// 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 domain name
_hzfunc("hzDomain::operator=(cstr)") ;
_domItem* destCtl ; // This domain name space
const char* i ; // Email iterator
char* j ; // Email iterator
uint32_t nLen = 0; // Length of domain name
uint32_t nLP = 0; // Offset to last period
Clear() ;
if (!cpStr || !cpStr[0])
return *this ;
nLen = _ckDomain(nLP, cpStr) ;
if (!nLen)
{
hzerr(E_FORMAT, "Cannot assign %s", cpStr) ;
return *this ;
}
m_addr = _domAlloc(nLen + DOM_FACTOR) ;
if (!m_addr)
hzexit(E_MEMORY, "Cannot assign %s", cpStr) ;
destCtl = _domXlate(m_addr) ;
// Assign the value
destCtl->m_copy = 1;
destCtl->m_len = nLen & 0xff;
destCtl->m_tld = nLP & 0xff;
for (j = destCtl->m_data, i = cpStr ; *i ; *j++ = _tolower(*i++)) ;
*j = 0;
return *this ;
}