From 8a91354f7b94c669c77fe628a81f9bfe9f599ef0 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 14 Oct 2024 00:05:43 +0200 Subject: Interface changes, progress with python --- src/core/cube.h | 4 ++-- src/core/io_moves.h | 9 +++++---- src/core/moves.h | 7 ------- 3 files changed, 7 insertions(+), 13 deletions(-) (limited to 'src/core') diff --git a/src/core/cube.h b/src/core/cube.h index a3c3e14..49d868c 100644 --- a/src/core/cube.h +++ b/src/core/cube.h @@ -4,7 +4,7 @@ STATIC bool isconsistent(cube_t); STATIC bool issolvable(cube_t); STATIC bool issolved(cube_t); STATIC bool iserror(cube_t); -STATIC void getcube_fix(int64_t *, int64_t *, int64_t *, int64_t *); +STATIC void getcube_fix(long long *, long long *, long long *, long long *); STATIC cube_t getcube(int64_t, int64_t, int64_t, int64_t); /* This is used only in tests, use SOLVED_CUBE directly everywhere else */ @@ -128,7 +128,7 @@ iserror(cube_t cube) } STATIC void -getcube_fix(int64_t *ep, int64_t *eo, int64_t *cp, int64_t *co) +getcube_fix(long long *ep, long long *eo, long long *cp, long long *co) { uint8_t e[12], c[8], coarr[8]; diff --git a/src/core/io_moves.h b/src/core/io_moves.h index be43568..806887b 100644 --- a/src/core/io_moves.h +++ b/src/core/io_moves.h @@ -43,6 +43,7 @@ writemoves(uint8_t *m, int n, uint64_t buf_size, char *buf) { int i; uint64_t len; + int64_t written; const char *s; char *b; @@ -51,16 +52,16 @@ writemoves(uint8_t *m, int n, uint64_t buf_size, char *buf) return NISSY_ERROR_BUFFER_SIZE; } - for (i = 0, b = buf; i < n; i++, b++, buf_size--) { + for (i = 0, b = buf, written = 0; i < n; i++, b++, written++) { s = movestr[m[i]]; len = strlen(s); - if (len >= buf_size) { + if (len + written >= buf_size) { LOG("Error: the given buffer is too small for " "writing the given moves.\n"); goto writemoves_error; } memcpy(b, s, len); - buf_size -= len; + written += len; b += len; *b = ' '; } @@ -69,7 +70,7 @@ writemoves(uint8_t *m, int n, uint64_t buf_size, char *buf) b--; /* Remove last space */ *b = '\0'; - return buf_size; + return written; writemoves_error: *buf = '\0'; diff --git a/src/core/moves.h b/src/core/moves.h index 28abc7f..d07bc19 100644 --- a/src/core/moves.h +++ b/src/core/moves.h @@ -15,7 +15,6 @@ STATIC void invertmoves(uint8_t *, uint8_t, uint8_t *); STATIC int readmoves(const char *, int, uint8_t *); STATIC cube_t applymoves(cube_t, const char *); -STATIC cube_t frommoves(const char *); #define FOREACH_READMOVE(ARG_BUF, ARG_MOVE, ARG_C, ARG_MAX, \ RET_ERROR, ARG_ACTION) \ @@ -246,9 +245,3 @@ applymoves(cube_t cube, const char *buf) return cube; } - -STATIC cube_t -frommoves(const char *buf) -{ - return applymoves(SOLVED_CUBE, buf); -} -- cgit v1.3