diff --git a/data/confs b/data/confs index 52f5396..1c295f8 100644 --- a/data/confs +++ b/data/confs @@ -1,3 +1,10 @@ 1,Rapport_du_GIEC,Jean_Jouzzel,15,11,2022 2,L_esprit_critique,Thomas_Durand,6,2,2023 3,La_resilience,Arthur_Keller,20,10,2022 +4,American_lobbying,Salah_Oueslati,30,11,2023 +5,Crysper_case9_et_ADN,Peggy_Baron,18,10,2023 +6,Materiaux_de_demain,Emmanuel_Chirache,15,11,2023 +7,Les_IA,Matthieu_Maurer,1,6,2023 +8,Therories_du_complots,Jean_Benoit,1,4,2021 +9,Le_lacet_irlandais,Mick_Oconnell,31,3,2022 +10,Litterature_et_SF,Terry_Pratchett,15,5,2021 diff --git a/data/listeners b/data/listeners index 487b2ac..8659b89 100644 --- a/data/listeners +++ b/data/listeners @@ -1,4 +1,20 @@ -2,Bertrand,42,5 +1,Simon,21,3 +2,Bertrand,42,8 3,Thomas,20,3 -4,Pasgrimaud_Victor,19,2 -5,Leizour_Lukian,19,2 +4,Victor,19,2 +5,Lukian,19,2 +6,Natacha,18,1 +7,Caroline,22,4 +8,Lucas,23,4 +9,Clodine,64,3 +10,Kevin,26,3 +11,Titouan,18,1 +12,Louise,20,3 +13,Chayma,22,5 +14,Elisa,23,5 +15,Erwan,19,2 +16,Juliette,32,8 +17,Malick,25,7 +18,Marion,17,1 +19,Tom,17,1 +20,Sebastien,45,5 diff --git a/data/relations b/data/relations index e69de29..f53a0b2 100644 --- a/data/relations +++ b/data/relations @@ -0,0 +1 @@ +1:3,2,1,6,11,12,13,14,15,16 diff --git a/fileManager.c b/fileManager.c index 6ceb7e3..58c5296 100644 --- a/fileManager.c +++ b/fileManager.c @@ -59,6 +59,39 @@ void readListeners(ptListener listenerChain) { fclose(file); } +void readRelations(ptConf confChain, ptListener listenerChain) { + FILE *file = fopen("./data/relations", "r"); + char line[100]; + char *tokens[50]; + char *token; + int i; + int j; + + if (file == NULL) { + printf("ça marche pas."); + return; + } + + while (fgets(line, sizeof(line), file)) { + token = strtok(line, ":"); + printf("%d\n", atoi(token)); + + i = 0; + + while (token != NULL) { + tokens[i] = token; + i ++; + token = strtok(NULL, ","); + } + } + + for (j = 1; j < i; j++) { + participateToConf(confChain, listenerChain, atoi(tokens[0]), atoi(tokens[j])); + } + + fclose(file); +} + void saveConf(ptConf confChain) { FILE *file = fopen("./data/confs", "w"); ptConf px = confChain; @@ -81,9 +114,25 @@ void saveListeners(ptListener listenerChain) { void saveRelations(ptConf confChain) { FILE *file = fopen("./data/relations", "w"); - ptListener px = listenerChain; + ptConf px = confChain; + ptListenerList py; while(px -> next != NULL){ - fprintf(file,"%d,%s,%d,%d\n",px -> id,px -> name,px -> age,px -> level); + py = px -> listeners; + + if (py -> next != NULL) { + fprintf(file, "%d:", px -> id); + } + + while (py -> next != NULL) { + fprintf(file, "%d", py -> listener -> id); + if (py -> next -> next != NULL) { + fprintf(file, ","); + } else { + fprintf(file, "\n"); + } + py = py -> next; + } + px = px -> next; } fclose(file); diff --git a/fileManager.h b/fileManager.h index 0c967e4..908ccf5 100644 --- a/fileManager.h +++ b/fileManager.h @@ -5,7 +5,9 @@ void readConfs(ptConf confChain); void readListeners(ptListener listenerChain); +void readRelations(ptConf confChain, ptListener listenerChain); void saveConf(ptConf confChain); void saveListeners(ptListener listenerChain); +void saveRelations(ptConf confChain); #endif // FILE_MANAHGER_H \ No newline at end of file diff --git a/main.c b/main.c index d09b600..c4dfd8f 100644 --- a/main.c +++ b/main.c @@ -11,11 +11,8 @@ int main() readConfs(confChain); readListeners(listenerChain); - + readRelations(confChain, listenerChain); menu(confChain, listenerChain); - - saveConf(confChain); - saveListeners(listenerChain); return 0; } \ No newline at end of file diff --git a/main.exe b/main.exe index 29d70e1..3fff024 100644 Binary files a/main.exe and b/main.exe differ diff --git a/screenManager.c b/screenManager.c index 0938504..8d30915 100644 --- a/screenManager.c +++ b/screenManager.c @@ -225,7 +225,7 @@ void menuAbo(ptConf confChain, ptListener listenerChain) { } void menu(ptConf confChain, ptListener listenerChain) -{ +{ char *options[] = {"1/ Gestion des conferences", "2/ Gestion des abonnes", "3/ Participer a une conference", "4/ Voir la meilleure conference", "5/ Voir la participation a une conference", "6/ Quitter"}; system("cls"); drawMenu(options, 6); @@ -253,6 +253,7 @@ void menu(ptConf confChain, ptListener listenerChain) scanf("%d", &listenerId); participateToConf(confChain, listenerChain, confId, listenerId); + saveRelations(confChain); menu(confChain, listenerChain); break; }