aboutsummaryrefslogtreecommitdiff
path: root/shell.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell.c')
-rw-r--r--shell.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/shell.c b/shell.c
index efabc6c..9db8a92 100644
--- a/shell.c
+++ b/shell.c
@@ -49,7 +49,7 @@ typedef struct {
49 char *str_moves; 49 char *str_moves;
50 char *str_trans; 50 char *str_trans;
51 char *str_solver; 51 char *str_solver;
52 char *str_nisstype; /* TODO: remove, use flags */ 52 char *str_nisstype;
53 int8_t minmoves; 53 int8_t minmoves;
54 int8_t maxmoves; 54 int8_t maxmoves;
55 int8_t optimal; 55 int8_t optimal;
@@ -108,7 +108,7 @@ struct {
108 OPTION(FLAG_MOVES, 1, set_str_moves), 108 OPTION(FLAG_MOVES, 1, set_str_moves),
109 OPTION(FLAG_TRANS, 1, set_str_trans), 109 OPTION(FLAG_TRANS, 1, set_str_trans),
110 OPTION(FLAG_SOLVER, 1, set_str_solver), 110 OPTION(FLAG_SOLVER, 1, set_str_solver),
111 OPTION(FLAG_NISSTYPE, 1, set_str_nisstype), /* TODO: remove, use flags */ 111 OPTION(FLAG_NISSTYPE, 1, set_str_nisstype), /* TODO: more args ? */
112 OPTION(FLAG_MINMOVES, 1, set_minmoves), 112 OPTION(FLAG_MINMOVES, 1, set_minmoves),
113 OPTION(FLAG_MAXMOVES, 1, set_maxmoves), 113 OPTION(FLAG_MAXMOVES, 1, set_maxmoves),
114 OPTION(FLAG_OPTIMAL, 1, set_optimal), 114 OPTION(FLAG_OPTIMAL, 1, set_optimal),
@@ -244,7 +244,7 @@ compose_exec(args_t *args)
244 int64_t ret; 244 int64_t ret;
245 245
246 ret = nissy_compose(args->cube, args->cube_perm, result); 246 ret = nissy_compose(args->cube, args->cube_perm, result);
247 if (ret == 0) 247 if (ret == NISSY_OK || ret == NISSY_WARNING_UNSOLVABLE)
248 printf("%s\n", result); 248 printf("%s\n", result);
249 249
250 return ret; 250 return ret;
@@ -257,7 +257,7 @@ inverse_exec(args_t *args)
257 int64_t ret; 257 int64_t ret;
258 258
259 ret = nissy_inverse(args->cube, result); 259 ret = nissy_inverse(args->cube, result);
260 if (ret == 0) 260 if (ret == NISSY_OK || ret == NISSY_WARNING_UNSOLVABLE)
261 printf("%s\n", result); 261 printf("%s\n", result);
262 262
263 return ret; 263 return ret;
@@ -270,7 +270,7 @@ applymoves_exec(args_t *args)
270 int64_t ret; 270 int64_t ret;
271 271
272 ret = nissy_applymoves(args->cube, args->str_moves, result); 272 ret = nissy_applymoves(args->cube, args->str_moves, result);
273 if (ret == 0) 273 if (ret == NISSY_OK || ret == NISSY_WARNING_UNSOLVABLE)
274 printf("%s\n", result); 274 printf("%s\n", result);
275 275
276 return ret; 276 return ret;
@@ -283,7 +283,7 @@ applytrans_exec(args_t *args)
283 int64_t ret; 283 int64_t ret;
284 284
285 ret = nissy_applytrans(args->cube, args->str_trans, result); 285 ret = nissy_applytrans(args->cube, args->str_trans, result);
286 if (ret == 0) 286 if (ret == NISSY_OK || ret == NISSY_WARNING_UNSOLVABLE)
287 printf("%s\n", result); 287 printf("%s\n", result);
288 288
289 return ret; 289 return ret;
@@ -296,7 +296,7 @@ frommoves_exec(args_t *args)
296 int64_t ret; 296 int64_t ret;
297 297
298 ret = nissy_frommoves(args->str_moves, result); 298 ret = nissy_frommoves(args->str_moves, result);
299 if (ret == 0) 299 if (ret == NISSY_OK || ret == NISSY_WARNING_UNSOLVABLE)
300 printf("%s\n", result); 300 printf("%s\n", result);
301 301
302 return ret; 302 return ret;
@@ -310,7 +310,7 @@ convert_exec(args_t *args)
310 310
311 ret = nissy_convert( 311 ret = nissy_convert(
312 args->str_format_in, args->str_format_out, args->str_cube, result); 312 args->str_format_in, args->str_format_out, args->str_cube, result);
313 if (ret == 0) 313 if (ret == NISSY_OK || ret == NISSY_WARNING_UNSOLVABLE)
314 printf("%s\n", result); 314 printf("%s\n", result);
315 315
316 return ret; 316 return ret;
@@ -327,7 +327,7 @@ randomcube_exec(args_t *args)
327 cp = rand64(); 327 cp = rand64();
328 co = rand64(); 328 co = rand64();
329 ret = nissy_getcube(ep, eo, cp, co, "fix", result); 329 ret = nissy_getcube(ep, eo, cp, co, "fix", result);
330 if (ret == 0) 330 if (ret == NISSY_OK || ret == NISSY_WARNING_UNSOLVABLE)
331 printf("%s\n", result); 331 printf("%s\n", result);
332 332
333 return ret; 333 return ret;
@@ -418,11 +418,14 @@ static int64_t
418solve_exec(args_t *args) 418solve_exec(args_t *args)
419{ 419{
420 int i; 420 int i;
421 uint8_t nissflag;
421 FILE *file; 422 FILE *file;
422 char *buf, solutions[SOLUTIONS_BUFFER_SIZE], path[MAX_PATH_LENGTH]; 423 char *buf, solutions[SOLUTIONS_BUFFER_SIZE], path[MAX_PATH_LENGTH];
423 int64_t ret, gendata_ret, size; 424 int64_t ret, gendata_ret, size;
424 size_t read; 425 size_t read;
425 426
427 nissflag = NISSY_NISSFLAG_NORMAL; /* TODO: parse str_nisstype */
428
426 for (i = 0; tablepaths[i] != NULL; i++) { 429 for (i = 0; tablepaths[i] != NULL; i++) {
427 strcpy(path, tablepaths[i]); 430 strcpy(path, tablepaths[i]);
428 strcat(path, args->str_solver); 431 strcat(path, args->str_solver);
@@ -469,12 +472,12 @@ solve_exec(args_t *args)
469 } 472 }
470 473
471 ret = nissy_solve( 474 ret = nissy_solve(
472 args->cube, args->str_solver, args->str_nisstype, args->minmoves, 475 args->cube, args->str_solver, nissflag, args->minmoves,
473 args->maxmoves, args->maxsolutions, args->optimal, buf, solutions); 476 args->maxmoves, args->maxsolutions, args->optimal, buf, solutions);
474 477
475 free(buf); 478 free(buf);
476 479
477 if (ret == 0) 480 if (ret == NISSY_OK || ret == NISSY_WARNING_UNSOLVABLE)
478 fprintf(stderr, "No solutions found\n"); 481 fprintf(stderr, "No solutions found\n");
479 else 482 else
480 printf("%s", solutions); 483 printf("%s", solutions);

Generated with cgit - Back to sebastiano.tronto.net