Exemplo n.º 1
0
boolean doTypeRow(struct hash *ra, char *org)
{
char *type = (char *)cvTermNormalized(hashMustFindVal(ra, CV_TYPE));

if (sameWord(type,CV_TOT))
    return doTypeOfTermRow(ra,org);
else if (sameWord(type,CV_TERM_CELL))
    return doCellRow(ra,org);
else if (sameWord(type,CV_TERM_ANTIBODY))
    return doAntibodyRow(ra,org);
else if (sameWord(type,CV_TERM_LAB))
    {
    puts("<TR>");
    char *term = printTerm(ra);
    printDescription(ra,"labInst",5);
    printSetting(ra,"labPiFull");
    printSetting(ra,"grantPi");
    printSetting(ra,"organism");
    printLabel(ra,term);
    puts("</TR>");
    }
else if (sameWord(type,CV_TERM_GRANT))
    {
    puts("<TR>");
    char *term = printTerm(ra);
    printDescription(ra,"grantInst",2);
    printLabel(ra,term);
    puts("</TR>");
    }
else if (sameWord(type,CV_TERM_LOCALIZATION))
    {
    puts("<TR>");
    char *term = printTerm(ra);
    printDescription(ra,NULL,3);
    printSettingsWithUrls(ra,"termUrl","termId",NULL);
    printLabel(ra,term);
    puts("</TR>");
    }
else  // generic term: term, description, label
    {
    puts("<TR>");
    char *term = printTerm(ra);
    printDescription(ra,NULL,2);
    printLabel(ra,term);
    puts("</TR>");
    }
return TRUE;
}
Exemplo n.º 2
0
void CLMapRenderer::renderMap(const Map& map, uint32_t points) {
  Vector2 player;
  Vector2 roomV;
  map.fillPlayerPosition(&player);

  printf("\n");
  for (int32_t y = 1; y >= -1; y--) {
    for (int32_t x = -1; x <= 1; x++) {
      if (x == 0 && y == 0) {
        printf("@");
      } else {
        roomV.set(player);
        roomV.add(Vector2(x, y));

        RoomType r = map.getRoomType(roomV);
        bool explored = map.getHasBeenExplored(roomV);

        printf("%c", charFromRoomType(r, explored));
      }
    }
    printf("\n");
  }

  printDescription(map.getRoomType(player));
  printClues(map);
  printf("[%u points] %s\n", points, map.isArmed() ? "You hold a club." : "");
}
Exemplo n.º 3
0
void LoginManager::processPasswordConfirmation(const QString& aLine, Client &aClient)
{
    auto account = getAccountOrDie(aClient);
    if(!account)
        return;
    QByteArray passwordBytes;
    passwordBytes.append(aLine);
    QString hash = QString(QCryptographicHash::hash(passwordBytes, QCryptographicHash::Md5).toHex());
    if(account->getPasswordHash() != hash)
    {
        aClient.printRawLine("Passwords do not match. Try again.");
        aClient.printRawLine("Enter a password for this account: ");
        state_ = ELoginStateNewPassword;
        return;
    }
    //passwords match, ok
    //creating a new character now
    account->confirmCreation();
    auto newCharacter = world::World::instance()->objectFactory()->createPtr<Person>(Person::TYPE);
	newCharacter->putInDefaultRoom();
	account->addCharacter(newCharacter->uid());	
    aClient.setState(EClientStateNormal);
    aClient.linkToPerson(newCharacter);
    auto room = newCharacter->getRoom();
    if(room)//first look around
        room->printDescription(*(newCharacter.get()), aClient);
}
Exemplo n.º 4
0
boolean doTypeOfTermRow(struct hash *ra, char *org)
// print one typeOfTerm row
{
char *term = (char *)hashMustFindVal(ra, CV_TERM);

if (sameString(term,cvTypeNormalized(CV_TERM_CELL)))
    term = CV_TERM_CELL;
else if (sameString(term,cvTypeNormalized(CV_TERM_ANTIBODY)))
    term = CV_TERM_ANTIBODY;

puts("<TR>");
printf("  <TD><A HREF='hgEncodeVocab?type=%s' title='%s details' "
        "TARGET=ucscVocabChild>%s</a></TD>\n", term, term, term);
printDescription(ra,NULL,2);
printLabel(ra,term);
puts("</TR>");
if (sameString(term,CV_TERM_CELL))
    {
    puts("<TR>");
    printf("  <TD><A HREF='hgEncodeVocab?type=%s&organism=Mouse' title='Mouse %s details' "
            "TARGET=ucscVocabChild>%s</a> <em>(for mouse)</em></TD>\n", term, term, term);
    char *s = getDescription(ra,NULL);
    printf("  <TD colspan=%d>%s <em>(for mouse)</em></TD>\n",
            TABLE_COLS_AVAILABLE(2), s?s:"&nbsp;");
    freeMem(s);
    printLabel(ra,term);
    puts("</TR>");
    }

return TRUE;
}
Exemplo n.º 5
0
void webMain(struct sqlConnection *conn, struct trackDb *tdb)
/* Set up fancy web page with hotlinks bar and
 * sections. */
{
struct section *sectionList = NULL;
printDescription(curGeneId, conn, tdb);
sectionList = loadSectionList(conn);
printIndex(sectionList);
printUpdateTime(database, tdb, NULL);
printSections(sectionList, conn, curGeneId);
printTiming(sectionList);
}
Exemplo n.º 6
0
void LoginManager::processPasswordState(const QString& aLine, Client &aClient)
{
    auto account = getAccountOrDie(aClient);
    if(!account)
        return;
    //aLine is a password
    QByteArray passwordBytes;
    passwordBytes.append(aLine);
    QString hash = QString(QCryptographicHash::hash(passwordBytes,QCryptographicHash::Md5).toHex());
    if(account->getPasswordHash() != hash)
    {
        aClient.printRawLine("Wrong password. Disconnecting...");
        aClient.setState(EClientStateQuit);
        return;
    }
    //password is correct
    account->confirmCreation();
    aClient.printRawLine("Password is correct. Welcome back, " + account->name() + ".");
	QVector<unsigned long> characterUids = account->characters();
    auto characters = world::objects<Person>(characterUids);
	if(characters.count() == 1)
    {
        //login to the character immediately

		auto person = characters[0];
        if(person)
        {
			person->setDisconnected(false);
            aClient.setState(EClientStateNormal);
			aClient.linkToPerson(world::World::instance()->objectFactory()->getPtr<Person>(person->uid()));
			auto clientPtr = world::World::instance()->getClientPtr(aClient.id());
			if(!clientPtr)
				qDebug() << "Bad client ptr for person " << person->name() << " " << QString::number(person->uid());
			else
				person->attachClient(clientPtr);
            auto room = person->getRoom();
            if(room)
                room->printDescription(*person, aClient);
            return;
        }
        //otherwise show account menu
        state_ = ELoginStateAccountMenu;
    }

}
Exemplo n.º 7
0
boolean doAntibodyRow(struct hash *ra, char *org)
// print one antibody row
{
puts("<TR>");
char *term = printTerm(ra);
printDescription(ra,"antibodyDescription",9);
printSetting(ra,"target");                  // target is NOT first but still is major sort order
printSetting(ra,"targetDescription");
printSettingsWithUrls(ra,"orderUrl","vendorName","vendorId");
printSetting(ra,"lab");
printDocumentLink(ra,term,"validation","/ENCODE/validation/antibodies/",NULL,FALSE);
printSetting(ra,"lots");
printSettingsWithUrls(ra,"targetUrl","targetId",NULL);
printLabel(ra,term);
puts("</TR>");

return TRUE;
}
Exemplo n.º 8
0
void Script::print(uint depth) {
	printDescription(depth);
	printData();

	// Print anything that is not a command
	for (uint i = 0; i < _children.size(); i++) {
		if (_children[i]->getType() != Type::kCommand) {
			_children[i]->print(depth + 1);
		}
	}

	Tools::Decompiler *decompiler = new Tools::Decompiler(this);

	// Print the decompiled output
	printWithDepth(depth + 1, "Decompiled output");
	if (decompiler->getError() == "") {
		decompiler->printDecompiled();
	} else {
		debug("Decompilation failure: %s", decompiler->getError().c_str());
	}

	delete decompiler;
}
Exemplo n.º 9
0
int main() {
	//obsah souboru nas zajimat nebude
	FILE* f = fopen("test-1.txt", "r");
	tToken t;
	
	
	printDescription("Do fronty tlacim bool = true");
	t = malloc(sizeof(struct stToken));
	t->typ = TYPE_BOOL;
	t->value.boolVal = true;
	ungetToken(&t);

	printDescription("Zkusim zavolat scanner ocekavam bool = true");
	getToken(&t, f);
	if (t->typ == TYPE_BOOL && t->value.boolVal) {
		printDescription("TEST OK");
	}
	else {
		printDescription("TEST FAILED");
	}
	freeTokenMem(t);
	printDescription("Od ted testuji jen pomoci fce void TQDequeue(tToken*);");
	printDescription("protoze jestli se vola skrz scanner j*z vime");

	printDescription("Do fronty tlacim int = 42");
	t = malloc(sizeof(struct stToken));
	t->typ = TYPE_INTEGER;
	t->value.intVal = 42;
	ungetToken(&t);
	printDescription("Do fronty tlacim KEYW_RETURN");
	t = malloc(sizeof(struct stToken));
	t->typ = KEYW_RETURN;
	ungetToken(&t);

	printDescription("Ocekavam int = 42 fronta by nemela byt deinicializovana");
	TQDequeue(&t);
	if (t->typ == TYPE_INTEGER && t->value.intVal == 42 && TQueue) {
		printDescription("TEST OK");
	}
	else {
		printDescription("TEST FAILED");
	}
	freeTokenMem(t);

	printDescription("Ocekavam return keyword fronta by mela byt deinicializovana");
	TQDequeue(&t);
	if (t->typ == KEYW_RETURN && !TQueue) {
		printDescription("TEST OK");
	}
	else {
		printDescription("TEST FAILED");
	}
	freeTokenMem(t);

	printDescription("Do fronty tlacim string = 'HuaHuaString'");
	t = malloc(sizeof(struct stToken));
	t->typ = TYPE_STRING;
	strInit(&t->value.stringVal);
	strConConstString(&t->value.stringVal, "HuaHuaString");
	ungetToken(&t);



	printDescription("Ocekavam string = 'HuaHuaString' fronta by mela byt deinicializovana");
	string s;
	strInit(&s);
	strConConstString(&s, "HuaHuaString");


	TQDequeue(&t);
	if (t->typ == TYPE_STRING && !strCmpString(&t->value.stringVal, &s) && !TQueue) {
		printDescription("TEST OK");
	}
	else {
		printDescription("TEST FAILED");
	}
	strFree(&s);
	freeTokenMem(t);

	printDescription("Zavolam void freeTokenMem(tToken); nad NULL");
	printDescription("Nemela by nastat chyba");
	printDescription("Test zrusen je to blbost");
	//freeTokenMem(t);
	printDescription("Mam deinicializovanou frontu zkusim z ni neco vytahnout");
	printDescription("behem programu nebude volano, ale pro jistotu");
	TQDequeue(&t);
	if (!TQueue/* && !t*/) {
		printDescription("TEST OK");
	}
	else {
		printDescription("TEST FAILED");
	}
	//freeTokenMem(t);//pro jistotu




	getchar();
	fclose(f);
	return 0;
}
Exemplo n.º 10
0
boolean doCellRow(struct hash *ra, char *org)
// print one cell row
{
char *s;

s = hashFindVal(ra, ORGANISM);
if (s != NULL)
    {
    char *cellOrg = cloneString(s);
    strLower(cellOrg);
    if (differentString(cellOrg, org))
        return FALSE;
    }

// pathBuffer for new protocols not in human
char pathBuffer[PATH_LEN];
safef(pathBuffer, sizeof(pathBuffer), "/ENCODE/protocols/cell/%s/",org);

if (sameWord(org, ORG_HUMAN))
    {
    if (cgiOptionalInt("tier",0))
        {
        if (hashFindVal(ra,"tier") == NULL)
            return FALSE;
        if (atoi(hashFindVal(ra,"tier"))!=cgiOptionalInt("tier",0))
            return FALSE;
        }
    if (cgiOptionalString("tiers"))
        {
        if (hashFindVal(ra,"tier") == NULL)
            return FALSE;
        boolean found=FALSE;
        char *tiers=cloneString(cgiOptionalString("tiers"));
        char *tier;
        (void)strSwapChar(tiers,',',' ');
        while ((tier=nextWord(&tiers)))
            {
            if (atoi(hashFindVal(ra,"tier"))==atoi(tier))
                {
                found=TRUE;
                break;
                }
            }
        if (!found)
            return FALSE;
        }
    puts("<TR>");
    char *term = printTerm(ra);

    printSetting(ra, "tier");
    printDescription(ra,NULL,-1);
    printSetting(ra,"lineage");
    printSetting(ra,"tissue");
    printSetting(ra,"karyotype");
    printSetting(ra,"sex");
    printDocumentLink(ra,term,"protocol",pathBuffer,NULL,TRUE);
    printSettingsWithUrls(ra,"orderUrl","vendorName","vendorId");
    printSettingsWithUrls(ra,"termUrl","termId",NULL);
    printLabel(ra,term);
    puts("</TR>");
    }
else        // non-human cell type
    {
    puts("<TR>");
    char *term = printTerm(ra);

    printDescription(ra,NULL,8);
    printSetting(ra,"category");
    printSetting(ra,"tissue");
    printSetting(ra,"sex");
    //printSetting(ra,"karyotype");
    printDocumentLink(ra,term,"protocol",pathBuffer,NULL,TRUE);
    printSettingsWithUrls(ra,"orderUrl","vendorName","vendorId");
    printSettingsWithUrls(ra,"termUrl","termId",NULL);
    printLabel(ra,term);
    puts("</TR>");

    }
return TRUE;
}