1
0
mirror of https://gitlab.com/klmp200/LO41.git synced 2024-11-15 21:33:22 +00:00
LO41/main.c

35 lines
911 B
C
Raw Normal View History

#include <stdio.h>
2018-06-10 02:00:01 +00:00
#include <unistd.h>
#include "Objects.h"
#include "List/List.h"
2018-06-06 01:00:35 +00:00
#include "Building/Building.h"
2018-06-06 11:50:11 +00:00
#include "SharedData/SharedData.h"
#include "Visitor/Visitor.h"
#include "Resident/Resident.h"
void clean_exit(int error_code){
2018-06-07 20:35:20 +00:00
printf("Signal %d received, exiting app\n", error_code);
DELETE(GET_INSTANCE(SharedData));
exit(0);
}
2018-06-20 12:25:54 +00:00
int main(int argc, char* argv[]) {
2018-06-10 23:58:52 +00:00
SharedData * shared_data = GET_INSTANCE(SharedData);
2018-06-10 02:00:01 +00:00
2018-06-15 09:50:38 +00:00
signal(SIGINT, clean_exit);
2018-06-20 12:25:54 +00:00
if(argc == 3){
shared_data->set_main_building(shared_data, NEW(Building, argv[1], argv[2]));
} else if (argc == 1){
shared_data->set_main_building(shared_data, NEW(Building, "../residents.txt", "../visitors.txt"));
} else{
CRASH("Arguments invalides\nUsage : ./LO41 [residents_file visitors_file]\n");
}
2018-06-10 23:58:52 +00:00
shared_data->start_all_threads(shared_data);
shared_data->wait_all_threads(shared_data);
DELETE(shared_data);
2018-06-10 02:00:01 +00:00
return 0;
2018-06-20 12:25:54 +00:00
}