Exemplo n.º 1
0
main(int argc, char **argv)
{

	if (argc < 2) {
		printf("usage: timefix filename ...\n");
		exit (1);
	}

	argc--;
	argv++;

	if (checkflags(&argc, argv))
		exit (1);

	pr_values("your installation", timezone, tzname[0], tzname[1], daylight);

	while (argc--)
		newtime(*argv++);
}
Exemplo n.º 2
0
struct Time time_demar(int jp,char* file,int* tire){			//!!!!!!! faire des fonctions
	    int i;
	    struct Time *time;
		
	   time = newtime();
	    jp =jp-4;
	    for(i=0;i<4;i++){
		time->year[i]=file[jp++];
	    }
	    time->year[i]='\0';
	    jp=tire[1]+1;

	    for(i=0;i<=2;i++){
		time->mon[i]=file[jp++];
	    }
	    time->mon[i]='\0';	    
	    jp=tire[2]+1;
	    for(i=0;i<2;i++){
		time->mday[i]=file[jp++];
	    }
	    time->mday[i]='\0';
	    jp=tire[3]+1;
	    for(i=0;i<2;i++){
		time->hour[i]=file[jp++];
	    }
	    time->hour[i]='\0';
	    jp=tire[3]+4;
	    for(i=0;i<2;i++){
		time->min[i]=file[jp++];
	    }
	    time->min[i]='\0';
	    jp=tire[3]+9;
	    for(i=0;i<2;i++){
		time->sec[i]=file[jp++];
	    }
	    time->sec[i]='\0';

//printf("abc\n");
	return *time;
}
Exemplo n.º 3
0
AGTime
AGTime::operator+(const AGTime& time) {
    AGTime newtime(time.sec + this->sec);
    return newtime;
}
Exemplo n.º 4
0
/*MAIN*/
int main()
{
	struct mossa *testa; /*Puntator to list's head*/
	struct mossa *nuova; /*Puntator to list's tail*/
	struct mossa *nuova_da_ordinare; /*Puntator to new move BEFORE is sorted*/
	struct mossa *testa_da_ordinare; /*Puntator to tail's head to be sorted*/
	struct mossa *temp; /*Puntator to temporary structure*/
	struct mossa *puntatore_ad_array_struct; /*Puntator to structure's array*/
	testa=NULL;/*Initializing head to NULL*/
	testa_da_ordinare=NULL;/*Initializing head to be sorted to NULL*/
	char name1[31], name2[31], *name, rigioca, deb[51];
	char r4[201]=MENU;
	int i, controlli, sottoScacco=0, partita=1, player=0, numero_celle, contatore3=0;
	time_t prima_della_mossa=0;
	pedina pedine[33];
	pedina *board[8][8], *testBoard[8][8], *toTest;
	posizione pos1, pos2;
	presentazione();
	name=name1;
	daCapo(pedine, board, name1, name2, name, &numero_celle);
	/*----------*/
	do {
		i=0, controlli=0;
		while (controlli==0)
		{
			printf("\n%s\n", r4);
			switch (userInput())
{
				case 'n':
					clear();
					daCapo(pedine, board, name1, name2, name, &numero_celle);
					showBoard(board);
					player=0;
					continue;
				case 'q':
					uscita();
					showBoard(board);
					continue;
				case 'h':
					help();
					showBoard(board);
					continue;
                #ifndef _WIN32
				case 'x':
					save(pedine, board, name1, name2, player, numero_celle, testa);
					continue;
				case 'c':
					testa = load(pedine, board, name1, name2, name, &player, &numero_celle);
					debug("Initializing head's test");
					temp=testa;
					while(temp != NULL)
					{
						sprintf(deb, "player: %s\n", (temp->player==0)?name1:name2); debug(deb);
						sprintf(deb, "move: %s\n", temp->coordinate); debug(deb);
						sprintf(deb, "duration: %.2lf secs\n", temp->durata_mossa); debug(deb);
						temp=temp->next;
						contatore3++;
					}
					debug("End head's test");
					continue;
                #endif
				case 's':
					stallo();
					showBoard(board);
					continue;
			}
			showBoard(board);
			if(prima_della_mossa==0)
			{
				time(&prima_della_mossa);
			}
			if (getCoordinate(board, &pos1, &pos2, name, player) &&
				pos1.loc->player==player &&
				checkMove(pedine, board, &pos1, &pos2, player, 0))
			{
				numero_celle=conteggio_celle(numero_celle);
				testa=newtime(player, testa, nuova, &pos1, &pos2, prima_della_mossa, numero_celle, name1, name2);
				prima_della_mossa=0;
				controlli = 1;
			}
			else { printf("\nWrong coordinates, re-enter\n"); }
		}
		toTest = (player==0)? pedine+27 : pedine+3;	//Re avversario
		if (scacco(toTest->l, toTest->n, player, board, pedine, player)) {sottoScacco=1; printf("\nScacco al RE\n"); }
		if (sottoScacco)
		{
			debug("UNDER CHECK");
			if(roundRe(toTest->l, toTest->n, player, board, pedine, player))
			{
				debug("maybe mate??\n");
				if(checkMatto(toTest->l, toTest->n, board, pedine, player))
				{
				    clear();
					printf("\nCheck mate!!!!!\n");
					rigioca=vittoria(player,name1,name2,testa,puntatore_ad_array_struct,numero_celle);
					if(rigioca=='y')
					{
						clear();
						daCapo(pedine, board, name1, name2, name, &numero_celle);
						showBoard(board);
						player=0;
						continue;
					}
					else
					{
						printf("\nThank for playing! Have a nice day.");
						getch();
						exit(0);
					}
				}
				else {debug("not mate..");}
			}
		}
		sprintf(deb, "%c --> moved=%d", pos1.loc->tipo, pos1.loc->moved); debug(deb);
		sprintf(deb, "%c (%d,%d) in %c (%d,%d)", pos1.loc->tipo, pos1.l+1, pos1.n+1, (*board[pos2.n][pos2.l]).tipo, pos2.l+1, pos2.n+1); debug(deb);
		sottoScacco=0;
		clear();
		nexTurn(&player);
		name=(player==0)?name1:name2;
	} while(partita != 0);
	return 0;
}