Adds usability features.

This commit is contained in:
Felix Queißner 2016-07-01 19:29:43 +02:00
parent 7388ab262c
commit 073c12600b
2 changed files with 21 additions and 8 deletions

View file

@ -286,12 +286,17 @@ int main(int argc, char **argv)
}
}
if(optind >= argc) {
fprintf(stderr, "No input files.\n");
exit(1);
}
if(output == NULL)
{
fprintf(stderr, "An output file must be given by -o fileName\n");
exit(1);
}
for (int index = optind; index < argc; index++)
{
FILE *f = fopen(argv[index], "r");

View file

@ -72,19 +72,27 @@ int main(int argc, char **argv)
for (int index = optind; index < argc; index++)
printf("Non-option argument %s\n", argv[index]);
///////////////////////////////////////////////////////////////////////////////
// fprintf(stderr, "Out: %s\n", outfileName);
// fprintf(stderr, "Code: %s\n", codefileName);
// fprintf(stderr, "Data: %s\n", datafileName);
if(!codefileName && !datafileName)
{
fprintf(stderr, "No input files.\n");
exit(1);
}
///////////////////////////////////////////////////////////////////////////////
FILE *f = fopen(outfileName, "wb");
if (f == NULL)
{
fprintf(stderr, "Could not open file %s\n", outfileName);
return 1;
}
///////////////////////////////////////////////////////////////////////////////
fprintf(stderr, "Out: %s\n", outfileName);
fprintf(stderr, "Code: %s\n", codefileName);
fprintf(stderr, "Data: %s\n", datafileName);
///////////////////////////////////////////////////////////////////////////////
int numSections = 0;