* Record the requested path elements. The input should be a set of * container or instances names, separated by slashes. */
| 605 | * container or instances names, separated by slashes. |
| 606 | */ |
| 607 | static int |
| 608 | csv_record_path (xo_handle_t *xop, csv_private_t *csv, const char *path_raw) |
| 609 | { |
| 610 | int count; |
| 611 | char *cp, *ep, *np; |
| 612 | ssize_t len = strlen(path_raw); |
| 613 | char *path_buf = xo_realloc(NULL, len + 1); |
| 614 | |
| 615 | memcpy(path_buf, path_raw, len + 1); |
| 616 | |
| 617 | for (cp = path_buf, ep = path_buf + len, count = 2; |
| 618 | cp && cp < ep; cp = np) { |
| 619 | np = strchr(cp, '/'); |
| 620 | if (np) { |
| 621 | np += 1; |
| 622 | count += 1; |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | path_frame_t *path = xo_realloc(NULL, sizeof(path[0]) * count); |
| 627 | if (path == NULL) { |
| 628 | xo_failure(xop, "allocation failure for path '%s'", path_buf); |
| 629 | return -1; |
| 630 | } |
| 631 | |
| 632 | bzero(path, sizeof(path[0]) * count); |
| 633 | |
| 634 | for (count = 0, cp = path_buf; cp && cp < ep; cp = np) { |
| 635 | path[count++].pf_name = cp; |
| 636 | |
| 637 | np = strchr(cp, '/'); |
| 638 | if (np) |
| 639 | *np++ = '\0'; |
| 640 | csv_dbg(xop, csv, "path: [%s]\n", cp); |
| 641 | } |
| 642 | |
| 643 | path[count].pf_name = NULL; |
| 644 | |
| 645 | if (csv->c_path) /* In case two paths are given */ |
| 646 | xo_free(csv->c_path); |
| 647 | if (csv->c_path_buf) /* In case two paths are given */ |
| 648 | xo_free(csv->c_path_buf); |
| 649 | |
| 650 | csv->c_path_buf = path_buf; |
| 651 | csv->c_path = path; |
| 652 | csv->c_path_max = count; |
| 653 | csv->c_path_cur = 0; |
| 654 | |
| 655 | return 0; |
| 656 | } |
| 657 | |
| 658 | /* |
| 659 | * Extract the option values. The format is: |
no test coverage detected