Return TypeFunction nameArguments
const char*GetIpLocation(const hzIpaddr&,)

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

Function Logic:

0:START 1:s_IpCity_max 2:pZones nDiv nPos nMax 3:!s_IpBasic_max 4:Return *ip_not_found 5:pZones nDiv nPos nMax 6:bFound ipval 7:; 8:nPos>=nMax 9:!nDiv 10:nPos nDiv 11:ipval>=pZones[nPos+1] 12:!nDiv 13:nPos nDiv 14:ipval 15:!nDiv 16:nPos nDiv 17:bFound 18:!bFound 19:Return *ip_not_found 20:s_IpCity_max 21:Return s_IpCity_text+s_IpCity_osets[nPos] 22:Return GetCountryCode(s_IpBasic_codes[nPos])

Function body:

const char* GetIpLocation (const hzIpaddr& ipa)
{
   _hzfunc(__func__) ;
   static  hzString    ip_not_found = "-- IP Location Not-found" ;
   static  hzString    ip_error = "-- IP Location Error" ;
   const uint32_t* pZones ;
   uint32_t        nDiv ;
   uint32_t        nPos ;
   uint32_t        nMax ;
   uint32_t        ipval ;
   bool            bFound ;
   if (s_IpCity_max)
   {
       pZones = s_IpCity_zones ;
       nDiv = s_IpCity_div ;
       nPos = s_IpCity_start ;
       nMax = s_IpCity_max ;
   }
   else
   {
       if (!s_IpBasic_max)
           return *ip_not_found ;
       pZones = s_IpBasic_zones ;
       nDiv = s_IpBasic_div ;
       nPos = s_IpBasic_start ;
       nMax = s_IpBasic_max ;
   }
   bFound = false ;
   ipval = (uint32_t) ipa ;
   for (;;)
   {
       if (nPos >&eq; nMax)
       {
           if (!nDiv)
               break ;
           nPos -= nDiv ;
           nDiv /= 2;
           continue ;
       }
       if (ipval >&eq; pZones[nPos+1])
       {
           if (!nDiv)
               break ;
           nPos += nDiv ;
           nDiv /= 2;
           continue ;
       }
       if (ipval < pZones[nPos])
       {
           if (!nDiv)
               break ;
           nPos -= nDiv ;
           nDiv /= 2;
           continue ;
       }
       bFound = true ;
       break ;
   }
   if (!bFound)
   {
       threadLog("Not found\n") ;
       return *ip_not_found ;
   }
   if (s_IpCity_max)
   {
       return s_IpCity_text + s_IpCity_osets[nPos] ;
   }
   return GetCountryCode(s_IpBasic_codes[nPos]) ;
}