예제 #1
0
KUser::KUser(UIDMode mode) {
	long _uid = ::getuid(), _euid;
	if (mode == UseEffectiveUID && (_euid = ::geteuid()) != _uid )
		fillPasswd( ::getpwuid( _euid ) );
	else {
		fillName( ::getenv( "LOGNAME" ) );
		if (uid() != _uid) {
			fillName( ::getenv( "USER" ) );
			if (uid() != _uid)
				fillPasswd( ::getpwuid( _uid ) );
		}
	}
}
예제 #2
0
파일: Card.c 프로젝트: jpmoreira/cardGame
/**
 * @brief A function that creates a Card struct with the specified parameters. The struct is allocated on the stack.
 * @param theSuit the suit of the card to be created
 * @param theValue the value of the card to be created
 * @return A card struct initialized with the specified parameters
 */
Card _createCard(Suit theSuit,CardValue theValue) {
    Card c;
    c.cardSuit=theSuit;
    c.cardValue=theValue;
    fillName(&c);
    c.malloced=false;
    return c;
}
예제 #3
0
파일: Card.c 프로젝트: jpmoreira/cardGame
/**
 * @brief A function that creates a Card struct with the provided values. The card is allocated on the heap and therefore the claimed memory should be freed as soon as it is no longer needed. This can be done by calling the function destroyCard
 * @param theSuit the suit of the card to be created
 * @param theValue the value of the card to be created
 * @return a pointer to the recently created card. NULL is returned if memory could not be allocated for the card.
 *
 */
Card * createCard(Suit theSuit,CardValue theValue) {
    Card *theCard=malloc(sizeof(Card));
    if(theCard!=NULL) {
        theCard->cardSuit=theSuit;
        theCard->cardValue=theValue;
        fillName(theCard);
        theCard->malloced=true;


    }
    return theCard;
}
예제 #4
0
void DocumentsBuilder::fillDocument(Document* doc)
{
	/* paper schema */
	static int64_t DOCID = 1;
	int docid_inc = randint(2, 4);
	DOCID += docid_inc;
	doc->set_docid(DOCID);

	if (rand() < LINKS_RATIO)
	{
		Document_Links* links = doc->mutable_links();
		int bwd_count = randint(10);
		int fwd_count = randint(10);

		while (bwd_count+fwd_count==0)
		{
			bwd_count = randint(10);
			fwd_count = randint(10);
		}

		for (int i = 0; i < bwd_count; i++)
		{
			links->add_backward(rand());
		}
		for (int i = 0; i < fwd_count; i++)
		{
			links->add_forward(rand());
		}
	}
	int name_count = randint(10);

	for (int i = 0; i < name_count; i++)
	{
		Document_Name* name = doc->add_name();
		fillName(name);
	}

	/* extension */
	static int64_t SESSION_ID = 1;
	int session_inc = randint(2, 5);
	SESSION_ID += session_inc;
	doc->set_sessionid(SESSION_ID);
	doc->set_userid(randint(UID_COUNT));
	doc->set_usergroup(randint(10));
	//doc->set_usergroup(randint(10000));
	doc->set_clientip(randint(IP_COUNT));

	if (rand() < COUNTRY_RATIO)
	{
		doc->set_country(COUNTRY_NAME[randint(COUNTRY_COUNT)]);
		//doc->set_country(new_country[randint(100000)]);
	}

	if (rand() < AGENT_RATIO)
	{
		doc->set_agent(agents[randint(AGENT_COUNT)]);
	}

	if (rand() < SALE_RATIO)
	{
		Document_Sales* sale = doc->mutable_sales();
		fillSale(sale);
	}

	int request_count = randint(10);

	for (int i = 0; i < request_count; i++)
	{
		Document_Requests* request = doc->add_requests();
		fillRequest(request);
	}

}
예제 #5
0
KUser::KUser(const char *name) {
	fillName( name );
}
예제 #6
0
KUser::KUser(const QString& name) {
	fillName( name.local8Bit().data() );
}
예제 #7
0
KUserGroup::KUserGroup(const char *name) {
  fillName(name);
}