BOOL CXmlDocument::CreateTag(CXmlElement *pElement, CString &strResult) { int i; m_nLevel++; // make sure we start empty strResult = ""; // add spaces before start-tag for (i=0; i<m_nLevel; i++) strResult += " "; // add start-tag strResult += "<"; strResult += pElement->m_strName; if (!pElement->m_strAttributes.IsEmpty()) { strResult += " "; strResult += pElement->m_strAttributes; } strResult += ">"; if (!pElement->m_strData.IsEmpty()) { strResult += pElement->m_strData; } else { strResult += "\r\n"; } // process child elements POSITION pos = pElement->m_ChildElements.GetHeadPosition(); while (pos != NULL) { CXmlElement *pChildElement = (CXmlElement *)pElement->m_ChildElements.GetNext(pos); CString strTag; CreateTag(pChildElement, strTag); strResult += strTag; } if (pElement->m_strData.IsEmpty()) { // add spaces before end tag for (i=0; i<m_nLevel; i++) strResult += " "; } // add end-tag strResult += "</"; strResult += pElement->m_strName; strResult += ">\r\n"; m_nLevel--; return TRUE; }
bool CEpg::UpdateEntry(const CEpgInfoTag &tag, bool bUpdateDatabase /* = false */) { bool bReturn = false; /* XXX tags aren't always fetched correctly here */ CEpgInfoTag *InfoTag = (CEpgInfoTag *) this->InfoTag(tag.UniqueBroadcastID(), tag.Start()); /* create a new tag if no tag with this ID exists */ if (!InfoTag) { CSingleLock lock(m_critSection); InfoTag = CreateTag(); InfoTag->SetUniqueBroadcastID(tag.UniqueBroadcastID()); push_back(InfoTag); } InfoTag->m_Epg = this; InfoTag->Update(tag); Sort(); if (bUpdateDatabase) bReturn = InfoTag->Persist(); else bReturn = true; return bReturn; }
void CEpg::AddEntry(const CEpgInfoTag &tag) { CEpgInfoTag *newTag = CreateTag(); if (newTag) { push_back(newTag); newTag->m_Epg = this; newTag->Update(tag); } }
SEXP exprToFunction(int nVariables, const char **vaList, SEXP rExpr) { PROTECT(rExpr); SEXP charList, rChar, pl; SEXP rFunc; PROTECT(rFunc= allocSExp(CLOSXP)); SET_CLOENV(rFunc, R_GlobalEnv); int i = 0, warn= 0, n= 0; if(nVariables > 0) { PROTECT(charList = allocVector(STRSXP, nVariables)); for(int i=0; i < nVariables; i++){ //TODO STRSXP fill PROTECT(rChar= mkChar(vaList[i])); SET_STRING_ELT(charList, i, rChar); UNPROTECT(1); } PROTECT(charList= VectorToPairList(charList)); n= length(charList); if(n > 0) { PROTECT(pl = allocList(n)); if(n == 1) { SET_TAG(pl, CreateTag(CAR(charList))); SETCAR(pl, R_MissingArg); } else { SET_TAG(pl, CreateTag(CAR(charList))); SETCAR(pl, R_MissingArg); SEXP nextpl= CDR(pl); SEXP nextChar= CDR(charList); for (i= 1; i < n; i++, nextpl = CDR(nextpl), nextChar = CDR(nextChar)) { SET_TAG(nextpl, CreateTag(CAR(nextChar))); SETCAR(nextpl, R_MissingArg); } } } } SET_FORMALS(rFunc, pl); SET_BODY(rFunc, rExpr); //setAttrib(rFunc, R_SourceSymbol, eval(lang2(install("deparse"), rFunc), R_BaseEnv)); // TODO: Deparse not necessary if(n > 0) {UNPROTECT(1);} UNPROTECT(4); return rFunc; }
CString CXmlDocument::Generate() { CString strResult; strResult = "<?xml version=\"1.0\"?>\r\n"; CString strTag; m_nLevel = -1; CreateTag(&m_RootElement, strTag); strResult += strTag; return strResult; }
SEXP make_closure(SEXP body, SEXP formal_parameter_list, SEXP envir) { SEXP closure, formals; PROTECT(closure = allocSExp(CLOSXP)); SET_CLOENV(closure, envir); const int number_of_formals = length(formal_parameter_list); PROTECT(formals = allocList(number_of_formals)); SEXP formals_iterator = formals; for (int i = 0; i < number_of_formals; i++, formals_iterator = CDR(formals_iterator)) { SEXP formal = STRING_ELT(VECTOR_ELT(formal_parameter_list, i), 0); SET_TAG(formals_iterator, CreateTag(formal)); SETCAR(formals_iterator, R_MissingArg); } SET_FORMALS(closure, formals); SET_BODY(closure, body); UNPROTECT(2); return closure; }
// Read next tag in data stream NBTTag NBT_Reader::ReadData() { if (!data) return TAG_Unknown; // Remove non-list tags and empty lists if (!tags.empty()) { NBTData * last = GetData(); if (last->tag <= TAG_String) RemoveTag(); last = GetData(); if (last->tag == TAG_List && last->size <= 0) RemoveTag(); } // Check for list NBTData * last = GetData(); bool isList = last && last->tag == TAG_List; NBTData * tagdata = CreateTag(); if (isList) { --last->size; tagdata->tag = last->list; } else { BYTE type = 0; // Get type ReadByte(&type); tagdata->tag = (NBTTag)type; // Get name if (tagdata->tag != TAG_End) ReadString(&tagdata->name); } // Read tag switch (tagdata->tag) { case TAG_End: RemoveTag(); RemoveTag(); if (tags.empty()) return TAG_Unknown; return TAG_End; break; case TAG_Byte: tagdata->size = ReadByte(&tagdata->b); break; case TAG_Short: tagdata->size = ReadShort(&tagdata->s); break; case TAG_Int: tagdata->size = ReadInt(&tagdata->i); break; case TAG_Long: tagdata->size = ReadLong(&tagdata->l); break; case TAG_Float: tagdata->size = ReadFloat(&tagdata->f); break; case TAG_Double: tagdata->size = ReadDouble(&tagdata->d); break; case TAG_ByteArray: tagdata->size = ReadByteArray(&tagdata->bas); break; case TAG_String: tagdata->size = ReadString(&tagdata->bas); break; case TAG_List: tagdata->size = ReadList(&tagdata->list); break; case TAG_Compound: ReadCompound(); break; } return tagdata->tag; }
static void NemesisMainThread(kernel_st *kst) { DomainMgrMod_clp dmm; DomainMgr_clp dm; TRC(printf("NemesisMainThread: entered.\n")); TRC(printf( " + Finding DomainMgr...\n")); dmm = NAME_FIND("modules>DomainMgrMod",DomainMgrMod_clp); dm = NAME_FIND("sys>DomainMgr",DomainMgr_clp); TRC(printf( " + Completing Domain Manager initialisation.\n")); DomainMgrMod$Done (dmm, dm); /* Get a tag for ourselves and tell the world about it */ TRC(printf( " + Creating a Security.Tag for the system.\n")); { Security_Tag tag; Security_clp sec; Type_Any any; sec=IDC_OPEN("sys>SecurityOffer", Security_clp); /* XXX will be local, so we don't need to worry about dropping it on the floor */ if (Security$CreateTag(sec, &tag)) { ANY_INIT(&any, Security_Tag, tag); Context$Add (Pvs(root), "sys>SystemTag", &any); } else { printf("Error: couldn't create system tag\n"); ntsc_dbgstop(); } } #if defined(CONFIG_MEMSYS_STD) || defined(CONFIG_MEMSYS_EXPT) TRC(printf( " + Creating mmentry.\n")); { MMEntryMod_cl *mmemod; MMEntry_cl *mmentry; MMNotify_cl *mmnfy; mmemod = NAME_FIND("modules>MMEntryMod", MMEntryMod_clp); mmnfy = NAME_FIND("sys>MMNotify", MMNotify_clp); mmentry = MMEntryMod$New(mmemod, mmnfy, (ThreadF_cl *)Pvs(thds), Pvs(heap), 10 /* XXX should be param? */); } #endif TRC(printf( " + Register binder's protection domain.\n")); { ProtectionDomain_ID pdid = VP$ProtDomID(Pvs(vp)); ANY_DECL(tmpany,ProtectionDomain_ID, pdid); Context$Add (Pvs(root), "sys>BinderPDom",&tmpany); } TRC(printf( " + Register standard root context.\n")); CX_ADD ("sys>StdRoot", Pvs(root), Context_clp); /* Interrupt Allocation Module */ TRC(printf( " + Init interrupt allocation module.\n")); { Interrupt_clp ipt; /* Find the interrupt allocation module */ ipt = InterruptInit(kst); TRC(printf(" + Created an Interrupt server at %p.\n", ipt)); TRC(printf(" + exporting... ")); IDC_EXPORT ("sys>InterruptOffer", Interrupt_clp, ipt); TRC(printf("done\n")); } #ifdef CONFIG_CALLPRIV /* CallPriv allocation module */ TRC(printf( " + Init CallPriv allocation module.\n")); { CallPriv_clp cp; /* Find the callpriv module */ cp = CallPrivInit(kst); TRC(printf(" + created a CallPriv server at %p\n", cp)); TRC(printf(" + exporting... ")); IDC_EXPORT ("sys>CallPrivOffer", CallPriv_clp, cp); TRC(printf("done.\n")); } #endif /* CONFIG_CALLPRIV */ #ifdef CONFIG_MODULE_OFFSET_DATA /* Module offset data module */ TRC(printf( " + Init ModData module.\n")); { ModData_clp md; md=ModDataInit(); TRC(printf(" + created a ModData server at %p\n", md)); TRC(printf(" + exporting... ")); IDC_EXPORT ("sys>ModDataOffer", ModData_clp, md); TRC(printf("done.\n")); } #endif /* CONFIG_MODULE_OFFSET_DATA */ { Type_Any any; if (Context$Get(Pvs(root), "modules>PCIBiosInstantiate", &any)) { Closure_clp pcibiosinstantiate; pcibiosinstantiate = NARROW(&any, Closure_clp); TRC(printf( " + Init PCIBios allocation module.\n")); Closure$Apply(pcibiosinstantiate); } } #ifdef AXP3000 TRC(printf( " + Probing Turbochannel...\n")); { char name[TC_ROMNAMLEN+2]; /* 1 extra for number, one for '\0' */ volatile uint32_t *romptr; volatile uint32_t *mchk_expected = &(kst->mchk_expected); volatile uint32_t *mchk_taken = &(kst->mchk_taken); Context_clp tc_cx; NOCLOBBER int i, j, k; NOCLOBBER char added, dev_no; tc_cx = CX_NEW("sys>tc"); for(i=0; i < 6; i++) { /* get a pointer to the 'name' of the card current slot */ romptr = (uint32_t *)((char *)slots[i].addr+(TC_NAME_OFFSET*2)); /* setup kernel to ignore a mchk (such as TC read timeout) */ *mchk_expected = True; *mchk_taken = 0; /* dereference the romptr & see if we get a mchk */ *((uint32_t *)TC_EREG) = 0; /* unlock tcerr */ *romptr; if(!(*mchk_taken)) { /* all is ok => read out the name */ #define TC_ROM_STRIDE 2 for (j = 0, k = 0; j < TC_ROMNAMLEN; j++, k += TC_ROM_STRIDE) name[j] = (char)romptr[k]; name[TC_ROMNAMLEN] = name[TC_ROMNAMLEN+1] = ' '; /* Get rid of extra spaces at the end & add in device number */ dev_no= '0'; added = False; for (j = 0; name[j]!=' '; j++) ; name[j] = dev_no; name[j+1] = '\0'; while(!added) { TRY { CX_ADD_IN_CX(tc_cx, (char *)name, &(slots[i]), TCOpt_SlotP); added= True; } CATCH_Context$Exists() { name[j]= dev_no++; } ENDTRY; } TRC(printf(" +++ probed slot %d: added card, name= \"%s\"\n", i, name)); } else { #define MCHK_K_TC_TIMEOUT_RD 0x14 if(*mchk_taken==MCHK_K_TC_TIMEOUT_RD) { TRC(printf(" +++ slot %d is empty.\n", i)); } else { TRC(printf(" *** Bad MCHK (code 0x%x) taken in TC probe." "Halting.\n", *mchk_taken)); } } } *((uint32_t *)TC_EREG) = 0; /* unlock tcerr */ *mchk_expected = False; /* enable mchks again */ TRC(printf(" + Turbochannel probe done.\n")); }