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
|
static sem_t sem;
static void ma_cb_kd_une_carte_est_inseree()
{
//Authentification par carte.
sem_post(&sem)
}
static void * key_event_routine(void *user_data)
{
//faire ta detection de login/mdp ici
if(authentification_ok)
sem_post(&sem);
}
void main (void)
{
pthread_t thread;
pthread_attr_t attr;
struct sched_param param;
pthread_attr_init(&attr);
pthread_create(&thread, &attr, key_event_routine, NULL);
pthread_attr_destroy(&attr);
carte_a_puce_insered_event_register(ma_cb_kd_une_carte_est_inseree);
sem_init(&sem, 0, 1);
//When for a post from anybody.
sem_wait(&sem);
pthread_cancel(thread);
//Authentification done.
} |
Partager