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,6 +286,11 @@ int main(int argc, char **argv)
} }
} }
if(optind >= argc) {
fprintf(stderr, "No input files.\n");
exit(1);
}
if(output == NULL) if(output == NULL)
{ {
fprintf(stderr, "An output file must be given by -o fileName\n"); fprintf(stderr, "An output file must be given by -o fileName\n");

View file

@ -72,6 +72,20 @@ int main(int argc, char **argv)
for (int index = optind; index < argc; index++) for (int index = optind; index < argc; index++)
printf("Non-option argument %s\n", argv[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"); FILE *f = fopen(outfileName, "wb");
if (f == NULL) if (f == NULL)
{ {
@ -81,12 +95,6 @@ int main(int argc, char **argv)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
fprintf(stderr, "Out: %s\n", outfileName);
fprintf(stderr, "Code: %s\n", codefileName);
fprintf(stderr, "Data: %s\n", datafileName);
///////////////////////////////////////////////////////////////////////////////
int numSections = 0; int numSections = 0;
if (codefileName != NULL) numSections++; if (codefileName != NULL) numSections++;
if (datafileName != NULL) numSections++; if (datafileName != NULL) numSections++;