| 622 | } |
| 623 | |
| 624 | void |
| 625 | ConfigVolumes::BuildListFromString(char *config_file_path, char *file_buf) |
| 626 | { |
| 627 | // Table build locals |
| 628 | Tokenizer bufTok("\n"); |
| 629 | tok_iter_state i_state; |
| 630 | const char *tmp; |
| 631 | int line_num = 0; |
| 632 | int total = 0; // added by YTS Team, yamsat for bug id 59632 |
| 633 | |
| 634 | char volume_seen[256]; |
| 635 | const char *matcher_name = "[CacheVolition]"; |
| 636 | |
| 637 | memset(volume_seen, 0, sizeof(volume_seen)); |
| 638 | num_volumes = 0; |
| 639 | num_http_volumes = 0; |
| 640 | |
| 641 | if (bufTok.Initialize(file_buf, SHARE_TOKS | ALLOW_EMPTY_TOKS) == 0) { |
| 642 | // We have an empty file |
| 643 | /* no volumes */ |
| 644 | return; |
| 645 | } |
| 646 | |
| 647 | // First get the number of entries |
| 648 | tmp = bufTok.iterFirst(&i_state); |
| 649 | while (tmp != nullptr) { |
| 650 | line_num++; |
| 651 | |
| 652 | char *end; |
| 653 | char *line_end = nullptr; |
| 654 | const char *err = nullptr; |
| 655 | int volume_number = 0; |
| 656 | CacheType scheme = CACHE_NONE_TYPE; |
| 657 | int size = 0; |
| 658 | int in_percent = 0; |
| 659 | bool ramcache_enabled = true; |
| 660 | int avg_obj_size = -1; // Defaults |
| 661 | int fragment_size = -1; |
| 662 | |
| 663 | while (true) { |
| 664 | // skip all blank spaces at beginning of line |
| 665 | while (*tmp && isspace(*tmp)) { |
| 666 | tmp++; |
| 667 | } |
| 668 | |
| 669 | if (*tmp == '\0' || *tmp == '#') { |
| 670 | break; |
| 671 | } else if (!(*tmp)) { |
| 672 | err = "Unexpected end of line"; |
| 673 | break; |
| 674 | } |
| 675 | |
| 676 | end = const_cast<char *>(tmp); |
| 677 | while (*end && !isspace(*end)) { |
| 678 | end++; |
| 679 | } |
| 680 | |
| 681 | if (!(*end)) { |
nothing calls this directly
no test coverage detected