aboutsummaryrefslogtreecommitdiff
path: root/tools/000_gendata/gendata.c
blob: 953343222621328dae6cc1753cdc76f336629cd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "../tool.h"
#include "../expected_distributions.h"

char *solver, *options;
uint64_t *expected;

static void
run(void) {
	int64_t size;
	char *buf, filename[1024];
	
	getfilename(solver, options, filename);
	size = generatetable(solver, options, &buf);
	switch (size) {
	case -1:
		return;
	case -2:
		goto gendata_run_finish;
	default:
		nissy_datainfo(buf, write_stdout);
		printf("\n");
		printf("Succesfully generated %" PRId64 " bytes. "
		       "See above for details on the tables.\n", size);

		writetable(buf, size, filename);
		break;
	}

gendata_run_finish:
	free(buf);
}

int main(int argc, char **argv) {
	uint8_t h, k;

	if (argc < 3) {
		fprintf(stderr, "Error: not enough arguments. "
		    "A solver and its options must be given.\n");
		return 1;
	}

	solver = argv[1];
	options = argv[2];
	parse_h48_options(options, &h, &k, NULL);
	expected = expected_h48[h][k];

	nissy_setlogger(log_stderr);

	timerun(run);

	return 0;
}

Generated with cgit - Back to sebastiano.tronto.net