| 483 | } |
| 484 | |
| 485 | static void CAR_parse_params(cache_t *cache, const char *cache_specific_params) { |
| 486 | CAR_params_t *params = (CAR_params_t *)cache->eviction_params; |
| 487 | char *params_str = strdup(cache_specific_params); |
| 488 | char *old_params_str = params_str; |
| 489 | char *end; |
| 490 | |
| 491 | while (params_str != NULL && params_str[0] != '\0') { |
| 492 | /* different parameters are separated by comma, |
| 493 | * key and value are separated by = */ |
| 494 | char *key = strsep((char **)¶ms_str, "="); |
| 495 | char *value = strsep((char **)¶ms_str, ","); |
| 496 | |
| 497 | // skip the white space |
| 498 | while (params_str != NULL && *params_str == ' ') { |
| 499 | params_str++; |
| 500 | } |
| 501 | |
| 502 | if (strcasecmp(key, "p") == 0) { |
| 503 | params->p = (int)strtol(value, &end, 0); |
| 504 | if (strlen(end) > 2) { |
| 505 | ERROR("param parsing error, find string \"%s\" after number\n", end); |
| 506 | } |
| 507 | } else if (strcasecmp(key, "print") == 0) { |
| 508 | printf("current parameters: %s\n", CAR_current_params(cache, params)); |
| 509 | exit(0); |
| 510 | } else { |
| 511 | ERROR("%s does not have parameter %s, example parameters %s\n", cache->cache_name, key, |
| 512 | CAR_current_params(cache, params)); |
| 513 | exit(1); |
| 514 | } |
| 515 | } |
| 516 | free(old_params_str); |
| 517 | } |
| 518 | |
| 519 | // *********************************************************************** |
| 520 | // **** **** |
no test coverage detected