aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <dbphillipsnz@gmail.com>2015-06-06 23:16:18 +1200
committerDavid Phillips <dbphillipsnz@gmail.com>2015-06-06 23:16:18 +1200
commitb2ca4dfa7dc64b9c03f4c12968bcf9179a04d5a4 (patch)
tree965b8695b775c5b5cbd03feca9987939e6edf171
parent7b5eb54e54aad01383912d2e67b996402eb9a602 (diff)
downloadfractal-gen-b2ca4dfa7dc64b9c03f4c12968bcf9179a04d5a4.tar.xz
Switched to using basename
-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>