/* * 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 . */ #include #include #include #include #include #include "logger.h" #include "structure.h" #include "algorithm.h" // gcc -g -Wall -Wextra -Wpedantic main.c -lSDL2 -lSDL2_image -lm -o main // ./main MP2I-creneaux.txt 33 MP2I-colleurs.txt 16 6 15 output.csv void print_help() { printf("Colloscope - A program that generates a colloscope for French 'classe prépas'. By Alexandre Aboujaib\n"); printf("Licensed under the terms of the GNU GPL version 3 or later.\n\n"); printf("Usage: colloscope [-qvh] \n\n"); printf("Available options :\n"); printf(" -q Quiet mode\n"); printf(" -v Verbose mode\n"); printf(" -h Print this help\n"); } int main(int argc, char **argv) { int offset; bool quiet=false; bool verbose=false; if (argc==2 && strcmp(argv[1], "-h")==0) { print_help(); exit(0); } else if (argc==9 && argv[1][0]!='-') { offset=0; } else if (argc==10 && argv[1][0]=='-') { offset=1; for (char *ch=&argv[1][1]; *ch != '\0'; ch++) { switch (*ch) { case 'q': quiet=true; break; case 'v': verbose=true; break; default: fprintf(stderr, "Unknown option '%c'. Available: [-qvh].\n", *ch); } } if (quiet && verbose) { fprintf(stderr, "You can't be both quiet and verbose!\n"); } } else { fprintf(stderr, "Usage: %s [-qvh] \n", argv[0]); exit(1); } char* path_creneaux = argv[1+offset]; int n_creneaux = str_to_int(argv[2+offset]); char* path_colleurs = argv[3+offset]; int n_colleurs = str_to_int(argv[4+offset]); int n_weeks = str_to_int(argv[5+offset]); int n_groups = str_to_int(argv[6+offset]); int n_iter = str_to_int(argv[7+offset]); char* path_output = argv[8+offset]; if (quiet) { create_logger("colloscope.log", LOG_WARN); } else if (verbose) { create_logger("colloscope.log", LOG_DEBUG); } else { create_logger("colloscope.log", LOG_INFO); } trace("%d %d %d %d", n_creneaux, n_colleurs, n_weeks, n_groups); info("Starting"); srand(time(NULL)); //creneau* edt = import_creneaux("file.txt", 76); creneau* edt = import_creneaux_oneweek(path_creneaux, n_creneaux, n_weeks); int len_edt = n_creneaux*n_weeks; //colleur* dudes = import_colleurs("some_data.txt", 13, len_creneau); colleur* dudes = import_colleurs_oneweek(path_colleurs, n_colleurs, n_weeks, n_creneaux); aux_2(edt, len_edt, dudes, n_colleurs, n_groups, n_weeks, n_iter, path_output); for(int i = 0; i < len_edt; i++) { free(edt[i].name); } free(edt); for(int i = 0; i < n_colleurs; i++) { free(dudes[i].disp); free(dudes[i].name); } free(dudes); destroy_logger(); return 0; }