QOL update

- you can now imput only the 1st week and ask the code to clone those colles for n weeks
This commit is contained in:
alexandre 2024-04-13 23:06:14 +02:00
parent 5dab5ad86a
commit 699e5b6bcb
5 changed files with 562 additions and 56 deletions

20
file2.txt Normal file
View File

@ -0,0 +1,20 @@
12 5 2 2024
13 5 2 2024
18 5 2 2024
17 6 2 2024
18 6 2 2024
14 7 2 2024
14 7 2 2024+
14 7 2 2024+
14 7 2 2024+
15 7 2 2024
16 7 2 2024
17 7 2 2024
18 7 2 2024
14 8 2 2024
15 8 2 2024
18 8 2 2024
16 9 2 2024
17 9 2 2024
18 9 2 2024
$

8
main.c
View File

@ -6,11 +6,13 @@ int main() {
printf("Starting\n");
srand(time(NULL));
creneau* edt = import_creneaux("file.txt", 76);
//creneau* edt = import_creneaux("file.txt", 76);
creneau* edt = import_creneaux_oneweek("file2.txt", 19, 4);
int len_creneau = 76;
colleur* dudes = import_colleurs("some_data.txt", 13, len_creneau);
int n_colleurs = 13;
//colleur* dudes = import_colleurs("some_data.txt", 13, len_creneau);
colleur* dudes = import_colleurs_oneweek("some_file2.txt", 12, 4, 19);
int n_colleurs = 12;
// {char* name; int namelen; topic mat; date* disp; int n_disp;} colleur;

View File

@ -1,77 +1,77 @@
hour,day,month,year,length,group,colleur,matiere
12,5,2,2024,1,1,Herbaud,Anglais
13,5,2,2024,1,2,Colin,Physique
18,5,2,2024,1,0,none,none
17,6,2,2024,1,4,Poupy,Physique
18,6,2,2024,1,6,Carpintero,Maths
14,7,2,2024,1,7,Mullaert,Maths
12,5,2,2024,1,5,Le_Gourielec,Anglais
13,5,2,2024,1,2,Poupy,Physique
18,5,2,2024,1,6,Chevalier,Physique
17,6,2,2024,1,4,Carpintero,Maths
18,6,2,2024,1,7,Carpintero,Maths
14,7,2,2024,1,6,Rapin,Maths
14,7,2,2024,2,4,Jospin,Info
14,7,2,2024,2,0,none,none
14,7,2,2024,2,0,none,none
15,7,2,2024,1,3,Boully,Maths
15,7,2,2024,1,3,Carpintero,Maths
16,7,2,2024,1,3,Belaggoune,Anglais
17,7,2,2024,1,6,Chibani,Physique
18,7,2,2024,1,5,Le_Gourielec,Anglais
14,8,2,2024,1,4,Rapin,Maths
15,8,2,2024,1,2,Rapin,Maths
18,8,2,2024,1,7,Belaggoune,Anglais
17,7,2,2024,1,7,Le_Gourielec,Anglais
18,7,2,2024,1,0,none,none
14,8,2,2024,1,0,none,none
15,8,2,2024,1,2,Mullaert,Maths
18,8,2,2024,1,4,Poupy,Physique
16,9,2,2024,1,0,none,none
17,9,2,2024,1,0,none,none
18,9,2,2024,1,0,none,none
12,12,2,2024,1,7,Chibani,Physique
13,12,2,2024,1,0,none,none
18,12,2,2024,1,3,Colin,Physique
17,13,2,2024,1,5,Chevalier,Physique
18,13,2,2024,1,0,none,none
14,14,2,2024,1,6,Mann,Anglais
12,12,2,2024,1,5,Chibani,Physique
13,12,2,2024,1,6,Mann,Anglais
18,12,2,2024,1,1,Chevalier,Physique
17,13,2,2024,1,7,Chevalier,Physique
18,13,2,2024,1,3,Chibani,Physique
14,14,2,2024,1,0,none,none
14,14,2,2024,2,3,Jospin,Info
14,14,2,2024,2,7,Jospin,Info
14,14,2,2024,2,0,none,none
15,14,2,2024,1,7,Rapin,Maths
16,14,2,2024,1,5,Mullaert,Maths
17,14,2,2024,1,1,Rapin,Maths
18,14,2,2024,1,1,Chevalier,Physique
14,14,2,2024,2,7,Jospin,Info
15,14,2,2024,1,3,Boully,Maths
16,14,2,2024,1,4,Rapin,Maths
17,14,2,2024,1,0,none,none
18,14,2,2024,1,5,Boully,Maths
14,15,2,2024,1,2,Belaggoune,Anglais
15,15,2,2024,1,3,Rapin,Maths
18,15,2,2024,1,4,Boully,Maths
16,16,2,2024,1,0,none,none
15,15,2,2024,1,1,Boully,Maths
18,15,2,2024,1,4,Belaggoune,Anglais
16,16,2,2024,1,7,Carpintero,Maths
17,16,2,2024,1,0,none,none
18,16,2,2024,1,0,none,none
12,19,2,2024,1,0,none,none
13,19,2,2024,1,7,Herbaud,Anglais
18,19,2,2024,1,0,none,none
17,20,2,2024,1,4,Mullaert,Maths
18,20,2,2024,1,6,Boully,Maths
14,21,2,2024,1,0,none,none
12,19,2,2024,1,1,Belaggoune,Anglais
13,19,2,2024,1,4,Rapin,Maths
18,19,2,2024,1,2,Mullaert,Maths
17,20,2,2024,1,5,Boully,Maths
18,20,2,2024,1,6,Carpintero,Maths
14,21,2,2024,1,7,Herbaud,Anglais
14,21,2,2024,2,2,Jospin,Info
14,21,2,2024,2,6,Jospin,Info
14,21,2,2024,2,0,none,none
15,21,2,2024,1,1,Mullaert,Maths
16,21,2,2024,1,2,Chibani,Physique
15,21,2,2024,1,2,Poupy,Physique
16,21,2,2024,1,5,Herbaud,Anglais
17,21,2,2024,1,3,Belaggoune,Anglais
18,21,2,2024,1,5,Mann,Anglais
14,22,2,2024,1,4,Colin,Physique
15,22,2,2024,1,2,Mullaert,Maths
18,22,2,2024,1,1,Mann,Anglais
16,23,2,2024,1,5,Mullaert,Maths
18,21,2,2024,1,1,Rapin,Maths
14,22,2,2024,1,6,Chibani,Physique
15,22,2,2024,1,0,none,none
18,22,2,2024,1,4,Chevalier,Physique
16,23,2,2024,1,0,none,none
17,23,2,2024,1,0,none,none
18,23,2,2024,1,0,none,none
12,26,2,2024,1,7,Chevalier,Physique
13,26,2,2024,1,1,Rapin,Maths
18,26,2,2024,1,2,Belaggoune,Anglais
17,27,2,2024,1,6,Rapin,Maths
18,27,2,2024,1,3,Boully,Maths
14,28,2,2024,1,3,Poupy,Physique
12,26,2,2024,1,3,Poupy,Physique
13,26,2,2024,1,5,Chibani,Physique
18,26,2,2024,1,7,Rapin,Maths
17,27,2,2024,1,1,Chevalier,Physique
18,27,2,2024,1,3,Carpintero,Maths
14,28,2,2024,1,4,Herbaud,Anglais
14,28,2,2024,2,1,Jospin,Info
14,28,2,2024,2,5,Jospin,Info
14,28,2,2024,2,0,none,none
15,28,2,2024,1,2,Rapin,Maths
16,28,2,2024,1,4,Mann,Anglais
17,28,2,2024,1,5,Mullaert,Maths
18,28,2,2024,1,6,Mann,Anglais
14,29,2,2024,1,7,Carpintero,Maths
15,29,2,2024,1,5,Chevalier,Physique
18,29,2,2024,1,1,Chibani,Physique
15,28,2,2024,1,5,Boully,Maths
16,28,2,2024,1,6,Mullaert,Maths
17,28,2,2024,1,7,Poupy,Physique
18,28,2,2024,1,2,Carpintero,Maths
14,29,2,2024,1,1,Mullaert,Maths
15,29,2,2024,1,2,Belaggoune,Anglais
18,29,2,2024,1,6,Herbaud,Anglais
16,1,3,2024,1,0,none,none
17,1,3,2024,1,0,none,none
18,1,3,2024,1,0,none,none

1 hour day month year length group colleur matiere
2 12 5 2 2024 1 1 5 Herbaud Le_Gourielec Anglais
3 13 5 2 2024 1 2 Colin Poupy Physique
4 18 5 2 2024 1 0 6 none Chevalier none Physique
5 17 6 2 2024 1 4 Poupy Carpintero Physique Maths
6 18 6 2 2024 1 6 7 Carpintero Maths
7 14 7 2 2024 1 7 6 Mullaert Rapin Maths
8 14 7 2 2024 2 4 Jospin Info
9 14 7 2 2024 2 0 none none
10 14 7 2 2024 2 0 none none
11 15 7 2 2024 1 3 Boully Carpintero Maths
12 16 7 2 2024 1 3 Belaggoune Anglais
13 17 7 2 2024 1 6 7 Chibani Le_Gourielec Physique Anglais
14 18 7 2 2024 1 5 0 Le_Gourielec none Anglais none
15 14 8 2 2024 1 4 0 Rapin none Maths none
16 15 8 2 2024 1 2 Rapin Mullaert Maths
17 18 8 2 2024 1 7 4 Belaggoune Poupy Anglais Physique
18 16 9 2 2024 1 0 none none
19 17 9 2 2024 1 0 none none
20 18 9 2 2024 1 0 none none
21 12 12 2 2024 1 7 5 Chibani Physique
22 13 12 2 2024 1 0 6 none Mann none Anglais
23 18 12 2 2024 1 3 1 Colin Chevalier Physique
24 17 13 2 2024 1 5 7 Chevalier Physique
25 18 13 2 2024 1 0 3 none Chibani none Physique
26 14 14 2 2024 1 6 0 Mann none Anglais none
27 14 14 2 2024 2 3 Jospin Info
14 14 2 2024 2 7 Jospin Info
28 14 14 2 2024 2 0 none none
29 15 14 14 2 2024 1 2 7 Rapin Jospin Maths Info
30 16 15 14 2 2024 1 5 3 Mullaert Boully Maths
31 17 16 14 2 2024 1 1 4 Rapin Maths
32 18 17 14 2 2024 1 1 0 Chevalier none Physique none
33 18 14 2 2024 1 5 Boully Maths
34 14 15 2 2024 1 2 Belaggoune Anglais
35 15 15 2 2024 1 3 1 Rapin Boully Maths
36 18 15 2 2024 1 4 Boully Belaggoune Maths Anglais
37 16 16 2 2024 1 0 7 none Carpintero none Maths
38 17 16 2 2024 1 0 none none
39 18 16 2 2024 1 0 none none
40 12 19 2 2024 1 0 1 none Belaggoune none Anglais
41 13 19 2 2024 1 7 4 Herbaud Rapin Anglais Maths
42 18 19 2 2024 1 0 2 none Mullaert none Maths
43 17 20 2 2024 1 4 5 Mullaert Boully Maths
44 18 20 2 2024 1 6 Boully Carpintero Maths
45 14 21 2 2024 1 0 7 none Herbaud none Anglais
46 14 21 2 2024 2 2 Jospin Info
47 14 21 2 2024 2 6 Jospin Info
48 14 21 2 2024 2 0 none none
49 15 21 2 2024 1 1 2 Mullaert Poupy Maths Physique
50 16 21 2 2024 1 2 5 Chibani Herbaud Physique Anglais
51 17 21 2 2024 1 3 Belaggoune Anglais
52 18 21 2 2024 1 5 1 Mann Rapin Anglais Maths
53 14 22 2 2024 1 4 6 Colin Chibani Physique
54 15 22 2 2024 1 2 0 Mullaert none Maths none
55 18 22 2 2024 1 1 4 Mann Chevalier Anglais Physique
56 16 23 2 2024 1 5 0 Mullaert none Maths none
57 17 23 2 2024 1 0 none none
58 18 23 2 2024 1 0 none none
59 12 26 2 2024 1 7 3 Chevalier Poupy Physique
60 13 26 2 2024 1 1 5 Rapin Chibani Maths Physique
61 18 26 2 2024 1 2 7 Belaggoune Rapin Anglais Maths
62 17 27 2 2024 1 6 1 Rapin Chevalier Maths Physique
63 18 27 2 2024 1 3 Boully Carpintero Maths
64 14 28 2 2024 1 3 4 Poupy Herbaud Physique Anglais
65 14 28 2 2024 2 1 Jospin Info
66 14 28 2 2024 2 5 Jospin Info
67 14 28 2 2024 2 0 none none
68 15 28 2 2024 1 2 5 Rapin Boully Maths
69 16 28 2 2024 1 4 6 Mann Mullaert Anglais Maths
70 17 28 2 2024 1 5 7 Mullaert Poupy Maths Physique
71 18 28 2 2024 1 6 2 Mann Carpintero Anglais Maths
72 14 29 2 2024 1 7 1 Carpintero Mullaert Maths
73 15 29 2 2024 1 5 2 Chevalier Belaggoune Physique Anglais
74 18 29 2 2024 1 1 6 Chibani Herbaud Physique Anglais
75 16 1 3 2024 1 0 none none
76 17 1 3 2024 1 0 none none
77 18 1 3 2024 1 0 none none

265
some_file2.txt Normal file
View File

@ -0,0 +1,265 @@
Mullaert
MATH
12 5 2 2024
13 5 2 2024
18 5 2 2024
17 6 2 2024
18 6 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
15 7 2 2024
16 7 2 2024
17 7 2 2024
18 7 2 2024
14 8 2 2024
15 8 2 2024
18 8 2 2024
16 9 2 2024
17 9 2 2024
18 9 2 2024
+
Rapin
MATH
12 5 2 2024
13 5 2 2024
18 5 2 2024
17 6 2 2024
18 6 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
15 7 2 2024
16 7 2 2024
17 7 2 2024
18 7 2 2024
14 8 2 2024
15 8 2 2024
18 8 2 2024
16 9 2 2024
17 9 2 2024
18 9 2 2024
+
Carpintero
MATH
12 5 2 2024
13 5 2 2024
18 5 2 2024
17 6 2 2024
18 6 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
15 7 2 2024
16 7 2 2024
17 7 2 2024
18 7 2 2024
14 8 2 2024
15 8 2 2024
18 8 2 2024
16 9 2 2024
17 9 2 2024
18 9 2 2024
+
Boully
MATH
12 5 2 2024
13 5 2 2024
18 5 2 2024
17 6 2 2024
18 6 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
15 7 2 2024
16 7 2 2024
17 7 2 2024
18 7 2 2024
14 8 2 2024
15 8 2 2024
18 8 2 2024
16 9 2 2024
17 9 2 2024
18 9 2 2024
+
Chevalier
PHYSICS
12 5 2 2024
13 5 2 2024
18 5 2 2024
17 6 2 2024
18 6 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
15 7 2 2024
16 7 2 2024
17 7 2 2024
18 7 2 2024
14 8 2 2024
15 8 2 2024
18 8 2 2024
16 9 2 2024
17 9 2 2024
18 9 2 2024
+
Poupy
PHYSICS
12 5 2 2024
13 5 2 2024
18 5 2 2024
17 6 2 2024
18 6 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
15 7 2 2024
16 7 2 2024
17 7 2 2024
18 7 2 2024
14 8 2 2024
15 8 2 2024
18 8 2 2024
16 9 2 2024
17 9 2 2024
18 9 2 2024
+
Chibani
PHYSICS
12 5 2 2024
13 5 2 2024
18 5 2 2024
17 6 2 2024
18 6 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
15 7 2 2024
16 7 2 2024
17 7 2 2024
18 7 2 2024
14 8 2 2024
15 8 2 2024
18 8 2 2024
16 9 2 2024
17 9 2 2024
18 9 2 2024
+
Belaggoune
ENGLISH
12 5 2 2024
13 5 2 2024
18 5 2 2024
17 6 2 2024
18 6 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
15 7 2 2024
16 7 2 2024
17 7 2 2024
18 7 2 2024
14 8 2 2024
15 8 2 2024
18 8 2 2024
16 9 2 2024
17 9 2 2024
18 9 2 2024
+
Mann
ENGLISH
12 5 2 2024
13 5 2 2024
18 5 2 2024
17 6 2 2024
18 6 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
15 7 2 2024
16 7 2 2024
17 7 2 2024
18 7 2 2024
14 8 2 2024
15 8 2 2024
18 8 2 2024
16 9 2 2024
17 9 2 2024
18 9 2 2024
+
Herbaud
ENGLISH
12 5 2 2024
13 5 2 2024
18 5 2 2024
17 6 2 2024
18 6 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
15 7 2 2024
16 7 2 2024
17 7 2 2024
18 7 2 2024
14 8 2 2024
15 8 2 2024
18 8 2 2024
16 9 2 2024
17 9 2 2024
18 9 2 2024
+
Le_Gourielec
ENGLISH
12 5 2 2024
13 5 2 2024
18 5 2 2024
17 6 2 2024
18 6 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
15 7 2 2024
16 7 2 2024
17 7 2 2024
18 7 2 2024
14 8 2 2024
15 8 2 2024
18 8 2 2024
16 9 2 2024
17 9 2 2024
18 9 2 2024
+
Jospin
INFO
12 5 2 2024
13 5 2 2024
18 5 2 2024
17 6 2 2024
18 6 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
14 7 2 2024
15 7 2 2024
16 7 2 2024
17 7 2 2024
18 7 2 2024
14 8 2 2024
15 8 2 2024
18 8 2 2024
16 9 2 2024
17 9 2 2024
18 9 2 2024
+
$

View File

@ -67,7 +67,10 @@ int date_dist(date d1, date d2) { /* returns distance between d1 and d2 in days
bool is_sorted(creneau* edt, int len) {
for(int i = 1; i < len; i++) {
if(date_dist(edt[i-1].date, edt[i].date) == -1) {
printf("Anomaly detected at lane %d (dates are not sorted in ascending order)\n", i);
printf("Anomaly detected at lane %d (dates are not sorted in ascending order) : \n", i);
printf("%d %d %d %d\n", edt[i-1].date.hour, edt[i-1].date.day, edt[i-1].date.month, edt[i-1].date.year);
printf("%d %d %d %d\n", edt[i].date.hour, edt[i].date.day, edt[i].date.month, edt[i].date.year);
printf("%d %d %d %d\n", edt[i+1].date.hour, edt[i+1].date.day, edt[i+1].date.month, edt[i+1].date.year);
return false;
}
}
@ -254,3 +257,219 @@ colleur* import_colleurs(char* filename, int n_colleurs, int max_available) {
return res;
}
date increment_date(date d, int inc) {
int remaining = inc;
date res = d;
int delta_day = 0;
while(remaining > 0) {
res.day++;
delta_day = (res.month == 1 || res.month == 3 || res.month == 5 || res.month == 7 || res.month == 8 || res.month == 10 || res.month == 12) - 2*(res.month == 2) + (res.month == 2 && res.year%4 == 0 && res.year%100 != 0);
// sweet jesus
if(res.day > 30 + delta_day) {
res.day = 1;
if(res.month == 12) {
res.month = 1;
res.year++;
} else {
res.month++;
}
}
remaining--;
}
return res;
}
creneau* import_creneaux_oneweek(char* filename, int len_file, int n_weeks) {
// import creneau data from a file then copy paste it for specified amount of weeks
FILE* ptr = fopen(filename, "r");
char c = fgetc(ptr);
creneau* edt = malloc(sizeof(creneau)*len_file*n_weeks);
int i = 0;
int to_fill = 0;
int buffer = 0;
while(c != EOF && c != '$') {
if((int)(c) >= 48 && (int)(c) <= 57) {
buffer *= 10;
buffer += (int)(c) - 48;
} else {
if(to_fill == 0) {
//printf("%d\n", i);
edt[i].date.hour = buffer;
edt[i].group = 0;
edt[i].name = malloc(sizeof(char)*35);
edt[i].name[0] = 'n';
edt[i].name[1] = 'o';
edt[i].name[2] = 'n';
edt[i].name[3] = 'e';
edt[i].name[4] = '\0';
edt[i].namelen = 4;
edt[i].mat = NOTHING;
edt[i].salle.building = 'N';
edt[i].salle.id = 0;
edt[i].length = 1;
} else if(to_fill == 1) {
edt[i].date.day = buffer;
} else if(to_fill == 2) {
edt[i].date.month = buffer;
} else if(to_fill == 3) {
edt[i].date.year = buffer;
} else {
edt[i].length++;
}
to_fill++;
buffer = 0;
if(c == '\n') {
i++;
to_fill = 0;
}
}
c = fgetc(ptr);
}
fclose(ptr);
for(int k = 1; k < n_weeks; k++) {
for(int i = 0; i < len_file; i++) {
edt[k*len_file+i].date = increment_date(edt[i].date, 7*k);
edt[k*len_file+i].group = 0;
edt[k*len_file+i].name = malloc(sizeof(char)*35);
edt[k*len_file+i].name[0] = 'n';
edt[k*len_file+i].name[1] = 'o';
edt[k*len_file+i].name[2] = 'n';
edt[k*len_file+i].name[3] = 'e';
edt[k*len_file+i].name[4] = '\0';
edt[k*len_file+i].namelen = 4;
edt[k*len_file+i].mat = NOTHING;
edt[k*len_file+i].salle.building = 'N';
edt[k*len_file+i].salle.id = 0;
edt[k*len_file+i].length = edt[i].length;
}
}
/*for(int k = 0; k < len_file*n_weeks; k++) {
printf("%d %d %d %d\n", edt[k].date.hour, edt[k].date.day, edt[k].date.month, edt[k].date.year);
}*/
if(!is_sorted(edt, n_weeks*len_file)) {
assert(0);
}
printf("Imported creneaux successfully\n");
return edt;
}
void expand(colleur* guy, int id, int n_horaires, int n_weeks) {
date* horaires = guy[id].disp;
date* res = malloc(sizeof(date)*n_horaires*n_weeks);
for (int i = 0; i < n_horaires; i++) {
res[i] = horaires[i];
}
for(int k = 1; k < n_weeks; k++) {
for(int i = 0; i < n_horaires; i++) {
res[k*n_horaires+i] = increment_date(res[i], 7*k);
}
}
/*for(int i = 0; i < n_horaires*n_weeks; i++) {
printf("%d %d %d %d\n", res[i].hour, res[i].day, res[i].month, res[i].year);
}
printf("\n\n");*/
free(guy[id].disp);
guy[id].disp = res;
guy[id].n_disp = n_weeks*n_horaires;
}
colleur* import_colleurs_oneweek(char* filename, int n_colleurs, int n_weeks, int len_oneweek) {
// same as before, but each colleur only set his/her creneaux for the 1st week
FILE* ptr = fopen(filename, "r");
char c = fgetc(ptr);
// {char* name; int namelen; topic mat; date* disp; int n_disp;}
colleur* res = malloc(sizeof(colleur)*n_colleurs);
char* word = malloc(sizeof(char)*30);
int wordlen = 0;
int buffer = 0;
int date_ptr = 0;
int current = 0; // 0 = name, 1 = mat, 2+ = dates
int colleur_ptr = 0;
while(c != EOF && c != '$') {
if(c == '\n') {
if(current == 0) {
word[wordlen] = '\0';
res[colleur_ptr].name = malloc(sizeof(char)*30);
str_copy(word, wordlen, res[colleur_ptr].name);
res[colleur_ptr].namelen = wordlen;
} else if(current == 1) {
if(word[0] == 'M') { // math
res[colleur_ptr].mat = MATH;
} else if(word[0] == 'P') { // physics
res[colleur_ptr].mat = PHYSICS;
} else if(word[0] == 'E') { // english
res[colleur_ptr].mat = ENGLISH;
} else if(word[0] == 'I') { // info
res[colleur_ptr].mat = INFO;
} else {
word[wordlen] = '\0';
printf("Wait that's illegal (%s)\n", word);
assert(0);
}
res[colleur_ptr].disp = malloc(sizeof(date)*len_oneweek);
} else {
res[colleur_ptr].disp[current-2].year = buffer;
}
current++;
wordlen = 0;
buffer = 0;
date_ptr = 0;
} else if(c == '+') {
res[colleur_ptr].n_disp = current-2;
current = 0;
colleur_ptr++;
c = fgetc(ptr); // always a '\n', this to avoid some seg fault
} else {
if(current <= 1) {
word[wordlen] = c;
wordlen++;
} else {
if((int)(c) >= 48 && (int)(c) <= 57) {
buffer *= 10;
buffer += (int)(c) - 48;
} else {
if(date_ptr == 0) {
res[colleur_ptr].disp[current-2].hour = buffer;
} else if(date_ptr == 1) {
res[colleur_ptr].disp[current-2].day = buffer;
} else if(date_ptr == 2) {
res[colleur_ptr].disp[current-2].month = buffer;
} else {
printf("Oh no (%d)\n", date_ptr);
assert(0);
}
buffer = 0;
date_ptr++;
}
}
}
//printf("%c", c);
c = fgetc(ptr);
}
// {char* name; int namelen; topic mat; date* disp; int n_disp;}
for(int c = 0; c < n_colleurs; c++) {
expand(res, c, len_oneweek, n_weeks);
}
printf("Imported colleurs with no problems\n");
fclose(ptr);
free(word);
return res;
}