static void doSendEmail(CMailInfo & info, CMailPart const & part) { info.open(); StringBuffer outbuff; info.read(); info.getHelo(outbuff); info.write(outbuff.str(), outbuff.length()); info.read(); info.getMailFrom(outbuff.clear()); info.write(outbuff.str(), outbuff.length()); info.read(); unsigned numRcpt = info.numRecipients(); for(unsigned i=0; i<numRcpt; ++i) { info.getRecipient(i, outbuff.clear()); info.write(outbuff.str(), outbuff.length()); info.read(); } info.write(data, strlen(data)); info.read(); info.getHeader(outbuff.clear()); part.getHeader(outbuff); outbuff.append("\r\n"); info.write(outbuff.str(), outbuff.length(), "mail header"); part.write(info); info.write(endMail, strlen(endMail), "end of mail body"); info.read(); info.write(quit, strlen(quit)); info.read(); }
bool build_globals(int argc, const char *argv[], IProperties * globals) { int i; for(i = 0; i < argc; i++) { if(argv[i] != NULL && argv[i][0] == '@' && argv[i][1] != '\0') { globals->loadFile(argv[i]+1); } } for (i = 1; i < argc; i++) { if (strchr(argv[i],'=')) { globals->loadProp(argv[i]); } } StringBuffer tmp; if(globals->hasProp("encrypt")) { encrypt(tmp.clear(),globals->queryProp("encrypt") ); // basic encryption at this stage globals->setProp("encrypt",tmp.str()); } if(globals->hasProp("decrypt")) { encrypt(tmp.clear(),globals->queryProp("decrypt") ); // basic encryption at this stage globals->setProp("decrypt",tmp.str()); } return true; }
CWsMachineSoapBindingEx::CWsMachineSoapBindingEx(IPropertyTree* cfg, const char *bindname/*=NULL*/, const char *procname/*=NULL*/) :Cws_machineSoapBinding(cfg, bindname, procname) { StringBuffer xpath; xpath.appendf("Software/EspProcess[@name=\"%s\"]", procname); IPropertyTree* pEspProcess = cfg->queryPropTree(xpath.str()); if (pEspProcess) { xpath.clear().appendf("EspBinding[@name=\"%s\"]/@service", bindname); const char* service = pEspProcess->queryProp(xpath.str()); if (service) { xpath.clear().appendf("EspService[@name=\"%s\"]/MachineInfo/Software/*", service); Owned<IPropertyTreeIterator> it = pEspProcess->getElements(xpath.str()); ForEach(*it) { m_processTypes.append(it->query().queryName()); } m_processTypes.sort(SortFunction); } } }
unsigned SWBackupNode::add(IPropertyTree *params) { unsigned rc = SWProcess::add(params); IPropertyTree * envTree = m_envHelper->getEnvTree(); const char* key = params->queryProp("@key"); StringBuffer xpath; xpath.clear().appendf(XML_TAG_SOFTWARE "/%s[@name=\"%s\"]", m_processName.str(), key); IPropertyTree * compTree = envTree->queryPropTree(xpath.str()); assert(compTree); const char* selector = params->queryProp("@selector"); if (selector && !stricmp("NodeGroup", selector)) { IPropertyTree *nodeGroup = createPTree(selector); IPropertyTree* pAttrs = params->queryPropTree("Attributes"); updateNode(nodeGroup, pAttrs, NULL); if (!nodeGroup->hasProp("@interval")) { xpath.clear().appendf("xs:element/xs:complexType/xs:sequence/xs:element[@name=\"NodeGroup\"]/xs:complexType/xs:attribute[@name=\"interval\"]/@default"); const char *interval = m_pSchema->queryProp(xpath.str()); if ( interval && *interval ) { nodeGroup->addProp("@interval", interval); } else { throw MakeStringException(CfgEnvErrorCode::MissingRequiredParam, "Missing required paramter \"interval\" and there is no default value."); } } compTree->addPropTree(selector, nodeGroup); } return rc; }
IPropertyTree * SWProcess::getPortDefinition() { StringBuffer xpath; xpath.clear().appendf("xs:element[@name=\"%s\"]", m_instanceElemName.str()); IPropertyTree * instanceNode = m_pSchema->queryPropTree(xpath.str()); if (!instanceNode) return NULL; xpath.clear().append("xs:attribute[@name=\"port\"]"); return instanceNode->queryPropTree(xpath.str()); }
inline LPCSTR getValue() const { static StringBuffer buf; if(isBinary()) buf.clear().append(binaryValue); else pTree->getProp(name, buf.clear()); return buf.toCharArray(); }
virtual void write() { StringBuffer rowTag; OwnedRoxieString xmlpath(helper->getXmlIteratorPath()); if (!xmlpath) { rowTag.append("Row"); } else { const char *path = xmlpath; if (*path == '/') path++; if (strchr(path, '/')) UNIMPLEMENTED; rowTag.append(path); } StringBuffer xmlOutput; CommonXmlWriter xmlWriter(helper->getXmlFlags()); if (!dlfn.isExternal() || firstNode()) // if external, 1 header,footer { OwnedRoxieString header(helper->getHeader()); if (header) xmlOutput.clear().append(header); else xmlOutput.clear().append("<Dataset>").newline(); outraw->write(xmlOutput.length(), xmlOutput.toCharArray()); if (calcFileCrc) fileCRC.tally(xmlOutput.length(), xmlOutput.toCharArray()); } while(!abortSoon) { OwnedConstThorRow row = input->ungroupedNextRow(); if (!row) break; xmlWriter.clear().outputBeginNested(rowTag, false); helper->toXML((const byte *)row.get(), xmlWriter); xmlWriter.outputEndNested(rowTag); outraw->write(xmlWriter.length(), xmlWriter.str()); if (calcFileCrc) fileCRC.tally(xmlWriter.length(), xmlWriter.str()); processed++; } if (!dlfn.isExternal() || lastNode()) // if external, 1 header,footer { OwnedRoxieString footer(helper->getFooter()); if (footer) xmlOutput.clear().append(footer); else xmlOutput.clear().append("</Dataset>").newline(); outraw->write(xmlOutput.length(), xmlOutput.toCharArray()); if (calcFileCrc) fileCRC.tally(xmlOutput.length(), xmlOutput.toCharArray()); } }
unsigned SWProcess::getInstanceCount(const char* clusterName) { StringBuffer xpath; if (clusterName && *clusterName) xpath.clear().appendf("%s[@name=\"%s\"]", m_processName.str(), clusterName); else xpath.clear().appendf("%s[1]", m_processName.str()); //IPropertyTree * comp = m_envHelper->getEnvTree()->getPropTree(xpath); IPropertyTree * comp = m_envHelper->getEnvTree()->queryPropTree(xpath); return comp->getCount(m_instanceElemName.str()); }
void RemoteXmlEclRepository::logException(IException *e) { if (e) { e->errorMessage(lastError.clear()); } else { lastError.clear().append("Unknown exception"); } DBGLOG("Log Exception: %s", lastError.str()); }
bool deletePkgInfo(const char *name, const char *target, const char *process, bool globalScope) { Owned<IRemoteConnection> pkgSetsConn = querySDS().connect("/PackageSets/", myProcessSession(), RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT); if (!pkgSetsConn) throw MakeStringException(PKG_NONE_DEFINED, "No package sets defined"); IPropertyTree* packageSets = pkgSetsConn->queryRoot(); StringBuffer pkgSetId; buildPkgSetId(pkgSetId, process); VStringBuffer pkgSet_xpath("PackageSet[@id='%s']", pkgSetId.str()); IPropertyTree *pkgSetRegistry = packageSets->queryPropTree(pkgSet_xpath.str()); if (!pkgSetRegistry) throw MakeStringException(PKG_TARGET_NOT_DEFINED, "No package sets defined for %s", process); StringBuffer lcTarget(target); target = lcTarget.toLowerCase().str(); StringBuffer lcName(name); name = lcName.toLowerCase().str(); Owned<IPropertyTree> mapEntry; StringBuffer xpath; if (!globalScope) { xpath.appendf("PackageMap[@id='%s::%s'][@querySet='%s']", target, name, target); mapEntry.setown(pkgSetRegistry->getPropTree(xpath.str())); } if (!mapEntry) { xpath.clear().appendf("PackageMap[@id='%s'][@querySet='%s']", name, target); mapEntry.setown(pkgSetRegistry->getPropTree(xpath.str())); if (!mapEntry) throw MakeStringException(PKG_DELETE_NOT_FOUND, "Unable to delete %s - information not found", lcName.str()); } StringAttr pmid(mapEntry->queryProp("@id")); pkgSetRegistry->removeTree(mapEntry); xpath.clear().appendf("PackageSet/PackageMap[@id='%s']", pmid.get()); if (!packageSets->hasProp(xpath)) { Owned<IRemoteConnection> pkgMapsConn = querySDS().connect("/PackageMaps/", myProcessSession(), RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT); if (!pkgMapsConn) throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to retrieve PackageMaps information from dali [/PackageMaps]"); IPropertyTree *pkgMaps = pkgMapsConn->queryRoot(); if (!pkgMaps) throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to retrieve PackageMaps information from dali [/PackageMaps]"); IPropertyTree *mapTree = pkgMaps->queryPropTree(xpath.clear().appendf("PackageMap[@id='%s']", pmid.get()).str()); if (mapTree) pkgMaps->removeTree(mapTree); } return true; }
void SWProcess::checkInstanceAttributes(IPropertyTree *instanceNode, IPropertyTree *parent) { assert(instanceNode); if (portIsRequired() && !instanceNode->hasProp("@port")) { int port = getDefaultPort(); if (!port) throw MakeStringException(CfgEnvErrorCode::InvalidParams, "Miss port attribute in instance"); instanceNode->addPropInt("@port", port); } StringBuffer xpath; xpath.clear().appendf("xs:element/xs:complexType/xs:sequence/xs:element[@name=\"%s\"]",m_instanceElemName.str()); IPropertyTree * instanceSchemaNode = m_pSchema->queryPropTree(xpath.str()); if (!instanceSchemaNode) return; bool needDirProp = false; Owned<IPropertyTreeIterator> attrIter = instanceSchemaNode->getElements("xs:complexType/xs:attribute"); ForEach(*attrIter) { IPropertyTree * attr = &attrIter->query(); const char *attrName = attr->queryProp("@name"); if (!stricmp(attrName, "directory")) { needDirProp = true; continue; } const char *defaultValue = attr->queryProp("@default"); if (!defaultValue) continue; xpath.clear().appendf("@%s", attrName); if (instanceNode->hasProp(xpath.str())) continue; const char *use = attr->queryProp("@use"); if (!use || !stricmp(use, "required") || !stricmp(use, "optional")) { StringBuffer sbDefaultValue; sbDefaultValue.clear().append(defaultValue); sbDefaultValue.replaceString("\\", "\\\\"); instanceNode->addProp(xpath.str(), sbDefaultValue.str()); } } if (needDirProp && !instanceNode->hasProp("@directory")) { const IProperties *props = m_envHelper->getEnvConfigOptions().getProperties(); StringBuffer sb; sb.clear().appendf("%s/%s", props->queryProp("runtime"), parent->queryProp(XML_ATTR_NAME)); instanceNode->addProp("@directory", sb.str()); } }
//--------------------------------------------------------------------------- // getPluginDirectory // // returns absolute path where plugins are to be deployed //--------------------------------------------------------------------------- void CPluginDeploymentEngine::getPluginDirectory(const char* destPath, StringBuffer& sPluginDest) const { sPluginDest.clear().append(destPath); sPluginDest.replace('\\', '/'); StringBuffer sPluginsDir; //relative path (from ECL server installation directory) for plugins m_process.getProp("@pluginsPath", sPluginsDir); if (sPluginsDir.length()) { sPluginsDir.replace('\\', '/'); sPluginsDir.replace('$', ':'); if (! ::PathIsRelative(sPluginsDir.str())) throw MakeStringExceptionDirect(-1, "Plugins path for ECL server must be relative to its installation directory!"); if (!strncmp(sPluginsDir.str(), "./", 2)) sPluginsDir.remove(0, 2); sPluginDest.append(sPluginsDir); } const char* pchLast = sPluginDest.str() + sPluginDest.length() - 1; if (*pchLast != '/') sPluginDest.append('/'); }
void getpassword(const char* prompt, StringBuffer& passwd, bool verify = true) { passwd.clear(); StringBuffer passwd1, passwd2; int tries = 0; while(1) { if(tries++ >= 3) { exit(-1); } inputpassword(prompt, passwd1); if(!verify) break; inputpassword("Verifying password, retype: ", passwd2); if(passwd1.length() < 4) { printf("password too short, should be 4 characters or longer\n"); } else if(strcmp(passwd1.str(), passwd2.str()) != 0) { printf("passwords don't match.\n"); } else break; } passwd.append(passwd1.str()); }
void SWProcess::modify(IPropertyTree *params) { SWComponentBase::modify(params); const char * selector = params->queryProp("@selector"); if ( selector ) { IPropertyTree * envTree = m_envHelper->getEnvTree(); const char* key = params->queryProp("@key"); StringBuffer xpath; xpath.clear().appendf(XML_TAG_SOFTWARE "/%s[@name=\"%s\"]", m_processName.str(), key); IPropertyTree * compTree = envTree->queryPropTree(xpath.str()); if (!compTree) throw MakeStringException(CfgEnvErrorCode::InvalidParams, "Selector should matche one element in modify."); String str(selector); if (str.startsWith("instance")) modifyInstance(compTree, params); return; } if (!(params->queryPropTree("Attributes/Attribute[@name=\"name\"]"))) return; //notify topoploy for component name change const char *oldName = params->queryProp("@key"); const char *newName = params->queryProp("Attributes/Attribute[@name=\"name\"]/@value"); if (m_notifyTopologyList.find(m_name.str()) != NotFound) { ((SWProcess*)m_envHelper->getEnvSWComp("topology"))->processNameChanged(m_name.str(), newName, oldName); } }
_LUCENE_THREAD_FUNC(atomicIndexTest, _writer){ IndexWriter* writer= (IndexWriter*)_writer; uint64_t stopTime = Misc::currentTimeMillis() + 1000*ATOMIC_SEARCH_RUN_TIME_SEC; int count = 0; try { while(Misc::currentTimeMillis() < stopTime && !atomicSearchFailed) { // Update all 100 docs... TCHAR buf[30]; StringBuffer sb; for(int i=0; i<100; i++) { Document d; _i64tot(rand(), buf, 10); sb.clear(); English::IntToEnglish(i+10*count, &sb); d.add(*_CLNEW Field(_T("contents"), sb.getBuffer() , Field::STORE_NO | Field::INDEX_TOKENIZED)); _i64tot(i,buf,10); d.add(*_CLNEW Field(_T("id"), buf, Field::STORE_YES | Field::INDEX_UNTOKENIZED)); Term* t = _CLNEW Term(_T("id"), buf); writer->updateDocument(t, &d); _CLDECDELETE(t); } count++; } } catch (CLuceneError& e) { fprintf(stderr, "err 1: #%d: %s\n", e.number(), e.what()); atomicSearchFailed = true; } _LUCENE_THREAD_FUNC_RETURN(0); }
unsigned SWProcess::add(IPropertyTree *params) { unsigned rc = SWComponentBase::add(params); IPropertyTree * envTree = m_envHelper->getEnvTree(); const char* key = params->queryProp("@key"); StringBuffer xpath; xpath.clear().appendf(XML_TAG_SOFTWARE "/%s[@name=\"%s\"]", m_processName.str(), key); IPropertyTree * compTree = envTree->queryPropTree(xpath.str()); assert(compTree); const char* selector = params->queryProp("@selector"); if (selector) { String str(selector); if (str.startsWith("instance")) { addInstances(compTree, params); } else { // Following method can be overwritten. // For example, NodeGroup in BackupNodeProcess, EspBinding in EspProcess addOtherSelector(compTree, params); } } else { IPropertyTree* pAttrs = params->queryPropTree("Attributes"); updateNode(compTree, pAttrs); } return rc; }
void inputpassword(const char* prompt, StringBuffer& passwd) { passwd.clear(); #ifdef _WIN32 printf("%s", prompt); char input=0; short num_entries=0; while (0x0d != (input = (char)getch())) { if (input == '\b') { printf("\b \b"); if (num_entries) { num_entries--; } continue; } passwd.append(input); num_entries++; printf("*"); } printf("\n"); #else const char* pass = getpass(prompt); passwd.append(pass); #endif }
IHqlExpression * XmlEclRepository::doLoadSymbol(IPropertyTree * repository, IAtom * modname, IAtom * attrname) { StringBuffer s; IPropertyTree* module = repository->queryPropTree(s.append("./Module[@name=\"").append(*modname).append("\"]").str()); if(!module) { if (logging()) DBGLOG("No data for module %s",modname->getAtomNamePtr()); return 0; } int access = module->getPropInt("@access",cs_full); s.clear().append("./Attribute[@name=\"").append(*attrname).append("\"]"); Owned<IPropertyTreeIterator> it = module->getElements(s.str()); for(it->first();it->isValid();it->next()) { Owned<IHqlExpression> item = toNamedSymbol(&it->query(), *modname,access); CHqlNamedSymbol* cur = QUERYINTERFACE(item.get(), CHqlNamedSymbol); if(cur) return LINK(cur); } return 0; }
void evaluate(StringBuffer& output) { StringBuffer variable; bool in_variable = false; for(const char* i = m_string.c_str(); *i != '\0'; ++i) { if(!in_variable) { switch(*i) { case '[': in_variable = true; break; default: output.push_back(*i); break; } } else { switch(*i) { case ']': in_variable = false; output.push_string(build_get_variable(variable.c_str())); variable.clear(); break; default: variable.push_back(*i); break; } } } }
void CEnvGen::addUpdateAttributesFromString(IPropertyTree *updateTree, const char *attrs) { StringArray saAttrs; saAttrs.appendList(attrs, ATTR_SEP); //printf("attribute: %s\n",attrs); IPropertyTree *pAttrs = updateTree->addPropTree("Attributes", createPTree("Attributes")); for ( unsigned i = 0; i < saAttrs.ordinality() ; i++) { IPropertyTree *pAttr = pAttrs->addPropTree("Attribute", createPTree("Attribute")); StringArray keyValues; keyValues.appendList(saAttrs[i], "="); pAttr->addProp("@name", keyValues[0]); StringBuffer sbValue; sbValue.clear().appendf("%s", keyValues[1]); sbValue.replaceString("[equal]", "="); StringArray newOldValues; if (strcmp(keyValues[1], "")) { newOldValues.appendList(sbValue.str(), ATTR_V_SEP); pAttr->addProp("@value", newOldValues[0]); if (newOldValues.ordinality() > 1) pAttr->addProp("@oldValue", newOldValues[1]); } else pAttr->addProp("@value", ""); } }
static void appendReplyMessage(StringBuffer &reply, const char *href,const char *format,...) { va_list args; va_start(args, format); StringBuffer msg; msg.valist_appendf(format, args); va_end(args); StringBuffer fmsg; const char *s=msg.str(); loop { char c=*(s++); if (!c||(c=='\n')) { Owned<IPropertyTree> tree = createPTree("Message"); tree->addProp("Value",fmsg.str()); if (href) { tree->addProp("href",href); href = NULL; } toXML(tree,reply); if (!c) break; fmsg.clear(); } else fmsg.append(c); } }
void test_uri(const char * str, bool shouldBeURI, URISchemeType scheme=URIScheme_error, const char * server=NULL, const char * path=NULL) { bool isURI = URI::isURI(str); ASSERT(isURI == shouldBeURI); if (!isURI) return; // Now, validate URI try { URI res(str); ASSERT(res.getScheme() == scheme); // No need to validate the rest if (scheme == URIScheme_error) return; StringBuffer response; res.appendServerStr(response); ASSERT(strcmp(response.str(), server) == 0); response.clear(); res.appendPathStr(response); ASSERT(strcmp(response.str(), path) == 0); } catch (IException *e) { StringBuffer buf; logctx.CTXLOG("Exception: %s", e->errorMessage(buf).str()); e->Release(); ASSERT(false); // Check exception log } }
bool CEnvGen::convertOverrideTask(IPropertyTree *config, const char * input) { StringArray sbarr; sbarr.appendList(input, ","); StringArray sbarrXPath; sbarrXPath.appendList(sbarr.item(1), "@"); StringBuffer sbTask; sbTask.clear().appendf("sw:%s", sbarr.item(0)); if (sbarrXPath.ordinality() < 2) { fprintf(stderr, "Override xpath miss '@'\n"); return false; } if ((sbarrXPath.ordinality() == 2) && !(*sbarrXPath.item(0))) sbTask.appendf("@%s=%s", sbarrXPath.item(1), sbarr.item(2)); else { sbTask.appendf(":selector=%s", sbarrXPath.item(0)); for (unsigned i=1; i < sbarrXPath.ordinality()-1; i++) sbTask.appendf("#%s", sbarrXPath.item(i)); sbTask.appendf("@%s=%s", sbarrXPath.item(sbarrXPath.ordinality()-1), sbarr.item(2)); } createUpdateTask("modify", config, sbTask.str()); return true; }
bool CLogThread::GenerateTransactionSeed(StringBuffer& UniqueID, char backendType) { CriticalBlock b(seed_gen_crit); if(bSeedAvailable == false && bMadeSeedRequest==true) { //we have checked for a seed but none are available return false; } else if (bSeedAvailable == false) { //we have not checked for a seed or we failed when making the request.. bSeedAvailable = FetchTransactionSeed(m_InitialTransactionSeedID); if(bSeedAvailable==false) return false; DBGLOG("Fetched Transaction Seed %s\n", m_InitialTransactionSeedID.str()); } UniqueID.appendf("%s%c%u",m_InitialTransactionSeedID.str(),backendType,++id_counter); if(UniqueID.length() > 16) { //Sybase limits transaction_id to 16 bytes. If longer, need to get another seed ID and reset id_counter. m_InitialTransactionSeedID.clear(); bSeedAvailable = FetchTransactionSeed(m_InitialTransactionSeedID); if(bSeedAvailable==false) return false; DBGLOG("TransactionID length exceeded 16 bytes. So re-fetched a Transaction Seed %s.\n", m_InitialTransactionSeedID.str()); id_counter = 0; UniqueID.clear().appendf("%s-%u",m_InitialTransactionSeedID.str(),++id_counter); } return true; }
static void emptyScopes() { PROGLOG("Removing empty scopes"); Owned<IDFScopeIterator> iter = queryDistributedFileDirectory().getScopeIterator(NULL,true,true); CDfsLogicalFileName dlfn; StringBuffer s; StringArray toremove; ForEach(*iter) { CDfsLogicalFileName dlfn; StringBuffer scope; scope.append(iter->query()); dlfn.set(scope.str(),"x"); dlfn.makeScopeQuery(s.clear(),true); Owned<IRemoteConnection> conn = querySDS().connect(s.str(),myProcessSession(),RTM_LOCK_READ, INFINITE); if (!conn) DBGLOG("Could not connect to '%s' using %s",iter->query(),s.str()); else { if (recursiveCheckEmptyScope(*conn->queryRoot())) { PROGLOG("Empty scope %s",iter->query()); toremove.append(iter->query()); } } } iter.clear(); ForEachItemIn(i,toremove) { PROGLOG("Removed scope %s",toremove.item(i)); queryDistributedFileDirectory().removeEmptyScope(toremove.item(i)); }
void SWBackupNode::addOtherSelector(IPropertyTree *compTree, IPropertyTree *params) { StringBuffer xpath; assert(compTree); const char* selector = params->queryProp("@selector"); if (selector && !stricmp("NodeGroup", selector)) { IPropertyTree *nodeGroup = createPTree(selector); IPropertyTree* pAttrs = params->queryPropTree("Attributes"); updateNode(nodeGroup, pAttrs, NULL); if (!nodeGroup->hasProp("@interval")) { xpath.clear().appendf("xs:element/xs:complexType/xs:sequence/xs:element[@name=\"NodeGroup\"]/xs:complexType/xs:attribute[@name=\"interval\"]/@default"); const char *interval = m_pSchema->queryProp(xpath.str()); if ( interval && *interval ) { nodeGroup->addProp("@interval", interval); } else { throw MakeStringException(CfgEnvErrorCode::MissingRequiredParam, "Missing required paramter \"interval\" and there is no default value."); } } compTree->addPropTree(selector, nodeGroup); } }
void LdapUtils::normalizeDn(const char* dn, const char* basedn, StringBuffer& dnbuf) { dnbuf.clear(); cleanupDn(dn, dnbuf); if(!containsBasedn(dnbuf.str())) dnbuf.append(",").append(basedn); }
const char *AbstractMacroReplacer::replace(const char *source){ if (isempty(source)) return NULL; StringEscaper *se = new StringEscaper(source); StringBuffer *pole = new StringBuffer(); sb->clear(); boolean b = false; while (!se->eof()){ char x = se->getChar(); if (!b){ if ((!se->getStatus() ) && (x == bdelim)) b = true; else sb->add(x); }else{ if ((!se->getStatus() ) && (x == edelim)){ sb->add( replaceField( pole->get() ) ); b = false; pole->clear(); } else pole->add(x); } } delete(pole); delete(se); return sb->get(); };
void StringBuffer::absorb(StringBuffer& buf) { if (empty()) { StringData* str = m_str; m_str = buf.m_str; m_buffer = buf.m_buffer; m_len = buf.m_len; m_cap = buf.m_cap; buf.m_str = str; if (str) { buf.m_buffer = (char*)str->data(); buf.m_len = str->size(); buf.m_cap = str->capacity(); } else { buf.m_buffer = 0; buf.m_len = 0; buf.m_cap = 0; } buf.clear(); return; } append(buf.detach()); }
void openEspLogFile(IPropertyTree* envpt, IPropertyTree* procpt) { StringBuffer logdir; if(procpt->hasProp("@name")) { StringBuffer espNameStr; procpt->getProp("@name", espNameStr); if (!getConfigurationDirectory(envpt->queryPropTree("Software/Directories"), "log", "esp", espNameStr.str(), logdir)) { logdir.clear(); } } if(logdir.length() == 0) { if(procpt->hasProp("@logDir")) procpt->getProp("@logDir", logdir); } Owned<IComponentLogFileCreator> lf = createComponentLogFileCreator(logdir.str(), "esp"); lf->setName("esp_main");//override default filename lf->setAliasName("esp"); lf->beginLogging(); if (procpt->getPropBool("@enableSysLog", false)) UseSysLogForOperatorMessages(); }