Necessaire
master
d3friski 2 years ago
commit 798edb2945

@ -91,7 +91,9 @@ typedef struct
void testJean(void); void testJean(void);
void Globale(void); void Globale(void);
Log * chargementLog(char * nomFichier); Log * chargementLog(char * nomFichier, int * nbLog);
int existeUtilisateur(char * utilisateur, int * indice, Log * tLog, int nbLog);
int mdpValide(char * mdp, int indice, Log * tLog);
//void menuVisiteur(VilleIut *villeIut, int nbVilles); //void menuVisiteur(VilleIut *villeIut, int nbVilles);
void menuVisiteur(Log * tLog); void menuVisiteur(Log * tLog);
int afficherMenuVisiteur(void); int afficherMenuVisiteur(void);

@ -9,9 +9,8 @@ int main(void)
color color
#endif #endif
//Globale(); Globale();
testJean();
return 0; return 0;

@ -15,9 +15,10 @@
void Globale(void) void Globale(void)
{ {
Log * tLog; Log * tLog;
int nbLog;
//Chargement des fichiers //Chargement des fichiers
tLog = chargementLog("../donnees/log.don"); tLog = chargementLog("../donnees/log.don", &nbLog);
//Appel du menu visiteur //Appel du menu visiteur
menuVisiteur(tLog); menuVisiteur(tLog);
@ -30,14 +31,14 @@ void Globale(void)
* @param nomFichier [CHAINE DE CARACTERE] Le nom du fichier à charger * @param nomFichier [CHAINE DE CARACTERE] Le nom du fichier à charger
* @return Log* [TABLEAU DYNAMIQUE DE STRUCTURE] Le tableau de structures Log contenant les logs du fichier * @return Log* [TABLEAU DYNAMIQUE DE STRUCTURE] Le tableau de structures Log contenant les logs du fichier
*/ */
Log * chargementLog(char * nomFichier) Log * chargementLog(char * nomFichier, int * nbLog)
{ {
FILE * fichier; FILE * fichier;
Log * tLog; Log * tLog;
Log * tAnnexe; Log * tAnnexe;
int nbLogMax; int nbLogMax;
int nbLog;
int i; int i;
fichier = fopen(nomFichier, "r"); fichier = fopen(nomFichier, "r");
@ -74,6 +75,7 @@ Log * chargementLog(char * nomFichier)
i++; i++;
} }
*nbLog = i;
return tLog; return tLog;
} }
@ -189,15 +191,63 @@ int choixMenuVisiteur(void)
*/ */
void seConnecterTest(void) void seConnecterTest(void)
{ {
Log * tLog;
char mdp[30], utilisateur[30]; char mdp[30], utilisateur[30];
int indice, existe, nbLog, valide;
nbLog = 0;
tLog = chargementLog("../donnees/log.don", &nbLog); //TEMP
banniereConnection(); // Affichage banniereConnection(); // Affichage
saisieNomUtilisateur(utilisateur); // Récupération du nom d'utilisateur saisieNomUtilisateur(utilisateur); // Récupération du nom d'utilisateur
existe = existeUtilisateur(utilisateur, &indice, tLog, nbLog);
saisieMdp(mdp); // Récupération du mot de passe saisieMdp(mdp); // Récupération du mot de passe
valide = mdpValide(mdp, indice, tLog);
} }
/**
* @brief Vérifie si un utilisateur existe dans le tableau de structures de log.
*
* @param utilisateur [CHAINE DE CARACTERES] Le nom de l'utilisateur à rechercher.
* @param indice [POINTEUR] Pointeur vers un entier qui sera modifié pour stocker l'indice de l'utilisateur s'il est trouvé.
* @param tLog [TABLEAU] Tableau de structures de log.
* @param nbLog [Taille Logique] Nombre d'éléments dans le tableau de structures de log.
*
* @return int 1 --> l'utilisateur existe | 0 --> l'utilisateur n'existe pas
*/
int existeUtilisateur(char * utilisateur, int * indice, Log * tLog, int nbLog)
{
for (int i = 0 ; i < nbLog ; i++)
{
if (strcmp(tLog[i].utilisateur,utilisateur) == 0)
{
*indice = i;
return 1;
}
}
return 0;
}
/**
* @brief Valide si le mot de passe donné correspond au mot de passe enregistré dans la structure de log.
*
* @param mdp [CHAINE DE CARACTERES] Le mot de passe à valider.
* @param indice L'indice de la structure de log à utiliser pour la vérification.
* @param tLog [TABLEAU] Le tableau de structures de log.
*
* @return int 1 --> le mot de passe correspond | 0 --> le mot de passe ne correspond pas
*/
int mdpValide(char * mdp, int indice, Log * tLog)
{
if (strcmp(tLog[indice].mdp, mdp) == 0) return 1;
else return 0;
}
/** /**
* @brief Affichage de la bannière de connexion. * @brief Affichage de la bannière de connexion.
*/ */

Loading…
Cancel
Save