fractal/fractal.c
2020-03-08 21:31:02 +00:00

72 lines
1.4 KiB
C

/*
* fractal
* Written in 2020 by Lucas
* CC0 1.0 Universal/Public domain - No rights reserved
*
* To the extent possible under law, the author(s) have dedicated all
* copyright and related and neighboring rights to this software to the
* public domain worldwide. This software is distributed without any
* warranty. You should have received a copy of the CC0 Public Domain
* Dedication along with this software. If not, see
* <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
/* gepopt visibility for GLIBC */
#if !defined(__OpenBSD__)
#define _DEFAULT_SOURCE
#endif
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "util.h"
int palette_main(int, char *[]);
int julia_main(int, char *[]);
static void
usage(void)
{
fprintf(stderr, "Usage: %s [-s seed] <prog> [prog_args]\n",
xgetprogname());
exit(1);
}
int
main(int argc, char *argv[])
{
long seed;
int ch;
seed = time(NULL);
while ((ch = getopt(argc, argv, "s:")) != -1)
switch (ch) {
case 's':
seed = parse_integer(optarg, LONG_MIN, LONG_MAX);
break;
default:
usage();
}
argc -= optind;
argv += optind;
optind = 1;
if (argc == 0)
usage();
fprintf(stderr, "seed=%ld\n", seed);
xsrand48(seed);
if (strcmp(argv[0], "palette") == 0)
return palette_main(argc, argv);
else if (strcmp(argv[0], "julia") == 0)
return julia_main(argc, argv);
else
usage();
return 1; /* UNREACHABLE */
}