//! Main loop. int main(void){ volatile unsigned int i; unsigned char app, verb; unsigned long len; // MSP reboot count for reset input & reboot function located at 0xFFFE volatile unsigned int reset_count = 0; silent=0; //Don't trust globals. #if (platform == tilaunchpad) int ret=0; //ret = setjmp(warmstart);// needs to be here since context from init() would be gone warmstart: if (ret == 0) { coldstart(); // basic hardware setup, clock to TUSB3410, and enable } else if (ret == 2) { dputs("\nalmost BSL only one RTS change\n"); } else if (ret > 2) { // reset released after more than two tst transisitions // We could write a BSL, a nice exercise for a Sunday afternoon. dputs("\nBSL\n"); //call_BSL(); // once you are done uncomment ;-) } else { // we come here after DTR high (release reset) dputs("\nWarmstart\n"); } #endif #if (platform == donbfet) extern void donbfet_reboot(void); void (*reboot_function)(void) = donbfet_reboot; #elif (platform == zigduino) extern void zigduino_reboot(void); void (*reboot_function)(void) = zigduino_reboot; #else void (*reboot_function)(void) = (void *) 0xFFFE; #endif init(); txstring(MONITOR,OK,"http://goodfet.sf.net/"); //txstring(0xab,0xcd,"http://goodfet.sf.net/"); //Command loop. There's no end! while(1){ //Magic 3 app = serial_rx(); // If the app is the reset byte (0x80) increment and loop if (app == RESET){ reset_count++; if (reset_count > 4){ // We could trigger the WDT with either: // WDTCTL = 0; // or // WDTCTL = WDTPW + WDTCNTCL + WDTSSEL + 0x00; // but instead we'll jump to our reboot function pointer (*reboot_function)(); debugstr("Rebooting not supported on this platform."); } continue; }else { reset_count = 0; } verb = serial_rx(); len = rxword(); //Read data, looking for buffer overflow. if(len <= CMDDATALEN){ for(i = 0; i < len; i++) cmddata[i] = serial_rx(); handle(app,verb,len); }else { //Listen to the blaberring. for(i = 0; i < len; i++) serial_rx(); //Reply with an error. debugstr("Buffer length exceeded."); txdata(MONITOR,NOK,0); } } }
bool LCHMFile::searchQuery( const QString& inquery, QStringList * searchresults, unsigned int limit ) { QStringList words_must_exist, words_must_not_exist, words_highlight; QVector<QStringList> phrases_must_exist; QString query = inquery; bool query_valid = true; LCHMSearchProgressResults results; int pos; int i; /* * Parse the search query with a simple state machine. * Query should consist of one of more words separated by a space with a possible prefix. * A prefix may be: * + indicates that the word is required; any page without this word is excluded from the result. * - indicates that the word is required to be absent; any page with this word is excluded from * the result. * "." indicates a phrase. Anything between quotes indicates a phrase, which is set of space-separated * words. Will be in result only if the words in phrase are in page in the same sequence, and * follow each other. * If there is no prefix, the word considered as required. */ QRegExp rxphrase( "\"(.*)\"" ); QRegExp rxword( "([^\\s]+)" ); rxphrase.setMinimal( TRUE ); // First, get the phrase queries while ( (pos = rxphrase.indexIn (query, 0)) != -1 ) { // A phrase query found. Locate its boundaries, and parse it. QStringList plist = rxphrase.cap ( 1 ).split ( QRegExp ("\\s+") ); validateWords ( plist, query_valid ); if ( plist.size() > 0 ) phrases_must_exist.push_back( plist ); query.remove (pos, rxphrase.matchedLength()); } // Then, parse the rest query while ( (pos = rxword.indexIn( query, 0 )) != -1 ) { // A phrase query found. Locate its boundaries, and parse it. QString word = rxword.cap ( 1 ); QChar type = '+'; if ( word[0] == '-' || word[0] == '+' ) { type = word[0]; word.remove (0, 1); } validateWord ( word, query_valid ); if ( type == '-' ) words_must_not_exist.push_back ( word ); else words_must_exist.push_back ( word ); query.remove (pos, rxword.matchedLength()); } #if defined (DUMP_SEARCH_QUERY) // Dump the search query QString qdump; for ( i = 0; i < phrases_must_exist.size(); i++ ) qdump += QString(" \"") + phrases_must_exist[i].join (" ") + QString ("\""); for ( i = 0; i < words_must_not_exist.size(); i++ ) qdump += QString (" -") + words_must_not_exist[i]; for ( i = 0; i < words_must_exist.size(); i++ ) qdump += QString (" +") + words_must_exist[i]; qDebug ("Search query dump: %s", qdump.ascii()); #endif // First search for phrases if ( phrases_must_exist.size() > 0 ) { LCHMSearchProgressResults tempres; for ( i = 0; i < phrases_must_exist.size(); i++ ) { if ( !searchPhrase ( impl(), phrases_must_exist[i], tempres ) ) return false; mergeResults ( results, tempres, true ); } } for ( i = 0; i < words_must_exist.size(); i++ ) { LCHMSearchProgressResults tempres; if ( !m_impl->searchWord ( words_must_exist[i], true, false, tempres, false ) ) return false; mergeResults ( results, tempres, true ); } for ( i = 0; i < words_must_not_exist.size(); i++ ) { LCHMSearchProgressResults tempres; m_impl->searchWord ( words_must_not_exist[i], true, false, tempres, false ); mergeResults ( results, tempres, false ); } m_impl->getSearchResults( results, searchresults, limit ); return true; }