コード例 #1
0
int main()
{
	char **str;
	int n,i,j;
	scanf("%d",&n);
	str=(char**)malloc(sizeof(char*)*n);
	for(i=0;i<n;i++)
	{
		str[i]=(char*)malloc(sizeof(char)*51);
		scanf(" %s",str[i]);
	}
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(isMatching(str[i],str[j]))
			{
				printf("vulnerable\n");
				return 0;
			}
		}
	}
	printf("non vulnerable\n");
	return 0;
}
コード例 #2
0
ファイル: dialoguemanager.cpp プロジェクト: dhardy/openmw
    void DialogueManager::startDialogue (const MWWorld::Ptr& actor)
    {
        std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl;

        const ESM::Dialogue *dialogue = mEnvironment.mWorld->getStore().dialogs.find ("hello");

        for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
            iter!=dialogue->mInfo.end(); ++iter)
        {
            if (isMatching (actor, *iter))
            {
                // start dialogue
                std::cout << "found matching info record" << std::endl;

                std::cout << "response: " << iter->response << std::endl;

                if (!iter->sound.empty())
                {
                    // TODO play sound
                }

                if (!iter->resultScript.empty())
                {
                    std::cout << "script: " << iter->resultScript << std::endl;
                    // TODO execute script
                }

                mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue);
                break;
            }
        }
    }
コード例 #3
0
//............................................................................
void filesearch(char const *dirname) {
    static char buffer[1024];

    DIR *dir = opendir(dirname);                 // open the current directory
    if (dir == (DIR *)0) {            // if open fails, the directory is empty
        return;
    }

    struct dirent *entry;
    while((entry = readdir(dir)) != (struct dirent *)0) {
        if ((strncmp(entry->d_name, "..", 2) != 0)
                && (strncmp(entry->d_name, ".",  1) != 0))
        {
            strncpy(buffer, dirname,       sizeof(buffer));
            strncat(buffer, "/",           sizeof(buffer));
            strncat(buffer, entry->d_name, sizeof(buffer));

            if (entry->d_type == DT_DIR) {               // is it a directory?
                filesearch(buffer);
            }
            else {
                int flags = isMatching(entry->d_name,
                                       access(buffer, W_OK) != 0);
                if (flags != 0) {
                    onMatchFound(buffer, flags);
                }
            }
        }
    }
    closedir(dir);
}
コード例 #4
0
unsigned char RotaryEncoder::getState() {
  int analogValue = readAnalog();
  // discard noise
  for (unsigned char i = 0; i < 3; i++) {
    int secondAnalogValue = readAnalog();
    if (abs(analogValue - secondAnalogValue) < 3) {
      continue;
    }

    analogValue = secondAnalogValue;
    i = 0;
  }

  if (isMatching(analogValue, ANALOG_A)) return STATE_A;
  if (isMatching(analogValue, ANALOG_B)) return STATE_B;
  if (isMatching(analogValue, ANALOG_AB)) return STATE_AB;
  if (isMatching(analogValue, ANALOG_S)) return STATE_S;
  if (isMatching(analogValue, ANALOG_AS)) return STATE_A | STATE_S;
  if (isMatching(analogValue, ANALOG_BS)) return STATE_B | STATE_S;
  if (isMatching(analogValue, ANALOG_ABS)) return STATE_AB | STATE_S;
  if (analogValue < 1000) {
    Serial.print("### invalid=");
    Serial.println(analogValue);
  }
  return STATE_NONE;
}
コード例 #5
0
ファイル: countingmcmc.cpp プロジェクト: Ace7k3/projektgruppe
BigCount BruteForceCountHGraphMatchings(const HGraph& G)
{
	BigCount rtn = 1; // = 1 because empty set is always matching

	std::vector<bool> edgeInMatching(G.M(), false);

	auto iter = edgeInMatching.begin();
	while(iter != edgeInMatching.end())
	{
		if(*iter == false){
			*iter = true;
			auto setNullIter = edgeInMatching.begin();
			while(setNullIter != iter){
				*setNullIter = false;
				setNullIter++;
			}

			iter = edgeInMatching.begin();
			//*setNullIter = false;

			if(isMatching(G, edgeInMatching))
				rtn++;
		}else{
			iter++;
			/*for( auto i = edgeInMatching.cbegin(); i != edgeInMatching.cend(); i++ )
			{
				std::cout << *i << " ";
			}
			std::cout << std::endl;*/
		}
	}
	if(isMatching(G, edgeInMatching))
		rtn++;

	return rtn;
}
コード例 #6
0
ファイル: filesearch.cpp プロジェクト: xygroup/qtools
void filesearch(char const *dname) {
    struct dirent *dent;
    DIR *dir;
    struct stat st;
    char fn[FILENAME_MAX];
    int len = strlen(dname);
    if (len >= FILENAME_MAX - 1) {
        return;
    }

    strcpy(fn, dname);
    fn[len++] = '/';
    if ((dir = opendir(dname)) == NULL) {
        return;
    }

    while ((dent = readdir(dir)) != NULL) {
        if ((dent->d_name[0] != '.')
             && (strcmp(dent->d_name, ".") != 0)
             && (strcmp(dent->d_name, "..") != 0))
        {
            strncpy(fn + len, dent->d_name, FILENAME_MAX - len);
            if (lstat(fn, &st) != -1) {
                /* don't follow symlink unless told so */
                if (S_ISLNK(st.st_mode)) {
                }
                else if (S_ISDIR(st.st_mode)) {    // false for symlinked dirs
                    filesearch(fn);                 // recursively follow dirs
                }
                else {
                    int flags = isMatching(dent->d_name,
                                           access(fn, W_OK) != 0);
                    if (flags != 0) {
                        onMatchFound(fn, flags);
                    }
                }
            }
        }
    }

    closedir(dir);
}
コード例 #7
0
ファイル: TextEditor.cpp プロジェクト: josephzizys/CM
bool TextBuffer::keyPressed (const KeyPress& key)
{

  //std::cout << "keyPressed: " << key.getTextDescription().toUTF8() << T("\n");
  if (isMatching()) 
    stopMatching();
  TextEditor::keyPressed(key);
  juce_wchar chr=key.getTextCharacter();
  CommandID com=CommandIDs::EditorTextChanged;

  if (key.getKeyCode()==KeyPress::returnKey)
    com=CommandIDs::EditorNewline;
  else if (key.getKeyCode()==KeyPress::backspaceKey)
    com=CommandIDs::EditorBackspace;
  else if (!testFlag(EditFlags::MatchingOff) &&
	   (chr==')' || ((textid==TextIDs::Sal) && chr=='}') || ((textid==TextIDs::Sal2) && chr=='}')))
    matchParens();
  colorizeAfterChange(com);
  setFlag(EditFlags::NeedsSave);
  return true;
}
コード例 #8
0
ファイル: dialoguemanager.cpp プロジェクト: dhardy/openmw
    bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const
    {
        // actor id
        if (!info.actor.empty())
            if (toLower (info.actor)!=MWWorld::Class::get (actor).getId (actor))
                return false;

        if (!info.race.empty())
        {
            ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();

            if (!cellRef)
                return false;

            if (toLower (info.race)!=toLower (cellRef->base->race))
                return false;
        }

        if (!info.clas.empty())
        {
            ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();

            if (!cellRef)
                return false;

            if (toLower (info.clas)!=toLower (cellRef->base->cls))
                return false;
        }

        if (!info.npcFaction.empty())
        {
            ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();

            if (!cellRef)
                return false;

            if (toLower (info.npcFaction)!=toLower (cellRef->base->faction))
                return false;
        }

        // TODO check player faction

        // check cell
        if (!info.cell.empty())
            if (mEnvironment.mWorld->getPlayerPos().getPlayer().getCell()->cell->name != info.cell)
                return false;

        // TODO check DATAstruct

        for (std::vector<ESM::DialInfo::SelectStruct>::const_iterator iter (info.selects.begin());
            iter != info.selects.end(); ++iter)
            if (!isMatching (actor, *iter))
                return false;

        std::cout
            << "unchecked entries:" << std::endl
            << "    player faction: " << info.pcFaction << std::endl
            << "    disposition: " << info.data.disposition << std::endl
            << "    NPC rank: " << static_cast<int> (info.data.rank) << std::endl
            << "    gender: " << static_cast<int> (info.data.gender) << std::endl
            << "    PC rank: " << static_cast<int> (info.data.PCrank) << std::endl;

        return true;
    }