colloscope/structure.h

78 lines
2.3 KiB
C

/*
* Colloscope - A program that generates a colloscope for French 'classes prépas'
* Copyright (C) 2024 Alexandre Aboujaib
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef STRUCTURE_H_INCLUDED
#define STRUCTURE_H_INCLUDED
#include <stdbool.h>
/* Feuilles mortes :
extern int* stats;
extern int* n_colles;
*/
typedef enum topic {NOTHING, MATH, PHYSICS, ENGLISH, FRENCH, INFO} topic;
// colles subjects
typedef struct date {int hour; int day; int month; int year;} date; /* format is {hour, day, month, year} */
// nothing to say here
typedef struct room {char building; int id;} room;
// rooms
// building can be C, M, R or V
typedef struct creneau {int length; date date; int group; char* name; int namelen; topic mat; room salle;} creneau;
// one créneau de colle
// /!\ creneau has to be sorted by ascending dates
// with edt being a creneau*, it is required to have edt[0] be a Monday and edt[len(edt)-1] has to be a Friday
typedef struct colleur {char* name; int namelen; topic mat; date* disp; int n_disp; int id;} colleur;
// available creneaux for the colleurs
typedef struct array {int* a; int len; int memlen;} array;
// yes
int date_dist(date d1, date d2);
bool is_sorted(creneau *edt, int len);
creneau *import_creneaux(char *filename, int size);
bool str_equal(char *s1, char *s2);
void str_copy(char *src, int l1, char *dest);
colleur *import_colleurs(char *filename, int n_colleurs, int max_available);
date increment_date(date d, int inc);
creneau *import_creneaux_oneweek(char *filename, int len_file, int n_weeks);
void expand(colleur *guy, int id, int n_weeks);
colleur *import_colleurs_oneweek(char *filename, int n_colleurs, int n_weeks, int len_oneweek);
int str_to_int(char *s);
#endif