Return TypeFunction nameArguments
hzUrl&hzUrl::SetValue(const hzString,const hzString,bool,unsigned int,)

Declared in file: hzUrl.h
Defined in file : hzUrl.cpp

Function Logic:

0:START 1:hzUrl::Clear 2:!domain 3:Return *this 4:!resource 5:Return *this 6:res hzString::TruncateUpto 7:memcmp(*res,http://,7)==0 8:hzUrl::operator= 9:Return *this 10:!nPort 11:nPort 12:bSecure 13:bPort 14:bPort 15:bPort 16:lenPort 17:lenPort 18:lenProt hzString::Length lenDom pRI 19:pRI[0]==(char)47 20:hzString::Length lenRes items 21:hzString::Length lenRes 22:lenTotal hzSSR::Alloc m_addr hzSSR::Xlate pTmp thisCtl pTmp thisCtl thisCtl thisCtl thisCtl thisCtl thisCtl 23:bSecure 24:memcpy 25:memcpy 26:memcpy 27:bPort 28:pTmp sprintf 29:thisCtl memcpy thisCtl 30:Return *this

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 ;
}