Example #1
0
int main(int argc, char ** argv)
{

  /*var locales*/
  int taille_v1=0,taille_v2=0;
  double * vect1;
  double * vect2;
  char nom1[TAILLE_NOM];
  char nom2[TAILLE_NOM];
  double prodS;

  printf("Saisissez le fichier du vecteur n°1 : ");
  fflush(stdout);
  scanf("%s%*c", nom1);

  printf("Saisissez le fichier du vecteur n°2 : ");
  fflush(stdout);
  scanf("%s%*c", nom2);

  vect1 = lecture(&taille_v1, nom1);
  afficheVect(taille_v1, vect1, nom1);

  vect2 = lecture(&taille_v2, nom2);
  afficheVect(taille_v2, vect2, nom2);

  prodS = prodScalaire(taille_v1, taille_v2, vect1, vect2, nom1, nom2);

  free(vect1);
  free(vect2);

  return 0;
}
Example #2
0
//c'est le vrai main. le coeur du service
void lancement_service(int ta_socket) {

	int n;
	int choix;
	choix = 1;
	char mMessage[TLIM] = "";
	char reponse[TLIM] = "";
	char nom[TLIM] = "";
	if ((n=read(ta_socket, nom, TLIM-1))>0);
	else strcpy(nom,"sombre inconnu");
	liste_referentiel(ta_socket);
	while (choix) {
		n = lecture_s(ta_socket);
		if (sscanf(get_message(),"%s",mMessage)>0) {
			while ((n=lecture(mMessage))==1) {
				ecriture_s(ta_socket);
			}
			if (n<0) {
				creation_message_erreur(mMessage);
				diffusion_erreur(ta_socket);
				//while (lecture("erreur.txt") == 1) ecriture_s(ta_socket);
			}
		}
		if (!strcmp(mMessage,"q") || !strcmp(mMessage,"Q")) {
			choix = 0;
			quitter(ta_socket);
		}
	}
}
Example #3
0
void ajout_info_liste(int fd) {
	while (lecture("entete_ref") == 1) write(fd,get_message(),size_message());
	while (liste_fichiers(".")) {
		write(fd,get_message(),size_message());
	}
	close(fd);
}
Example #4
0
Joueur::Joueur(OldJoueur &old, OldListe* liste)
{
    lastModified_ = 0;
    nom_ = string(old.getNom());
    dateNaissance_ = old.getDateNaissance();
    id_ = 0;
    this->setPerso((string)old.getPerso());
    this->setClasse(Systeme::fromOldClasses(old.getClasse()));
    this->setRace(Systeme::fromOldRaces(old.getRace()));
    this->setExp(old.getExp());
    this->setGroupe(-1);
    int extensionLength = 4;
    string fichier = liste->getfichier();
    fichier = fichier.erase(fichier.length() - extensionLength);
    fichier += "_notes_"+string(old.getNom()) + ".txt";
    ifstream lecture(fichier.c_str());

        if (!lecture.fail())
        {

            std::string temporaire, complet;

            while (!lecture.eof())
            {

                string enter = "\n";
                getline(lecture, temporaire);
                complet += temporaire;
                complet += enter;


            }
            this->notes_ = complet;
        }
}
Example #5
0
void clavierSpecial(int touche, int x, int y)
{
	switch(touche)
	{
	case GLUT_KEY_PAGE_UP :	
		if(conf.nbIterations<10)
		{
			conf.nbIterations++;
			glDeleteLists(laMontagne,1);
			creationDisplayList();
			glutPostRedisplay();
		}
		break;
	case GLUT_KEY_PAGE_DOWN :
		if(conf.nbIterations>0)
		{
			conf.nbIterations--;
			glDeleteLists(laMontagne,1);
			creationDisplayList();
			glutPostRedisplay();
		}
		break;
	case GLUT_KEY_HOME ://on calcule une nouvelle montagne + relecture des conditions de départ
		glDeleteLists(laMontagne,1);
		lecture();
		creationDisplayList();
		glutPostRedisplay();
		break;
	}	
}
Example #6
0
// lit le fichier dont le nom est transmis sur la ligne de commande
int main(int argc, char * argv[])
{
    if(argc != 2) erreur(LECTURE_ARG);

    lecture(argv[1]);

    return EXIT_SUCCESS;
}
Example #7
0
int main()
{
	int choix = 0;
	char schoix[10];
	int nbthread = 0;
	char snbthread[10];

	/*introduction du programme*/
	printf("----- Programme SuperPremier -----\n");
	printf("Voici les nombres des premiers nombres premiers que vous pouvez chercher:\n");
	printf("\t0 : exit\t5 : 2M\n");
	printf("\t1 : 128K\t6 : 4M\n");
	printf("\t2 : 256K\t7 : 8M\n");
	printf("\t3 : 512K\t8 : 16M\n");
	printf("\t4 : 1M  \t9 : 32M\n");
	
	/*selection du nb de nombre premier*/
	printf("Faites votre choix: ");
	lecture(schoix);
	choix = atoi(schoix);

#ifdef DEBUG
    debug("choix = %d",choix);
#endif
	
	if(choix != 0)
	{
		/*selection du nb de thread*/
		printf("Choississez le nombre de threads (de 1 à 8) : ");
		lecture(snbthread);

		nbthread = atoi(snbthread);
#ifdef DEBUG
		debug("snbthread = %s",snbthread);
		debug("nbthread = %d",nbthread);
		debug("initThread(nbthread = %d, choix = %d)",nbthread,choix);
#endif

		initThread(nbthread, choix);
	}
	printf("\n----- Fin du programme -----\n");
    return 0;
}
Example #8
0
void Controles::on_button_clicked()
{
	lectureEnCours = !lectureEnCours;
	updateButtonText(lectureEnCours);
	ui->largeurSlider->setEnabled(!lectureEnCours);

	if(lectureEnCours)
	{
		emit lecture();
	}
	else
	{
		emit pause();
	}
}
Example #9
0
int main(int argc,char **argv)
{
	Clause **tabClauses;
	Litteral **tabLitteraux;
	int nbClauses,nbLitteraux;
	Formule *f=NULL,*f1=NULL;
	
	f=(Formule*) malloc(sizeof(Formule));
	if(!lecture("testsupression.cnf",&(f->tabClauses),&(f->tabLitteraux),&(f->nbClauses),&(f->nbLitteraux)))
	{
		f->tailleTabClauses=f->nbClauses;
		f->tailleTabLitteraux=f->nbLitteraux;
		affichageClauses(f->tabClauses,f->nbClauses);
		affichageLitteraux(f->tabLitteraux,f->nbLitteraux);
		f1=genererFormule(f,1,1);
		affichageClauses(f1->tabClauses,f1->nbClauses);
		affichageLitteraux(f1->tabLitteraux,f1->nbLitteraux);
		//f->tailleTabClauses=nbClauses;
		//f->tailleTabLitteraux=nbLitteraux;
	}
	else printf("erreur\n");
	return 0;
}
Example #10
0
int main(int argc, char **argv) {
    if (argc != 2) {
        printf("Usage : ./lectures fichier\n");
        return EXIT_FAILURE;
    }
    
    struct stat sb;
    if (stat(argv[1], &sb) == -1) {
        perror("Erreur stat.\n");
        return EXIT_FAILURE;
    }
    
    /* On vérifie que c'est bien un fichier régulier */
    if ((sb.st_mode & S_IFMT) != S_IFREG) {
        perror("Le fichier n'est pas un fichier régulier.\n");
        return EXIT_FAILURE;
    }
    
    printf("Fonction lecture\n");
    lecture(argv[1]);
    
    
    return EXIT_SUCCESS;
}
Example #11
0
void decrypte(char* fentree, char* fsortie)
{
	int i, j, n, tailleCle, taille, choix, stop;
	char car;
	int* tabFreq = (int*)malloc(26*sizeof(int));
	double indice = 0.0;
	double e = 0.003;
	double ic = 0.0;
	double a = 0.076-e;
	double b = 0.076+e;
	char* cle;
	
	char* message = lecture(fentree);

	tailleCle = calculeIndice(message, 0);
	cle = calculeCle(tailleCle, message);
	
	printf("La clé est : ");
	for(i=0;i<tailleCle;i++)
	{
		printf("%c", cle[i]);
	}
	printf("\n");
	
	
	dechiffre(fentree, cle, fsortie);
	message = lecture(fsortie);
	printf("\n");
;
	stop = 0;
	
	while(1)
	{
		printf("0. Arrêter.\n");
		printf("1. Modifier la taille de la clé.\n");
		printf("2. Modifier un caractère de la clé manuellement.\n");
		scanf("%d",&choix);
		scanf("%*[^\n]s");
		getchar();
	
		switch(choix) 
		{
			case 0:
			{
				exit(1);
			}
			break;
			case 1: 
			{
				printf("Taille précédente : %d.\n", tailleCle);
				printf("Nouvelle taille de clé : ");
				scanf("%d",&tailleCle);
				scanf("%*[^\n]s");
				getchar();
				
				calculeIndice(message, tailleCle);
				cle = calculeCle(tailleCle, message);
				dechiffre(fentree, cle, fsortie);
			}
			break;
			case 2:
			{
				while(stop == 0)
				{
					printf("Clé actuelle : %s.\n", cle);
					printf("Indice du caractère à modifier : ");
					scanf("%d",&i);
					scanf("%*[^\n]s");
					getchar();
					if((i > tailleCle-1)||(i<0))
					{
						printf("Erreur, l'indice n'est pas compris dans la clé.\n");
					}
					else
					{
						printf("Nouvelle lettre de la clé à l'indice %d : ", i);
						scanf("%c",&car);
						scanf("%*[^\n]s");
						getchar();
						if((car < 'A')||( car > 'Z'))
						{
							printf("Erreur, la lettre saisie n'est pas compris entre A et Z\n");
						}
						else
						{
							cle[i] = car;
							printf("La nouvelle clé est donc %s\n", cle);
							
							dechiffre(fentree, cle, fsortie);
							lecture(fsortie);
							
							printf("1. La clé convient.\n");
							printf("0. La clé ne convient pas.(annuler)\n");
							scanf("%d",&stop);
							scanf("%*[^\n]s");
							getchar();
							
						}
					}
				}
				
			}
			break;
			default:  
			{
				printf("Commande non spécifiée.\n");
			}
		}
	}
}
Example #12
0
/*
 * Returns true if the user successfully authenticates, false if not
 * or -1 on error.
 */
int
check_user(int validated, int mode)
{
    struct passwd *auth_pw;
    char *timestampdir = NULL;
    char *timestampfile = NULL;
    char *prompt;
    struct stat sb;
    int status, rval = true;
    debug_decl(check_user, SUDO_DEBUG_AUTH)

    /*
     * Init authentication system regardless of whether we need a password.
     * Required for proper PAM session support.
     */
    auth_pw = get_authpw();
    if (sudo_auth_init(auth_pw) == -1) {
	rval = -1;
	goto done;
    }

    /*
     * Don't prompt for the root passwd or if the user is exempt.
     * If the user is not changing uid/gid, no need for a password.
     */
    if (!def_authenticate || user_uid == 0 || user_is_exempt())
	goto done;
    if (user_uid == runas_pw->pw_uid &&
	(!runas_gr || user_in_group(sudo_user.pw, runas_gr->gr_name))) {
#ifdef HAVE_SELINUX
	if (user_role == NULL && user_type == NULL)
#endif
#ifdef HAVE_PRIV_SET
	if (runas_privs == NULL && runas_limitprivs == NULL)
#endif
	    goto done;
    }

    /* Always need a password when -k was specified with the command. */
    if (ISSET(mode, MODE_IGNORE_TICKET))
	SET(validated, FLAG_CHECK_USER);

    /* Stash the tty's ctime for tty ticket comparison. */
    if (def_tty_tickets && user_ttypath && stat(user_ttypath, &sb) == 0) {
	tty_info.dev = sb.st_dev;
	tty_info.ino = sb.st_ino;
	tty_info.rdev = sb.st_rdev;
	if (tty_is_devpts(user_ttypath))
	    ctim_get(&sb, &tty_info.ctime);
    }

    if (build_timestamp(&timestampdir, &timestampfile) == -1) {
	rval = -1;
	goto done;
    }

    status = timestamp_status(timestampdir, timestampfile, user_name,
	TS_MAKE_DIRS);

    if (status != TS_CURRENT || ISSET(validated, FLAG_CHECK_USER)) {
	/* Bail out if we are non-interactive and a password is required */
	if (ISSET(mode, MODE_NONINTERACTIVE)) {
	    validated |= FLAG_NON_INTERACTIVE;
	    log_auth_failure(validated, 0);
	    rval = -1;
	    goto done;
	}

	/* XXX - should not lecture if askpass helper is being used. */
	lecture(status);

	/* Expand any escapes in the prompt. */
	prompt = expand_prompt(user_prompt ? user_prompt : def_passprompt,
	    user_name, user_shost);

	rval = verify_user(auth_pw, prompt, validated);
    }
    /* Only update timestamp if user was validated. */
    if (rval == true && ISSET(validated, VALIDATE_OK) &&
	!ISSET(mode, MODE_IGNORE_TICKET) && status != TS_ERROR)
	update_timestamp(timestampdir, timestampfile);
    efree(timestampdir);
    efree(timestampfile);

done:
    sudo_auth_cleanup(auth_pw);
    sudo_pw_delref(auth_pw);

    debug_return_bool(rval);
}
Example #13
0
int main(int argc, char *argv[])
{
    SDL_Init(SDL_INIT_VIDEO);
    TTF_Init();
    SDL_Surface* ecran = NULL, *ecranSurface = NULL;
    //SDL_Surface *ecran2;
    //ecran = SDL_CreateRGBSurface(0,700,700,32,0xff000000,0x00ff0000,0x0000ff00,0x000000ff);
    SDL_Rect origine;
    origine.x = 0;
    origine.y = 0;

    /*TTF_Font *police = NULL;
    SDL_Color couleurNoire = {0, 0, 0};
    police = TTF_OpenFont("annexes/Arial.ttf", 18);
    texte = TTF_RenderText_Blended(police, "Projet d'info !!!!!!!!!!!!!", couleurNoire);
    position.x = 10;
    position.y = 10;
    SDL_BlitSurface(texte, NULL, ecran, &position);*/

    ecranSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, 0, 0, 32, 0, 0, 0, 0); // On cre notre surface de dpart : un rectangle de taille nulle !
    int i;

    char * nomImages[NB_IMAGES] = { "M", "M1", "M2", "M3","M3b", "M4", "M5", "M6", "M7", "M7b" ,"M8", "M9", "M10", "M11", "M12", "M13", "M14", "T1", "T2", "T3", "RA", "RB", "RC", "RD", "RE", "Val"};
    /*char tmp[TAILLE_NOM] ="";
    SDL_Surface * tabImages[NB_IMAGES];
    for ( i = 0 ; i < NB_IMAGES ; i++ )
    {
    	strcat(tmp,CHEMIN);
    	strcat(tmp,nomImages[i]);
    	strcat(tmp,".png");
    	printf("%s\n",tmp);
    	tabImages[i] = IMG_Load(tmp);
    	strcpy(tmp,"");
    }

    for ( i = 0 ; i < NB_IMAGES ; i++ )
    {
    	//position.x=30*i%610;
    	//position.y=30*i/610;
    	position.x=30*i;
    	position.y=30*i;
    	SDL_BlitSurfaceSecure(tabImages[i], NULL, ecran, &position);
    }*/
    //tabImage[PIETON]

    int nbStation, numDep, numArr;
    char nomDep[TAILLE_NOM], nomArr[TAILLE_NOM];
    char nom[] =  "graphes/metro2012.csv";
    Station * plan = NULL;
    puts("lecture ...");
    plan = lecture(nom, &nbStation);

    ListeRes resultat = NULL;
    ListeChangement final = NULL;

    puts("Choix de la station de départ :");
    fgets(nomDep,TAILLE_NOM,stdin);
    nomDep[strlen(nomDep)-1]='\0';
    numDep = nomToNum(nomDep, plan, nbStation);

    viderBuffer();

    puts("Choix de la station d'arrivée :");
    fgets(nomArr,TAILLE_NOM,stdin);
    nomArr[strlen(nomArr)-1]='\0';
    numArr = nomToNum(nomArr, plan, nbStation);

    puts("aStar ...");
    resultat = aStar(numDep, numArr, plan);
    afficherRes(resultat);

    puts("Changement :");
    final = traitementAffichage(resultat);
Example #14
0
int main(int argc, const char* argv[])
{
	lecture();
	return EXIT_SUCCESS;
}
Example #15
0
void Configuration::lire (std::string chemin)
{
	std::ifstream fichierEnregistrement(chemin);
	boost::archive::text_iarchive lecture(fichierEnregistrement);
    lecture >> *this;
}
Example #16
0
void liste_referentiel(int ta_socket) {
	int liste_ref = creation_fichier_liste("liste_ref");
	ajout_info_liste(liste_ref);
	while (lecture("liste_ref") == 1) ecriture_s(ta_socket);
}
Example #17
0
diffusion_erreur(int ta_socket) {
	while (lecture("erreur.txt") == 1) ecriture_s(ta_socket);
}