int main(){ int pass; int score = 0; int delayDiff = 5000; //5s setup(); while(1){ sendPattern(delayDiff); pass = readPattern(); if(pass == 1){ makeSound(95); //passTune delayDiff -= 500; //Increase difficulty -0.5s score += 10; makePattern(); //new pattern } else{ makeSound(10); //failTune(); print(1,score); PWME = 0x00; //kill sound break; } } }
QMimeMagicRule::QMimeMagicRule(const QString &typeStr, const QByteArray &theValue, const QString &offsets, const QByteArray &theMask, QString *errorString) : d(new QMimeMagicRulePrivate) { d->value = theValue; d->mask = theMask; d->matchFunction = 0; d->type = QMimeMagicRule::type(typeStr.toLatin1()); if (d->type == Invalid) { *errorString = QStringLiteral("Type %s is not supported").arg(typeStr); } // Parse for offset as "1" or "1:10" const int colonIndex = offsets.indexOf(QLatin1Char(':')); const QString startPosStr = colonIndex == -1 ? offsets : offsets.mid(0, colonIndex); const QString endPosStr = colonIndex == -1 ? offsets : offsets.mid(colonIndex + 1); if (!QMimeTypeParserBase::parseNumber(startPosStr, &d->startPos, errorString) || !QMimeTypeParserBase::parseNumber(endPosStr, &d->endPos, errorString)) { d->type = Invalid; return; } if (d->value.isEmpty()) { d->type = Invalid; if (errorString) *errorString = QLatin1String("Invalid empty magic rule value"); return; } if (d->type >= Host16 && d->type <= Byte) { bool ok; d->number = d->value.toUInt(&ok, 0); // autodetect if (!ok) { d->type = Invalid; if (errorString) *errorString = QString::fromLatin1("Invalid magic rule value \"%1\"").arg( QString::fromLatin1(d->value)); return; } d->numberMask = !d->mask.isEmpty() ? d->mask.toUInt(&ok, 0) : 0; // autodetect } switch (d->type) { case String: d->pattern = makePattern(d->value); d->pattern.squeeze(); if (!d->mask.isEmpty()) { if (d->mask.size() < 4 || !d->mask.startsWith("0x")) { d->type = Invalid; if (errorString) *errorString = QString::fromLatin1("Invalid magic rule mask \"%1\"").arg( QString::fromLatin1(d->mask)); return; } const QByteArray &tempMask = QByteArray::fromHex(QByteArray::fromRawData( d->mask.constData() + 2, d->mask.size() - 2)); if (tempMask.size() != d->pattern.size()) { d->type = Invalid; if (errorString) *errorString = QString::fromLatin1("Invalid magic rule mask size \"%1\"").arg( QString::fromLatin1(d->mask)); return; } d->mask = tempMask; } else { d->mask.fill(char(-1), d->pattern.size()); } d->mask.squeeze(); d->matchFunction = matchString; break; case Byte: if (d->number <= quint8(-1)) { if (d->numberMask == 0) d->numberMask = quint8(-1); d->matchFunction = matchNumber<quint8>; } break; case Big16: case Host16: case Little16: if (d->number <= quint16(-1)) { d->number = d->type == Little16 ? qFromLittleEndian<quint16>(d->number) : qFromBigEndian<quint16>(d->number); if (d->numberMask == 0) d->numberMask = quint16(-1); d->matchFunction = matchNumber<quint16>; } break; case Big32: case Host32: case Little32: if (d->number <= quint32(-1)) { d->number = d->type == Little32 ? qFromLittleEndian<quint32>(d->number) : qFromBigEndian<quint32>(d->number); if (d->numberMask == 0) d->numberMask = quint32(-1); d->matchFunction = matchNumber<quint32>; } break; default: break; } }
void makeLine(int count){ int i; for (i=0; i<count;i++) makePattern(); backward(count*5); }
QMimeMagicRule::QMimeMagicRule(QMimeMagicRule::Type theType, const QByteArray &theValue, int theStartPos, int theEndPos, const QByteArray &theMask) : d(new QMimeMagicRulePrivate) { Q_ASSERT(!theValue.isEmpty()); d->type = theType; d->value = theValue; d->startPos = theStartPos; d->endPos = theEndPos; d->mask = theMask; d->matchFunction = 0; if (d->type >= Host16 && d->type <= Byte) { bool ok; d->number = d->value.toUInt(&ok, 0); // autodetect Q_ASSERT(ok); d->numberMask = !d->mask.isEmpty() ? d->mask.toUInt(&ok, 0) : 0; // autodetect } switch (d->type) { case String: d->pattern = makePattern(d->value); d->pattern.squeeze(); if (!d->mask.isEmpty()) { Q_ASSERT(d->mask.size() >= 4 && d->mask.startsWith("0x")); d->mask = QByteArray::fromHex(QByteArray::fromRawData(d->mask.constData() + 2, d->mask.size() - 2)); Q_ASSERT(d->mask.size() == d->pattern.size()); } else { d->mask.fill(char(-1), d->pattern.size()); } d->mask.squeeze(); d->matchFunction = matchString; break; case Byte: if (d->number <= quint8(-1)) { if (d->numberMask == 0) d->numberMask = quint8(-1); d->matchFunction = matchNumber<quint8>; } break; case Big16: case Host16: case Little16: if (d->number <= quint16(-1)) { d->number = d->type == Little16 ? qFromLittleEndian<quint16>(d->number) : qFromBigEndian<quint16>(d->number); if (d->numberMask == 0) d->numberMask = quint16(-1); d->matchFunction = matchNumber<quint16>; } break; case Big32: case Host32: case Little32: if (d->number <= quint32(-1)) { d->number = d->type == Little32 ? qFromLittleEndian<quint32>(d->number) : qFromBigEndian<quint32>(d->number); if (d->numberMask == 0) d->numberMask = quint32(-1); d->matchFunction = matchNumber<quint32>; } break; default: break; } }
void createPam5Patterns(void) { struct compiledPatternTraversal *t[15]; struct compiledPatternAtom *a[15]; if (VanDerWaalsCutoffRadius < 0.0) { // this indicates that the model has no pam5 atoms return; } stack_match_initialized = 0; a[0] = makePatternAtom(0, "P5G"); a[1] = makePatternAtom(1, "P5S"); a[2] = makePatternAtom(2, "P5S"); t[0] = makeTraversal(a[0], a[1], '1'); t[1] = makeTraversal(a[0], a[2], '1'); makePattern("PAM5-basepair", pam5_basepair_match, 3, 2, t); a[0] = makePatternAtom(0, "P5G"); a[1] = makePatternAtom(1, "P5G"); a[2] = makePatternAtom(2, "P5S"); a[3] = makePatternAtom(3, "P5S"); a[4] = makePatternAtom(4, "P5S"); a[5] = makePatternAtom(5, "P5S"); t[0] = makeTraversal(a[0], a[1], '1'); t[1] = makeTraversal(a[0], a[2], '1'); t[2] = makeTraversal(a[0], a[3], '1'); t[3] = makeTraversal(a[1], a[4], '1'); t[4] = makeTraversal(a[1], a[5], '1'); makePattern("PAM5-stack", pam5_stack_match, 6, 5, t); a[0] = makePatternAtom(0, "P5P"); a[1] = makePatternAtom(1, "P5S"); t[0] = makeTraversal(a[0], a[1], '1'); makePattern("PAM5-phosphate-sugar", pam5_phosphate_sugar_match, 2, 1, t); a[0] = makePatternAtom(0, "P5P"); a[1] = makePatternAtom(1, "P5S"); a[2] = makePatternAtom(2, "P5P"); t[0] = makeTraversal(a[0], a[1], '1'); t[1] = makeTraversal(a[1], a[2], '1'); makePattern("PAM5-phosphate-phosphate", pam5_phosphate_phosphate_match, 3, 2, t); a[0] = makePatternAtom(0, "P5G"); a[1] = makePatternAtom(1, "P5S"); a[2] = makePatternAtom(2, "P5P"); t[0] = makeTraversal(a[0], a[1], '1'); t[1] = makeTraversal(a[1], a[2], '1'); makePattern("PAM5-groove-phosphate", pam5_groove_phosphate_match, 3, 2, t); a[0] = makePatternAtom(0, "P5G"); a[1] = makePatternAtom(1, "P5S"); a[2] = makePatternAtom(2, "P5P"); a[3] = makePatternAtom(3, "P5S"); a[4] = makePatternAtom(4, "P5G"); a[5] = makePatternAtom(5, "P5P"); a[6] = makePatternAtom(6, "P5S"); a[7] = makePatternAtom(7, "P5P"); a[8] = makePatternAtom(8, "P5P"); a[9] = makePatternAtom(9, "P5S"); a[10] = makePatternAtom(10, "P5P"); t[0] = makeTraversal(a[0], a[1], '1'); t[1] = makeTraversal(a[1], a[2], '1'); t[2] = makeTraversal(a[2], a[3], '1'); t[3] = makeTraversal(a[3], a[4], '1'); t[4] = makeTraversal(a[4], a[0], '0'); t[5] = makeTraversal(a[1], a[5], '1'); t[6] = makeTraversal(a[5], a[6], '1'); t[7] = makeTraversal(a[6], a[7], '1'); t[8] = makeTraversal(a[3], a[8], '1'); t[9] = makeTraversal(a[8], a[9], '1'); t[10] = makeTraversal(a[9], a[10], '1'); makePattern("PAM5-crossover", pam5_crossover_match, 11, 11, t); a[0] = makePatternAtom(0, "P5G"); a[1] = makePatternAtom(1, "P5G"); a[2] = makePatternAtom(2, "P5S"); a[3] = makePatternAtom(3, "P5P"); a[4] = makePatternAtom(4, "P5S"); a[5] = makePatternAtom(5, "P5G"); a[6] = makePatternAtom(6, "P5G"); a[7] = makePatternAtom(7, "P5S"); a[8] = makePatternAtom(8, "P5P"); a[9] = makePatternAtom(9, "P5S"); t[0] = makeTraversal(a[0], a[1], '1'); t[1] = makeTraversal(a[1], a[2], '1'); t[2] = makeTraversal(a[2], a[3], '1'); t[3] = makeTraversal(a[3], a[4], '1'); t[4] = makeTraversal(a[4], a[5], '1'); t[5] = makeTraversal(a[5], a[6], '1'); t[6] = makeTraversal(a[6], a[7], '1'); t[7] = makeTraversal(a[7], a[8], '1'); t[8] = makeTraversal(a[8], a[9], '1'); t[9] = makeTraversal(a[9], a[0], '1'); makePattern("PAM5-full-crossover", pam5_full_crossover_match, 10, 10, t); a[0] = makePatternAtom(0, "Ah5"); a[1] = makePatternAtom(1, "P5G"); a[2] = makePatternAtom(2, "P5S"); a[3] = makePatternAtom(3, "P5S"); t[0] = makeTraversal(a[0], a[1], '1'); t[1] = makeTraversal(a[1], a[2], '1'); t[2] = makeTraversal(a[1], a[3], '1'); makePattern("PAM5-basepair-handle", pam5_basepair_handle_match, 4, 3, t); a[0] = makePatternAtom(0, "PAM3"); t[0] = makeTraversal(a[0], a[0], '?'); // how to match a bare atom makePattern("PAM3-any", pam3_any_match, 1, 1, t); a[0] = makePatternAtom(0, "Ax3"); a[1] = makePatternAtom(1, "Ss3"); a[2] = makePatternAtom(2, "Ss3"); a[3] = makePatternAtom(3, "Ax3"); a[4] = makePatternAtom(4, "Ss3"); a[5] = makePatternAtom(5, "Ss3"); a[6] = makePatternAtom(6, "Ss3"); a[7] = makePatternAtom(7, "Ss3"); t[0] = makeTraversal(a[0], a[1], '1'); t[1] = makeTraversal(a[1], a[2], '1'); t[2] = makeTraversal(a[2], a[3], '1'); t[3] = makeTraversal(a[3], a[0], '0'); t[4] = makeTraversal(a[1], a[4], '1'); t[5] = makeTraversal(a[4], a[5], '1'); t[6] = makeTraversal(a[2], a[6], '1'); t[7] = makeTraversal(a[6], a[7], '1'); makePattern("PAM3-crossover", pam3_crossover_match, 8, 8, t); }
InterestFilter::InterestFilter(const char* prefixUri, const char* regexFilter) : prefix_(prefixUri), regexFilter_(regexFilter), regexFilterPattern_(makePattern(regexFilter)) { }
InterestFilter::InterestFilter(const string& prefixUri, const string& regexFilter) : prefix_(prefixUri), regexFilter_(regexFilter), regexFilterPattern_(makePattern(regexFilter)) { }
InterestFilter::InterestFilter(const Name& prefix, const char* regexFilter) : prefix_(prefix), regexFilter_(regexFilter), regexFilterPattern_(makePattern(regexFilter)) { }