Return TypeFunction nameArguments
hzUrl&hzUrl::operator=(const char*,)

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

Function Logic:

0:START 1:hzUrl::Clear 2:!url||!url[0] 3:Return *this 4:*_ptr<=(char)32; 5:strstr(_ptr,//) 6:!memcmp(_ptr,http://,7) 7:nPort nProto lenProt memcmp 8:!memcmp(_ptr,https://,8) 9:nPort nProto lenProt memcmp 10:!memcmp(_ptr,ws://,5) 11:nPort nProto lenProt memcmp 12:!memcmp(_ptr,wss://,6) 13:nPort nProto lenProt memcmp 14:!memcmp(_ptr,ftp://,6) 15:nPort nProto lenProt 16:Return *this 17:_ptr 18:pDom 19:*_ptr; 20:*_ptr==(char)58 21:*_ptr==(char)47 22:*_ptr==(char)46 23:items 24:*_ptr==(char)45 25:items 26:*_ptr<=(char)32 27:items 28:items 29:nWhite 30:Return *this 31:!nPeriod 32:Return *this 33:!nAlphas 34:Return *this 35:*_ptr==(char)58 36:items nPort 37:IsDigit(*_ptr); 38:nPort nPort items 39:nPort>=65536 40:Return *this 41:bPort 42:*_ptr>=(char)32&&*_ptr!=(char)47 43:Return *this 44:pRes 45:*_ptr>' '&&*_ptr!=(char)63; 46:lenTotal hzSSR::Alloc m_addr hzSSR::Xlate thisCtl thisCtl thisCtl thisCtl thisCtl thisCtl thisCtl 47:nProto==80&&lenProt==7 48:memcpy 49:nProto==443&&lenProt==8 50:memcpy 51:nProto==80&&lenProt==5 52:memcpy 53:nProto==443&&lenProt==6 54:memcpy 55:nProto==21 56:memcpy 57:Return *this 58:memcpy 59:bPort 60:sprintf 61:memcpy thisCtl 62:Return *this

Function body:

hzUrl& hzUrl::operator= (const char* url)
{
   _hzfunc("hzUrl::operator=") ;
   _url_space* thisCtl ;
   const char* pDom ;
   const char* pRes ;
   const char* _ptr ;
   uint32_t    lenProt = 0;
   uint32_t    lenDom = 0;
   uint32_t    lenPort = 0;
   uint32_t    lenRes = 0;
   uint32_t    lenTotal ;
   uint32_t    nPort = 80;
   uint32_t    nProto = 80;
   uint32_t    nAlphas = 0;
   uint32_t    nPeriod = 0;
   uint32_t    nWhite = 0;
   bool        bPort = false ;
   Clear() ;
   if (!url || !url[0])
       return *this ;
   for (_ptr = url ; *_ptr <&eq; CHAR_SPACE ; _ptr++) ;
   /*
   **  ** Handle protocol component - Remove http:// or https:// to get to domain
   **      */
   if (strstr(_ptr, "//"))
   {
       if      (!memcmp(_ptr, "http://", 7))   { nProto = nPort = 80;lenProt = 7; }
       else if (!memcmp(_ptr, "https://", 8))  { nProto = nPort = 443;lenProt= 8; }
       else if (!memcmp(_ptr, "ws://", 5))     { nProto = nPort = 80;lenProt = 5; }
       else if (!memcmp(_ptr, "wss://", 6)){ nProto = nPort = 443;lenProt= 6; }
       else if (!memcmp(_ptr, "ftp://", 6)){ nProto = nPort = 21;lenProt = 6; }
       else
       {
           hzerr(E_FORMAT, "Scheme not supported") ;
           return *this ;
       }
       _ptr += lenProt ;
   }
   pDom = _ptr ;
   /*
   **  ** Handle domain component: Read up to the end of the domain name. This could be the end of the test string or it
   **   ** could be a forward slash or a colon (for the port number)
   **      */
   for (; *_ptr ; lenDom++, _ptr++)
   {
       if (*_ptr == CHAR_COLON)    break ;
       if (*_ptr == CHAR_FWSLASH)  break ;
       if (*_ptr == CHAR_PERIOD)   { nPeriod++ ; continue ; }
       if (*_ptr == CHAR_MINUS)    { nAlphas++ ; continue ; }
       if (*_ptr <&eq; CHAR_SPACE)    { nWhite++ ; continue ; }
       nAlphas++ ;
   }
   if (nWhite)     { hzerr(E_FORMAT, "Has whitespace\n") ; return *this ; }
   if (!nPeriod)   { hzerr(E_FORMAT, "No periods\n") ; return *this ; }
   if (!nAlphas)   { hzerr(E_FORMAT, "No alphas\n") ; return *this ; }
   /*
   **  ** Handle port component: Deal with case where domain string is terminated by a port indicator
   **      */
   if (*_ptr == CHAR_COLON)
   {
       _ptr++ ;
       for (nPort = 0,lenPort++ ; IsDigit(*_ptr) ; lenPort++)
           { nPort *= 10;nPort += (*_ptr - ''0'');_ptr++ ; }
       if (nPort >&eq; 65536)
       {
           hzerr(E_FORMAT, "Bad port\n") ;
           return *this ;
       }
       bPort = true ;
   }
   if (*_ptr >&eq; CHAR_SPACE && *_ptr != CHAR_FWSLASH)
       return *this ;
   /*
   **  ** Handle resource component: Read up to end of resource
   **      */
   pRes = _ptr ;
   for (; *_ptr > '' ''&&*_ptr != CHAR_QUERY ; lenRes++, _ptr++) ;
   /*
   **  ** Compile finished URL
   **      */
   lenTotal = lenProt + lenDom + lenPort + lenRes ;
   m_addr = g_ssrInet.Alloc(lenTotal + URL_FACTOR) ;
   thisCtl = (_url_space*) g_ssrInet.Xlate(m_addr) ;
   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      (nProto == 80&&lenProt == 7)memcpy(thisCtl->m_data, "http://", lenProt) ;
   else if (nProto == 443&&lenProt== 8)memcpy(thisCtl->m_data, "https://", lenProt) ;
   else if (nProto == 80&&lenProt == 5)memcpy(thisCtl->m_data, "ws://", lenProt) ;
   else if (nProto == 443&&lenProt== 6)memcpy(thisCtl->m_data, "wss://", lenProt) ;
   else if (nProto == 21)  memcpy(thisCtl->m_data, "ftp://", lenProt) ;
   else
   {
       hzerr(E_FORMAT, "Bad scheme\n") ;
       return *this ;
   }
   memcpy(thisCtl->m_data + lenProt, pDom, lenDom) ;
   if (bPort)
       sprintf(thisCtl->m_data + lenProt + lenDom, ":%d", nPort) ;
   memcpy(thisCtl->m_data + lenProt + lenDom + lenPort, pRes, lenRes) ;
   thisCtl->m_data[lenTotal] = 0;
   return *this ;
}