|
|
@ -17,6 +17,7 @@
|
|
|
|
#include "../II/deux.c"
|
|
|
|
#include "../II/deux.c"
|
|
|
|
|
|
|
|
|
|
|
|
void identificationCandidat(int* id, ListeCandidats* listePointer, int* nbCandidats) {
|
|
|
|
void identificationCandidat(int* id, ListeCandidats* listePointer, int* nbCandidats) {
|
|
|
|
|
|
|
|
Candidat* candidat;
|
|
|
|
char connexion, poubelle;
|
|
|
|
char connexion, poubelle;
|
|
|
|
int verif;
|
|
|
|
int verif;
|
|
|
|
|
|
|
|
|
|
|
@ -56,7 +57,7 @@ void identificationCandidat(int* id, ListeCandidats* listePointer, int* nbCandid
|
|
|
|
if(connexion == 'n' || connexion == 'N') {
|
|
|
|
if(connexion == 'n' || connexion == 'N') {
|
|
|
|
printf("\nTrès bien, nous allons donc précéder à votre enregistrement.\n\n");
|
|
|
|
printf("\nTrès bien, nous allons donc précéder à votre enregistrement.\n\n");
|
|
|
|
|
|
|
|
|
|
|
|
Candidat* candidat = creerCandidat(); // malloc
|
|
|
|
candidat = creerCandidat(); // malloc
|
|
|
|
|
|
|
|
|
|
|
|
printf("Nom de famille : ");
|
|
|
|
printf("Nom de famille : ");
|
|
|
|
scanf("%*c%[^\n]", candidat->nom);
|
|
|
|
scanf("%*c%[^\n]", candidat->nom);
|
|
|
@ -116,8 +117,10 @@ void titreMenuPrincipal(void) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void menuCandidat(VilleIUT** tiut, ListeCandidats* listePointer, int nbVilles, int* nbCandidats) {
|
|
|
|
void menuCandidat(VilleIUT** tiut, ListeCandidats* listePointer, int nbVilles, int* nbCandidats) {
|
|
|
|
char poubelle; // Permet de stocker les caractères aspirés en trop sur stdin lors du choix dans le menu
|
|
|
|
// poubelle: Permet de stocker les caractères aspirés en trop sur stdin lors du choix dans le menu
|
|
|
|
|
|
|
|
char poubelle, searchIUT[LEN_MAX], searchDept[LEN_MAX];
|
|
|
|
Candidat* candidat;
|
|
|
|
Candidat* candidat;
|
|
|
|
|
|
|
|
|
|
|
|
// choix: Contient le choix de l'utilisateur dans le menu / id: contient id user si login / status: candidatures ouvertes ou fermées
|
|
|
|
// choix: Contient le choix de l'utilisateur dans le menu / id: contient id user si login / status: candidatures ouvertes ou fermées
|
|
|
|
int choix, id = 0, status = readStatus();
|
|
|
|
int choix, id = 0, status = readStatus();
|
|
|
|
char connexion;
|
|
|
|
char connexion;
|
|
|
@ -167,7 +170,6 @@ void menuCandidat(VilleIUT** tiut, ListeCandidats* listePointer, int nbVilles, i
|
|
|
|
printf("Voir les disponibilités des départements dans un IUT...\n\n");
|
|
|
|
printf("Voir les disponibilités des départements dans un IUT...\n\n");
|
|
|
|
printf("Saisissez le nom de la ville recherchée (tapez q pour annuler) : ");
|
|
|
|
printf("Saisissez le nom de la ville recherchée (tapez q pour annuler) : ");
|
|
|
|
|
|
|
|
|
|
|
|
char searchIUT[LEN_MAX];
|
|
|
|
|
|
|
|
scanf("\n%[^\n]", searchIUT);
|
|
|
|
scanf("\n%[^\n]", searchIUT);
|
|
|
|
|
|
|
|
|
|
|
|
if(strcasecmp(searchIUT, "q") == 0)
|
|
|
|
if(strcasecmp(searchIUT, "q") == 0)
|
|
|
@ -179,7 +181,6 @@ void menuCandidat(VilleIUT** tiut, ListeCandidats* listePointer, int nbVilles, i
|
|
|
|
printf("Rechercher un département...\n\n");
|
|
|
|
printf("Rechercher un département...\n\n");
|
|
|
|
printf("Saisissez le nom du département recherché (tapez q pour annuler) : ");
|
|
|
|
printf("Saisissez le nom du département recherché (tapez q pour annuler) : ");
|
|
|
|
|
|
|
|
|
|
|
|
char searchDept[LEN_MAX];
|
|
|
|
|
|
|
|
scanf("\n%[^\n]", searchDept);
|
|
|
|
scanf("\n%[^\n]", searchDept);
|
|
|
|
|
|
|
|
|
|
|
|
if(strcasecmp(searchDept, "q") == 0)
|
|
|
|
if(strcasecmp(searchDept, "q") == 0)
|
|
|
@ -547,7 +548,7 @@ void menuPrincipal(/* TODO: prise en compte des status actuels du recrutement */
|
|
|
|
// FONCTIONS MENU ADMIN
|
|
|
|
// FONCTIONS MENU ADMIN
|
|
|
|
|
|
|
|
|
|
|
|
void menuAdmin_modifierPlaces(VilleIUT** tiut, int nbVilles) {
|
|
|
|
void menuAdmin_modifierPlaces(VilleIUT** tiut, int nbVilles) {
|
|
|
|
int nbPlaces;
|
|
|
|
int nbPlaces, code;
|
|
|
|
char searchIUT[LEN_MAX], searchDept[LEN_MAX];
|
|
|
|
char searchIUT[LEN_MAX], searchDept[LEN_MAX];
|
|
|
|
printf("Entrez une ville (tapez q pour annuler) : ");
|
|
|
|
printf("Entrez une ville (tapez q pour annuler) : ");
|
|
|
|
scanf("\n%[^\n]", searchIUT);
|
|
|
|
scanf("\n%[^\n]", searchIUT);
|
|
|
@ -555,7 +556,7 @@ void menuAdmin_modifierPlaces(VilleIUT** tiut, int nbVilles) {
|
|
|
|
if(strcasecmp(searchIUT, "q") == 0)
|
|
|
|
if(strcasecmp(searchIUT, "q") == 0)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
int code = afficherListeDepartement(tiut, nbVilles, searchIUT);
|
|
|
|
code = afficherListeDepartement(tiut, nbVilles, searchIUT);
|
|
|
|
|
|
|
|
|
|
|
|
if(code != -1) {
|
|
|
|
if(code != -1) {
|
|
|
|
printf("Quel département souhaitez-vous modifier ? : ");
|
|
|
|
printf("Quel département souhaitez-vous modifier ? : ");
|
|
|
@ -568,6 +569,7 @@ void menuAdmin_modifierPlaces(VilleIUT** tiut, int nbVilles) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void menuAdmin_creerIUT(VilleIUT*** tiutPointer, int* nbVilles) {
|
|
|
|
void menuAdmin_creerIUT(VilleIUT*** tiutPointer, int* nbVilles) {
|
|
|
|
|
|
|
|
VilleIUT* ville;
|
|
|
|
char nameIUT[LEN_MAX];
|
|
|
|
char nameIUT[LEN_MAX];
|
|
|
|
printf("Entrez le nom de la ville (tapez q pour annuler) : ");
|
|
|
|
printf("Entrez le nom de la ville (tapez q pour annuler) : ");
|
|
|
|
scanf("\n%[^\n]", nameIUT);
|
|
|
|
scanf("\n%[^\n]", nameIUT);
|
|
|
@ -575,7 +577,7 @@ void menuAdmin_creerIUT(VilleIUT*** tiutPointer, int* nbVilles) {
|
|
|
|
if(strcasecmp(nameIUT, "q") == 0)
|
|
|
|
if(strcasecmp(nameIUT, "q") == 0)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
VilleIUT* ville = creerVille();
|
|
|
|
ville = creerVille();
|
|
|
|
strcpy(ville->ville, nameIUT);
|
|
|
|
strcpy(ville->ville, nameIUT);
|
|
|
|
|
|
|
|
|
|
|
|
ajouterVille(tiutPointer, ville, nbVilles);
|
|
|
|
ajouterVille(tiutPointer, ville, nbVilles);
|
|
|
@ -641,6 +643,7 @@ void menuAdmin_creerDepartement(VilleIUT** tiut, int nbVilles) {
|
|
|
|
|
|
|
|
|
|
|
|
void menuAdmin_supprimerDepartement(VilleIUT** tiut, int nbVilles) {
|
|
|
|
void menuAdmin_supprimerDepartement(VilleIUT** tiut, int nbVilles) {
|
|
|
|
if(readStatus() == 0) {
|
|
|
|
if(readStatus() == 0) {
|
|
|
|
|
|
|
|
int i;
|
|
|
|
char searchIUT[LEN_MAX], searchDept[LEN_MAX];
|
|
|
|
char searchIUT[LEN_MAX], searchDept[LEN_MAX];
|
|
|
|
|
|
|
|
|
|
|
|
VilleIUT* ville;
|
|
|
|
VilleIUT* ville;
|
|
|
@ -651,7 +654,7 @@ void menuAdmin_supprimerDepartement(VilleIUT** tiut, int nbVilles) {
|
|
|
|
if(strcasecmp(searchIUT, "q") == 0)
|
|
|
|
if(strcasecmp(searchIUT, "q") == 0)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
int i = rechercherVille(tiut, nbVilles, searchIUT);
|
|
|
|
i = rechercherVille(tiut, nbVilles, searchIUT);
|
|
|
|
|
|
|
|
|
|
|
|
if(i == -1)
|
|
|
|
if(i == -1)
|
|
|
|
fprintf(stderr, "\e[1;91mErreur: la ville '%s' n'est pas dans la liste des IUT.\e[0m\n\n", searchIUT);
|
|
|
|
fprintf(stderr, "\e[1;91mErreur: la ville '%s' n'est pas dans la liste des IUT.\e[0m\n\n", searchIUT);
|
|
|
@ -744,6 +747,7 @@ ListeDept creerListeDepartement(void) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int afficherListeDepartement(VilleIUT** tiut, int nbVilles, char* searchIUT) {
|
|
|
|
int afficherListeDepartement(VilleIUT** tiut, int nbVilles, char* searchIUT) {
|
|
|
|
|
|
|
|
ListeDept ldept;
|
|
|
|
int i = rechercherVille(tiut, nbVilles, searchIUT);
|
|
|
|
int i = rechercherVille(tiut, nbVilles, searchIUT);
|
|
|
|
|
|
|
|
|
|
|
|
if(i == -1) {
|
|
|
|
if(i == -1) {
|
|
|
@ -751,7 +755,7 @@ int afficherListeDepartement(VilleIUT** tiut, int nbVilles, char* searchIUT) {
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ListeDept ldept = tiut[i]->ldept;
|
|
|
|
ldept = tiut[i]->ldept;
|
|
|
|
|
|
|
|
|
|
|
|
if(ldept == NULL)
|
|
|
|
if(ldept == NULL)
|
|
|
|
fprintf(stderr, "\n\e[1;91mErreur: la ville '%s' ne contient aucun département\e[0m\n\n", tiut[i]->ville);
|
|
|
|
fprintf(stderr, "\n\e[1;91mErreur: la ville '%s' ne contient aucun département\e[0m\n\n", tiut[i]->ville);
|
|
|
@ -770,18 +774,20 @@ int afficherListeDepartement(VilleIUT** tiut, int nbVilles, char* searchIUT) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void afficherDepartement(VilleIUT** tiut, int nbVilles, char* searchDept) {
|
|
|
|
void afficherDepartement(VilleIUT** tiut, int nbVilles, char* searchDept) {
|
|
|
|
|
|
|
|
int i, nb=0;
|
|
|
|
|
|
|
|
ListeDept ldept, search;
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n\e[4;37mListe des IUT contenant le département '%s':\e[0m\n\n", searchDept);
|
|
|
|
printf("\n\e[4;37mListe des IUT contenant le département '%s':\e[0m\n\n", searchDept);
|
|
|
|
|
|
|
|
|
|
|
|
int i, nb=0;
|
|
|
|
|
|
|
|
for(i=0; i<nbVilles; i++) {
|
|
|
|
for(i=0; i<nbVilles; i++) {
|
|
|
|
ListeDept ldept = tiut[i]->ldept;
|
|
|
|
ldept = tiut[i]->ldept;
|
|
|
|
|
|
|
|
|
|
|
|
if(ldept != NULL) {
|
|
|
|
if(ldept != NULL) {
|
|
|
|
if(strcasecmp(ldept->departement, searchDept) == 0) {
|
|
|
|
if(strcasecmp(ldept->departement, searchDept) == 0) {
|
|
|
|
printf(" - %s\n", tiut[i]->ville);
|
|
|
|
printf(" - %s\n", tiut[i]->ville);
|
|
|
|
nb++;
|
|
|
|
nb++;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ListeDept search = ldept;
|
|
|
|
search = ldept;
|
|
|
|
|
|
|
|
|
|
|
|
while(search->suiv != NULL) {
|
|
|
|
while(search->suiv != NULL) {
|
|
|
|
search = search->suiv;
|
|
|
|
search = search->suiv;
|
|
|
@ -833,12 +839,13 @@ ListeDept ajouterDepartement(ListeDept ldept, MaillonDept* dept) {
|
|
|
|
|
|
|
|
|
|
|
|
ListeDept supprimerDepartement(ListeDept ldept, char* searchDept) {
|
|
|
|
ListeDept supprimerDepartement(ListeDept ldept, char* searchDept) {
|
|
|
|
int foundDept=0;
|
|
|
|
int foundDept=0;
|
|
|
|
|
|
|
|
ListeDept search, tmp;
|
|
|
|
|
|
|
|
|
|
|
|
if(strcasecmp(ldept->departement, searchDept) == 0) {
|
|
|
|
if(strcasecmp(ldept->departement, searchDept) == 0) {
|
|
|
|
ldept = ldept->suiv;
|
|
|
|
ldept = ldept->suiv;
|
|
|
|
foundDept = 1;
|
|
|
|
foundDept = 1;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ListeDept search = ldept, tmp;
|
|
|
|
search = ldept;
|
|
|
|
|
|
|
|
|
|
|
|
while(search->suiv != NULL && strcasecmp(search->departement, searchDept) != 0) {
|
|
|
|
while(search->suiv != NULL && strcasecmp(search->departement, searchDept) != 0) {
|
|
|
|
tmp = search;
|
|
|
|
tmp = search;
|
|
|
@ -861,13 +868,14 @@ ListeDept supprimerDepartement(ListeDept ldept, char* searchDept) {
|
|
|
|
|
|
|
|
|
|
|
|
void modifierNbPlaces(VilleIUT** tiut, int nbVilles, char* searchIUT, char* searchDept, int nb) {
|
|
|
|
void modifierNbPlaces(VilleIUT** tiut, int nbVilles, char* searchIUT, char* searchDept, int nb) {
|
|
|
|
int foundDept=0, i = rechercherVille(tiut, nbVilles, searchIUT);
|
|
|
|
int foundDept=0, i = rechercherVille(tiut, nbVilles, searchIUT);
|
|
|
|
|
|
|
|
ListeDept ldept, search;
|
|
|
|
|
|
|
|
|
|
|
|
if(i == -1) {
|
|
|
|
if(i == -1) {
|
|
|
|
fprintf(stderr, "\n\e[1;91mErreur: la ville '%s' n'est pas dans la liste des IUT.\e[0m\n\n", searchIUT);
|
|
|
|
fprintf(stderr, "\n\e[1;91mErreur: la ville '%s' n'est pas dans la liste des IUT.\e[0m\n\n", searchIUT);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ListeDept ldept = tiut[i]->ldept;
|
|
|
|
ldept = tiut[i]->ldept;
|
|
|
|
|
|
|
|
|
|
|
|
if(ldept != NULL) {
|
|
|
|
if(ldept != NULL) {
|
|
|
|
if(strcasecmp(ldept->departement, searchDept) == 0) {
|
|
|
|
if(strcasecmp(ldept->departement, searchDept) == 0) {
|
|
|
@ -875,7 +883,7 @@ void modifierNbPlaces(VilleIUT** tiut, int nbVilles, char* searchIUT, char* sear
|
|
|
|
ldept->nbP = nb;
|
|
|
|
ldept->nbP = nb;
|
|
|
|
foundDept = 1;
|
|
|
|
foundDept = 1;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ListeDept search = ldept;
|
|
|
|
search = ldept;
|
|
|
|
|
|
|
|
|
|
|
|
while(search->suiv != NULL) {
|
|
|
|
while(search->suiv != NULL) {
|
|
|
|
search = search->suiv;
|
|
|
|
search = search->suiv;
|
|
|
@ -893,6 +901,7 @@ void modifierNbPlaces(VilleIUT** tiut, int nbVilles, char* searchIUT, char* sear
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void modifierNomResponsable(VilleIUT** tiut, int nbVilles, char* searchIUT, char* searchDept, char* nom) {
|
|
|
|
void modifierNomResponsable(VilleIUT** tiut, int nbVilles, char* searchIUT, char* searchDept, char* nom) {
|
|
|
|
|
|
|
|
ListeDept ldept, search;
|
|
|
|
int foundDept=0, i = rechercherVille(tiut, nbVilles, searchIUT);
|
|
|
|
int foundDept=0, i = rechercherVille(tiut, nbVilles, searchIUT);
|
|
|
|
|
|
|
|
|
|
|
|
if(i == -1) {
|
|
|
|
if(i == -1) {
|
|
|
@ -900,7 +909,7 @@ void modifierNomResponsable(VilleIUT** tiut, int nbVilles, char* searchIUT, char
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ListeDept ldept = tiut[i]->ldept;
|
|
|
|
ldept = tiut[i]->ldept;
|
|
|
|
|
|
|
|
|
|
|
|
if(ldept != NULL) {
|
|
|
|
if(ldept != NULL) {
|
|
|
|
if(strcasecmp(ldept->departement, searchDept) == 0) {
|
|
|
|
if(strcasecmp(ldept->departement, searchDept) == 0) {
|
|
|
@ -908,7 +917,7 @@ void modifierNomResponsable(VilleIUT** tiut, int nbVilles, char* searchIUT, char
|
|
|
|
printf("\n\e[1;32mLe responsable de la formation '%s' à l'IUT '%s' est désormais '%s'.\e[0m\n\n", searchDept, searchIUT, ldept->responsable);
|
|
|
|
printf("\n\e[1;32mLe responsable de la formation '%s' à l'IUT '%s' est désormais '%s'.\e[0m\n\n", searchDept, searchIUT, ldept->responsable);
|
|
|
|
foundDept = 1;
|
|
|
|
foundDept = 1;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ListeDept search = ldept;
|
|
|
|
search = ldept;
|
|
|
|
|
|
|
|
|
|
|
|
while(search->suiv != NULL) {
|
|
|
|
while(search->suiv != NULL) {
|
|
|
|
search = search->suiv;
|
|
|
|
search = search->suiv;
|
|
|
@ -926,6 +935,10 @@ void modifierNomResponsable(VilleIUT** tiut, int nbVilles, char* searchIUT, char
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void saveVilles(VilleIUT* tiut[], int nbVilles) {
|
|
|
|
void saveVilles(VilleIUT* tiut[], int nbVilles) {
|
|
|
|
|
|
|
|
int i, longueurNomVille, nbDepartements, lenDepartement, lenNomResponsable;
|
|
|
|
|
|
|
|
VilleIUT ville;
|
|
|
|
|
|
|
|
MaillonDept* maillon;
|
|
|
|
|
|
|
|
|
|
|
|
FILE *fe = fopen("donnees/villes.bin", "wb");
|
|
|
|
FILE *fe = fopen("donnees/villes.bin", "wb");
|
|
|
|
|
|
|
|
|
|
|
|
if(fe == NULL) {
|
|
|
|
if(fe == NULL) {
|
|
|
@ -935,15 +948,15 @@ void saveVilles(VilleIUT* tiut[], int nbVilles) {
|
|
|
|
|
|
|
|
|
|
|
|
fwrite(&nbVilles, sizeof(int), 1, fe);
|
|
|
|
fwrite(&nbVilles, sizeof(int), 1, fe);
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < nbVilles; i++) {
|
|
|
|
for (i=0; i<nbVilles; i++) {
|
|
|
|
VilleIUT ville = *tiut[i];
|
|
|
|
ville = *tiut[i];
|
|
|
|
|
|
|
|
|
|
|
|
int longueurNomVille = strlen(ville.ville)+1;
|
|
|
|
longueurNomVille = strlen(ville.ville)+1;
|
|
|
|
fwrite(&longueurNomVille, sizeof(int), 1, fe);
|
|
|
|
fwrite(&longueurNomVille, sizeof(int), 1, fe);
|
|
|
|
fwrite(ville.ville, sizeof(char), longueurNomVille, fe);
|
|
|
|
fwrite(ville.ville, sizeof(char), longueurNomVille, fe);
|
|
|
|
|
|
|
|
|
|
|
|
int nbDepartements = 0;
|
|
|
|
nbDepartements = 0;
|
|
|
|
MaillonDept* maillon = ville.ldept;
|
|
|
|
maillon = ville.ldept;
|
|
|
|
while (maillon != NULL) {
|
|
|
|
while (maillon != NULL) {
|
|
|
|
nbDepartements++;
|
|
|
|
nbDepartements++;
|
|
|
|
maillon = maillon->suiv;
|
|
|
|
maillon = maillon->suiv;
|
|
|
@ -952,13 +965,13 @@ void saveVilles(VilleIUT* tiut[], int nbVilles) {
|
|
|
|
|
|
|
|
|
|
|
|
maillon = ville.ldept;
|
|
|
|
maillon = ville.ldept;
|
|
|
|
while (maillon != NULL) {
|
|
|
|
while (maillon != NULL) {
|
|
|
|
int lenDepartement = strlen(maillon->departement)+1;
|
|
|
|
lenDepartement = strlen(maillon->departement)+1;
|
|
|
|
fwrite(&lenDepartement, sizeof(int), 1, fe);
|
|
|
|
fwrite(&lenDepartement, sizeof(int), 1, fe);
|
|
|
|
fwrite(maillon->departement, sizeof(char), lenDepartement, fe);
|
|
|
|
fwrite(maillon->departement, sizeof(char), lenDepartement, fe);
|
|
|
|
|
|
|
|
|
|
|
|
fwrite(&maillon->nbP, sizeof(int), 1, fe);
|
|
|
|
fwrite(&maillon->nbP, sizeof(int), 1, fe);
|
|
|
|
|
|
|
|
|
|
|
|
int lenNomResponsable = strlen(maillon->responsable)+1;
|
|
|
|
lenNomResponsable = strlen(maillon->responsable)+1;
|
|
|
|
fwrite(&lenNomResponsable, sizeof(int), 1, fe);
|
|
|
|
fwrite(&lenNomResponsable, sizeof(int), 1, fe);
|
|
|
|
fwrite(maillon->responsable, sizeof(char), lenNomResponsable, fe);
|
|
|
|
fwrite(maillon->responsable, sizeof(char), lenNomResponsable, fe);
|
|
|
|
|
|
|
|
|
|
|
@ -972,6 +985,11 @@ void saveVilles(VilleIUT* tiut[], int nbVilles) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VilleIUT** readVilles(int* nbVilles) {
|
|
|
|
VilleIUT** readVilles(int* nbVilles) {
|
|
|
|
|
|
|
|
VilleIUT** tiut;
|
|
|
|
|
|
|
|
VilleIUT* ville;
|
|
|
|
|
|
|
|
MaillonDept* maillon, *maillonPrecedent;
|
|
|
|
|
|
|
|
int i, lenNomVille, nbDepartements, lenDepartement, lenNomResponsable;
|
|
|
|
|
|
|
|
|
|
|
|
FILE *fe = fopen("donnees/villes.bin", "rb");
|
|
|
|
FILE *fe = fopen("donnees/villes.bin", "rb");
|
|
|
|
|
|
|
|
|
|
|
|
if(fe == NULL) {
|
|
|
|
if(fe == NULL) {
|
|
|
@ -981,34 +999,32 @@ VilleIUT** readVilles(int* nbVilles) {
|
|
|
|
|
|
|
|
|
|
|
|
fread(nbVilles, sizeof(int), 1, fe);
|
|
|
|
fread(nbVilles, sizeof(int), 1, fe);
|
|
|
|
|
|
|
|
|
|
|
|
VilleIUT** tiut = (VilleIUT**) malloc(*nbVilles*sizeof(VilleIUT*));
|
|
|
|
tiut = (VilleIUT**) malloc(*nbVilles*sizeof(VilleIUT*));
|
|
|
|
|
|
|
|
|
|
|
|
if(tiut == NULL) {
|
|
|
|
if(tiut == NULL) {
|
|
|
|
perror("malloc");
|
|
|
|
perror("malloc");
|
|
|
|
exit(errno);
|
|
|
|
exit(errno);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < *nbVilles; i++) {
|
|
|
|
for (i=0; i<*nbVilles; i++) {
|
|
|
|
VilleIUT* ville = (VilleIUT*) malloc(sizeof(VilleIUT));
|
|
|
|
ville = (VilleIUT*) malloc(sizeof(VilleIUT));
|
|
|
|
|
|
|
|
|
|
|
|
if(ville == NULL) {
|
|
|
|
if(ville == NULL) {
|
|
|
|
perror("malloc");
|
|
|
|
perror("malloc");
|
|
|
|
exit(errno);
|
|
|
|
exit(errno);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int lenNomVille;
|
|
|
|
|
|
|
|
fread(&lenNomVille, sizeof(int), 1, fe);
|
|
|
|
fread(&lenNomVille, sizeof(int), 1, fe);
|
|
|
|
fread(ville->ville, sizeof(char), lenNomVille, fe);
|
|
|
|
fread(ville->ville, sizeof(char), lenNomVille, fe);
|
|
|
|
|
|
|
|
|
|
|
|
int nbDepartements;
|
|
|
|
|
|
|
|
fread(&nbDepartements, sizeof(int), 1, fe);
|
|
|
|
fread(&nbDepartements, sizeof(int), 1, fe);
|
|
|
|
|
|
|
|
|
|
|
|
ville->ldept = creerListeDepartement();
|
|
|
|
ville->ldept = creerListeDepartement();
|
|
|
|
MaillonDept* maillonPrecedent = NULL;
|
|
|
|
maillonPrecedent = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
int j;
|
|
|
|
int j;
|
|
|
|
for (j=0; j<nbDepartements; j++) {
|
|
|
|
for (j=0; j<nbDepartements; j++) {
|
|
|
|
MaillonDept* maillon = (MaillonDept*) malloc(sizeof(MaillonDept));
|
|
|
|
maillon = (MaillonDept*) malloc(sizeof(MaillonDept));
|
|
|
|
|
|
|
|
|
|
|
|
if(maillon == NULL) {
|
|
|
|
if(maillon == NULL) {
|
|
|
|
perror("malloc");
|
|
|
|
perror("malloc");
|
|
|
@ -1018,13 +1034,11 @@ VilleIUT** readVilles(int* nbVilles) {
|
|
|
|
if(maillonPrecedent != NULL)
|
|
|
|
if(maillonPrecedent != NULL)
|
|
|
|
maillonPrecedent->suiv = maillon;
|
|
|
|
maillonPrecedent->suiv = maillon;
|
|
|
|
|
|
|
|
|
|
|
|
int lenDepartement;
|
|
|
|
|
|
|
|
fread(&lenDepartement, sizeof(int), 1, fe);
|
|
|
|
fread(&lenDepartement, sizeof(int), 1, fe);
|
|
|
|
fread(maillon->departement, sizeof(char), lenDepartement, fe);
|
|
|
|
fread(maillon->departement, sizeof(char), lenDepartement, fe);
|
|
|
|
|
|
|
|
|
|
|
|
fread(&maillon->nbP, sizeof(int), 1, fe);
|
|
|
|
fread(&maillon->nbP, sizeof(int), 1, fe);
|
|
|
|
|
|
|
|
|
|
|
|
int lenNomResponsable;
|
|
|
|
|
|
|
|
fread(&lenNomResponsable, sizeof(int), 1, fe);
|
|
|
|
fread(&lenNomResponsable, sizeof(int), 1, fe);
|
|
|
|
fread(maillon->responsable, sizeof(char), lenNomResponsable, fe);
|
|
|
|
fread(maillon->responsable, sizeof(char), lenNomResponsable, fe);
|
|
|
|
|
|
|
|
|
|
|
|