Пример #1
0
	void PropertyControl::setProperty(PropertyPtr _value)
	{
		unadvice();
		mProperty = _value;
		advice();

		updateCaption();
		updateProperty();
	}
Пример #2
0
int
main(int argc, char **argv)
{
	int			i;
	int			j;
	int			ret;

	set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_config"));

	progname = get_progname(argv[0]);

	/* check for --help */
	for (i = 1; i < argc; i++)
	{
		if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-?") == 0)
		{
			help();
			exit(0);
		}
	}

	ret = find_my_exec(argv[0], mypath);

	if (ret)
	{
		fprintf(stderr, _("%s: could not find own program executable\n"), progname);
		exit(1);
	}

	/* no arguments -> print everything */
	if (argc < 2)
	{
		show_all();
		exit(0);
	}

	for (i = 1; i < argc; i++)
	{
		for (j = 0; info_items[j].switchname != NULL; j++)
		{
			if (strcmp(argv[i], info_items[j].switchname) == 0)
			{
				(*info_items[j].show_func) (false);
				break;
			}
		}
		if (info_items[j].switchname == NULL)
		{
			fprintf(stderr, _("%s: invalid argument: %s\n"),
					progname, argv[i]);
			advice();
			exit(1);
		}
	}

	return 0;
}
Пример #3
0
string UnsatCondition::getAdviceString() const
{
   
   string ans;
   ostringstream aStringStream;
   ostream * oldReport = report;
   report = &aStringStream;
   advice();
   
		ans = aStringStream.str();

   report = oldReport;
   return ans;
};
Пример #4
0
    virtual ResultExpr EvaluateSyscall(int sysno) const override {
        switch (sysno) {
            // Simulate opening the plugin file.
#ifdef __NR_open
        case __NR_open:
#endif
        case __NR_openat:
            return Trap(OpenTrap, mPlugin);

        // ipc::Shmem
        case __NR_mprotect:
            return Allow();
        case __NR_madvise: {
            Arg<int> advice(2);
            return If(advice == MADV_DONTNEED, Allow())
                   .Else(InvalidSyscall());
        }

        default:
            return SandboxPolicyCommon::EvaluateSyscall(sysno);
        }
    }
Пример #5
0
int
main(int argc, char **argv)
{
	ConfigData *configdata;
	size_t		configdata_len;
	char		my_exec_path[MAXPGPATH];
	int			i;
	int			j;

	set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_config"));

	progname = get_progname(argv[0]);

	/* check for --help */
	for (i = 1; i < argc; i++)
	{
		if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-?") == 0)
		{
			help();
			exit(0);
		}
	}

	if (find_my_exec(argv[0], my_exec_path) < 0)
	{
		fprintf(stderr, _("%s: could not find own program executable\n"), progname);
		exit(1);
	}

	configdata = get_configdata(my_exec_path, &configdata_len);
	/* no arguments -> print everything */
	if (argc < 2)
	{
		for (i = 0; i < configdata_len; i++)
			printf("%s = %s\n", configdata[i].name, configdata[i].setting);
		exit(0);
	}

	/* otherwise print requested items */
	for (i = 1; i < argc; i++)
	{
		for (j = 0; info_items[j].switchname != NULL; j++)
		{
			if (strcmp(argv[i], info_items[j].switchname) == 0)
			{
				show_item(info_items[j].configname,
						  configdata, configdata_len);
				break;
			}
		}
		if (info_items[j].switchname == NULL)
		{
			fprintf(stderr, _("%s: invalid argument: %s\n"),
					progname, argv[i]);
			advice();
			exit(1);
		}
	}

	return 0;
}
Пример #6
0
void SGHelpLayer::itemselect(SNSTableView* tableView, SNSIndexPath* indexPath)
{
    EFFECT_PLAY(MUSIC_BTN);

    
    int index = tableView->getItemPointerWithIndexPath(indexPath);
    
    if (true /*SGPlayerInfo::sharePlayerInfo()->getPlayerLevel() >= 10*/)
    {
        switch (index)
        {
            case SGSFT_GALLERY:
            {
                showCards();
            }
                break;
            case SGSFT_FRIEND:
            {
                showFriendFunc();
            }
                break;
            case SGSFT_SETTING:
            {
                playerSet();
            }
                break;
            case SGSFT_HELP:
            {
                help();
            }
                break;
            case SGSFT_ADVICE:
            {
                CCArray *temp = SGPlayerInfo::sharePlayerInfo()->getQAContent();
                int count=temp->count();
                //                for(int i=0;i<temp->count();i++)
                //                {
                //                    SGQAConcent * qa = (SGQAConcent*)temp->objectAtIndex(i);
                //
                //                    if(!qa->getState())
                //                    {
                //                        count ++;
                //                    }
                //                }
                //
                //
                
                if(count)
                {
                    
                    advice();
                }
                
                else
                {
                    
                    SGMainManager::shareMain()->showliuyanlayer();
                }
                
                
            }
                break;
            case SGSFT_SHARE:
            {
                //                band();
                if(SGPlayerInfo::sharePlayerInfo()->getShowvip()==SHOW_SHAREBOX_ID)
                {
                    showShareBox();
                }else{
                    enterUserCommunity();
                }
            }
                break;
            case SGSFT_FANS:
            {
                if (isTaiWanGo2Play) //台湾版本要添加fb粉丝团的直达通道。
                {
                    CCLOG("open url %s", GlobalConfig::gi()->getTaiWanFbFansGroupUrl().c_str());
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
                    OcCaller::getInstance()->openUrl(GlobalConfig::gi()->getTaiWanFbFansGroupUrl());
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
                    AndroidSDKAdp::getInstance()->openUrl(GlobalConfig::gi()->getTaiWanFbFansGroupUrl());
#else
                    ;
#endif
                }
                else
                {
                    //do nothing
                }
                break;
                //这以下是添加引流功能之前的老代码,保留待命,不执行。
                /*
                //                band();
                if(SGPlayerInfo::sharePlayerInfo()->getShowvip()==SHOW_SHAREBOX_ID)
                {
                    enterUserCommunity();
                }else{
                    change();
                }
                */
            }
                break;
            case SGSFT_RELOGIN:
            {
                change();
            }
                break;
            default:
                break;
        }
    }
}
Пример #7
0
int main(){
	float result;
	char userName [40];
	int i, count, choice, betMarker, pLeft;
	double bet, pot;
	Player newPlayers [PLAYERS];

	/*Intro for the game*/
	setup(newPlayers, userName);
	Deck newDeck;
	srand(time(NULL));
	
	/*MAIN GAME LOOP, BASED ON GALLEONS*/

	while (newPlayers[0].galleons >= 5){
		printf("\n\n========  NEW ROUND  ========\n\n\n");
		pot = bet = 0;

		/*Always update each player to be in the game initially, unless they have less than 5 galleons*/
		for(i = 0; i<PLAYERS; i++){
			newPlayers[i].inGame = 1;
			if (newPlayers[i].galleons < 5){
				newPlayers[i].galleons = 0;
				newPlayers[i].inGame = 0;
				newPlayers[i].checkBet = 0;
			}
			newPlayers[i].checkBet = 0;
			newPlayers[i].galleons = newPlayers[i].galleons - 5;
			if(newPlayers[i].inGame == 1){
				pot = pot + 5;
			}
		}
		/*if the three computers are out of the game, user has won, so end the game!*/
		pLeft = 0;
		for (i = 1; i<PLAYERS; i++){
			if (newPlayers[i].inGame == 0){
				pLeft++;
			}
			if (pLeft == 3){
				printf("\n\nCONGRATULATIONS %s, you won! Harry, Voldy and Dumbly seem to have lost all their money!!!\n\n", newPlayers[0].name);
				return 0;
			}
		}


		sleep(2);
		/*Print out current standings, how many galleons each player has and if they are still in*/	
		printf("Current Standings:\n\n");
		for (i = 0; i<PLAYERS; i++){
			if (newPlayers[i].inGame == 1){
				printf("%s has %.2f Galleons\n", newPlayers[i].name, newPlayers[i].galleons);
			}
		}
		for (i = 0; i<PLAYERS; i++){
			if (newPlayers[i].inGame == 0){
				printf("%s is out of the game\n", newPlayers[i].name);
			}
		}

		/*Initialize Game*/
		fillDeck(&newDeck);
		shuffleDeck(&newDeck);
		dealOut(&newDeck, newPlayers);
		printf("\nYou are about to receive your hand!\n");
		
		/*User specifics*/
		sleep(1);
		displayHand(newPlayers);	
		result = MC_rate(newPlayers, 0);
		sleep(1);

		/*Monte Carlo Advice in MC.c*/
		advice(&newPlayers[0]);

		/*This exchange is only for the user, computers have its own function*/
		exchangeCards(newPlayers, &newDeck);
		displayHand(newPlayers);
		printf("\nYou can now either: \n1) Place a Bet\n2) Pass\n3) Fold\nPlease type 1,2, or 3: ");
		scanf("%d", &choice);
		if (choice == 1){
			bet = placeBet(newPlayers, &pot);
		}
		else if (choice == 3){
			endPlayer(newPlayers, 0);
		}
		else if (choice == 2){
			printf("You have chosen to pass.\n");
		}

		/*run Computer exchanges and whether they decide to raise, pass or fold*/	
		count = 1;
		while (count <= 3){
			if(newPlayers[count].inGame == 1){
				
				sleep(1);
				/*result value is more for testing purposes, but still needs to run to fill in the correct*/
				/*int array mcAdivce for Monte carlo advice for each computer*/
				result = MC_rate(newPlayers, count);
				
				/*This can be found in exchange.c, just exchange based on MC advice*/
				computerExchange(newPlayers, &newDeck, count);
				
				/*This can be found in display.c, determines for the computer what to do (raise, pass, fold)*/
				comp_decision(newPlayers, count, &bet, &pot);
				
				/*keep track of which computer raises for later*/
				if (newPlayers[count].checkBet > 0){
					betMarker = count;
				}
			}

			count++;
		}


		/*if any computer raises, then go back to user one time to either match or fold, then each computer*/

		if (betMarker > 0){
			if (newPlayers[0].galleons < newPlayers[betMarker].checkBet){
				printf("\nOH NOOOO, the bet is more than you can afford, and by wizarding rules, you lose the game!!!\n\n");
					return 0;
			}
		if (newPlayers[0].inGame != 0){	
		printf("%s raised by %.2lf. Would you like to either:\n1) Match\n2) Fold \nPlease type 1 or 2: ", newPlayers[betMarker].name, newPlayers[betMarker].checkBet);
		scanf("%d", &choice);
			if (choice == 1){
				newPlayers[0].galleons = newPlayers[0].galleons - newPlayers[betMarker].checkBet;
				pot = pot + newPlayers[betMarker].checkBet;
				printf("You have matched the raise\n");
			}
			else {
				newPlayers[0].inGame = 0;
				printf("You Folded\n");
			}
			}

	/*Determine whether each computer should match or fold*/	
		for (i = 1; i<betMarker; i++){
			if (newPlayers[i].inGame == 1){
				if (newPlayers[i].galleons > newPlayers[betMarker].checkBet){
					result = analyze_hand(newPlayers[i]);
					if (result < 23){
						newPlayers[i].inGame = 0;
						printf("%s has folded\n", newPlayers[i].name);
					}
					else{	
						newPlayers[i].galleons = newPlayers[i].galleons - newPlayers[betMarker].checkBet;	
						pot = pot + newPlayers[betMarker].checkBet;
						printf("%s has matched the raise\n",newPlayers[i].name);
						}
					}
				}
			}
		}
		
		sleep(2);
		/*find winner of the game, give winning's to rightful winner, display winner's hand*/
		findWinner(newPlayers, &pot);
		
		/*reset betMarker for next game*/
		betMarker = 0;
		sleep(2);
	}

	/*After game loop, you have lost all your money or you have less than the 5 Galleon entrance amount*/	
		printf("\n\nOH NO, you lost at Wizard's poker!!!!\n");
		printf("Final Galleon Count for each player:\n");
		for (i = 0; i < PLAYERS; i++){
			if (newPlayers[i].galleons < 0){
				newPlayers[i].galleons = 0;
			}
			printf("\t%s has %.2f Galleons\n", newPlayers[i].name, newPlayers[i].galleons);
		}

	return 0;
}
Пример #8
0
int
main(int argc, char **argv)
{
	int			i;
	int			ret;
	char		mypath[MAXPGPATH];
	char		otherpath[MAXPGPATH];

	set_pglocale_pgservice(argv[0], "pg_config");

	progname = get_progname(argv[0]);

	if (argc < 2)
	{
		fprintf(stderr, _("%s: argument required\n"), progname);
		advice();
		exit(1);
	}

	for (i = 1; i < argc; i++)
	{
		if (strcmp(argv[i], "--bindir") == 0 ||
			strcmp(argv[i], "--includedir") == 0 ||
			strcmp(argv[i], "--includedir-server") == 0 ||
			strcmp(argv[i], "--libdir") == 0 ||
			strcmp(argv[i], "--pkglibdir") == 0 ||
			strcmp(argv[i], "--pgxs") == 0 ||
			strcmp(argv[i], "--configure") == 0)
		{
			/* come back to these later */
			continue;
		}

		if (strcmp(argv[i], "--version") == 0)
		{
			printf("PostgreSQL " PG_VERSION "\n");
			exit(0);
		}
		if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-?") == 0)
		{
			help();
			exit(0);
		}
		fprintf(stderr, _("%s: invalid argument: %s\n"), progname, argv[i]);
		advice();
		exit(1);
	}

	ret = find_my_exec(argv[0], mypath);

	if (ret)
	{
		fprintf(stderr, _("%s: could not find own executable\n"), progname);
		exit(1);
	}

	for (i = 1; i < argc; i++)
	{
		if (strcmp(argv[i], "--configure") == 0)
		{
			/* the VAL_CONFIGURE macro must be defined by the Makefile */
			printf("%s\n", VAL_CONFIGURE);
			continue;
		}

		if (strcmp(argv[i], "--bindir") == 0)
		{
			/* assume we are located in the bindir */
			char	   *lastsep;

			strcpy(otherpath, mypath);
			lastsep = strrchr(otherpath, '/');
			if (lastsep)
				*lastsep = '\0';
		}
		else if (strcmp(argv[i], "--includedir") == 0)
			get_include_path(mypath, otherpath);
		else if (strcmp(argv[i], "--includedir-server") == 0)
			get_includeserver_path(mypath, otherpath);
		else if (strcmp(argv[i], "--libdir") == 0)
			get_lib_path(mypath, otherpath);
		else if (strcmp(argv[i], "--pkglibdir") == 0)
			get_pkglib_path(mypath, otherpath);
		else if (strcmp(argv[i], "--pgxs") == 0)
		{
			get_pkglib_path(mypath, otherpath);
			strncat(otherpath, "/pgxs/src/makefiles/pgxs.mk", MAXPGPATH - 1);
		}

		printf("%s\n", otherpath);
	}

	return 0;
}