diff options
Diffstat (limited to '')
| -rw-r--r-- | src/nissy.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/nissy.c b/src/nissy.c index 5641dd9..f8c1f4d 100644 --- a/src/nissy.c +++ b/src/nissy.c | |||
| @@ -26,23 +26,31 @@ struct { | |||
| 26 | _static int | 26 | _static int |
| 27 | parse_h48_options(const char *buf, uint8_t *h, uint8_t *k, uint8_t *maxdepth) | 27 | parse_h48_options(const char *buf, uint8_t *h, uint8_t *k, uint8_t *maxdepth) |
| 28 | { | 28 | { |
| 29 | bool h_valid, k_valid, maxdepth_valid; | ||
| 29 | int i; | 30 | int i; |
| 30 | 31 | ||
| 31 | /* TODO temporarily, options are in the form "h;k;maxdepth" */ | 32 | /* TODO temporarily, options are in the form "h;k;maxdepth" */ |
| 32 | if (h != NULL) | 33 | if (h != NULL) |
| 33 | *h = atoi(buf); | 34 | *h = atoi(buf); |
| 35 | h_valid = h == NULL || *h <= 11; | ||
| 36 | |||
| 34 | for (i = 0; buf[i] != ';'; i++) | 37 | for (i = 0; buf[i] != ';'; i++) |
| 35 | if (buf[i] == 0) | 38 | if (buf[i] == 0) |
| 36 | goto parse_h48_options_error; | 39 | goto parse_h48_options_error; |
| 40 | |||
| 37 | if (k != NULL) | 41 | if (k != NULL) |
| 38 | *k = atoi(&buf[i+1]); | 42 | *k = atoi(&buf[i+1]); |
| 43 | k_valid = k == NULL || (*k == 2 || *k == 4); | ||
| 44 | |||
| 39 | for (i = i+1; buf[i] != ';'; i++) | 45 | for (i = i+1; buf[i] != ';'; i++) |
| 40 | if (buf[i] == 0) | 46 | if (buf[i] == 0) |
| 41 | goto parse_h48_options_error; | 47 | goto parse_h48_options_error; |
| 48 | |||
| 42 | if (maxdepth != NULL) | 49 | if (maxdepth != NULL) |
| 43 | *maxdepth = atoi(&buf[i+1]); | 50 | *maxdepth = atoi(&buf[i+1]); |
| 51 | maxdepth_valid = maxdepth == NULL || *maxdepth <= 20; | ||
| 44 | 52 | ||
| 45 | return (*h <= 11 && (*k == 2 || *k == 4) && *maxdepth <= 20) ? 0 : 1; | 53 | return h_valid && k_valid && maxdepth_valid ? 0 : 1; |
| 46 | 54 | ||
| 47 | parse_h48_options_error: | 55 | parse_h48_options_error: |
| 48 | *h = 0; | 56 | *h = 0; |
| @@ -202,7 +210,7 @@ nissy_gendata( | |||
| 202 | if (!strcmp(solver, "h48")) { | 210 | if (!strcmp(solver, "h48")) { |
| 203 | p = parse_h48_options(options, &arg.h, &arg.k, &arg.maxdepth); | 211 | p = parse_h48_options(options, &arg.h, &arg.k, &arg.maxdepth); |
| 204 | if (p != 0) { | 212 | if (p != 0) { |
| 205 | LOG("gendata: ould not parse options\n"); | 213 | LOG("gendata: could not parse options\n"); |
| 206 | ret = -1; | 214 | ret = -1; |
| 207 | } else { | 215 | } else { |
| 208 | ret = gendata_h48(&arg); | 216 | ret = gendata_h48(&arg); |
