From 7dbd34574f629cacf3b89292d2a06ad0ae612f26 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 13 Oct 2024 15:37:02 +0200 Subject: Removed nissy_explainerror and moved datainfo to tools --- src/nissy.c | 144 ------------------------------------------------------------ 1 file changed, 144 deletions(-) (limited to 'src/nissy.c') diff --git a/src/nissy.c b/src/nissy.c index d5d0270..6b083e0 100644 --- a/src/nissy.c +++ b/src/nissy.c @@ -571,149 +571,5 @@ nissy_setlogger( ) { nissy_log = log; - - if (log == NULL) - return NISSY_WARNING_NULL_CALLBACK; - return NISSY_OK; } - -int64_t -nissy_explainerror( - int64_t error_code, - void (*write)(const char *, ...) -) -{ - if (write == NULL) - return NISSY_WARNING_NULL_CALLBACK; - - switch (error_code) { - case NISSY_OK: - write( - "The value %" PRId64 " denotes a success.\n" - "If returned by solve, it means that no solutions has " - "been found.\n", NISSY_OK - ); - return NISSY_OK; - case NISSY_WARNING_UNSOLVABLE: - write( - "The value %" PRId64 " 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.\n", NISSY_WARNING_UNSOLVABLE - ); - return NISSY_OK; - case NISSY_WARNING_NULL_CALLBACK: - write( - "The value %" PRId64 " is a warning. It means that the " - "provided pointer to a writer function is NULL.\n" - "If returned by nissy_setlogger, it means that any future " - "log messages will not be printed.\n", - NISSY_WARNING_NULL_CALLBACK - ); - return NISSY_OK; - case NISSY_ERROR_INVALID_CUBE: - write( - "The value %" PRId64 " 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.\n", NISSY_ERROR_INVALID_CUBE - ); - return NISSY_OK; - case NISSY_ERROR_UNSOLVABLE_CUBE: - write( - "The value %" PRId64 " means that the provided cube is " - "in an unsolvable state.\n", NISSY_ERROR_INVALID_CUBE - ); - return NISSY_OK; - case NISSY_ERROR_INVALID_MOVES: - write( - "The value %" PRId64 " means that the given moves are " - "invalid.\n", NISSY_ERROR_INVALID_MOVES - ); - return NISSY_OK; - case NISSY_ERROR_INVALID_TRANS: - write( - "The value %" PRId64 " means that the given transformation " - "is invalid.\n", NISSY_ERROR_INVALID_TRANS - ); - return NISSY_OK; - case NISSY_ERROR_INVALID_FORMAT: - write( - "The value %" PRId64 " means that the given format is not " - "known.\n", NISSY_ERROR_INVALID_FORMAT - ); - return NISSY_OK; - case NISSY_ERROR_INVALID_SOLVER: - write( - "The value %" PRId64 " means that the given solver is not " - "known.\n", NISSY_ERROR_INVALID_SOLVER - ); - return NISSY_OK; - case NISSY_ERROR_NULL_POINTER: - write( - "The value %" PRId64 " 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.\n", NISSY_ERROR_NULL_POINTER - ); - return NISSY_OK; - case NISSY_ERROR_BUFFER_SIZE: - write( - "The value %" PRId64 " 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.\n", NISSY_ERROR_BUFFER_SIZE - ); - return NISSY_OK; - case NISSY_ERROR_DATA: - write( - "The value %" PRId64 " means that the provided data is " - "invalid. For example, it may be returned by solve when " - "called with incompatible solver and data arguments.\n", - NISSY_ERROR_DATA - ); - return NISSY_OK; - case NISSY_ERROR_OPTIONS: - write( - "The value %" PRId64 " 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.\n", NISSY_ERROR_OPTIONS - ); - return NISSY_OK; - case NISSY_ERROR_INVALID_CODE: - write( - "The value %" PRId64 " means that the given error code " - "is not known. It may be returned by explainerror.\n", - NISSY_ERROR_INVALID_CODE - ); - return NISSY_OK; - case NISSY_ERROR_UNKNOWN: - write( - "The value %" PRId64 " denotes an unexpected error. It " - "probably means that there some bug in this library.\n" - "If you can, report any error of this kind to " - "sebastiano@tronto.net. Thanks!\n", NISSY_ERROR_UNKNOWN - ); - return NISSY_OK; - default: - break; - } - - if (error_code > 0) { - write( - "A positive return values does not denote an error\n" - "If returned by gendata or datasize, it denotes the size " - "of the data, in bytes\n" - "If returned by solve, it denotes the number of solutions " - "found.\n" - ); - return NISSY_OK; - } else { - write("Unknown error code %" PRId64 "\n", error_code); - return NISSY_ERROR_INVALID_CODE; - } -} -- cgit v1.3