void ILI2Handler::startElement( CPL_UNUSED const XMLCh* const uri, CPL_UNUSED const XMLCh* const localname, const XMLCh* const qname, const Attributes& attrs ) { // start to add the layers, features with the DATASECTION char *tmpC = NULL; m_nEntityCounter = 0; if ((level >= 0) || (cmpStr(ILI2_DATASECTION, tmpC = XMLString::transcode(qname)) == 0)) { level++; if (level >= 2) { // create the dom tree DOMElement *elem = (DOMElement*)dom_doc->createElement(qname); // add all attributes unsigned int len = attrs.getLength(); for (unsigned int index = 0; index < len; index++) elem->setAttribute(attrs.getQName(index), attrs.getValue(index)); dom_elem->appendChild(elem); dom_elem = elem; } } XMLString::release(&tmpC); }
static bool isBinaryRunning(std::string binary) { const char *syncapp = binary.c_str(); bool result = false; PROCESSENTRY32 entry; entry.dwSize = sizeof(PROCESSENTRY32); HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL); if (Process32First(snapshot, &entry)) { while (Process32Next(snapshot, &entry)) { _bstr_t cmpStr(entry.szExeFile); if (!_stricmp(cmpStr, syncapp)) { result = true; } } } CloseHandle(snapshot); return result; }
IINST Bsc1::iinstSupSz(SZ szReqd) // find the smallest ISYM whose value is greater or equal to the given SZ // { IINST Lo = 0; IINST Hi = cEntities; while (Lo < Hi) { IINST Mid = Lo + (Hi - Lo) / 2; // this way there can be no overflow SZ szCur = szFrIinst(Mid); int Cmp = cmpStr(szCur, szReqd); if (Cmp >= 0) Hi = Mid; else Lo = Mid + 1; } if (Hi == cEntities) Hi = iinstNil; return Hi; }
int main(int argc, char *argv[]) { int fd,count=0,len,line=0; char buffer,flag='y'; fd = open(argv[2],O_RDWR); if(fd!=-1) { len=lseek(fd,0L,2); while(lseek(fd,count,0)<len) { count++; read(fd,&buffer,sizeof(char)); if(argv[1][0]==(char)buffer) { if(cmpStr(fd,count,argv[1])) { count=printLine(fd,line); line=count; } } else if((char)buffer=='\n') line=count; } } else printf("\nFile not found\n"); close(fd); return 0; }
IPROP Bsc1::ipropFrEn(ENTITY en, IMOD imod) { IPROP Lo = rgidx[imod].ipropMin; IPROP Hi = Lo + rghead[imod].cprop; IPROP ipropMac = Hi; SZ szReqd = szFrNi(en.ni); while (Lo < Hi) { ULONG Mid = Lo + (Hi - Lo) / 2; // this way there can be no overflow SZ szCur = szFrNi(rgProp[Mid].en.ni); int Cmp = cmpStr(szCur, szReqd); if (Cmp >= 0) Hi = Mid; else Lo = Mid + 1; } if (Hi == ipropMac) return ipropNil; IPROP iprop = Hi; while (iprop < ipropMac) { ENTITY enT = rgProp[iprop].en; // if we found something that doesn't match case-insenstively, we give up if (_stricmp(szReqd, szFrNi(enT.ni))) break; // wait for the case sensitive match, we need an exact match because // we're starting from an entity... the name has already been resolved // to a specific object as far as the user is concerned if (strcmp(szReqd, szFrNi(enT.ni))) { iprop++; continue; } if (en.typ == enT.typ && en.atr == enT.atr) return iprop; iprop++; } return ipropNil; }
int Bsc1::cmpStrPrefix(SZ szPrefix, SZ szMain) // checks to see if szMain begins with szPrefix // returns lexical prefix only comparison like cmpStr() // { int lenp = strlen(szPrefix); int lenf = strlen(szMain); char buffer[256]; assert(lenf < sizeof(buffer)); strcpy(buffer, szMain); if (szPrefix[0] != '?' && szMain[0] == '?') lenp++; if (lenf > lenp) buffer[lenp] = '\0'; return cmpStr(szPrefix, buffer); }
// primitives for managing object instances (iinst) BOOL Bsc1::getIinstByvalue(SZ szReqd, TYP typ, ATR atr, OUT IINST *piinst) { IINST iinst = iinstSupSz(szReqd); if (iinst == iinstNil) return iinstNil; while (iinst < cEntities) { ENTITY enT = rgEn[iinst]; if (cmpStr(szReqd, szFrNi(enT.ni))) break; if (typ == enT.typ && atr == enT.atr) { *piinst = iinst; return TRUE; } iinst++; } *piinst = iinstNil; return FALSE; }