Return TypeFunction nameArguments
hzEcodehdsExec::SrchPages(hzChain&,hzHttpEvent*,)

Declared in file: hzDissemino.h
Defined in file : hdsExec.cpp

Function Logic:

0:START 1:!pE 2:Fatal 3:hzChain::Printf hzVect::Clear m_Criteria V hzMapS::Exists 4:!pE->m_mapStrings.Exists(V) 5:hzChain::Printf pE 6:Return E_NOTFOUND 7:S hzChain::Printf hdbIndexText::Eval rc 8:rc!=E_OK 9:pE 10:Return E_NOTFOUND 11:!R.Count() 12:hzChain::Printf pE 13:Return E_NOTFOUND 14:hdbIdset::Count Err2Txt hzChain::Printf hdbIdset::Count sprintf S hzHttpEvent::SetVarString rc 15:rc!=E_OK 16:hzChain::Printf 17:items items nStart 18:; 19:hdbIdset::Fetch hzVect::Count hzChain::Printf nCount 20:nCount 21:hzMapS::GetObj pRes items 22:!pPage 23:hzChain::Printf hzVect::Add hzChain::Printf 24:res.Count()<20 25:nStart 26:items items V hzHttpEvent::SetVarChain rc 27:rc!=E_OK 28:hzChain::Size hzChain::Printf 29:hzVect::Count hzChain::Printf 30:Return rc

Function body:

hzEcode hdsExec::SrchPages (hzChain& errorReport, hzHttpEvent* pE)
{
   _hzfunc("hdsExec::SrchPages") ;
   hzVect<hdsPage*>    Result ;
   hzVect<uint32_t>    res ;
   hzChain         Z ;
   hzToken         T ;
   hdbIdset        R ;
   hdsResource*    pRes ;
   hdsPage*        pPage ;
   hzString        m_Action ;
   hzString        m_Source ;
   hzString        m_Criteria ;
   hzString        m_Count ;
   hzString        m_Found ;
   hzString        V ;
   hzString        S ;
   uint32_t        nCount ;
   uint32_t        nStart ;
   hzEcode         bSelect ;
   hzEcode         rc = E_OK ;
   char            buf [20];
   if (!pE)
       Fatal("No HTTP event supplied\n") ;
   errorReport.Printf("SrchPages ...\n") ;
   Result.Clear() ;
   m_Criteria = m_pApp->m_ExecParams[m_FstParam] ;
   V = "srch_pages_criteria" ;
   if (!pE->m_mapStrings.Exists(V))
   {
       errorReport.Printf("%s. No such field as srch_pages_criteria\n", __func__) ;
       pE->m_appError = "Due to an Internal Error (Field name mismatch) we could not process your request" ;
       return E_NOTFOUND ;
   }
   S = pE->m_mapStrings[V] ;
   errorReport.Printf("%s. Search page index for [%s]\n", __func__, *S) ;
   rc = m_pApp->m_PageIndex.Eval(R, S) ;
   if (rc != E_OK)
   {
       pE->m_appError = "Due to an Internal Error (Evaluation of page index) we could not process your request" ;
       return E_NOTFOUND ;
   }
   if (!R.Count())
   {
       Z.Printf("Your search for %s found 0 results. Please try again", *S) ;
       pE->m_appError = Z ;
       return E_NOTFOUND ;
   }
   errorReport.Printf("%s. Results are %d pages, error=%s\n", __func__, R.Count(), Err2Txt(rc)) ;
   sprintf(buf, "%d", R.Count()) ;
   S = buf ;
   rc = pE->SetVarString(m_Count, S) ;
   if (rc != E_OK)
       errorReport.Printf("%s. Could not set var %s to %s\n", __func__, *m_Count, buf) ;
   Z << "<div id="stdlist">\n"   ;
   Z << "<table align="center" border="0" cellspacing="0" cellpadding="0">\n"         ;
   for (nStart = 0;;)
   {
       R.Fetch(res, nStart, 20);
       errorReport.Printf("%s: Fetched %d records (total)\n", __func__, res.Count()) ;
       for (nCount = 0; nCount < res.Count() ; nCount++)
       {
           pRes = m_pApp->m_ResourcesName.GetObj(res[nCount]) ;
           pPage = dynamic_cast<hdsPage*>(pRes) ;
           if (!pPage)
               continue ;
           errorReport.Printf("%s: Page No %d is page %p\n", __func__, res[nCount], pPage) ;
           Result.Add(pPage) ;
           Z.Printf("<tr><td><a href="%s">%s</a></td><td> </td><td><a href="%s">%s</a></td></tr>\n"    ,
               *pPage->m_Url, *pPage->m_Title, *pPage->m_Url, *pPage->m_Desc) ;
       }
       if (res.Count() < 20)
           break ;
       nStart += 20;
   }
   Z << "</table>\n" ;
   Z << "</div>\n" ;
   V = "srch_pages_result" ;
   rc = pE->SetVarChain(m_Found, Z) ;
   if (rc != E_OK)
       errorReport.Printf("%s. Could not set var %s to chain of %d bytes\n", __func__, *m_Found, Z.Size()) ;
   errorReport.Printf("%s: Site scanned. %d pages\n", __func__, Result.Count()) ;
   return rc ;
}