Return Type | Function name | Arguments |
---|---|---|
hzUrl& | hzUrl::SetValue | (const hzString,const hzString,bool,unsigned int,) |
Declared in file: hzUrl.h
Defined in file : hzUrl.cpp
Function Logic:
Function body:
hzUrl& hzUrl::SetValue (const hzString domain, const hzString resource, bool bSecure, unsigned int nPort) { _url_space* thisCtl ; const char* pRI ; char* pTmp ; hzString res ; uint32_t lenTotal ; uint32_t lenProt ; uint32_t lenDom ; uint32_t lenRes ; uint32_t lenPort = 0; bool bPort = false ; /* ** ** Test arguments ** */ Clear() ; if (!domain) return *this ; if (!resource) return *this ; res = resource ; res.TruncateUpto("?") ; if (memcmp(*res, "http://", 7)== 0) { operator=(res) ; return *this ; } if (!nPort) nPort = bSecure ? 443:80; else { if (bSecure) bPort = nPort == 443?false: true ; else bPort = nPort == 80?false : true ; } if (bPort) lenPort = nPort > 9999?6:nPort> 999?5:nPort > 99?4: nPort > 9? 3: 2; else lenPort = 0; lenProt = bSecure ? 8: 7; lenDom = domain.Length() ; pRI = *res ; if (pRI[0]== CHAR_FWSLASH) { lenRes = res.Length() ; pRI++ ; } else lenRes = res.Length() + 1; /* ** ** Compile finished URL ** */ lenTotal = lenProt + lenDom + lenPort + lenRes ; m_addr = g_ssrInet.Alloc(lenTotal + URL_FACTOR) ; pTmp = (char*) g_ssrInet.Xlate(m_addr) ; thisCtl = (_url_space*) pTmp ; pTmp += 11; thisCtl->m_copy = 1; thisCtl->m_lenProt = lenProt ; thisCtl->m_lenDom = lenDom ; thisCtl->m_lenPort = lenPort ; thisCtl->m_lenRes = lenRes ; thisCtl->m_port = nPort ; if (bSecure) memcpy(thisCtl->m_data, "https://", lenProt) ; else memcpy(thisCtl->m_data, "http://", lenProt) ; memcpy(thisCtl->m_data + lenProt, *domain, lenDom) ; if (bPort) { pTmp += (lenProt + lenDom) ; sprintf(pTmp, ":%d", nPort) ; } thisCtl->m_data[lenProt + lenDom + lenPort] = CHAR_FWSLASH ; memcpy(thisCtl->m_data + lenProt + lenDom + lenPort + 1,pRI, lenRes - 1); thisCtl->m_data[lenTotal] = 0; return *this ; }