commit ff7cee6df128cbf6b05c57585fd9b8ca8f3665f4
parent 5e7c8b2f3684d8de1c2722515f693c2e54323208
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Tue, 8 Apr 2025 15:30:22 +0200
Fixed shell; reorganized nissy.h
Diffstat:
M | shell/shell.c | | | 14 | +++++--------- |
M | src/nissy.h | | | 186 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
2 files changed, 98 insertions(+), 102 deletions(-)
diff --git a/shell/shell.c b/shell/shell.c
@@ -344,7 +344,7 @@ static int64_t
solverinfo_exec(args_t *args)
{
int64_t ret;
- char buf[NISSY_DATAID_SIZE];
+ char buf[NISSY_SIZE_DATAID];
ret = nissy_solverinfo(args->str_solver, buf);
if (ret < 0)
@@ -359,7 +359,7 @@ gendata_exec(args_t *args)
{
int i;
FILE *file;
- char *buf, path[MAX_PATH_LENGTH], dataid[NISSY_DATAID_SIZE];
+ char *buf, path[MAX_PATH_LENGTH], dataid[NISSY_SIZE_DATAID];
int64_t ret, size;
size_t written;
@@ -427,7 +427,7 @@ solve_exec(args_t *args)
uint8_t nissflag;
FILE *file;
char *buf, solutions[SOLUTIONS_BUFFER_SIZE], path[MAX_PATH_LENGTH];
- char dataid[NISSY_DATAID_SIZE];
+ char dataid[NISSY_SIZE_DATAID];
long long stats[NISSY_SIZE_SOLVE_STATS];
int64_t ret, gendata_ret, size;
size_t read;
@@ -780,13 +780,9 @@ set_threads(int argc, char **argv, args_t *args)
}
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);
}
int
diff --git a/src/nissy.h b/src/nissy.h
@@ -40,6 +40,99 @@ for example 'rotation UF' or 'mirrored BL'.
#define NISSY_SOLVED_CUBE "ABCDEFGH=ABCDEFGHIJKL"
+/* Error codes ***************************************************************/
+
+/*
+The value NISSY_OK denotes a success. If returned by solve, it means
+that no solution has been found.
+*/
+#define NISSY_OK 0LL
+
+/*
+The value NISSY_WARNING_UNSOLVABLE is a warning. It means that the
+operation was completed succesfully, but the resulting cube is in an
+unsolvable state. This could be intended, for example if the user has
+provided an unsolvable cube as input.
+*/
+#define NISSY_WARNING_UNSOLVABLE -1LL
+
+/*
+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.
+*/
+#define NISSY_ERROR_INVALID_CUBE -10LL
+
+/*
+The value NISSY_ERROR_UNSOLVABLE_CUBE means that the provided cube is in
+an unsolvable state for the given solver. This could mean either that the
+cube is not solvable at all (for example in case it has a single twisted
+corner), or that it is not ready for the given step (for example if the
+caller wants to solve a DR finish without the cube being in DR state).
+*/
+#define NISSY_ERROR_UNSOLVABLE_CUBE -11LL
+
+/*
+The value NISSY_ERROR_INVALID_MOVES means that the given moves are
+invalid.
+*/
+#define NISSY_ERROR_INVALID_MOVES -20LL
+
+/*
+The value NISSY_ERROR_INVALID_TRANS means that the given transformation
+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.
+*/
+#define NISSY_ERROR_INVALID_SOLVER -50LL
+
+/*
+The value NISSY_ERROR_NULL_POINTER means that one of the provided pointer
+arguments is NULL. For example, it may be returned by solve when called
+with a solver that requires some pre-computed data, but the provided
+data is NULL.
+*/
+#define NISSY_ERROR_NULL_POINTER -60LL
+
+/*
+The value NISSY_ERROR_BUFFER_SIZE means that one of the buffers provided
+is too small. For example, it could be too small to hold the result or
+too small to hold the data generated by gendata.
+*/
+#define NISSY_ERROR_BUFFER_SIZE -61LL
+
+/*
+The value NISSY_ERROR_DATA means that the provided data is invalid. For
+example, it may be returned by solve when called with incompatible solver
+and data arguments.
+*/
+#define NISSY_ERROR_DATA -70LL
+
+/*
+The value NISSY_ERROR_OPTIONS means that one or more of the given options
+are invalid. For example, it may be returned by solve when called with
+a negative maximum number of solutions.
+*/
+#define NISSY_ERROR_OPTIONS -80LL
+
+/*
+The value NISSY_ERROR_UNKNOWN denotes an unexpected error. It probably
+means that there some bug in this library. If you can, report any error
+of this kind to sebastiano@tronto.net. Thanks!
+*/
+#define NISSY_ERROR_UNKNOWN -999LL
+
+
/* Library functions *********************************************************/
/*
@@ -338,96 +431,3 @@ long long
nissy_setlogger(
void (*logger_function)(const char *)
);
-
-
-/* Error codes ***************************************************************/
-
-/*
-The value NISSY_OK denotes a success. If returned by solve, it means
-that no solution has been found.
-*/
-#define NISSY_OK 0LL
-
-/*
-The value NISSY_WARNING_UNSOLVABLE is a warning. It means that the
-operation was completed succesfully, but the resulting cube is in an
-unsolvable state. This could be intended, for example if the user has
-provided an unsolvable cube as input.
-*/
-#define NISSY_WARNING_UNSOLVABLE -1LL
-
-/*
-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.
-*/
-#define NISSY_ERROR_INVALID_CUBE -10LL
-
-/*
-The value NISSY_ERROR_UNSOLVABLE_CUBE means that the provided cube is in
-an unsolvable state for the given solver. This could mean either that the
-cube is not solvable at all (for example in case it has a single twisted
-corner), or that it is not ready for the given step (for example if the
-caller wants to solve a DR finish without the cube being in DR state).
-*/
-#define NISSY_ERROR_UNSOLVABLE_CUBE -11LL
-
-/*
-The value NISSY_ERROR_INVALID_MOVES means that the given moves are
-invalid.
-*/
-#define NISSY_ERROR_INVALID_MOVES -20LL
-
-/*
-The value NISSY_ERROR_INVALID_TRANS means that the given transformation
-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.
-*/
-#define NISSY_ERROR_INVALID_SOLVER -50LL
-
-/*
-The value NISSY_ERROR_NULL_POINTER means that one of the provided pointer
-arguments is NULL. For example, it may be returned by solve when called
-with a solver that requires some pre-computed data, but the provided
-data is NULL.
-*/
-#define NISSY_ERROR_NULL_POINTER -60LL
-
-/*
-The value NISSY_ERROR_BUFFER_SIZE means that one of the buffers provided
-is too small. For example, it could be too small to hold the result or
-too small to hold the data generated by gendata.
-*/
-#define NISSY_ERROR_BUFFER_SIZE -61LL
-
-/*
-The value NISSY_ERROR_DATA means that the provided data is invalid. For
-example, it may be returned by solve when called with incompatible solver
-and data arguments.
-*/
-#define NISSY_ERROR_DATA -70LL
-
-/*
-The value NISSY_ERROR_OPTIONS means that one or more of the given options
-are invalid. For example, it may be returned by solve when called with
-a negative maximum number of solutions.
-*/
-#define NISSY_ERROR_OPTIONS -80LL
-
-/*
-The value NISSY_ERROR_UNKNOWN denotes an unexpected error. It probably
-means that there some bug in this library. If you can, report any error
-of this kind to sebastiano@tronto.net. Thanks!
-*/
-#define NISSY_ERROR_UNKNOWN -999LL