|
|
|
@ -10,24 +10,26 @@
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <unistd.h> // sleep
|
|
|
|
|
#include "un.h"
|
|
|
|
|
#include "../II/deux.c"
|
|
|
|
|
|
|
|
|
|
void titreMenuPrincipal(void) {
|
|
|
|
|
system("clear");
|
|
|
|
|
printf("██████╗ ███████╗ ██████╗██████╗ ██╗ ██╗████████╗███████╗███╗ ███╗███████╗███╗ ██╗████████╗ ██╗██╗ ██╗████████╗\n");
|
|
|
|
|
printf("\e[1;35m██████╗ ███████╗ ██████╗██████╗ ██╗ ██╗████████╗███████╗███╗ ███╗███████╗███╗ ██╗████████╗ ██╗██╗ ██╗████████╗\n");
|
|
|
|
|
printf("██╔══██╗██╔════╝██╔════╝██╔══██╗██║ ██║╚══██╔══╝██╔════╝████╗ ████║██╔════╝████╗ ██║╚══██╔══╝ ██║██║ ██║╚══██╔══╝\n");
|
|
|
|
|
printf("██████╔╝█████╗ ██║ ██████╔╝██║ ██║ ██║ █████╗ ██╔████╔██║█████╗ ██╔██╗ ██║ ██║ ██║██║ ██║ ██║ \n");
|
|
|
|
|
printf("██╔══██╗██╔══╝ ██║ ██╔══██╗██║ ██║ ██║ ██╔══╝ ██║╚██╔╝██║██╔══╝ ██║╚██╗██║ ██║ ██║██║ ██║ ██║ \n");
|
|
|
|
|
printf("██║ ██║███████╗╚██████╗██║ ██║╚██████╔╝ ██║ ███████╗██║ ╚═╝ ██║███████╗██║ ╚████║ ██║ ██║╚██████╔╝ ██║ \n");
|
|
|
|
|
printf("╚═╝ ╚═╝╚══════╝ ╚═════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ \n\n");
|
|
|
|
|
printf("╚═╝ ╚═╝╚══════╝ ╚═════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ \e[0m\n\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void menuCandidat(VilleIUT** tiut, int* nbVilles) {
|
|
|
|
|
int choix; // Contient le choix de l'utilisateur dans le menu
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n-----------------------------------------------------------------------\n");
|
|
|
|
|
printf("-----------------------------------------------------------------------\n");
|
|
|
|
|
printf("\t1 - Consulter les ville possédant un IUT\n\n");
|
|
|
|
|
printf("\t2 - Voir les disponibilités des départements dans un IUT\n\n");
|
|
|
|
|
printf("\t3 - Rechercher un département\n\n");
|
|
|
|
@ -97,13 +99,13 @@ void menuCandidat(VilleIUT** tiut, int* nbVilles) {
|
|
|
|
|
void menuResponsable(VilleIUT** tiut, int* nbVilles) {
|
|
|
|
|
int choix;
|
|
|
|
|
|
|
|
|
|
printf("\n--------------------------------------------------------------------\n");
|
|
|
|
|
printf("--------------------------------------------------------------------\n");
|
|
|
|
|
printf("\t1 - Lister les candidatures\n\n");
|
|
|
|
|
printf("\t2 - Traiter les candidatures\n\n");
|
|
|
|
|
printf("\t9 - Quitter\n");
|
|
|
|
|
printf("---------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
|
|
if(scanf("%d", &choix) == 0)
|
|
|
|
|
if(scanf("%d", &choix) == 0)
|
|
|
|
|
choix=0;
|
|
|
|
|
|
|
|
|
|
printf("-----------------------------------------------------------------------\n");
|
|
|
|
@ -136,8 +138,21 @@ void menuResponsable(VilleIUT** tiut, int* nbVilles) {
|
|
|
|
|
|
|
|
|
|
void menuAdmin(VilleIUT** tiut, int* nbVilles) {
|
|
|
|
|
int choix; // Contient le choix de l'utilisateur dans le menu
|
|
|
|
|
char pass[LEN_MAX];
|
|
|
|
|
|
|
|
|
|
printf("Merci d'entrer le mot de passe administrateur : ");
|
|
|
|
|
system("stty -echo");
|
|
|
|
|
scanf("%s", pass);
|
|
|
|
|
system("stty echo");
|
|
|
|
|
|
|
|
|
|
printf("\n--------------------------------------------------------------------\n");
|
|
|
|
|
if(strcmp(pass, "admin2023") != 0) {
|
|
|
|
|
fprintf(stderr, "\n\e[1;91mErreur: mot de passe incorrect !\n\n\e[0m");
|
|
|
|
|
sleep(2);
|
|
|
|
|
return;
|
|
|
|
|
} else
|
|
|
|
|
printf("\n\n\e[1;32mMot de passe correct !\e[0m\n\n");
|
|
|
|
|
|
|
|
|
|
printf("--------------------------------------------------------------------\n");
|
|
|
|
|
printf("\t1 - Modifier le nombre de place d'une formation\n\n");
|
|
|
|
|
printf("\t2 - Créer un nouveau département\n\n");
|
|
|
|
|
printf("\t3 - Supprimer un département\n\n");
|
|
|
|
@ -160,12 +175,18 @@ void menuAdmin(VilleIUT** tiut, int* nbVilles) {
|
|
|
|
|
char searchIUT[LEN_MAX], searchDept[LEN_MAX];
|
|
|
|
|
printf("Entrez une ville : ");
|
|
|
|
|
scanf("%s", searchIUT);
|
|
|
|
|
printf("Entrez un département : ");
|
|
|
|
|
scanf("%s", searchDept);
|
|
|
|
|
printf("Entrez le nouveau nombre de places pour le département '%s' : ", searchDept);
|
|
|
|
|
scanf("%d", &nbPlaces);
|
|
|
|
|
|
|
|
|
|
modifierNbPlaces(tiut, *nbVilles, searchIUT, searchDept, nbPlaces);
|
|
|
|
|
int code = afficherListeDepartement(tiut, *nbVilles, searchIUT);
|
|
|
|
|
|
|
|
|
|
if(code) {
|
|
|
|
|
printf("Quel département souhaitez-vous modifier ? : ");
|
|
|
|
|
scanf("%s", searchDept);
|
|
|
|
|
printf("Entrez le nouveau nombre de places pour le département '%s' : ", searchDept);
|
|
|
|
|
scanf("%d", &nbPlaces);
|
|
|
|
|
|
|
|
|
|
modifierNbPlaces(tiut, *nbVilles, searchIUT, searchDept, nbPlaces);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
printf("Créer un nouveau département...\n\n");
|
|
|
|
@ -174,19 +195,36 @@ void menuAdmin(VilleIUT** tiut, int* nbVilles) {
|
|
|
|
|
printf("Entrez la ville dans laquelle vous souhaitez ajouter un département : ");
|
|
|
|
|
scanf("%s", searchIUT2);
|
|
|
|
|
|
|
|
|
|
VilleIUT* ville = NULL;
|
|
|
|
|
int i;
|
|
|
|
|
for(i=0; i<*nbVilles; i++)
|
|
|
|
|
if(strcmp(tiut[i]->ville, searchIUT2) == 0)
|
|
|
|
|
ville = tiut[i];
|
|
|
|
|
int i2 = rechercherVille(tiut, *nbVilles, searchIUT2);
|
|
|
|
|
|
|
|
|
|
if(ville == NULL)
|
|
|
|
|
fprintf(stderr, "\e[1;91mErreur: la ville '%s' n'est pas dans la liste des IUT.\e[0m\n\n", searchIUT2);
|
|
|
|
|
if(i2 == -1)
|
|
|
|
|
fprintf(stderr, "\n\e[1;91mErreur: la ville '%s' n'est pas dans la liste des IUT.\e[0m\n\n", searchIUT2);
|
|
|
|
|
else {
|
|
|
|
|
VilleIUT* ville = tiut[i2];
|
|
|
|
|
|
|
|
|
|
int nbP;
|
|
|
|
|
char addDept[LEN_MAX], responsable[LEN_MAX];
|
|
|
|
|
|
|
|
|
|
printf("Entrez le nom du nouveau département : ");
|
|
|
|
|
scanf("%*c%[^\n]", addDept);
|
|
|
|
|
|
|
|
|
|
ListeDept ldept = ville->ldept;
|
|
|
|
|
|
|
|
|
|
if(strcmp(ldept->departement, addDept) == 0) {
|
|
|
|
|
fprintf(stderr, "\n\e[1;91mErreur: le département '%s' existe déjà dans l'IUT '%s'.\e[0m\n\n", addDept, searchIUT2);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while(ldept->suiv != NULL) {
|
|
|
|
|
if(strcmp(ldept->suiv->departement, addDept) == 0) break;
|
|
|
|
|
ldept = ldept->suiv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(strcmp(ldept->suiv->departement, addDept) == 0) {
|
|
|
|
|
fprintf(stderr, "\n\e[1;91mErreur: le département '%s' existe déjà dans l'IUT '%s'.\e[0m\n\n", addDept, searchIUT2);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("Entrez le nombre de place disponibles en 1ère année : ");
|
|
|
|
|
scanf("%d", &nbP);
|
|
|
|
|
printf("Entrez le nom du responsable de ce département : ");
|
|
|
|
@ -195,7 +233,7 @@ void menuAdmin(VilleIUT** tiut, int* nbVilles) {
|
|
|
|
|
MaillonDept* dept = creerDepartement(addDept, nbP, responsable);
|
|
|
|
|
ville->ldept = ajouterDepartement(ville->ldept, dept);
|
|
|
|
|
|
|
|
|
|
printf("\nLe département '%s' a bien été ajouté à l'IUT '%s' !\n\n", addDept, searchIUT2);
|
|
|
|
|
printf("\n\e[1;32mLe département '%s' a bien été ajouté à l'IUT '%s' !\e[0m\n\n", addDept, searchIUT2);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
@ -205,22 +243,22 @@ void menuAdmin(VilleIUT** tiut, int* nbVilles) {
|
|
|
|
|
printf("Entrez la ville dans laquelle vous souhaitez supprimer un département : ");
|
|
|
|
|
scanf("%s", searchIUT3);
|
|
|
|
|
|
|
|
|
|
VilleIUT* ville3 = NULL;
|
|
|
|
|
int i3;
|
|
|
|
|
for(i3=0; i<*nbVilles; i++)
|
|
|
|
|
if(strcmp(tiut[i3]->ville, searchIUT3) == 0)
|
|
|
|
|
ville3 = tiut[i3];
|
|
|
|
|
int i3 = rechercherVille(tiut, *nbVilles, searchIUT3);
|
|
|
|
|
|
|
|
|
|
if(ville3 == NULL)
|
|
|
|
|
if(i3 == -1)
|
|
|
|
|
fprintf(stderr, "\e[1;91mErreur: la ville '%s' n'est pas dans la liste des IUT.\e[0m\n\n", searchIUT3);
|
|
|
|
|
else {
|
|
|
|
|
VilleIUT* ville3 = tiut[i3];
|
|
|
|
|
|
|
|
|
|
afficherListeDepartement(tiut, *nbVilles, searchIUT3);
|
|
|
|
|
|
|
|
|
|
char searchDept3[LEN_MAX];
|
|
|
|
|
printf("Entrez le nom du département à supprimer : ");
|
|
|
|
|
printf("Quel département souhaitez-vous supprimer ? : ");
|
|
|
|
|
scanf("%*c%[^\n]", searchDept3);
|
|
|
|
|
|
|
|
|
|
ville3->ldept = supprimerDepartement(ville3->ldept, searchDept3);
|
|
|
|
|
|
|
|
|
|
printf("\nLe département '%s' a bien été supprimé de l'IUT '%s' !\n\n", searchDept3, searchIUT3);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
@ -231,14 +269,20 @@ void menuAdmin(VilleIUT** tiut, int* nbVilles) {
|
|
|
|
|
printf("Modifier le nom du responsable d'un département...\n\n");
|
|
|
|
|
|
|
|
|
|
char searchIUT5[LEN_MAX], searchDept5[LEN_MAX], nom[LEN_MAX];
|
|
|
|
|
printf("Entrez une ville : ");
|
|
|
|
|
printf("Dans quel IUT souhaitez-vous faire une modification ? : ");
|
|
|
|
|
scanf("%s", searchIUT5);
|
|
|
|
|
printf("Entrez un département : ");
|
|
|
|
|
scanf("%s", searchDept5);
|
|
|
|
|
printf("Entrez le nom du nouveau responsable : ");
|
|
|
|
|
scanf("%*c%[^\n]", nom);
|
|
|
|
|
|
|
|
|
|
modifierNomResponsable(tiut, *nbVilles, searchIUT5, searchDept5, nom);
|
|
|
|
|
int code5 = afficherListeDepartement(tiut, *nbVilles, searchIUT5);
|
|
|
|
|
|
|
|
|
|
if(code5 != -1) {
|
|
|
|
|
printf("Quel département souhaitez-vous modifier ? : ");
|
|
|
|
|
scanf("%s", searchDept5);
|
|
|
|
|
|
|
|
|
|
printf("Quel est le nom du nouveau responsable : ");
|
|
|
|
|
scanf("%*c%[^\n]", nom);
|
|
|
|
|
|
|
|
|
|
modifierNomResponsable(tiut, *nbVilles, searchIUT5, searchDept5, nom);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fprintf(stderr, "\e[0;91mErreur : la valeur entrée est invalide, merci de réessayer.\n\n\e[0m");
|
|
|
|
@ -285,36 +329,36 @@ void menuPrincipal(/* TODO: prise en compte des status actuels du recrutement */
|
|
|
|
|
switch (choix) {
|
|
|
|
|
case 1:
|
|
|
|
|
system("clear");
|
|
|
|
|
printf(" ██████╗ █████╗ ███╗ ██╗██████╗ ██╗██████╗ █████╗ ████████╗\n");
|
|
|
|
|
printf("\e[1;34m ██████╗ █████╗ ███╗ ██╗██████╗ ██╗██████╗ █████╗ ████████╗\n");
|
|
|
|
|
printf("██╔════╝██╔══██╗████╗ ██║██╔══██╗██║██╔══██╗██╔══██╗╚══██╔══╝\n");
|
|
|
|
|
printf("██║ ███████║██╔██╗ ██║██║ ██║██║██║ ██║███████║ ██║ \n");
|
|
|
|
|
printf("██║ ██╔══██║██║╚██╗██║██║ ██║██║██║ ██║██╔══██║ ██║ \n");
|
|
|
|
|
printf("╚██████╗██║ ██║██║ ╚████║██████╔╝██║██████╔╝██║ ██║ ██║ \n");
|
|
|
|
|
printf(" ╚═════╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═════╝ ╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═╝ \n\n");
|
|
|
|
|
printf(" ╚═════╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═════╝ ╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═╝ \e[0m\n\n");
|
|
|
|
|
|
|
|
|
|
menuCandidat(tiut, &nbVilles);
|
|
|
|
|
titreMenuPrincipal();
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
system("clear");
|
|
|
|
|
printf(" █████╗ ██████╗ ███╗ ███╗██╗███╗ ██╗██╗███████╗████████╗██████╗ █████╗ ████████╗███████╗██╗ ██╗██████╗ \n");
|
|
|
|
|
printf("\e[1;34m █████╗ ██████╗ ███╗ ███╗██╗███╗ ██╗██╗███████╗████████╗██████╗ █████╗ ████████╗███████╗██╗ ██╗██████╗ \n");
|
|
|
|
|
printf("██╔══██╗██╔══██╗████╗ ████║██║████╗ ██║██║██╔════╝╚══██╔══╝██╔══██╗██╔══██╗╚══██╔══╝██╔════╝██║ ██║██╔══██╗\n");
|
|
|
|
|
printf("███████║██║ ██║██╔████╔██║██║██╔██╗ ██║██║███████╗ ██║ ██████╔╝███████║ ██║ █████╗ ██║ ██║██████╔╝\n");
|
|
|
|
|
printf("██╔══██║██║ ██║██║╚██╔╝██║██║██║╚██╗██║██║╚════██║ ██║ ██╔══██╗██╔══██║ ██║ ██╔══╝ ██║ ██║██╔══██╗\n");
|
|
|
|
|
printf("██║ ██║██████╔╝██║ ╚═╝ ██║██║██║ ╚████║██║███████║ ██║ ██║ ██║██║ ██║ ██║ ███████╗╚██████╔╝██║ ██║\n");
|
|
|
|
|
printf("╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝\n\n");
|
|
|
|
|
printf("╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝\e[0m\n\n");
|
|
|
|
|
|
|
|
|
|
menuAdmin(tiut, &nbVilles);
|
|
|
|
|
titreMenuPrincipal();
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
system("clear");
|
|
|
|
|
printf("██████╗ ███████╗███████╗██████╗ ██████╗ ███╗ ██╗███████╗ █████╗ ██████╗ ██╗ ███████╗\n");
|
|
|
|
|
printf("\e[1;34m██████╗ ███████╗███████╗██████╗ ██████╗ ███╗ ██╗███████╗ █████╗ ██████╗ ██╗ ███████╗\n");
|
|
|
|
|
printf("██╔══██╗██╔════╝██╔════╝██╔══██╗██╔═══██╗████╗ ██║██╔════╝██╔══██╗██╔══██╗██║ ██╔════╝\n");
|
|
|
|
|
printf("██████╔╝█████╗ ███████╗██████╔╝██║ ██║██╔██╗ ██║███████╗███████║██████╔╝██║ █████╗ \n");
|
|
|
|
|
printf("██╔══██╗██╔══╝ ╚════██║██╔═══╝ ██║ ██║██║╚██╗██║╚════██║██╔══██║██╔══██╗██║ ██╔══╝ \n");
|
|
|
|
|
printf("██║ ██║███████╗███████║██║ ╚██████╔╝██║ ╚████║███████║██║ ██║██████╔╝███████╗███████╗\n");
|
|
|
|
|
printf("╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚══════╝╚══════╝\n\n");
|
|
|
|
|
printf("╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚══════╝╚══════╝\e[0m\n\n");
|
|
|
|
|
|
|
|
|
|
menuResponsable(tiut, &nbVilles);
|
|
|
|
|
titreMenuPrincipal();
|
|
|
|
@ -340,6 +384,12 @@ void menuPrincipal(/* TODO: prise en compte des status actuels du recrutement */
|
|
|
|
|
|
|
|
|
|
VilleIUT* creerVille(void) {
|
|
|
|
|
VilleIUT* ville = (VilleIUT*) malloc(sizeof(VilleIUT));
|
|
|
|
|
|
|
|
|
|
if(ville == NULL) {
|
|
|
|
|
perror("malloc");
|
|
|
|
|
exit(errno);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ville->ldept = creerListeDepartement();
|
|
|
|
|
|
|
|
|
|
return ville;
|
|
|
|
@ -354,8 +404,17 @@ VilleIUT** ajouterVille(VilleIUT** tiut, VilleIUT* ville, int* nbVilles) {
|
|
|
|
|
return tiut;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int rechercherVille(VilleIUT** tiut, int nbVilles, char* searchIUT) {
|
|
|
|
|
int i=0;
|
|
|
|
|
for(i=0; i<nbVilles; i++)
|
|
|
|
|
if(strcmp(tiut[i]->ville, searchIUT) == 0)
|
|
|
|
|
return i;
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void afficherListeVilles(VilleIUT** tiut, int nbVilles) {
|
|
|
|
|
printf("Liste des villes ayant un IUT disponibles :\n\n");
|
|
|
|
|
printf("\e[4;37mListe des villes ayant un IUT disponibles :\e[0m\n\n");
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
for(i=0; i<nbVilles; i++)
|
|
|
|
@ -368,35 +427,34 @@ ListeDept creerListeDepartement(void) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void afficherListeDepartement(VilleIUT** tiut, int nbVilles, char* searchIUT) {
|
|
|
|
|
int i, foundIUT=0;
|
|
|
|
|
int afficherListeDepartement(VilleIUT** tiut, int nbVilles, char* searchIUT) {
|
|
|
|
|
int i = rechercherVille(tiut, nbVilles, searchIUT);
|
|
|
|
|
|
|
|
|
|
for(i=0; i<nbVilles; i++) {
|
|
|
|
|
if(strcmp(tiut[i]->ville, searchIUT) == 0) {
|
|
|
|
|
foundIUT = 1;
|
|
|
|
|
ListeDept ldept = tiut[i]->ldept;
|
|
|
|
|
|
|
|
|
|
if(ldept == NULL)
|
|
|
|
|
fprintf(stderr, "\n\e[1;91mErreur: la ville '%s' ne contient aucun département\e[0m\n\n", tiut[i]->ville);
|
|
|
|
|
else {
|
|
|
|
|
printf("\nDépartements disponibles dans la ville '%s' :\n", tiut[i]->ville);
|
|
|
|
|
|
|
|
|
|
while (ldept != NULL) {
|
|
|
|
|
printf(" - %s, %d places disponibles\n", ldept->departement, ldept->nbP);
|
|
|
|
|
ldept = ldept->suiv;
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
ListeDept ldept = tiut[i]->ldept;
|
|
|
|
|
|
|
|
|
|
if(ldept == NULL)
|
|
|
|
|
fprintf(stderr, "\n\e[1;91mErreur: la ville '%s' ne contient aucun département\e[0m\n\n", tiut[i]->ville);
|
|
|
|
|
else {
|
|
|
|
|
printf("\n\e[4;37mDépartements disponibles dans la ville '%s' :\e[0m\n\n", tiut[i]->ville);
|
|
|
|
|
|
|
|
|
|
while (ldept != NULL) {
|
|
|
|
|
printf(" - %s, \e[0;32m%d places disponibles\e[0m\n", ldept->departement, ldept->nbP);
|
|
|
|
|
ldept = ldept->suiv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(foundIUT == 0)
|
|
|
|
|
fprintf(stderr, "\n\e[1;91mErreur: l'IUT '%s' n'existe pas !\e[0m\n\n", searchIUT);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void afficherDepartement(VilleIUT** tiut, int nbVilles, char* searchDept) {
|
|
|
|
|
printf("\nListe des IUT contenant le département '%s':\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++) {
|
|
|
|
@ -423,11 +481,17 @@ void afficherDepartement(VilleIUT** tiut, int nbVilles, char* searchDept) {
|
|
|
|
|
if(nb == 0)
|
|
|
|
|
fprintf(stderr, " \e[1;91mAucun IUT ne contient ce département !\e[0m\n");
|
|
|
|
|
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MaillonDept* creerDepartement(char* departement, int nbP, char* responsable) {
|
|
|
|
|
MaillonDept* newDept = (MaillonDept*) malloc(sizeof(MaillonDept));
|
|
|
|
|
|
|
|
|
|
if(newDept == NULL) {
|
|
|
|
|
perror("malloc");
|
|
|
|
|
exit(errno);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strcpy(newDept->departement, departement);
|
|
|
|
|
newDept->nbP = nbP;
|
|
|
|
|
strcpy(newDept->responsable, responsable);
|
|
|
|
@ -451,9 +515,11 @@ ListeDept ajouterDepartement(ListeDept ldept, MaillonDept* dept) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListeDept supprimerDepartement(ListeDept ldept, char* searchDept) {
|
|
|
|
|
int foundDept=0;
|
|
|
|
|
|
|
|
|
|
if(strcmp(ldept->departement, searchDept) == 0) {
|
|
|
|
|
ldept = ldept->suiv;
|
|
|
|
|
return ldept;
|
|
|
|
|
foundDept = 1;
|
|
|
|
|
} else {
|
|
|
|
|
ListeDept search = ldept, tmp;
|
|
|
|
|
|
|
|
|
@ -464,85 +530,82 @@ ListeDept supprimerDepartement(ListeDept ldept, char* searchDept) {
|
|
|
|
|
|
|
|
|
|
if(strcmp(search->departement, searchDept) == 0) {
|
|
|
|
|
tmp->suiv = search->suiv;
|
|
|
|
|
return ldept;
|
|
|
|
|
foundDept=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(foundDept)
|
|
|
|
|
printf("\n\e[1;32mLe département '%s' a bien été supprimé !\e[0m\n\n", searchDept);
|
|
|
|
|
else
|
|
|
|
|
fprintf(stderr, "\n\e[1;91mErreur: la département '%s' n'existe pas.\e[0m\n\n", searchDept);
|
|
|
|
|
|
|
|
|
|
return ldept;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void modifierNbPlaces(VilleIUT** tiut, int nbVilles, char* searchIUT, char* searchDept, int nb) {
|
|
|
|
|
int i, foundIUT=0, foundDept=0;
|
|
|
|
|
for(i=0; i<nbVilles; i++) {
|
|
|
|
|
if(strcmp(tiut[i]->ville, searchIUT) == 0) {
|
|
|
|
|
foundIUT = 1;
|
|
|
|
|
ListeDept ldept = tiut[i]->ldept;
|
|
|
|
|
|
|
|
|
|
if(ldept != NULL) {
|
|
|
|
|
if(strcmp(ldept->departement, searchDept) == 0) {
|
|
|
|
|
printf("Le nombre de places de la formation '%s' à l'IUT '%s' est passé de %d à %d\n\n", searchDept, searchIUT, ldept->nbP, nb);
|
|
|
|
|
ldept->nbP = nb;
|
|
|
|
|
int foundDept=0, i = rechercherVille(tiut, nbVilles, searchIUT);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListeDept ldept = tiut[i]->ldept;
|
|
|
|
|
|
|
|
|
|
if(ldept != NULL) {
|
|
|
|
|
if(strcmp(ldept->departement, searchDept) == 0) {
|
|
|
|
|
printf("\n\e[1;32mLe nombre de places de la formation '%s' à l'IUT '%s' est passé de %d à %d\e[0m\n\n", searchDept, searchIUT, ldept->nbP, nb);
|
|
|
|
|
ldept->nbP = nb;
|
|
|
|
|
foundDept = 1;
|
|
|
|
|
} else {
|
|
|
|
|
ListeDept search = ldept;
|
|
|
|
|
|
|
|
|
|
while(search->suiv != NULL) {
|
|
|
|
|
if(strcmp(search->departement, searchDept) == 0) {
|
|
|
|
|
printf("\n\e[1;32mLe nombre de places de la formation '%s' à l'IUT '%s' est passé de %d à %d\e[0m\n\n", searchDept, searchIUT, search->nbP, nb);
|
|
|
|
|
search->nbP = nb;
|
|
|
|
|
foundDept = 1;
|
|
|
|
|
} else {
|
|
|
|
|
ListeDept search = ldept;
|
|
|
|
|
|
|
|
|
|
while(search->suiv != NULL) {
|
|
|
|
|
if(strcmp(ldept->departement, searchDept) == 0) {
|
|
|
|
|
printf("Le nombre de places de la formation '%s' à l'IUT '%s' est passé de %d à %d\n\n", searchDept, searchIUT, search->nbP, nb);
|
|
|
|
|
search->nbP = nb;
|
|
|
|
|
foundDept = 1;
|
|
|
|
|
}
|
|
|
|
|
search = search->suiv;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
search = search->suiv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(foundIUT == 0)
|
|
|
|
|
fprintf(stderr, "\e[1;91mErreur: l'IUT '%s' n'a pas été trouvé !\e[0m\n\n", searchIUT);
|
|
|
|
|
else
|
|
|
|
|
if(foundDept == 0)
|
|
|
|
|
fprintf(stderr, "\e[1;91mErreur: le département '%s' n'a pas été trouvé dans l'IUT '%s'\e[0m\n\n", searchDept, searchIUT);
|
|
|
|
|
if(!foundDept)
|
|
|
|
|
fprintf(stderr, "\n\e[1;91mErreur: le département '%s' n'a pas été trouvé dans l'IUT '%s'\e[0m\n\n", searchDept, searchIUT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void modifierNomResponsable(VilleIUT** tiut, int nbVilles, char* searchIUT, char* searchDept, char* nom) {
|
|
|
|
|
int i, foundIUT=0, foundDept=0;
|
|
|
|
|
for(i=0; i<nbVilles; i++) {
|
|
|
|
|
if(strcmp(tiut[i]->ville, searchIUT) == 0) {
|
|
|
|
|
foundIUT = 1;
|
|
|
|
|
ListeDept ldept = tiut[i]->ldept;
|
|
|
|
|
|
|
|
|
|
if(ldept != NULL) {
|
|
|
|
|
if(strcmp(ldept->departement, searchDept) == 0) {
|
|
|
|
|
strcpy(ldept->responsable, nom);
|
|
|
|
|
printf("\nLe responsable de la formation '%s' à l'IUT '%s' est désormais '%s'.\n\n", searchDept, searchIUT, ldept->responsable);
|
|
|
|
|
int foundDept=0, i = rechercherVille(tiut, nbVilles, searchIUT);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListeDept ldept = tiut[i]->ldept;
|
|
|
|
|
|
|
|
|
|
if(ldept != NULL) {
|
|
|
|
|
if(strcmp(ldept->departement, searchDept) == 0) {
|
|
|
|
|
strcpy(ldept->responsable, nom);
|
|
|
|
|
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;
|
|
|
|
|
} else {
|
|
|
|
|
ListeDept search = ldept;
|
|
|
|
|
|
|
|
|
|
while(search->suiv != NULL) {
|
|
|
|
|
if(strcmp(search->departement, searchDept) == 0) {
|
|
|
|
|
strcpy(search->responsable, nom);
|
|
|
|
|
printf("\n\e[1;32mLe responsable de la formation '%s' à l'IUT '%s' est désormais '%s'.\e[0m\n\n", searchDept, searchIUT, search->responsable);
|
|
|
|
|
foundDept = 1;
|
|
|
|
|
} else {
|
|
|
|
|
ListeDept search = ldept;
|
|
|
|
|
|
|
|
|
|
while(search->suiv != NULL) {
|
|
|
|
|
if(strcmp(ldept->departement, searchDept) == 0) {
|
|
|
|
|
strcpy(search->responsable, nom);
|
|
|
|
|
printf("\nLe responsable de la formation '%s' à l'IUT '%s' est désormais '%s'.\n\n", searchDept, searchIUT, search->responsable);
|
|
|
|
|
foundDept = 1;
|
|
|
|
|
}
|
|
|
|
|
search = search->suiv;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
search = search->suiv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(foundIUT == 0)
|
|
|
|
|
fprintf(stderr, "\n\e[1;91mErreur: l'IUT '%s' n'a pas été trouvé !\e[0m\n\n", searchIUT);
|
|
|
|
|
else
|
|
|
|
|
if(foundDept == 0)
|
|
|
|
|
fprintf(stderr, "\n\e[1;91mErreur: le département '%s' n'a pas été trouvé dans l'IUT '%s'.\e[0m\n\n", searchDept, searchIUT);
|
|
|
|
|
if(foundDept == 0)
|
|
|
|
|
fprintf(stderr, "\n\e[1;91mErreur: le département '%s' n'a pas été trouvé dans l'IUT '%s'.\e[0m\n\n", searchDept, searchIUT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void saveVilles(VilleIUT* tiut[], int nbVilles) {
|
|
|
|
@ -601,9 +664,19 @@ VilleIUT** readVilles(int* nbVilles) {
|
|
|
|
|
|
|
|
|
|
VilleIUT** tiut = (VilleIUT**) malloc(*nbVilles*sizeof(VilleIUT*));
|
|
|
|
|
|
|
|
|
|
if(tiut == NULL) {
|
|
|
|
|
perror("malloc");
|
|
|
|
|
exit(errno);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < *nbVilles; i++) {
|
|
|
|
|
VilleIUT* ville = (VilleIUT*) malloc(sizeof(VilleIUT));
|
|
|
|
|
|
|
|
|
|
if(ville == NULL) {
|
|
|
|
|
perror("malloc");
|
|
|
|
|
exit(errno);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int lenNomVille;
|
|
|
|
|
fread(&lenNomVille, sizeof(int), 1, fe);
|
|
|
|
|
fread(ville->ville, sizeof(char), lenNomVille, fe);
|
|
|
|
@ -617,6 +690,11 @@ VilleIUT** readVilles(int* nbVilles) {
|
|
|
|
|
int j;
|
|
|
|
|
for (j=0; j<nbDepartements; j++) {
|
|
|
|
|
MaillonDept* maillon = (MaillonDept*) malloc(sizeof(MaillonDept));
|
|
|
|
|
|
|
|
|
|
if(maillon == NULL) {
|
|
|
|
|
perror("malloc");
|
|
|
|
|
exit(errno);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(maillonPrecedent != NULL)
|
|
|
|
|
maillonPrecedent->suiv = maillon;
|
|
|
|
@ -650,6 +728,12 @@ void test(void) {
|
|
|
|
|
Ajout des premières données
|
|
|
|
|
*/
|
|
|
|
|
VilleIUT** tiut = (VilleIUT**) malloc(sizeof(VilleIUT*));
|
|
|
|
|
|
|
|
|
|
if(tiut == NULL) {
|
|
|
|
|
perror("malloc");
|
|
|
|
|
exit(errno);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int nbVilles = 0;
|
|
|
|
|
|
|
|
|
|
VilleIUT* clermont = creerVille();
|
|
|
|
|