From 8b72e391c7185e3da0dfbf0ab60068ac37e4d5cc Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Tue, 22 Apr 2025 09:00:15 +0200 Subject: Removed old scripts and updated public API --- src/core/core.h | 1 - src/core/cube.h | 190 ++++++++++++++++++++++++ src/core/io_formats.h | 403 -------------------------------------------------- src/nissy.c | 80 +++------- src/nissy.h | 98 ++++-------- 5 files changed, 238 insertions(+), 534 deletions(-) delete mode 100644 src/core/io_formats.h (limited to 'src') diff --git a/src/core/core.h b/src/core/core.h index de1c198..fce1751 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -1,5 +1,4 @@ #include "constant_cubes.h" #include "cube.h" -#include "io_formats.h" #include "moves.h" #include "transform.h" diff --git a/src/core/cube.h b/src/core/cube.h index ce8a6b8..798c99c 100644 --- a/src/core/cube.h +++ b/src/core/cube.h @@ -174,3 +174,193 @@ getcube(int64_t ep, int64_t eo, int64_t cp, int64_t co) return cubefromarray(carr, earr); } + + +/******************************************************************************/ + +STATIC cube_t readcube(const char *, const char *); +STATIC int64_t writecube(const char *, cube_t, size_t n, char [n]); +STATIC uint8_t readco(const char *); +STATIC uint8_t readcp(const char *); +STATIC uint8_t readeo(const char *); +STATIC uint8_t readep(const char *); + +STATIC cube_t readcube_B32(const char *); +STATIC int64_t writecube_B32(cube_t, size_t n, char [n]); + +STATIC uint8_t b32toedge(char); +STATIC uint8_t b32tocorner(char); +STATIC char edgetob32(uint8_t); +STATIC char cornertob32(uint8_t); + +STATIC cube_t +readcube(const char *format, const char *buf) +{ + return readcube_B32(buf); +} + +STATIC int64_t +writecube(const char *format, cube_t cube, size_t buf_size, char buf[buf_size]) +{ + return writecube_B32(cube, buf_size, buf); +} + +STATIC uint8_t +readco(const char *str) +{ + if (*str == '0') + return 0; + if (*str == '1') + return CTWIST_CW; + if (*str == '2') + return CTWIST_CCW; + + LOG("Error reading CO\n"); + return UINT8_ERROR; +} + +STATIC uint8_t +readcp(const char *str) +{ + uint8_t c; + + for (c = 0; c < 8; c++) + if (!strncmp(str, cornerstr[c], 3) || + !strncmp(str, cornerstralt[c], 3)) + return c; + + LOG("Error reading CP\n"); + return UINT8_ERROR; +} + +STATIC uint8_t +readeo(const char *str) +{ + if (*str == '0') + return 0; + if (*str == '1') + return EFLIP; + + LOG("Error reading EO\n"); + return UINT8_ERROR; +} + +STATIC uint8_t +readep(const char *str) +{ + uint8_t e; + + for (e = 0; e < 12; e++) + if (!strncmp(str, edgestr[e], 2)) + return e; + + LOG("Error reading EP\n"); + return UINT8_ERROR; +} + +STATIC cube_t +readcube_B32(const char *buf) +{ + int i; + uint8_t c[8], e[12]; + + for (i = 0; i < 8; i++) { + c[i] = b32tocorner(buf[i]); + if (c[i] == UINT8_ERROR) { + LOG("Error reading B32 corner %d ", i); + if (buf[i] == 0) { + LOG("(string terminated early)\n"); + } else { + LOG("(char '%c')\n", buf[i]); + } + return ZERO_CUBE; + } + } + + if (buf[8] != '=') { + LOG("Error reading B32 separator: a single '=' " + "must be used to separate edges and corners\n"); + return ZERO_CUBE; + } + + for (i = 0; i < 12; i++) { + e[i] = b32toedge(buf[i+9]); + if (e[i] == UINT8_ERROR) { + LOG("Error reading B32 edge %d ", i); + if (buf[i+9] == 0) { + LOG("(string terminated early)\n"); + } else { + LOG("(char '%c')\n", buf[i+9]); + } + return ZERO_CUBE; + } + } + + return cubefromarray(c, e); +} + +STATIC int64_t +writecube_B32(cube_t cube, size_t buf_size, char buf[buf_size]) +{ + int i; + uint8_t corner[8], edge[12]; + + if (buf_size < NISSY_SIZE_CUBE) { + LOG("Cannot write cube: buffer size must be at least %u " + "bytes, but the provided one is %zu bytes.\n", + NISSY_SIZE_CUBE, buf_size); + return NISSY_ERROR_BUFFER_SIZE; + } + + pieces(&cube, corner, edge); + + for (i = 0; i < 8; i++) + buf[i] = cornertob32(corner[i]); + + buf[8] = '='; + + for (i = 0; i < 12; i++) + buf[i+9] = edgetob32(edge[i]); + + buf[21] = '\0'; + + return NISSY_OK; +} + +STATIC uint8_t +b32toedge(char c) +{ + if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'f'))) + return UINT8_ERROR; + + return c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a') + 26; +} + +STATIC uint8_t +b32tocorner(char c) { + uint8_t val; + + if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'f'))) + return UINT8_ERROR; + + val = c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a') + 26; + + return (val & 7) | ((val & 24) << 2); +} + +STATIC char +edgetob32(uint8_t edge) +{ + return edge < 26 ? 'A' + (char)edge : 'a' + (char)(edge - 26); +} + +STATIC char +cornertob32(uint8_t corner) +{ + uint8_t val; + + val = (corner & 7) | ((corner & 96) >> 2); + + return val < 26 ? 'A' + (char)val : 'a' + (char)(val - 26); +} +/******************************************************************************/ diff --git a/src/core/io_formats.h b/src/core/io_formats.h deleted file mode 100644 index f5668d4..0000000 --- a/src/core/io_formats.h +++ /dev/null @@ -1,403 +0,0 @@ -STATIC cube_t readcube(const char *, const char *); -STATIC int64_t writecube(const char *, cube_t, size_t n, char [n]); -STATIC void log_available_formats(void); -STATIC uint8_t readco(const char *); -STATIC uint8_t readcp(const char *); -STATIC uint8_t readeo(const char *); -STATIC uint8_t readep(const char *); -STATIC cube_t readcube_B32(const char *); -STATIC cube_t readcube_H48(const char *); -STATIC uint8_t readpiece_LST(const char **); -STATIC cube_t readcube_LST(const char *); - -STATIC int64_t writepiece_LST(uint8_t, size_t n, char [n]); -STATIC int64_t writecube_B32(cube_t, size_t n, char [n]); -STATIC int64_t writecube_H48(cube_t, size_t n, char [n]); -STATIC int64_t writecube_LST(cube_t, size_t n, char [n]); - -STATIC uint8_t b32toedge(char); -STATIC uint8_t b32tocorner(char); -STATIC char edgetob32(uint8_t); -STATIC char cornertob32(uint8_t); - -STATIC struct { - const char *name; - cube_t (*read)(const char *); - int64_t (*write)(cube_t, size_t n, char [n]); -} ioformat[] = -{ - { .name = "B32", .read = readcube_B32, .write = writecube_B32 }, - { .name = "LST", .read = readcube_LST, .write = writecube_LST }, - { .name = "H48", .read = readcube_H48, .write = writecube_H48 }, - { .name = "NONE", .read = NULL, .write = NULL }, -}; - -STATIC cube_t -readcube(const char *format, const char *buf) -{ - int i; - - for (i = 0; ioformat[i].read != NULL; i++) - if (!strcmp(format, ioformat[i].name)) - return ioformat[i].read(buf); - - LOG("Cannot read cube: unknown format '%s'\n", format); - log_available_formats(); - return ZERO_CUBE; -} - -STATIC int64_t -writecube(const char *format, cube_t cube, size_t buf_size, char buf[buf_size]) -{ - int i; - - for (i = 0; ioformat[i].write != NULL; i++) - if (!strcmp(format, ioformat[i].name)) - return ioformat[i].write(cube, buf_size, buf); - - LOG("Cannot write cube: unknown format '%s'\n", format); - log_available_formats(); - return NISSY_ERROR_INVALID_FORMAT; -} - -STATIC void -log_available_formats(void) -{ - int i; - - LOG("Available formats: "); - for (i = 0; ioformat[i].read != NULL; i++) - LOG("'%s' ", ioformat[i].name); - LOG("\n"); -} - -STATIC uint8_t -readco(const char *str) -{ - if (*str == '0') - return 0; - if (*str == '1') - return CTWIST_CW; - if (*str == '2') - return CTWIST_CCW; - - LOG("Error reading CO\n"); - return UINT8_ERROR; -} - -STATIC uint8_t -readcp(const char *str) -{ - uint8_t c; - - for (c = 0; c < 8; c++) - if (!strncmp(str, cornerstr[c], 3) || - !strncmp(str, cornerstralt[c], 3)) - return c; - - LOG("Error reading CP\n"); - return UINT8_ERROR; -} - -STATIC uint8_t -readeo(const char *str) -{ - if (*str == '0') - return 0; - if (*str == '1') - return EFLIP; - - LOG("Error reading EO\n"); - return UINT8_ERROR; -} - -STATIC uint8_t -readep(const char *str) -{ - uint8_t e; - - for (e = 0; e < 12; e++) - if (!strncmp(str, edgestr[e], 2)) - return e; - - LOG("Error reading EP\n"); - return UINT8_ERROR; -} - -STATIC cube_t -readcube_B32(const char *buf) -{ - int i; - uint8_t c[8], e[12]; - - for (i = 0; i < 8; i++) { - c[i] = b32tocorner(buf[i]); - if (c[i] == UINT8_ERROR) { - LOG("Error reading B32 corner %d ", i); - if (buf[i] == 0) { - LOG("(string terminated early)\n"); - } else { - LOG("(char '%c')\n", buf[i]); - } - return ZERO_CUBE; - } - } - - if (buf[8] != '=') { - LOG("Error reading B32 separator: a single '=' " - "must be used to separate edges and corners\n"); - return ZERO_CUBE; - } - - for (i = 0; i < 12; i++) { - e[i] = b32toedge(buf[i+9]); - if (e[i] == UINT8_ERROR) { - LOG("Error reading B32 edge %d ", i); - if (buf[i+9] == 0) { - LOG("(string terminated early)\n"); - } else { - LOG("(char '%c')\n", buf[i+9]); - } - return ZERO_CUBE; - } - } - - return cubefromarray(c, e); -} - -STATIC cube_t -readcube_H48(const char *buf) -{ - int i; - uint8_t piece, orient, c[8], e[12]; - const char *b; - - b = buf; - - for (i = 0; i < 12; i++) { - while (*b == ' ' || *b == '\t' || *b == '\n') - b++; - if ((piece = readep(b)) == UINT8_ERROR) - return ZERO_CUBE; - b += 2; - if ((orient = readeo(b)) == UINT8_ERROR) - return ZERO_CUBE; - b++; - e[i] = piece | orient; - } - for (i = 0; i < 8; i++) { - while (*b == ' ' || *b == '\t' || *b == '\n') - b++; - if ((piece = readcp(b)) == UINT8_ERROR) - return ZERO_CUBE; - b += 3; - if ((orient = readco(b)) == UINT8_ERROR) - return ZERO_CUBE; - b++; - c[i] = piece | orient; - } - - return cubefromarray(c, e); -} - -STATIC uint8_t -readpiece_LST(const char **b) -{ - uint8_t ret; - bool read; - - while (**b == ',' || **b == ' ' || **b == '\t' || **b == '\n') - (*b)++; - - for (ret = 0, read = false; **b >= '0' && **b <= '9'; (*b)++) { - read = true; - ret = ret * 10 + (**b) - '0'; - } - - return read ? ret : UINT8_ERROR; -} - -STATIC cube_t -readcube_LST(const char *buf) -{ - int i; - uint8_t c[8], e[12]; - - for (i = 0; i < 8; i++) - c[i] = readpiece_LST(&buf); - - for (i = 0; i < 12; i++) - e[i] = readpiece_LST(&buf); - - return cubefromarray(c, e); -} - -STATIC int64_t -writepiece_LST(uint8_t piece, size_t buf_size, char buf[buf_size]) -{ - char digits[3]; - size_t i, len; - - if (piece > 99 || buf_size < 3) - return 0; - - len = 0; - while (piece != 0) { - digits[len++] = (piece % 10) + '0'; - piece /= 10; - } - - if (buf_size < len+2) - return 0; - - if (len == 0) - digits[len++] = '0'; - - for (i = 0; i < len; i++) - buf[i] = digits[len-i-1]; - - buf[len] = ','; - buf[len+1] = ' '; - - return len+2; -} - -STATIC int64_t -writecube_B32(cube_t cube, size_t buf_size, char buf[buf_size]) -{ - int i; - uint8_t corner[8], edge[12]; - - if (buf_size < NISSY_SIZE_B32) { - LOG("Cannot write cube in B32 format: buffer size must be at " - "least %u bytes, but the provided one is %zu bytes.\n", - NISSY_SIZE_B32, buf_size); - return NISSY_ERROR_BUFFER_SIZE; - } - - pieces(&cube, corner, edge); - - for (i = 0; i < 8; i++) - buf[i] = cornertob32(corner[i]); - - buf[8] = '='; - - for (i = 0; i < 12; i++) - buf[i+9] = edgetob32(edge[i]); - - buf[21] = '\0'; - - return NISSY_OK; -} - -STATIC int64_t -writecube_H48(cube_t cube, size_t buf_size, char buf[buf_size]) -{ - uint8_t piece, perm, orient, corner[8], edge[12]; - int i; - - if (buf_size < NISSY_SIZE_H48) { - LOG("Cannot write cube in H48 format: buffer size must be " - "at least %u bytes, but the provided one is %zu bytes.\n", - NISSY_SIZE_H48, buf_size); - return NISSY_ERROR_BUFFER_SIZE; - } - - pieces(&cube, corner, edge); - - for (i = 0; i < 12; i++) { - piece = edge[i]; - perm = piece & PBITS; - orient = (piece & EOBIT) >> EOSHIFT; - buf[4*i ] = edgestr[perm][0]; - buf[4*i + 1] = edgestr[perm][1]; - buf[4*i + 2] = orient + '0'; - buf[4*i + 3] = ' '; - } - for (i = 0; i < 8; i++) { - piece = corner[i]; - perm = piece & PBITS; - orient = (piece & COBITS) >> COSHIFT; - buf[48 + 5*i ] = cornerstr[perm][0]; - buf[48 + 5*i + 1] = cornerstr[perm][1]; - buf[48 + 5*i + 2] = cornerstr[perm][2]; - buf[48 + 5*i + 3] = orient + '0'; - buf[48 + 5*i + 4] = ' '; - } - - buf[48+39] = '\0'; - - return NISSY_OK; -} - -STATIC int64_t -writecube_LST(cube_t cube, size_t buf_size, char buf[buf_size]) -{ - int i; - uint64_t ptr; - uint8_t piece, corner[8], edge[12]; - - ptr = 0; - pieces(&cube, corner, edge); - - for (i = 0; i < 8; i++) { - piece = corner[i]; - ptr += writepiece_LST(piece, buf_size - ptr, buf + ptr); - if (ptr == 0) - goto writecube_LST_error; - } - - for (i = 0; i < 12; i++) { - piece = edge[i]; - ptr += writepiece_LST(piece, buf_size - ptr, buf + ptr); - if (ptr == 0) - goto writecube_LST_error; - } - - *(buf+ptr-2) = '\0'; - - return NISSY_OK; - -writecube_LST_error: - LOG("Cannot write cube in LST: buffer is too small (%" PRIu64 - " bytes given). The LST format has a variable size, try a " - "larger buffer.\n", buf_size); - return NISSY_ERROR_BUFFER_SIZE; -} - -STATIC uint8_t -b32toedge(char c) -{ - if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'f'))) - return UINT8_ERROR; - - return c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a') + 26; -} - -STATIC uint8_t -b32tocorner(char c) { - uint8_t val; - - if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'f'))) - return UINT8_ERROR; - - val = c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a') + 26; - - return (val & 7) | ((val & 24) << 2); -} - -STATIC char -edgetob32(uint8_t edge) -{ - return edge < 26 ? 'A' + (char)edge : 'a' + (char)(edge - 26); -} - -STATIC char -cornertob32(uint8_t corner) -{ - uint8_t val; - - val = (corner & 7) | ((corner & 96) >> 2); - - return val < 26 ? 'A' + (char)val : 'a' + (char)(val - 26); -} diff --git a/src/nissy.c b/src/nissy.c index dfa1a90..fb3cc11 100644 --- a/src/nissy.c +++ b/src/nissy.c @@ -17,7 +17,7 @@ long long parse_h48_solver( STATIC bool checkdata(const unsigned char *, const tableinfo_t [static 1]); STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); -STATIC long long write_result(cube_t, char [static NISSY_SIZE_B32]); +STATIC long long write_result(cube_t, char [static NISSY_SIZE_CUBE]); STATIC size_t my_strnlen(const char *, size_t); STATIC long long nissy_dataid(const char *, char [static NISSY_SIZE_DATAID]); STATIC long long nissy_gendata_unsafe( @@ -117,9 +117,9 @@ distribution_equal( } STATIC long long -write_result(cube_t cube, char result[static NISSY_SIZE_B32]) +write_result(cube_t cube, char result[static NISSY_SIZE_CUBE]) { - writecube("B32", cube, NISSY_SIZE_B32, result); + writecube("B32", cube, NISSY_SIZE_CUBE, result); if (!issolvable(cube)) { LOG("Warning: resulting cube is not solvable\n"); @@ -143,9 +143,9 @@ my_strnlen(const char *str, size_t maxlen) long long nissy_compose( - const char cube[static NISSY_SIZE_B32], - const char permutation[static NISSY_SIZE_B32], - char result[static NISSY_SIZE_B32] + const char cube[static NISSY_SIZE_CUBE], + const char permutation[static NISSY_SIZE_CUBE], + char result[static NISSY_SIZE_CUBE] ) { cube_t c, p, res; @@ -178,14 +178,14 @@ nissy_compose( return write_result(res, result); nissy_compose_error: - writecube("B32", ZERO_CUBE, NISSY_SIZE_B32, result); + writecube("B32", ZERO_CUBE, NISSY_SIZE_CUBE, result); return err; } long long nissy_inverse( - const char cube[static NISSY_SIZE_B32], - char result[static NISSY_SIZE_B32] + const char cube[static NISSY_SIZE_CUBE], + char result[static NISSY_SIZE_CUBE] ) { cube_t c, res; @@ -210,15 +210,15 @@ nissy_inverse( return write_result(res, result); nissy_inverse_error: - writecube("B32", ZERO_CUBE, NISSY_SIZE_B32, result); + writecube("B32", ZERO_CUBE, NISSY_SIZE_CUBE, result); return err; } long long nissy_applymoves( - const char cube[static NISSY_SIZE_B32], + const char cube[static NISSY_SIZE_CUBE], const char *moves, - char result[static NISSY_SIZE_B32] + char result[static NISSY_SIZE_CUBE] ) { cube_t c, res; @@ -249,15 +249,15 @@ nissy_applymoves( return write_result(res, result); nissy_applymoves_error: - writecube("B32", ZERO_CUBE, NISSY_SIZE_B32, result); + writecube("B32", ZERO_CUBE, NISSY_SIZE_CUBE, result); return err; } long long nissy_applytrans( - const char cube[static NISSY_SIZE_B32], + const char cube[static NISSY_SIZE_CUBE], const char transformation[static NISSY_SIZE_TRANSFORMATION], - char result[static NISSY_SIZE_B32] + char result[static NISSY_SIZE_CUBE] ) { cube_t c, res; @@ -282,51 +282,7 @@ nissy_applytrans( return write_result(res, result); nissy_applytrans_error: - writecube("B32", ZERO_CUBE, NISSY_SIZE_B32, result); - return err; -} - -long long -nissy_convert( - const char *format_in, - const char *format_out, - const char *cube_string, - unsigned result_size, - char result[result_size] -) -{ - cube_t c; - long long err; - - if (format_in == NULL) { - LOG("[convert] Error: 'format_in' argument is NULL\n"); - err = NISSY_ERROR_NULL_POINTER; - goto nissy_convert_error; - } - - if (format_out == NULL) { - LOG("[convert] Error: 'format_out' argument is NULL\n"); - err = NISSY_ERROR_NULL_POINTER; - goto nissy_convert_error; - } - - if (cube_string == NULL) { - LOG("[convert] Error: 'cube_string' argument is NULL\n"); - err = NISSY_ERROR_NULL_POINTER; - goto nissy_convert_error; - } - - c = readcube(format_in, cube_string); - - if (!isconsistent(c)) { - err = NISSY_ERROR_INVALID_CUBE; - goto nissy_convert_error; - } - - return writecube(format_out, c, result_size, result); - -nissy_convert_error: - result[0] = '\0'; + writecube("B32", ZERO_CUBE, NISSY_SIZE_CUBE, result); return err; } @@ -337,7 +293,7 @@ nissy_getcube( long long cp, long long co, const char *options, - char result[static NISSY_SIZE_B32] + char result[static NISSY_SIZE_CUBE] ) { int i; @@ -526,7 +482,7 @@ nissy_checkdata( long long nissy_solve( - const char cube[static NISSY_SIZE_B32], + const char cube[static NISSY_SIZE_CUBE], const char *solver, unsigned nissflag, unsigned minmoves, diff --git a/src/nissy.h b/src/nissy.h index a5b3015..963571f 100644 --- a/src/nissy.h +++ b/src/nissy.h @@ -5,12 +5,11 @@ All the functions return 0 or a positive integer in case of success and a negative integer in case of error, unless otherwise specified. See at the bottom of this file for the list of error codes and their meaning. -All cube arguments are in B32 formats, unless otherwise specified. -Other available formats are H48 and SRC. See README.md for more info on -these formats. +TODO: explain cube format Accepted moves are U, D, R, L, F and B, optionally followed by a 2, a ' or a 3. +TODO update when we accept also wide moves, slices and rotations A transformation must be given in the format (rotation|mirrored) (2 letters) @@ -21,9 +20,7 @@ for example 'rotation UF' or 'mirrored BL'. /* Constants *****************************************************************/ /* Some constants for size for I/O buffers */ -#define NISSY_SIZE_B32 22U -#define NISSY_SIZE_H48 88U -#define NISSY_SIZE_CUBE_MAX NISSY_SIZE_H48 +#define NISSY_SIZE_CUBE 24U #define NISSY_SIZE_TRANSFORMATION 12U #define NISSY_SIZE_SOLVE_STATS 10U #define NISSY_SIZE_DATAID 255U @@ -37,8 +34,8 @@ for example 'rotation UF' or 'mirrored BL'. #define NISSY_NISSFLAG_ALL \ (NISSY_NISSFLAG_NORMAL | NISSY_NISSFLAG_INVERSE | NISSY_NISSFLAG_MIXED) -/* The solved cube in B32 format */ -#define NISSY_SOLVED_CUBE "ABCDEFGH=ABCDEFGHIJKL" +/* The solved cube */ +#define NISSY_SOLVED_CUBE "ABCDEFGH=ABCDEFGHIJKL=A" /* Error codes ***************************************************************/ @@ -58,8 +55,7 @@ provided an unsolvable cube as input. /* The value NISSY_ERROR_INVALID_CUBE means that the provided cube is -invalid. It could be written in an unknown format, or in a format -different from what specified, or simply ill-formed. +invalid. It could be written in an unknown format, or be ill-formed. */ #define NISSY_ERROR_INVALID_CUBE -10LL @@ -84,12 +80,6 @@ is invalid. */ #define NISSY_ERROR_INVALID_TRANS -30LL -/* -The value NISSY_ERROR_INVALID_FORMAT means that the given format is -not known. -*/ -#define NISSY_ERROR_INVALID_FORMAT -40LL - /* The value NISSY_ERROR_INVALID_SOLVER means that the given solver is not known. @@ -139,10 +129,10 @@ of this kind to sebastiano@tronto.net. Thanks! Apply the secod argument as a permutation on the first argument. Parameters: - cube - The first cube, in B32 format. - permutation - The second cube, in B32 format. This cube is treated as a - permutation and "applied" to the first cube. - result - The return parameter for the resulting cube, in B32 format. + cube - The first cube. + permutation - The second cub. This cube is treated as a permutation and + "applied" to the first cube. + result - The return parameter for the resulting cube. Return values: NISSY_OK - The cubes were composed succesfully. @@ -155,17 +145,17 @@ Return values: */ long long nissy_compose( - const char cube[static NISSY_SIZE_B32], - const char permutation[static NISSY_SIZE_B32], - char result[static NISSY_SIZE_B32] + const char cube[static NISSY_SIZE_CUBE], + const char permutation[static NISSY_SIZE_CUBE], + char result[static NISSY_SIZE_CUBE] ); /* Compute the inverse of the given cube. Parameters: - cube - The cube to be inverted, in B32 format. - result - The return parameter for the resulting cube, in B32 format. + cube - The cube to be inverted. + result - The return parameter for the resulting cube. Return values: NISSY_OK - The cube was inverted succesfully. @@ -177,17 +167,17 @@ Return values: */ long long nissy_inverse( - const char cube[static NISSY_SIZE_B32], - char result[static NISSY_SIZE_B32] + const char cube[static NISSY_SIZE_CUBE], + char result[static NISSY_SIZE_CUBE] ); /* Apply the given sequence of moves on the given cube. Parameters: - cube - The cube to move, in B32 format. + cube - The cube to move. moves - The moves to apply to the cube. Must be a NULL-terminated string. - result - The return parameter for the resulting cube, in B32 format. + result - The return parameter for the resulting cube. Return values: NISSY_OK - The moves were applied succesfully. @@ -200,18 +190,18 @@ Return values: */ long long nissy_applymoves( - const char cube[static NISSY_SIZE_B32], + const char cube[static NISSY_SIZE_CUBE], const char *moves, - char result[static NISSY_SIZE_B32] + char result[static NISSY_SIZE_CUBE] ); /* Apply the single given transformation to the given cube. Parameters: - cube - The cube to be transformed, in B32 format. - transformation - The transformation in (rotation|mirrored) xy format. - result - The return parameter for the resulting cube, in B32 format. + cube - The cube to be transformed. + transformation - The transformation in "(rotation|mirrored) __" format. + result - The return parameter for the resulting cube. Return values: NISSY_OK - The transformation was performed succesfully. @@ -222,37 +212,9 @@ Return values: */ long long nissy_applytrans( - const char cube[static NISSY_SIZE_B32], + const char cube[static NISSY_SIZE_CUBE], const char transformation[static NISSY_SIZE_TRANSFORMATION], - char result[static NISSY_SIZE_B32] -); - -/* -Convert the given cube between the two given formats. - -Parameters: - format_in - The input format. - format_out - The output format. - cube_string - The cube, in format_in format. - result_size - The allocated size of the result array. - result - Return parameter for the cube in format_out format. - -Return values: - NISSY_OK - The conversion was performed succesfully. - NISSY_ERROR_BUFFER_SIZE - The given buffer is too small for the result. - NISSY_ERROR_INVALID_CUBE - The given cube is invalid. - NISSY_ERROR_INVALID_FORMAT - At least one of the given formats is invalid. - NISSY_ERROR_UNKNOWN - An unknown error occurred. - NISSY_ERROR_NULL_POINTER - At least one of 'format_in', 'format_out' or - 'cube_string' arguments is NULL. -*/ -long long -nissy_convert( - const char *format_in, - const char *format_out, - const char *cube_string, - unsigned result_size, - char result[result_size] + char result[static NISSY_SIZE_CUBE] ); /* @@ -267,7 +229,7 @@ Parameters: cp - The corner permutation, 0 <= cp <= 40320 (8!) co - The corner orientation, 0 <= co <= 2187 (3^7) options - Other options. - result - The return parameter for the resulting cube, in B32 format. + result - The return parameter for the resulting cube. Return values: NISSY_OK - The cube was generated succesfully. @@ -281,7 +243,7 @@ nissy_getcube( long long cp, long long co, const char *options, - char result[static NISSY_SIZE_B32] + char result[static NISSY_SIZE_CUBE] ); /* @@ -354,7 +316,7 @@ nissy_checkdata( Solve the given cube using the given solver and options. Parameters: - cube - The cube to solver, in B32 format. + cube - The cube to solver. solver - The name of the solver. nissflag - The flags for NISS (linear, inverse, mixed, or combinations). minmoves - The minimum number of moves for a solution. @@ -386,7 +348,7 @@ Return values: */ long long nissy_solve( - const char cube[static NISSY_SIZE_B32], + const char cube[static NISSY_SIZE_CUBE], const char *solver, unsigned nissflag, unsigned minmoves, -- cgit v1.3