aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/moves.h5
-rw-r--r--src/nissy.c12
-rw-r--r--src/nissy.h13
3 files changed, 28 insertions, 2 deletions
diff --git a/src/core/moves.h b/src/core/moves.h
index d07bc19..e3a9bc1 100644
--- a/src/core/moves.h
+++ b/src/core/moves.h
@@ -223,8 +223,9 @@ readmoves(const char *buf, int max, uint8_t *ret)
223 uint8_t m; 223 uint8_t m;
224 int c; 224 int c;
225 225
226 FOREACH_READMOVE(buf, m, c, max, -1, 226 FOREACH_READMOVE(buf, m, c, max, NISSY_ERROR_INVALID_MOVES,
227 ret[c] = m; 227 if (ret != NULL)
228 ret[c] = m;
228 ) 229 )
229 230
230 return c; 231 return c;
diff --git a/src/nissy.c b/src/nissy.c
index fe2747b..986f27f 100644
--- a/src/nissy.c
+++ b/src/nissy.c
@@ -1,4 +1,5 @@
1#include <inttypes.h> 1#include <inttypes.h>
2#include <limits.h>
2#include <pthread.h> 3#include <pthread.h>
3#include <stdatomic.h> 4#include <stdatomic.h>
4#include <stdarg.h> 5#include <stdarg.h>
@@ -521,6 +522,17 @@ nissy_solve(
521} 522}
522 523
523long long 524long long
525nissy_countmoves(
526 const char *moves
527)
528{
529 if (moves == NULL)
530 return NISSY_ERROR_NULL_POINTER;
531
532 return readmoves(moves, INT_MAX, NULL);
533}
534
535long long
524nissy_setlogger( 536nissy_setlogger(
525 void (*log)(const char *, ...) 537 void (*log)(const char *, ...)
526) 538)
diff --git a/src/nissy.h b/src/nissy.h
index 8f4f363..7a39927 100644
--- a/src/nissy.h
+++ b/src/nissy.h
@@ -281,6 +281,19 @@ long long nissy_solve(
281); 281);
282 282
283/* 283/*
284Parameters:
285 moves - The moves to be counted.
286
287Return values:
288 NISSY_ERROR_INVALID_MOVES - The given moves are invalid.
289 NISSY_ERROR_NULL_POINTER - The 'moves' argument is NULL.
290 Any value >= 0 - The number of moves.
291*/
292long long nissy_countmoves(
293 const char *moves
294);
295
296/*
284Set a global logger function used by this library. 297Set a global logger function used by this library.
285 298
286Parameters: 299Parameters:

Generated with cgit - Back to sebastiano.tronto.net