aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fractal-gen.c12
-rw-r--r--fractal-gen.h1
2 files changed, 9 insertions, 4 deletions
diff --git a/fractal-gen.c b/fractal-gen.c
index 6f3cb5f..13bd6ba 100644
--- a/fractal-gen.c
+++ b/fractal-gen.c
@@ -4,16 +4,20 @@ int main(int argc, char **argv)
{
unsigned int size, iterat, cores, i, x, y, s;
double power;
+ char* bname;
void *(*generator)(void *);
// Select correct generator for the fractal type
- // TO DO: use basename
- if (strcmp(argv[0], "./mbrot-gen") == 0)
+ bname = basename(argv[0]);
+ if (strcmp(bname, "mbrot-gen") == 0)
+ {
generator = &generate_mbrot_section;
- else if (strcmp(argv[0], "./bship-gen") == 0)
+ } else if (strcmp(bname, "bship-gen") == 0) {
generator = &generate_bship_section;
- else
+ } else {
fprintf(stderr, "Don't call this directly, call a symlink to me\n");
+ return EXIT_FAILURE;
+ }
if (argc != 4)
{
diff --git a/fractal-gen.h b/fractal-gen.h
index 99d41ff..e710606 100644
--- a/fractal-gen.h
+++ b/fractal-gen.h
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <libgen.h>
#include <complex.h>
#include <math.h>
#include <unistd.h>