aboutsummaryrefslogtreecommitdiff
path: root/src/nissy.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-10-13 15:37:02 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-10-13 15:37:02 +0200
commit7dbd34574f629cacf3b89292d2a06ad0ae612f26 (patch)
treee1832627d897eed10e3e300853f667aa00bcb635 /src/nissy.h
parentee129a671620de49a5477b1e84bfcd110c522831 (diff)
downloadnissy-core-7dbd34574f629cacf3b89292d2a06ad0ae612f26.tar.gz
nissy-core-7dbd34574f629cacf3b89292d2a06ad0ae612f26.zip
Removed nissy_explainerror and moved datainfo to tools
Diffstat (limited to 'src/nissy.h')
-rw-r--r--src/nissy.h142
1 files changed, 89 insertions, 53 deletions
diff --git a/src/nissy.h b/src/nissy.h
index d365a32..6d78778 100644
--- a/src/nissy.h
+++ b/src/nissy.h
@@ -9,8 +9,8 @@ If you include this file, you should also use the following includes:
9#include <string.h> 9#include <string.h>
10 10
11All the functions return 0 or a positive integer in case of success and 11All the functions return 0 or a positive integer in case of success and
12a negative integer in case of error, unless otherwise specified. 12a negative integer in case of error, unless otherwise specified. See at
13You can see the list of error codes below, or use nissy_explainerror(). 13the bottom of this file for the list of error codes and their meaning.
14 14
15All cube arguments are in B32 formats, unless otherwise specified. 15All cube arguments are in B32 formats, unless otherwise specified.
16Other available formats are H48 and SRC. See README.md for more info on 16Other available formats are H48 and SRC. See README.md for more info on
@@ -24,23 +24,6 @@ A transformation must be given in the format
24for example 'rotation UF' or 'mirrored BL'. 24for example 'rotation UF' or 'mirrored BL'.
25*/ 25*/
26 26
27/* Error codes */
28#define NISSY_OK INT64_C(0)
29#define NISSY_WARNING_UNSOLVABLE INT64_C(-1)
30#define NISSY_WARNING_NULL_CALLBACK INT64_C(-2)
31#define NISSY_ERROR_INVALID_CUBE INT64_C(-10)
32#define NISSY_ERROR_UNSOLVABLE_CUBE INT64_C(-11)
33#define NISSY_ERROR_INVALID_MOVES INT64_C(-20)
34#define NISSY_ERROR_INVALID_TRANS INT64_C(-30)
35#define NISSY_ERROR_INVALID_FORMAT INT64_C(-40)
36#define NISSY_ERROR_INVALID_SOLVER INT64_C(-50)
37#define NISSY_ERROR_NULL_POINTER INT64_C(-60)
38#define NISSY_ERROR_BUFFER_SIZE INT64_C(-61)
39#define NISSY_ERROR_DATA INT64_C(-70)
40#define NISSY_ERROR_OPTIONS INT64_C(-80)
41#define NISSY_ERROR_INVALID_CODE INT64_C(-90)
42#define NISSY_ERROR_UNKNOWN INT64_C(-999)
43
44/* Some constants for size for I/O buffers */ 27/* Some constants for size for I/O buffers */
45#define NISSY_SIZE_B32 UINT64_C(22) 28#define NISSY_SIZE_B32 UINT64_C(22)
46#define NISSY_SIZE_H48 UINT64_C(88) 29#define NISSY_SIZE_H48 UINT64_C(88)
@@ -257,24 +240,6 @@ int64_t nissy_gendata(
257); 240);
258 241
259/* 242/*
260Print information on a data table via the provided callback writer.
261
262Parameters:
263 data_size - The size of the data buffer.
264 data - The data to be read.
265 write - A callback writer with the same signature as printf(3).
266
267Return values:
268 NISSY_OK - The data is correct.
269 NISSY_ERROR_DATA - The data contains errors.
270*/
271int64_t nissy_datainfo(
272 uint64_t data_size,
273 const char data[data_size],
274 void (*write)(const char *, ...)
275);
276
277/*
278Check that the data is a valid data table for a solver. 243Check that the data is a valid data table for a solver.
279 244
280Parameters: 245Parameters:
@@ -340,28 +305,99 @@ Parameters:
340 write - A callback writer with the same signature as printf(3). 305 write - A callback writer with the same signature as printf(3).
341 306
342Return values: 307Return values:
343 NISSY_OK - Logger set succesfully. 308 NISSY_OK - Logger set succesfully. No warning or error is goind to be given
344 NISSY_WARNING_NULL_CALLBACK - The provided callback writer is NULL. 309 if the logger is NULL or invalid.
345*/ 310*/
346int64_t nissy_setlogger( 311int64_t nissy_setlogger(
347 void (*logger_function)(const char *, ...) 312 void (*logger_function)(const char *, ...)
348); 313);
349 314
315
316/* Error codes */
317
350/* 318/*
351Print an explanation of the given error code via the provided callback writer. 319The value NISSY_OK denotes a success. If returned by solve, it means
320that no solution has been found.
321*/
322#define NISSY_OK INT64_C(0)
352 323
353Parameters: 324/*
354 error_code - The error code to be explained. It can be any value returned 325The value NISSY_WARNING_UNSOLVABLE is a warning. It means that the
355 by a function in this library, not necessarily an error. 326operation was completed succesfully, but the resulting cube is in an
356 write - A callback writer with the same signature as printf(3). 327unsolvable state. This could be intended, for example if the user has
357 Must be non-NULL. 328provided an unsolvable cube as input.
329*/
330#define NISSY_WARNING_UNSOLVABLE INT64_C(-1)
358 331
359Return values: 332/*
360 NISSY_OK - The error code is known. 333The value NISSY_ERROR_INVALID_CUBE means that the provided cube is
361 NISSY_WARNING_NULL_CALLBACK - The provided callback writer is NULL. 334invalid. It could be written in an unknown format, or in a format
362 NISSY_ERROR_INVALID_CODE - The error code is unknown. 335different from what specified, or simply ill-formed.
363*/ 336*/
364int64_t nissy_explainerror( 337#define NISSY_ERROR_INVALID_CUBE INT64_C(-10)
365 int64_t error_code, 338
366 void (*write)(const char *, ...) 339/*
367); 340The value NISSY_ERROR_UNSOLVABLE_CUBE means that the provided cube is
341in an unsolvable state.
342*/
343#define NISSY_ERROR_UNSOLVABLE_CUBE INT64_C(-11)
344
345/*
346The value NISSY_ERROR_INVALID_MOVES means that the given moves are
347invalid.
348*/
349#define NISSY_ERROR_INVALID_MOVES INT64_C(-20)
350
351/*
352The value NISSY_ERROR_INVALID_TRANS means that the given transformation
353is invalid.
354*/
355#define NISSY_ERROR_INVALID_TRANS INT64_C(-30)
356
357/*
358The value NISSY_ERROR_INVALID_FORMAT means that the given format is
359not known.
360*/
361#define NISSY_ERROR_INVALID_FORMAT INT64_C(-40)
362
363/*
364The value NISSY_ERROR_INVALID_SOLVER means that the given solver is
365not known.
366*/
367#define NISSY_ERROR_INVALID_SOLVER INT64_C(-50)
368
369/*
370The value NISSY_ERROR_NULL_POINTER means that one of the provided pointer
371arguments is NULL. For example, it may be returned by solve when called
372with a solver that requires some pre-computed data, but the provided
373data is NULL.
374*/
375#define NISSY_ERROR_NULL_POINTER INT64_C(-60)
376
377/*
378The value NISSY_ERROR_BUFFER_SIZE means that one of the buffers provided
379is too small. For example, it could be too small to hold the result or
380too small to hold the data generated by gendata.
381*/
382#define NISSY_ERROR_BUFFER_SIZE INT64_C(-61)
383
384/*
385The value NISSY_ERROR_DATA means that the provided data is invalid. For
386example, it may be returned by solve when called with incompatible solver
387and data arguments.
388*/
389#define NISSY_ERROR_DATA INT64_C(-70)
390
391/*
392The value NISSY_ERROR_OPTIONS means that one or more of the given options
393are invalid. For example, it may be returned by solve when called with
394a negative maximum number of solutions.
395*/
396#define NISSY_ERROR_OPTIONS INT64_C(-80)
397
398/*
399The value NISSY_ERROR_UNKNOWN denotes an unexpected error. It probably
400means that there some bug in this library. If you can, report any error
401of this kind to sebastiano@tronto.net. Thanks!
402*/
403#define NISSY_ERROR_UNKNOWN INT64_C(-999)

Generated with cgit - Back to sebastiano.tronto.net