コード例 #1
0
ファイル: example.c プロジェクト: shailikapoor/fusegit
int
main(int argc, char *argv[])
{
	create_repo("repo.git");
	read_repo("repo.git");
	//edit_repo("repo.git");
	//read_repo("repo.git");
	return 0;
}
コード例 #2
0
ファイル: server.c プロジェクト: asosso/ProgettoSo
/* Funzione utilizzata per allocare aree di memoria e settare il valore dei semafori  */
int setup() {
	log_date(LOG_PATH, "Settaggio parametri");

	// Allocazione aree di memoria
	rep = (repo *) shmat(shmid, NULL, 0);
	ls = (numlettori *) shmat(shmls, NULL, 0);
	aut = (auth *) shmat(shmauth, NULL, 0);
	pus = (push *) shmat(shmpush, NULL, 0);

	// Impostazione a 0 delle variabili contatori
	rep->n = 0;
	aut->n = 0;
	pus->n = 0;

	int po = 0;
	for(; po < SEM_TOT; po++)
		ls->n[po] = 0;

	// Settaggio seamfori
	semctl(semid, SEM_SERVER, SETVAL, MAX_SERVER - 1);
	semctl(semid, BUFFER_MUTEX, SETVAL, 1);
	semctl(semid, LS_SCRIVI, SETVAL, 1);
	semctl(semid, LS_MUTEX, SETVAL, 1);
	semctl(semid, AUTH_MUTEX, SETVAL, 1);
	semctl(semid, AUTH_SCRIVI, SETVAL, 1);
	semctl(semid, PUSH_MUTEX, SETVAL, 1);
	semctl(semid, PUSH_SCRIVI, SETVAL, 1);
	semctl(semid, QUEUE_SEM, SETVAL, QUEUE_MAX - 1);

	padre = getpid();

	writebuf("\n(start) Avvio del server completato: ID %d\n", padre);
	writebuf("\n(Aree di memora allocate)\nSEM: %d\nMSG: %d\nSHM: %d\nSHMLOG: %d\nSHMLS: %d\nSHMAUTH: %d\nSHMPUSH: %d\n\n",
			semid, msgid, shmid, shmlog, shmls, shmauth, shmpush);
	/* SIG_IGN al segnlae di terminazione dei figli
	 * i figli terminati non diventeranno zombie */
	signal(SIGCHLD, SIG_IGN);
	signal(SIGINT, server_stop);  // Forza lo spegnimento premendo ctrl + c
	// Lettura repository iniziale
	return read_repo(SERVER_INITIAL_REPO);
}