aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--shell/shell.c14
-rw-r--r--src/nissy.h186
2 files changed, 98 insertions, 102 deletions
diff --git a/shell/shell.c b/shell/shell.c
index 4b354c6..6b349e5 100644
--- a/shell/shell.c
+++ b/shell/shell.c
@@ -344,7 +344,7 @@ static int64_t
344solverinfo_exec(args_t *args) 344solverinfo_exec(args_t *args)
345{ 345{
346 int64_t ret; 346 int64_t ret;
347 char buf[NISSY_DATAID_SIZE]; 347 char buf[NISSY_SIZE_DATAID];
348 348
349 ret = nissy_solverinfo(args->str_solver, buf); 349 ret = nissy_solverinfo(args->str_solver, buf);
350 if (ret < 0) 350 if (ret < 0)
@@ -359,7 +359,7 @@ gendata_exec(args_t *args)
359{ 359{
360 int i; 360 int i;
361 FILE *file; 361 FILE *file;
362 char *buf, path[MAX_PATH_LENGTH], dataid[NISSY_DATAID_SIZE]; 362 char *buf, path[MAX_PATH_LENGTH], dataid[NISSY_SIZE_DATAID];
363 int64_t ret, size; 363 int64_t ret, size;
364 size_t written; 364 size_t written;
365 365
@@ -427,7 +427,7 @@ solve_exec(args_t *args)
427 uint8_t nissflag; 427 uint8_t nissflag;
428 FILE *file; 428 FILE *file;
429 char *buf, solutions[SOLUTIONS_BUFFER_SIZE], path[MAX_PATH_LENGTH]; 429 char *buf, solutions[SOLUTIONS_BUFFER_SIZE], path[MAX_PATH_LENGTH];
430 char dataid[NISSY_DATAID_SIZE]; 430 char dataid[NISSY_SIZE_DATAID];
431 long long stats[NISSY_SIZE_SOLVE_STATS]; 431 long long stats[NISSY_SIZE_SOLVE_STATS];
432 int64_t ret, gendata_ret, size; 432 int64_t ret, gendata_ret, size;
433 size_t read; 433 size_t read;
@@ -780,13 +780,9 @@ set_threads(int argc, char **argv, args_t *args)
780} 780}
781 781
782void 782void
783log_stderr(const char *str, ...) 783log_stderr(const char *str)
784{ 784{
785 va_list args; 785 fprintf(stderr, "%s", str);
786
787 va_start(args, str);
788 vfprintf(stderr, str, args);
789 va_end(args);
790} 786}
791 787
792int 788int
diff --git a/src/nissy.h b/src/nissy.h
index 42429d3..a6a0ac1 100644
--- a/src/nissy.h
+++ b/src/nissy.h
@@ -40,6 +40,99 @@ for example 'rotation UF' or 'mirrored BL'.
40#define NISSY_SOLVED_CUBE "ABCDEFGH=ABCDEFGHIJKL" 40#define NISSY_SOLVED_CUBE "ABCDEFGH=ABCDEFGHIJKL"
41 41
42 42
43/* Error codes ***************************************************************/
44
45/*
46The value NISSY_OK denotes a success. If returned by solve, it means
47that no solution has been found.
48*/
49#define NISSY_OK 0LL
50
51/*
52The value NISSY_WARNING_UNSOLVABLE is a warning. It means that the
53operation was completed succesfully, but the resulting cube is in an
54unsolvable state. This could be intended, for example if the user has
55provided an unsolvable cube as input.
56*/
57#define NISSY_WARNING_UNSOLVABLE -1LL
58
59/*
60The value NISSY_ERROR_INVALID_CUBE means that the provided cube is
61invalid. It could be written in an unknown format, or in a format
62different from what specified, or simply ill-formed.
63*/
64#define NISSY_ERROR_INVALID_CUBE -10LL
65
66/*
67The value NISSY_ERROR_UNSOLVABLE_CUBE means that the provided cube is in
68an unsolvable state for the given solver. This could mean either that the
69cube is not solvable at all (for example in case it has a single twisted
70corner), or that it is not ready for the given step (for example if the
71caller wants to solve a DR finish without the cube being in DR state).
72*/
73#define NISSY_ERROR_UNSOLVABLE_CUBE -11LL
74
75/*
76The value NISSY_ERROR_INVALID_MOVES means that the given moves are
77invalid.
78*/
79#define NISSY_ERROR_INVALID_MOVES -20LL
80
81/*
82The value NISSY_ERROR_INVALID_TRANS means that the given transformation
83is invalid.
84*/
85#define NISSY_ERROR_INVALID_TRANS -30LL
86
87/*
88The value NISSY_ERROR_INVALID_FORMAT means that the given format is
89not known.
90*/
91#define NISSY_ERROR_INVALID_FORMAT -40LL
92
93/*
94The value NISSY_ERROR_INVALID_SOLVER means that the given solver is
95not known.
96*/
97#define NISSY_ERROR_INVALID_SOLVER -50LL
98
99/*
100The value NISSY_ERROR_NULL_POINTER means that one of the provided pointer
101arguments is NULL. For example, it may be returned by solve when called
102with a solver that requires some pre-computed data, but the provided
103data is NULL.
104*/
105#define NISSY_ERROR_NULL_POINTER -60LL
106
107/*
108The value NISSY_ERROR_BUFFER_SIZE means that one of the buffers provided
109is too small. For example, it could be too small to hold the result or
110too small to hold the data generated by gendata.
111*/
112#define NISSY_ERROR_BUFFER_SIZE -61LL
113
114/*
115The value NISSY_ERROR_DATA means that the provided data is invalid. For
116example, it may be returned by solve when called with incompatible solver
117and data arguments.
118*/
119#define NISSY_ERROR_DATA -70LL
120
121/*
122The value NISSY_ERROR_OPTIONS means that one or more of the given options
123are invalid. For example, it may be returned by solve when called with
124a negative maximum number of solutions.
125*/
126#define NISSY_ERROR_OPTIONS -80LL
127
128/*
129The value NISSY_ERROR_UNKNOWN denotes an unexpected error. It probably
130means that there some bug in this library. If you can, report any error
131of this kind to sebastiano@tronto.net. Thanks!
132*/
133#define NISSY_ERROR_UNKNOWN -999LL
134
135
43/* Library functions *********************************************************/ 136/* Library functions *********************************************************/
44 137
45/* 138/*
@@ -338,96 +431,3 @@ long long
338nissy_setlogger( 431nissy_setlogger(
339 void (*logger_function)(const char *) 432 void (*logger_function)(const char *)
340); 433);
341
342
343/* Error codes ***************************************************************/
344
345/*
346The value NISSY_OK denotes a success. If returned by solve, it means
347that no solution has been found.
348*/
349#define NISSY_OK 0LL
350
351/*
352The value NISSY_WARNING_UNSOLVABLE is a warning. It means that the
353operation was completed succesfully, but the resulting cube is in an
354unsolvable state. This could be intended, for example if the user has
355provided an unsolvable cube as input.
356*/
357#define NISSY_WARNING_UNSOLVABLE -1LL
358
359/*
360The value NISSY_ERROR_INVALID_CUBE means that the provided cube is
361invalid. It could be written in an unknown format, or in a format
362different from what specified, or simply ill-formed.
363*/
364#define NISSY_ERROR_INVALID_CUBE -10LL
365
366/*
367The value NISSY_ERROR_UNSOLVABLE_CUBE means that the provided cube is in
368an unsolvable state for the given solver. This could mean either that the
369cube is not solvable at all (for example in case it has a single twisted
370corner), or that it is not ready for the given step (for example if the
371caller wants to solve a DR finish without the cube being in DR state).
372*/
373#define NISSY_ERROR_UNSOLVABLE_CUBE -11LL
374
375/*
376The value NISSY_ERROR_INVALID_MOVES means that the given moves are
377invalid.
378*/
379#define NISSY_ERROR_INVALID_MOVES -20LL
380
381/*
382The value NISSY_ERROR_INVALID_TRANS means that the given transformation
383is invalid.
384*/
385#define NISSY_ERROR_INVALID_TRANS -30LL
386
387/*
388The value NISSY_ERROR_INVALID_FORMAT means that the given format is
389not known.
390*/
391#define NISSY_ERROR_INVALID_FORMAT -40LL
392
393/*
394The value NISSY_ERROR_INVALID_SOLVER means that the given solver is
395not known.
396*/
397#define NISSY_ERROR_INVALID_SOLVER -50LL
398
399/*
400The value NISSY_ERROR_NULL_POINTER means that one of the provided pointer
401arguments is NULL. For example, it may be returned by solve when called
402with a solver that requires some pre-computed data, but the provided
403data is NULL.
404*/
405#define NISSY_ERROR_NULL_POINTER -60LL
406
407/*
408The value NISSY_ERROR_BUFFER_SIZE means that one of the buffers provided
409is too small. For example, it could be too small to hold the result or
410too small to hold the data generated by gendata.
411*/
412#define NISSY_ERROR_BUFFER_SIZE -61LL
413
414/*
415The value NISSY_ERROR_DATA means that the provided data is invalid. For
416example, it may be returned by solve when called with incompatible solver
417and data arguments.
418*/
419#define NISSY_ERROR_DATA -70LL
420
421/*
422The value NISSY_ERROR_OPTIONS means that one or more of the given options
423are invalid. For example, it may be returned by solve when called with
424a negative maximum number of solutions.
425*/
426#define NISSY_ERROR_OPTIONS -80LL
427
428/*
429The value NISSY_ERROR_UNKNOWN denotes an unexpected error. It probably
430means that there some bug in this library. If you can, report any error
431of this kind to sebastiano@tronto.net. Thanks!
432*/
433#define NISSY_ERROR_UNKNOWN -999LL

Generated with cgit - Back to sebastiano.tronto.net