diff options
Diffstat (limited to 'src/nissy.c')
| -rw-r--r-- | src/nissy.c | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/nissy.c b/src/nissy.c index eb483a0..2766b12 100644 --- a/src/nissy.c +++ b/src/nissy.c | |||
| @@ -19,6 +19,7 @@ STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], | |||
| 19 | const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); | 19 | const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); |
| 20 | STATIC long long write_result(cube_t, char [static NISSY_SIZE_B32]); | 20 | STATIC long long write_result(cube_t, char [static NISSY_SIZE_B32]); |
| 21 | STATIC size_t my_strnlen(const char *, size_t); | 21 | STATIC size_t my_strnlen(const char *, size_t); |
| 22 | STATIC long long nissy_dataid(const char *, char [static NISSY_DATAID_SIZE]); | ||
| 22 | STATIC long long nissy_gendata_unsafe( | 23 | STATIC long long nissy_gendata_unsafe( |
| 23 | const char *, unsigned long long, char *); | 24 | const char *, unsigned long long, char *); |
| 24 | 25 | ||
| @@ -412,11 +413,37 @@ nissy_datainfo( | |||
| 412 | return NISSY_OK; | 413 | return NISSY_OK; |
| 413 | } | 414 | } |
| 414 | 415 | ||
| 416 | STATIC long long | ||
| 417 | nissy_dataid(const char *solver, char dataid[static NISSY_DATAID_SIZE]) | ||
| 418 | { | ||
| 419 | if (!strncmp(solver, "h48", 3)) { | ||
| 420 | uint8_t h, k; | ||
| 421 | long long err; | ||
| 422 | if ((err = parse_h48_solver(solver, &h, &k)) != NISSY_OK) | ||
| 423 | return err; | ||
| 424 | /* TODO: also check that h and k are admissible */ | ||
| 425 | else strcpy(dataid, solver); | ||
| 426 | return err; | ||
| 427 | /* TODO: do this when moved parser */ | ||
| 428 | /* return dataid_h48(solver, dataid); */ | ||
| 429 | } else if (!strncmp(solver, "coord_", 6)) { | ||
| 430 | return dataid_coord(solver+6, dataid); | ||
| 431 | } else { | ||
| 432 | LOG("gendata: unknown solver %s\n", solver); | ||
| 433 | return NISSY_ERROR_INVALID_SOLVER; | ||
| 434 | } | ||
| 435 | } | ||
| 436 | |||
| 415 | long long | 437 | long long |
| 416 | nissy_datasize( | 438 | nissy_solverinfo( |
| 417 | const char *solver | 439 | const char *solver, |
| 440 | char dataid[static NISSY_DATAID_SIZE] | ||
| 418 | ) | 441 | ) |
| 419 | { | 442 | { |
| 443 | long long err; | ||
| 444 | if ((err = nissy_dataid(solver, dataid)) != NISSY_OK) | ||
| 445 | return err; | ||
| 446 | |||
| 420 | /* gendata() handles a NULL *data as a "dryrun" request */ | 447 | /* gendata() handles a NULL *data as a "dryrun" request */ |
| 421 | return nissy_gendata_unsafe(solver, 0, NULL); | 448 | return nissy_gendata_unsafe(solver, 0, NULL); |
| 422 | } | 449 | } |
| @@ -447,7 +474,7 @@ nissy_gendata_unsafe( | |||
| 447 | } | 474 | } |
| 448 | 475 | ||
| 449 | if ((size_t)data % 8 != 0) { | 476 | if ((size_t)data % 8 != 0) { |
| 450 | LOG("nissy_datainfo: buffere is not 8-byte aligned\n"); | 477 | LOG("nissy_gendata: buffere is not 8-byte aligned\n"); |
| 451 | return NISSY_ERROR_DATA; | 478 | return NISSY_ERROR_DATA; |
| 452 | } | 479 | } |
| 453 | 480 | ||
| @@ -478,7 +505,7 @@ nissy_checkdata( | |||
| 478 | int64_t err; | 505 | int64_t err; |
| 479 | 506 | ||
| 480 | if ((size_t)data % 8 != 0) { | 507 | if ((size_t)data % 8 != 0) { |
| 481 | LOG("nissy_datainfo: buffere is not 8-byte aligned\n"); | 508 | LOG("nissy_checkdata: buffere is not 8-byte aligned\n"); |
| 482 | return NISSY_ERROR_DATA; | 509 | return NISSY_ERROR_DATA; |
| 483 | } | 510 | } |
| 484 | 511 | ||
| @@ -560,7 +587,7 @@ nissy_solve( | |||
| 560 | } | 587 | } |
| 561 | 588 | ||
| 562 | if ((size_t)data % 8 != 0) { | 589 | if ((size_t)data % 8 != 0) { |
| 563 | LOG("nissy_datainfo: buffere is not 8-byte aligned\n"); | 590 | LOG("nissy_solve: buffere is not 8-byte aligned\n"); |
| 564 | return NISSY_ERROR_DATA; | 591 | return NISSY_ERROR_DATA; |
| 565 | } | 592 | } |
| 566 | 593 | ||
