static int findFirstMatch (char *pFileName, char *wpName) { int x; APIRET rc = NO_ERROR; ulFindCount = 1; rc = DosFindFirst (pFileName, &hdirFindHandle, FILE_NORMAL, &FindBuffer, ulResultBufLen, &ulFindCount, FIL_STANDARD); if (rc != NO_ERROR) return FALSE; if ((FindBuffer.attrFile & FILE_DIRECTORY) != 0) return findNextMatch (pFileName, wpName); strcpy (wpName, pFileName); for (x = strlen(wpName)-1; wpName[x] != '\\' && wpName[x] !='/' && wpName[x] != ':' && x > 0; x--) {} /* avoid compiler warning */ if (x != 0) x++; strcpy (wpName + x, FindBuffer.achName); return TRUE; }
bool SkExampleWindow::onHandleChar(SkUnichar unichar) { if ('n' == unichar) { bool found = findNextMatch(); if (!found) { SkDebugf("No SkExample that matches your query\n"); } } return true; }
std::vector<std::string> Matcher::findAll() { std::vector<std::string> ret; reset(); while (findNextMatch()) { ret.push_back(getGroup()); } return ret; }
void CtrlrLuaMethodCodeEditor::replaceNextMatch(const String &search, const String &replace, bool bMatchCase) { if (owner.getCurrentEditor() == nullptr) { return; } CodeDocument &doc = owner.getCurrentEditor()->getCodeDocument(); findNextMatch(search, bMatchCase); if (lastFoundPosition >= 0) { doc.newTransaction(); doc.deleteSection (lastFoundPosition, lastFoundPosition+search.length()); doc.insertText (lastFoundPosition, replace); } }
/* The getNextEntry function search the next file which is specified DIR */ int pcsl_file_getnextentry(void *handle, const pcsl_string * string, pcsl_string * result) { PCSLFileIterator* pIterator = (PCSLFileIterator *)handle; if (pIterator == NULL) { return -1; } if (pIterator->iteratorHandle == INVALID_HANDLE_VALUE) { return findFirstMatch(pIterator, string, result); } return findNextMatch(pIterator, string, result); }
int expandWildcards (argLink **ppArgLink) { argLink *pFirstNewLink = NULL; argLink **wppPrev = &pFirstNewLink; argLink *pArgLink = *ppArgLink; argLink *pTmp; int nNew = 0; int x; char temp[MAX_NAMELEN]; while (pArgLink != NULL) { #ifdef MSWIN if (strchr (pArgLink->pString, '*') != NULL || strchr (pArgLink->pString, '?') != NULL || strchr (pArgLink->pString, '~') != NULL) #else if (strchr (pArgLink->pString, '*') != NULL || strchr (pArgLink->pString, '?') != NULL) #endif { x = findFirstMatch (pArgLink->pString, temp); while (x) { pTmp = insertStringInArgLink (wppPrev, temp); wppPrev = &pTmp->psNext; nNew++; x = findNextMatch (pArgLink->pString, temp); } pTmp = pArgLink; pArgLink = pArgLink->psNext; free (pTmp); } else { *wppPrev = pArgLink; wppPrev = &pArgLink->psNext; pArgLink = pArgLink->psNext; } } *wppPrev = NULL; *ppArgLink = pFirstNewLink; return nNew; }
static int findFirstMatch (char *pFileName, char *wpName) { int x; hFind = _findfirst (pFileName, &sFind); if (hFind == -1) return FALSE; if ((sFind.attrib & _A_SUBDIR) != 0) return findNextMatch (pFileName, wpName); strcpy (wpName, pFileName); for (x = strlen(wpName)-1; wpName[x] != '\\' && wpName[x] !='/' && wpName[x] != ':' && x > 0; x--) {} /* avoid compiler warning */ if (x != 0) x++; strcpy (wpName + x, sFind.name); return TRUE; }
bool PatchContentFindSupport::computeMatches() { matches.clear(); if (!m_text || m_text->isEmpty()) { return false; } if (isRegExp) { pickAxeRE.setPattern(*m_text); } QTextDocument* document = m_patchContent->document(); QTextCursor cursor; while (!(cursor = findNextMatch(document, cursor)).isNull()) { matches.append(MatchSelection()); MatchSelection& s = matches.last(); s.from = cursor.selectionStart(); s.to = cursor.selectionEnd(); } return !matches.isEmpty(); }
MStatus stringFormat::compute (const MPlug& plug, MDataBlock& data) { MStatus status; // Check that the requested recompute is one of the output values // if (plug == attrOutput) { // Read the input values // MDataHandle inputData = data.inputValue (attrFormat, &status); CHECK_MSTATUS( status ); MString format = inputData.asString(); // Get input data handle, use outputArrayValue since we do not // want to evaluate all inputs, only the ones related to the // requested multiIndex. This is for efficiency reasons. // MArrayDataHandle vals = data.outputArrayValue(attrValues, &status); CHECK_MSTATUS( status ); int indx = 0; int param; char letter; while ((indx = findNextMatch(format, indx, param, letter)) > 0) { double val = 0.; status = vals.jumpToElement(param); if (status == MStatus::kSuccess) { MDataHandle thisVal = vals.inputValue( &status ); if (status == MStatus::kSuccess) { val = thisVal.asDouble(); } } MString replace; bool valid = false; switch (letter) { case 'd': // Integer val = floor(val+.5); // No break here case 'f': // Float replace.set(val); valid = true; break; case 't': // Timecode { const char * sign = ""; if (val<0) { sign = "-"; val = -val; } int valInt = (int)(val+.5); int sec = valInt / 24; int frame = valInt - sec * 24; int min = sec / 60; sec -= min * 60; int hour = min / 60; min -= hour * 60; char buffer[90]; if (hour>0) sprintf(buffer, "%s%d:%02d:%02d.%02d", sign, hour, min, sec, frame); else sprintf(buffer, "%s%02d:%02d.%02d", sign, min, sec, frame); replace = buffer; } valid = true; break; } if (valid) { format = format.substring(0, indx-2) + replace + format.substring(indx+2, format.length()-1); indx += replace.length() - 3; } } // Store the result // MDataHandle output = data.outputValue(attrOutput, &status ); CHECK_MSTATUS( status ); output.set( format ); } else { return MS::kUnknownParameter; } return MS::kSuccess; }
int main(int argc, char *argv[]){ int s, ret, clientAddrLen, hitsCount; char prefix[64]; struct node *i, *tmpNode; struct sockaddr_in serverAddress, clientAddress; struct ip_mreq mreq; unsigned char buff[UDP_PACKET_SIZE]; //creates a socket s = socket (PF_INET, SOCK_DGRAM, 0); if (s == -1){ perror(NULL); } //sets the server's address serverAddress.sin_family = AF_INET; serverAddress.sin_addr.s_addr = htonl(INADDR_ANY); //INADDR_ANY refers to every IP on this mashine serverAddress.sin_port = htons (SERVER_PORT); //binds the socket to the server ret = bind(s, (struct sockaddr*)&serverAddress, sizeof(serverAddress)); if (ret == -1){ perror(NULL); } //binds the socket to the localhost's multicast address mreq.imr_multiaddr.s_addr=inet_addr("224.0.0.1"); mreq.imr_interface.s_addr=htonl(INADDR_ANY); if(setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0){ printf("setsockopt() failed"); return 0; } //initializes the linked list head = NULL; //this is the server's main loop while(1){ //waits to recieve a request from any (unknown) client clientAddrLen = sizeof(clientAddress); ret = recvfrom(s, buff, UDP_PACKET_SIZE, 0, (struct sockaddr*)&clientAddress, &clientAddrLen); if (ret == -1){ perror(NULL); } #ifdef USE_LOG_FILE openFileAndRead(); #endif //serves the request switch(buff[0]){ case REQUEST_DISCOVERY: buff[0] = RESPONSE_DISCOVERY; strcpy(&buff[1],SERVER_IP); buff[17] = (int)(SERVER_PORT/256); buff[18] = SERVER_PORT%256; ret = sendto(s, buff, 19, 0, (struct sockaddr*)&clientAddress, clientAddrLen); if (ret == -1){ perror(NULL); } break; case REQUEST_ADD: buff[0] = RESPONSE_ADD; buff[1] = addNode(&buff[1], &buff[65], buff[81]*256+buff[82], &buff[83]); ret = sendto(s, buff, 2, 0, (struct sockaddr*)&clientAddress, clientAddrLen); if (ret == -1){ perror(NULL); } break; case REQUEST_REMOVE: buff[0] = RESPONSE_REMOVE; buff[1] = removeNode(&buff[1], &buff[65], buff[81]*256+buff[82]); ret = sendto(s, buff, 2, 0, (struct sockaddr*)&clientAddress, clientAddrLen); if (ret == -1){ perror(NULL); } break; case REQUEST_FIND: buff[0] = RESPONSE_FIND; strcpy(prefix, &buff[1]); hitsCount = 0; tmpNode = findNextMatch(head, prefix); while(tmpNode!=NULL && hitsCount < ((UDP_PACKET_SIZE-3) / DIR_ENTRY_SIZE)-1){ strcpy(&buff[3+hitsCount*90], tmpNode->name); strcpy(&buff[3+hitsCount*90+64], tmpNode->ip); buff[3+hitsCount*90+80] = (int)(tmpNode->port/256); buff[3+hitsCount*90+81] = tmpNode->port%256; strcpy(&buff[3+hitsCount*90+82], tmpNode->properties); hitsCount++; tmpNode = findNextMatch(tmpNode->next, prefix); } buff[1] = (int)(hitsCount/256); buff[2] = hitsCount%256; ret = sendto(s, buff, 2+hitsCount*DIR_ENTRY_SIZE, 0, (struct sockaddr*)&clientAddress, clientAddrLen); if (ret == -1){ perror(NULL); } break; default: printf("invalid request code"); break; } #ifdef USE_LOG_FILE writeFileAndClose(); #endif } //for cosmetic reasons - never reaches this point!! close(s); return; }
void findDialog::findClicked() { emit findNextMatch(); }