Return Type | Function name | Arguments |
---|---|---|
hzEcode | hdsExec::Extract | (hzChain&,hzHttpEvent*,) |
Declared in file: hzDissemino.h
Defined in file : hdsExec.cpp
Function Logic:
Function body:
hzEcode hdsExec::Extract (hzChain& errorReport, hzHttpEvent* pE) { _hzfunc("hdsExec::Extract") ; hzVect<hzXmlNode*> vx ; hzList<hzHttpFile>::Iter fx ; hzDocXml xdoc ; hzHttpFile hf ; hzChain Z ; hzChain D ; hzChain E ; hzChain T ; chIter zi ; hzXmlNode* pN ; const char* i ; hzString m_Input ; hzString m_Target ; hzString fldname ; uint32_t n ; hzEcode rc ; m_Input = m_pApp->m_ExecParams[m_FstParam] ; m_Target = m_pApp->m_ExecParams[m_FstParam+1]; errorReport.Printf("Extracting from %s to %s\n", *m_Input, *m_Target) ; i = *m_Input ; if (memcmp(i, "%e:", 3)) { errorReport.Printf("Not an identifiable input\n") ; return E_NOTFOUND ; } fldname = i + 3; if (pE->m_Uploads.Exists(fldname)) { hf = pE->m_Uploads[fldname] ; errorReport.Printf("Found input (fld %s file %s of %d bytes) mime=%d\n", *hf.m_fldname, *hf.m_filename, hf.m_file.Size(), hf.m_mime) ; if (hf.m_mime == HMTYPE_APP_OPEN_DOCX) { Gunzip(Z, hf.m_file) ; for (zi = Z ; !zi.eof() ; zi++) { if (*zi != CHAR_LESS) continue ; if (zi == "<w:document") { D << "<w:document" ; for (zi += 11;!zi.eof() ; zi++) { if (*zi == CHAR_LESS) { D.AddByte(CHAR_NL) ; if (zi == "</w:document>") { D << "</w:document>\n" ; break ; } } D.AddByte(*zi) ; if (*zi == CHAR_MORE) D.AddByte(CHAR_NL) ; } break ; } } rc = xdoc.Load(D) ; errorReport.Printf("%s. XML load status err=%s\n", __func__, Err2Txt(rc)) ; if (rc == E_OK) { xdoc.FindNodes(vx, "w:t") ; for (n = 0; n < vx.Count() ; n++) { pN = vx[n] ; E += "<p>\n" ; E << pN->m_fixContent ; E += "\n</p>\n" ; } } errorReport.Printf("Setting var %s with chain of %d bytes\n", *m_Target, E.Size()) ; pE->SetVarChain(m_Target, E) ; } } return rc ; }