You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
2.5 KiB

#include "Msae.h"
//################ fonction commune ###################################
void clearpage(void)
{
char entre;
printf("\nappuyé sur la touche [ENTREE] pour continuer");
scanf("%*c%c", &entre);
system("clear");
}
int login(void)
{
int i=3;
char id,mdp[31]="mettez20svp",mdpatrouve[31];
system("clear");
printf("################################################################\n\tBienvenue!\n\n\n\tSouhaitez-vous vous connecter en tant qu'utilisateur ou administeur? (U/A)\t");
scanf("%c%*c",&id);
if(id=='q')
return -1;
while(id!='A' && id!='a' && id!='U' && id!='u')
{
system("clear");
printf("################################################################\n\tMauvaise saisie (q pour quitter)\n\n\n\tSouhaitez-vous vous connecter en tant qu'utilisateur ou administeur? (U/A)\t");
scanf("%c%*c",&id);
if(id=='q')
return -1;
}
if(id=='A' || id=='a')
{
while(i!=0)
{
printf("\n\n\n\tMot de passe :\t");
system("stty -echo");
fgets(mdpatrouve,31,stdin);
mdpatrouve[strlen(mdpatrouve)-1] = '\0';
if( strcmp(mdpatrouve,mdp) == 0 )
{
system("stty echo");
return 1;
}
else
{
i--;
printf("Mot de passe incorrect, il vous reste %d chances\n",i);
}
system("stty echo");
}
return -1;
}
else return 0;
system("clear");
}
//################# fonctions affichage ###########################
void afficherPlace(MaillonDept m)
{
printf("\nPour ce département il y a %d places en 1ère année \n\n",m.nbP);
}
/*
//################## fonctions insertion #########################
int insererDept(VilleIUT v, MaillonDept m)
{
int trouve;
MaillonDept *pos;
pos=rechercheDept(v.lDept,&trouve,m.dept);
if(trouve==0)
{
printf("\nDépartement déjà présent dans cet IUT\n")
return -1;
}
m->suiv=pos;
pos=&m;
return 1;
}
//################# fonctions recherche #########################
MaillonDept* rechercheDept(ListeDept lDept, int *trouve, char nom[])
{
while(lDept->suiv!=NULL)
{
if(strcmp(nom,lDept->dept)==0)
{
*trouve=1;
return lDept;
}
if(strcmp(nom,lDept->dept)<0)
{
*trouve=0;
return lDept;
}
lDept=lDept->suiv;
}
*trouve=0;
return lDept;
}
*/
int rechercheIUT(VilleIUT *tiut[], int tLog, char ville[], int *trouve)
{
int inf,sup,t;
inf=0;
sup=tLog-1;
while(inf<=sup)
{
t=(inf+sup)/2;
if(strcmp(ville,tiut[t]->nom)==0)
{
*trouve=1;
return t;
}
if(strcmp(ville,tiut[t]->nom)<0)
sup=t-1;
else inf=t+1;
}
*trouve=0;
return inf;
}