1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
void* ask_for_login(void* data) {
printf("debut ask_for_login\n");
thread_handle_t *th;
th = (thread_handle_t *) data;
while(((*th).use_lp == 0) && ((*th).use_sc == 0)){
printf("ask_for_login...\n");
login = getchar();
(*th).use_lp = 1;
}
printf("fin ask_for_login\n");
pthread_exit(NULL);
return NULL;
}
int main (void) {
pthread_t thread_lp;
void* status;
int cpt = 0;
thread_handle_t *th;
(*th).use_sc = 0;
(*th).use_lp = 0;
//(*th)->thread_pamh = NULL;
printf("veuillez inserer votre carte ou entrer votre login\n");
/* On attend que l'user entre son login */
if (pthread_create(&thread_lp, NULL, ask_for_login,(void *)th)) {
perror("pthread_create");
printf("erreur : pthread_create\n");
exit(EXIT_FAILURE);
}
/* On attend qu'une carte soit inseree */
sleep(5);
while(((*th).use_lp == 0) && ((*th).use_sc == 0)){
printf("j'attend l'insertion d'une carte...\n");
sleep(1);
cpt ++;
if(cpt == 6){
(*th).use_sc = 1;
//pthread_kill(thread_lp, 1);
}
}
if((*th).use_sc == 1){
//tuer thread_L;
printf("Carte inseree, bonjour Aro. Veuillez entrer votre code PIN :\n");
sleep(3);
}
else{
printf("Veuillez entrer votre mot de passe\n");
sleep(3);
}
printf("Authentification terminee\n");
return (EXIT_SUCCESS);
} |