From 6dcb9d356fa33195276bfeb4284603690c62ecba Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Wed, 15 Sep 2021 23:43:16 +0200 Subject: [PATCH] contest file now working --- src/utictactoe.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/utictactoe.c b/src/utictactoe.c index 935d1cb..ba6943a 100644 --- a/src/utictactoe.c +++ b/src/utictactoe.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "utictactoe.h" #define OPTIONAL_ARGUMENT_IS_PRESENT \ @@ -42,7 +43,7 @@ int main(int argc, char* argv[]) { int cross_ai, round_ai = 0; int inception_level = 0; bool contest = false; - + char * contest_file; static struct option long_opts[] = { {"inception-level", optional_argument, 0, 'i'}, @@ -103,7 +104,15 @@ int main(int argc, char* argv[]) { case 'c': if ( OPTIONAL_ARGUMENT_IS_PRESENT ) { - fprintf(stderr, "Error: contest option doesn't support arguments\n"); + if ( access(optarg, R_OK | W_OK) != -1) { + printf("Contest file valid\n"); + } + else { + fprintf(stderr, "Can't access to file %s\n", optarg); + } exit (EXIT_FAILURE); + } + else { + fprintf(stderr, "Error: contest need a file\n"); exit (EXIT_FAILURE); } contest = true;