diff options
Diffstat (limited to 'src/nissy.c')
| -rw-r--r-- | src/nissy.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/nissy.c b/src/nissy.c index 793d659..c09c99e 100644 --- a/src/nissy.c +++ b/src/nissy.c | |||
| @@ -13,10 +13,11 @@ | |||
| 13 | #include "solvers/solvers.h" | 13 | #include "solvers/solvers.h" |
| 14 | 14 | ||
| 15 | int parse_h48_solver(const char *, uint8_t [static 1], uint8_t [static 1]); | 15 | int parse_h48_solver(const char *, uint8_t [static 1], uint8_t [static 1]); |
| 16 | STATIC long long write_result(cube_t, char [static NISSY_SIZE_B32]); | 16 | STATIC bool checkdata(const char *, const tableinfo_t *); |
| 17 | STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], | 17 | STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], |
| 18 | const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); | 18 | const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); |
| 19 | STATIC bool checkdata(const char *, const tableinfo_t *); | 19 | STATIC long long write_result(cube_t, char [static NISSY_SIZE_B32]); |
| 20 | STATIC size_t my_strnlen(const char *, size_t); | ||
| 20 | 21 | ||
| 21 | #define GETCUBE_OPTIONS(S, F) { .option = S, .fix = F } | 22 | #define GETCUBE_OPTIONS(S, F) { .option = S, .fix = F } |
| 22 | struct { | 23 | struct { |
| @@ -71,7 +72,8 @@ checkdata(const char *buf, const tableinfo_t *info) | |||
| 71 | { | 72 | { |
| 72 | uint64_t distr[INFO_DISTRIBUTION_LEN]; | 73 | uint64_t distr[INFO_DISTRIBUTION_LEN]; |
| 73 | 74 | ||
| 74 | if (info == NULL) { | 75 | if (info == NULL || my_strnlen(info->solver, INFO_SOLVER_STRLEN) |
| 76 | == INFO_SOLVER_STRLEN) { | ||
| 75 | LOG("checkdata: error reading table info\n"); | 77 | LOG("checkdata: error reading table info\n"); |
| 76 | return false; | 78 | return false; |
| 77 | } else if (!strncmp(info->solver, "cocsep", 6)) { | 79 | } else if (!strncmp(info->solver, "cocsep", 6)) { |
| @@ -122,6 +124,18 @@ write_result(cube_t cube, char result[static NISSY_SIZE_B32]) | |||
| 122 | return NISSY_OK; | 124 | return NISSY_OK; |
| 123 | } | 125 | } |
| 124 | 126 | ||
| 127 | STATIC size_t | ||
| 128 | my_strnlen(const char *str, size_t maxlen) | ||
| 129 | { | ||
| 130 | size_t i; | ||
| 131 | |||
| 132 | for (i = 0; i < maxlen; i++) | ||
| 133 | if (str[i] == '\0') | ||
| 134 | return i; | ||
| 135 | |||
| 136 | return maxlen; | ||
| 137 | } | ||
| 138 | |||
| 125 | long long | 139 | long long |
| 126 | nissy_compose( | 140 | nissy_compose( |
| 127 | const char cube[static NISSY_SIZE_B32], | 141 | const char cube[static NISSY_SIZE_B32], |
