mirror of
https://gitlab.com/klmp200/LO41.git
synced 2024-11-22 00:33:22 +00:00
gestion des arguments
This commit is contained in:
parent
e7601243fa
commit
4b01841b20
13
main.c
13
main.c
@ -14,14 +14,21 @@ void clean_exit(int error_code){
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main(int argc, char* argv[]) {
|
||||||
SharedData * shared_data = GET_INSTANCE(SharedData);
|
SharedData * shared_data = GET_INSTANCE(SharedData);
|
||||||
|
|
||||||
signal(SIGINT, clean_exit);
|
signal(SIGINT, clean_exit);
|
||||||
shared_data->set_main_building(shared_data, NEW(Building, "../residents.txt", "../visitors.txt"));
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
shared_data->start_all_threads(shared_data);
|
shared_data->start_all_threads(shared_data);
|
||||||
shared_data->wait_all_threads(shared_data);
|
shared_data->wait_all_threads(shared_data);
|
||||||
DELETE(shared_data);
|
DELETE(shared_data);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user