added: no longer accepts when an input is lacking
This commit is contained in:
+49
-4
@@ -52,7 +52,7 @@ void benchmarking(size_t benchmarking_amount, int version_to_use, float complex
|
|||||||
tricorn_implementation = tricorn_V5;
|
tricorn_implementation = tricorn_V5;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("Invalid version to use");
|
fprintf(stderr,"Invalid version to use: V%d. Available versions are : V0,V1,V2,V3,V4,V5\n",version_to_use);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +97,31 @@ unsigned tests(void) {
|
|||||||
free(tempArrNotColored);
|
free(tempArrNotColored);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void checkInputs(_Bool n,_Bool r,_Bool o,_Bool d,_Bool s) {
|
||||||
|
if (!n)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ERROR: Input n not given.\n");
|
||||||
|
}
|
||||||
|
if (!r)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ERROR: Input r not given.\n");
|
||||||
|
}
|
||||||
|
if (!o)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ERROR: Input o not given.\n");
|
||||||
|
}
|
||||||
|
if (!d)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ERROR: Input d not given.\n");
|
||||||
|
}
|
||||||
|
if (!s)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ERROR: Input s not given.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// REMOVE LATER: interesting test command ./tricorn -s -2.0,0.6 -r 0.0010 -n 200 -d 1920,1080 -o image.bmp -C
|
// REMOVE LATER: interesting test command ./tricorn -s -2.0,0.6 -r 0.0010 -n 200 -d 1920,1080 -o image.bmp -C
|
||||||
@@ -171,6 +195,12 @@ int main(int argc, char** argv)
|
|||||||
_Bool will_benchmark = false; // actual initial value
|
_Bool will_benchmark = false; // actual initial value
|
||||||
_Bool will_test = false;
|
_Bool will_test = false;
|
||||||
|
|
||||||
|
|
||||||
|
_Bool nGiven = false;
|
||||||
|
_Bool rGiven = false;
|
||||||
|
_Bool oGiven = false;
|
||||||
|
_Bool dGiven = false;
|
||||||
|
_Bool sGiven = false;
|
||||||
int amount_function_called = -1; // initial values, so that the compiler doesn't complain
|
int amount_function_called = -1; // initial values, so that the compiler doesn't complain
|
||||||
unsigned n = 0;
|
unsigned n = 0;
|
||||||
float starting_point_real = -1;
|
float starting_point_real = -1;
|
||||||
@@ -189,7 +219,11 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
case 'V': // done, function needed
|
case 'V': // done, function needed
|
||||||
version_to_use = strtol(optarg,NULL,10);
|
version_to_use = strtol(optarg,NULL,10);
|
||||||
|
if (version_to_use < 0 || version_to_use > 5)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"Invalid version to use: V%d. Available versions are : V0,V1,V2,V3,V4,V5\n", version_to_use);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
printf("version is %d\n", version_to_use);
|
printf("version is %d\n", version_to_use);
|
||||||
// call different version functions
|
// call different version functions
|
||||||
|
|
||||||
@@ -202,7 +236,7 @@ int main(int argc, char** argv)
|
|||||||
// wird die Laufzeit der angegebenen Implementierung gemessen und ausgegeben (do this later)
|
// wird die Laufzeit der angegebenen Implementierung gemessen und ausgegeben (do this later)
|
||||||
amount_function_called = strtol(optarg,NULL,10);
|
amount_function_called = strtol(optarg,NULL,10);
|
||||||
if (amount_function_called <= 0) {
|
if (amount_function_called <= 0) {
|
||||||
printf("Invalid benchmarking input, the value should be greater than 0\n");
|
fprintf(stderr, "Invalid benchmarking input, the value should be greater than 0\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
will_benchmark = true;
|
will_benchmark = true;
|
||||||
@@ -213,6 +247,7 @@ int main(int argc, char** argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 's': {
|
case 's': {
|
||||||
|
sGiven = true;
|
||||||
char *imaginary_string;
|
char *imaginary_string;
|
||||||
char *end;
|
char *end;
|
||||||
|
|
||||||
@@ -238,6 +273,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'd': {
|
case 'd': {
|
||||||
|
dGiven = true;
|
||||||
char* height_string;
|
char* height_string;
|
||||||
char *end;
|
char *end;
|
||||||
width = strtol(optarg,&height_string,10);
|
width = strtol(optarg,&height_string,10);
|
||||||
@@ -261,12 +297,14 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
|
nGiven = true;
|
||||||
n = strtol(optarg,NULL,10);
|
n = strtol(optarg,NULL,10);
|
||||||
printf("n:%d\n",n);
|
printf("n:%d\n",n);
|
||||||
// -n <Zahl> —MaximaleAnzahlanIterationen pro Bildpixel
|
// -n <Zahl> —MaximaleAnzahlanIterationen pro Bildpixel
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r': {
|
case 'r': {
|
||||||
|
rGiven = true;
|
||||||
char *end;
|
char *end;
|
||||||
resolution = strtof(optarg,&end);
|
resolution = strtof(optarg,&end);
|
||||||
if (end == optarg || *end != '\0')
|
if (end == optarg || *end != '\0')
|
||||||
@@ -280,6 +318,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
|
oGiven = true;
|
||||||
output_data = malloc(strlen(optarg) + 1);
|
output_data = malloc(strlen(optarg) + 1);
|
||||||
strcpy(output_data,optarg);
|
strcpy(output_data,optarg);
|
||||||
printf("output data: %s\n", output_data); // test
|
printf("output data: %s\n", output_data); // test
|
||||||
@@ -331,6 +370,12 @@ int main(int argc, char** argv)
|
|||||||
return tests() ? EXIT_FAILURE : EXIT_SUCCESS;
|
return tests() ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(nGiven && rGiven && oGiven && dGiven && sGiven))
|
||||||
|
{
|
||||||
|
checkInputs(nGiven,rGiven,oGiven,dGiven,sGiven);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
if (will_benchmark)
|
if (will_benchmark)
|
||||||
{
|
{
|
||||||
printf("\nDoing benchmarking. No images will be created\n");
|
printf("\nDoing benchmarking. No images will be created\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user