Rework contest argument parsing.
This commit is contained in:
parent
b16d91fb2e
commit
90508a3b3b
1 changed files with 4 additions and 6 deletions
|
@ -104,12 +104,10 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
if ( OPTIONAL_ARGUMENT_IS_PRESENT ) {
|
if ( OPTIONAL_ARGUMENT_IS_PRESENT ) {
|
||||||
if ( access(optarg, R_OK) == 0) {
|
if ( access(optarg, F_OK | R_OK) == -1) {
|
||||||
printf("Contest file valid\n");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fprintf(stderr, "Can't access to file %s\n", optarg);
|
fprintf(stderr, "Can't access to file %s\n", optarg);
|
||||||
} exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "Error: contest need a file\n");
|
fprintf(stderr, "Error: contest need a file\n");
|
||||||
|
@ -128,10 +126,10 @@ int main(int argc, char* argv[]) {
|
||||||
printf("This software implements a full ultimate tictactoe game.\n");
|
printf("This software implements a full ultimate tictactoe game.\n");
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
help();
|
help();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Try `utictactie --help' for more information.\n");
|
fprintf(stderr, "Try `utictactie --help' for more information.\n");
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue