fractal/fractal.c

72 lines
1.4 KiB
C
Raw Normal View History

2020-03-07 23:32:57 +01:00
/*
* 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
2020-03-07 23:32:57 +01:00
#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':
2020-03-08 22:24:10 +01:00
seed = parse_integer(optarg, LONG_MIN, LONG_MAX);
2020-03-07 23:32:57 +01:00
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 */
}