Skip to content

Commit

Permalink
Add operation arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Torphedo committed Oct 27, 2022
1 parent 908529c commit 0652969
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion alr_parser/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

static char* input_name;

static const char* operations[2] = { "--split", "--dump" };

int main(int argc, char* argv[])
{
// Parse command-line arguments.
Expand All @@ -20,13 +22,25 @@ int main(int argc, char* argv[])
printf("Failed to allocate memory for input filename!\n");
exit(0);
}
char* operation_argument = malloc(strlen(argv[2]));
if (operation_argument != NULL) {
strcpy(operation_argument, argv[2]);
if (!(strcmp(operation_argument, operations[0]))) { dump_chunks(input_name); }
else if (!(strcmp(operation_argument, operations[1]))) { parse_by_block(input_name); }
else {
dump_chunks(input_name);
}
}
else {
printf("Failed to allocate memory for input filename!\n");
exit(0);
}
}
else {
printf("Please provide an input fileame.\n");
system("pause"); // Windows-only and should be replaced.
exit(1);
}

parse_by_block(input_name);
return 0;
}

0 comments on commit 0652969

Please sign in to comment.