From e4f356b9592599ad91aac34bf2265c9bcdfbb81f Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Tue, 8 Apr 2025 15:16:21 +0200 Subject: Some minor changes to the interface. - Simplified logger to accept only a string, not a variadic list of args like printf(). This can still use some improvement, but now it is easier to use from other languages. - Fixed some misuses of the logger (wrong types etc) - Renamed some constants - Fixed some typos in comments. --- tools/000_gendata/gendata.c | 2 +- tools/100_checkdata/checkdata.c | 2 +- tools/300_solve_small/solve_small.c | 2 +- tools/301_solve_file/solve_file.c | 2 +- tools/302_solve_multisol/solve_multisol.c | 2 +- tools/400_solvetest/solve_test.c | 2 +- tools/nissy_extra.h | 3 +-- tools/tool.h | 30 +++++++++++------------------- 8 files changed, 18 insertions(+), 27 deletions(-) (limited to 'tools') diff --git a/tools/000_gendata/gendata.c b/tools/000_gendata/gendata.c index 51c2f47..f2ac1a0 100644 --- a/tools/000_gendata/gendata.c +++ b/tools/000_gendata/gendata.c @@ -8,7 +8,7 @@ static void run(void) { int64_t size; bool consistent, expected; - char *buf, filename[1024], dataid[NISSY_DATAID_SIZE]; + char *buf, filename[1024], dataid[NISSY_SIZE_DATAID]; size = generatetable(solver, &buf, dataid); switch (size) { diff --git a/tools/100_checkdata/checkdata.c b/tools/100_checkdata/checkdata.c index 8bc308c..5b3db2c 100644 --- a/tools/100_checkdata/checkdata.c +++ b/tools/100_checkdata/checkdata.c @@ -6,7 +6,7 @@ char *solver, *filename; static void run(void) { long long int size, result; - char *buf, dataid[NISSY_DATAID_SIZE]; + char *buf, dataid[NISSY_SIZE_DATAID]; FILE *f; size = nissy_solverinfo(solver, dataid); diff --git a/tools/300_solve_small/solve_small.c b/tools/300_solve_small/solve_small.c index 6a1f7b5..bec8add 100644 --- a/tools/300_solve_small/solve_small.c +++ b/tools/300_solve_small/solve_small.c @@ -46,7 +46,7 @@ void run(void) { } int main(int argc, char **argv) { - char filename[255], dataid[NISSY_DATAID_SIZE]; + char filename[255], dataid[NISSY_SIZE_DATAID]; if (argc < 2) { printf("Error: not enough arguments. " diff --git a/tools/301_solve_file/solve_file.c b/tools/301_solve_file/solve_file.c index cefc608..a772e95 100644 --- a/tools/301_solve_file/solve_file.c +++ b/tools/301_solve_file/solve_file.c @@ -33,7 +33,7 @@ void run(void) { } int main(int argc, char **argv) { - char filename[255], dataid[NISSY_DATAID_SIZE], *scrfilename; + char filename[255], dataid[NISSY_SIZE_DATAID], *scrfilename; FILE *scrfile; if (argc < 3) { diff --git a/tools/302_solve_multisol/solve_multisol.c b/tools/302_solve_multisol/solve_multisol.c index c6ab685..e933a94 100644 --- a/tools/302_solve_multisol/solve_multisol.c +++ b/tools/302_solve_multisol/solve_multisol.c @@ -39,7 +39,7 @@ void run(void) { } int main(int argc, char **argv) { - char filename[255], dataid[NISSY_DATAID_SIZE]; + char filename[255], dataid[NISSY_SIZE_DATAID]; if (argc < 3) { printf("Error: not enough arguments. " diff --git a/tools/400_solvetest/solve_test.c b/tools/400_solvetest/solve_test.c index a98be26..e881030 100644 --- a/tools/400_solvetest/solve_test.c +++ b/tools/400_solvetest/solve_test.c @@ -94,7 +94,7 @@ void run(void) { } int main(int argc, char **argv) { - char filename[255], dataid[NISSY_DATAID_SIZE]; + char filename[255], dataid[NISSY_SIZE_DATAID]; if (argc < 2) { printf("Error: not enough arguments. " diff --git a/tools/nissy_extra.h b/tools/nissy_extra.h index 1600681..3e9c9ab 100644 --- a/tools/nissy_extra.h +++ b/tools/nissy_extra.h @@ -11,6 +11,5 @@ for testing purposes only. size_t gendata_h48_derive(uint8_t, const void *, void *); int parse_h48_solver(const char *, uint8_t [static 1], uint8_t [static 1]); -long long int nissy_datainfo( - uint64_t, const char *, void (*)(const char *, ...)); +long long int nissy_datainfo(uint64_t, const char *, void (*)(const char *)); long long int nissy_derivedata(const char *, const void *, void *); diff --git a/tools/tool.h b/tools/tool.h index b65f33a..51301c6 100644 --- a/tools/tool.h +++ b/tools/tool.h @@ -9,12 +9,12 @@ #include "../src/nissy.h" #include "nissy_extra.h" -static void log_stderr(const char *, ...); -static void log_stdout(const char *, ...); +static void log_stderr(const char *); +static void log_stdout(const char *); static double timerun(void (*)(void)); static void writetable(const char *, int64_t, const char *); static long long int generatetable(const char *, char **, - char [static NISSY_DATAID_SIZE]); + char [static NISSY_SIZE_DATAID]); static long long int derivetable( const char *, const char *, const char *, char **); static int getdata(const char *, char **, const char *); @@ -23,23 +23,15 @@ static void derivedata_run( const char *, const char *, const char *, const char *); static void -log_stderr(const char *str, ...) +log_stderr(const char *str) { - va_list args; - - va_start(args, str); - vfprintf(stderr, str, args); - va_end(args); + fprintf(stderr, "%s", str); } static void -write_stdout(const char *str, ...) +write_stdout(const char *str) { - va_list args; - - va_start(args, str); - vfprintf(stdout, str, args); - va_end(args); + fprintf(stdout, "%s", str); } static double @@ -90,7 +82,7 @@ static long long int generatetable( const char *solver, char **buf, - char dataid[static NISSY_DATAID_SIZE] + char dataid[static NISSY_SIZE_DATAID] ) { long long int size, gensize; @@ -125,7 +117,7 @@ derivetable( { uint8_t h, k; long long int size, gensize; - char *fulltable, dataid[NISSY_DATAID_SIZE]; + char *fulltable, dataid[NISSY_SIZE_DATAID]; if (getdata(solver_large, &fulltable, filename_large) != 0) { printf("Error reading full table.\n"); @@ -169,7 +161,7 @@ getdata( ) { long long int size, sizeread; FILE *f; - char dataid[NISSY_DATAID_SIZE]; + char dataid[NISSY_SIZE_DATAID]; if ((f = fopen(filename, "rb")) == NULL) { printf("Table file not found, generating it.\n"); @@ -209,7 +201,7 @@ gendata_run( uint64_t expected[static 21] ) { long long int size; - char *buf, filename[1024], dataid[NISSY_DATAID_SIZE]; + char *buf, filename[1024], dataid[NISSY_SIZE_DATAID]; size = generatetable(solver, &buf, dataid); sprintf(filename, "tables/%s", dataid); -- cgit v1.3