diff options
| author | Paul Duncan <pabs@pablotron.org> | 2019-01-15 21:10:27 -0500 | 
|---|---|---|
| committer | Paul Duncan <pabs@pablotron.org> | 2019-01-15 21:10:27 -0500 | 
| commit | 19a5965400f9a252adf540050046d2dc3a026d13 (patch) | |
| tree | 0fb29c1a0f61a38eae8f2aded462bf12e5a3d60e /src/text | |
| parent | edbbfd40714ba9adfd770b9ccb6a0eecdc43a736 (diff) | |
| download | sok-19a5965400f9a252adf540050046d2dc3a026d13.tar.xz sok-19a5965400f9a252adf540050046d2dc3a026d13.zip | |
add sok_solve_cbs_t and refactor code to use it
Diffstat (limited to 'src/text')
| -rw-r--r-- | src/text/main.c | 11 | 
1 files changed, 9 insertions, 2 deletions
| diff --git a/src/text/main.c b/src/text/main.c index 204da0f..6b7513c 100644 --- a/src/text/main.c +++ b/src/text/main.c @@ -10,11 +10,18 @@  static void  solve_on_error( -  const char * const err +  const char * const err, +  void *data  ) { +  UNUSED(data);    die("Error solving level: %s", err);  } +static const sok_solve_cbs_t +SOLVE_CBS = { +  .on_error = solve_on_error, +}; +  static void  draw_moves(    const sok_ctx_t * const ctx, @@ -104,7 +111,7 @@ int main(int argc, char *argv[]) {          // get current number of moves          const size_t old_num_moves = ctx.num_moves; -        if (sok_solve(&ctx, solve_on_error)) { +        if (sok_solve(&ctx, &SOLVE_CBS, NULL)) {            // found solution, print it            draw_moves(&ctx, old_num_moves);          } else { | 
