Return TypeFunction nameArguments
hzString&hzString::UrlEncode(bool,)

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

Function Logic:

0:START 1:!m_addr 2:Return *this 3:_strXlate thisCtl _strItem::_getSize nLen _strItem::_data 4:*i; 5:*i==(char)37 6:IsUrlnorm(*i) 7:IsUrlresv(*i) 8:bResv 9:nLen 10:nLen 11:nLen==thisCtl->_getSize() 12:Return *this 13:_strAlloc destAddr _strXlate destCtl _strItem::_setSize destCtl _strItem::_data j _strItem::_data 14:*i; 15:*i==(char)37 16:* IsUrlnorm 17:IsUrlnorm(*i) 18:* 19:IsUrlresv(*i)&&!bResv 20:* 21:* sprintf * * 22:thisCtl->m_copy&&thisCtl->m_copy<50 23:!_hzGlobal_MT 24:items 25:!thisCtl->m_copy 26:_strItem::_getSize _strFree 27:__sync_add_and_fetch(&(thisCtl->m_copy),-1)==0 28:_strItem::_getSize _strFree 29:m_addr 30:Return *this

Function body:

hzString& hzString::UrlEncode (bool bResv)
{
   _hzfunc("hzString::UrlEncode") ;
   _strItem*   thisCtl ;
   _strItem*   destCtl ;
   char*       i ;
   char*       j ;
   uint32_t    nLen ;
   uint32_t    destAddr ;
   char        buf [4];
   if (!m_addr)
       return *this ;
   thisCtl = (_strItem*) _strXlate(m_addr) ;
   nLen = thisCtl->_getSize() ;
   for (i = (char*) thisCtl->_data() ; *i ; i++)
   {
       if (*i == CHAR_PERCENT)
           continue ;
       if (IsUrlnorm(*i))
           continue ;
       if (IsUrlresv(*i))
       {
           if (bResv)
               nLen += 2;
           continue ;
       }
       nLen += 2;
   }
   if (nLen == thisCtl->_getSize())
       return *this ;
   destAddr = _strAlloc(nLen) ;
   destCtl = (_strItem*) _strXlate(destAddr) ;
   destCtl->_setSize(nLen) ;
   destCtl->m_copy = 1;
   j = (char*) destCtl->_data() ;
   for (i = (char*) thisCtl->_data() ; *i ; i++)
   {
       if (*i == CHAR_PERCENT)
           *j++ = *i ;
       else if (IsUrlnorm(*i))
           *j++ = *i ;
       else if (IsUrlresv(*i) && !bResv)
           *j++ = *i ;
       else
       {
           *j++ = CHAR_PERCENT ;
           sprintf(buf, "%02x", (uint32_t) *i) ;
           *j++ = buf[0];
           *j++ = buf[1];
       }
   }
   if (thisCtl->m_copy && thisCtl->m_copy < 50)
   {
       if (!_hzGlobal_MT)
       {
           thisCtl->m_copy-- ;
           if (!thisCtl->m_copy)
               _strFree(m_addr, thisCtl->_getSize()) ;
       }
       else
       {
           if (__sync_add_and_fetch(&(thisCtl->m_copy), -1)== 0)
               _strFree(m_addr, thisCtl->_getSize()) ;
       }
   }
   m_addr = destAddr ;
   return *this ;
}