nissy-core

The "engine" of nissy, including the H48 optimal solver.
git clone https://git.tronto.net/nissy-core
Download | Log | Files | Refs | README | LICENSE

checkdata.c (919B)


      1 #include "../tool.h"
      2 #include "../expected_distributions.h"
      3 
      4 char *solver, *filename;
      5 
      6 static void
      7 run(void) {
      8 	long long int size, result;
      9 	char dataid[NISSY_SIZE_DATAID];
     10 	unsigned char *buf;
     11 	FILE *f;
     12 	
     13 	size = nissy_solverinfo(solver, dataid);
     14 
     15 	if (size <= 0) {
     16 		printf("Error in solverinfo\n");
     17 		return;
     18 	}
     19 
     20 	if ((f = fopen(filename, "rb")) == NULL) {
     21 		printf("Error reading file %s\n", filename);
     22 		return;
     23 	}
     24 
     25 	buf = malloc(size);
     26 	fread(buf, size, 1, f);
     27 	fclose(f);
     28 	result = nissy_checkdata(size, buf);
     29 	free(buf);
     30 
     31 	printf("checkdata %s\n", result == 0 ? "succeeded" : "failed");
     32 
     33 	/* TODO: cross-check with expected distributions? */
     34 }
     35 
     36 int main(int argc, char **argv) {
     37 	if (argc < 3) {
     38 		printf("Error: not enough arguments. "
     39 		    "A solver and a file name must be given.\n");
     40 		return 1;
     41 	}
     42 
     43 	solver = argv[1];
     44 	filename = argv[2];
     45 	nissy_setlogger(log_stderr, NULL);
     46 
     47 	timerun(run);
     48 
     49 	return 0;
     50 }