* Extract the option values. The format is: * -libxo encoder=csv:kw=val:kw=val:kw=val,pretty * -libxo encoder=csv+kw=val+kw=val+kw=val,pretty */
| 661 | * -libxo encoder=csv+kw=val+kw=val+kw=val,pretty |
| 662 | */ |
| 663 | static int |
| 664 | csv_options (xo_handle_t *xop, csv_private_t *csv, |
| 665 | const char *raw_opts, char opts_char) |
| 666 | { |
| 667 | ssize_t len = strlen(raw_opts); |
| 668 | char *options = alloca(len + 1); |
| 669 | memcpy(options, raw_opts, len); |
| 670 | options[len] = '\0'; |
| 671 | |
| 672 | char *cp, *ep, *np, *vp; |
| 673 | for (cp = options, ep = options + len + 1; cp && cp < ep; cp = np) { |
| 674 | np = strchr(cp, opts_char); |
| 675 | if (np) |
| 676 | *np++ = '\0'; |
| 677 | |
| 678 | vp = strchr(cp, '='); |
| 679 | if (vp) |
| 680 | *vp++ = '\0'; |
| 681 | |
| 682 | if (xo_streq(cp, "path")) { |
| 683 | /* Record the path */ |
| 684 | if (vp != NULL && csv_record_path(xop, csv, vp)) |
| 685 | return -1; |
| 686 | |
| 687 | csv->c_flags |= CF_HAS_PATH; /* Yup, we have an explicit path now */ |
| 688 | |
| 689 | } else if (xo_streq(cp, "leafs") |
| 690 | || xo_streq(cp, "leaf") |
| 691 | || xo_streq(cp, "leaves")) { |
| 692 | /* Record the leafs */ |
| 693 | if (vp != NULL && csv_record_leafs(xop, csv, vp)) |
| 694 | return -1; |
| 695 | |
| 696 | } else if (xo_streq(cp, "no-keys")) { |
| 697 | csv->c_flags |= CF_NO_KEYS; |
| 698 | } else if (xo_streq(cp, "no-header")) { |
| 699 | csv->c_flags |= CF_NO_HEADER; |
| 700 | } else if (xo_streq(cp, "value-only")) { |
| 701 | csv->c_flags |= CF_VALUE_ONLY; |
| 702 | } else if (xo_streq(cp, "dos")) { |
| 703 | csv->c_flags |= CF_DOS_NEWLINE; |
| 704 | } else if (xo_streq(cp, "no-quotes")) { |
| 705 | csv->c_flags |= CF_NO_QUOTES; |
| 706 | } else if (xo_streq(cp, "debug")) { |
| 707 | csv->c_flags |= CF_DEBUG; |
| 708 | } else { |
| 709 | xo_warn_hc(xop, -1, |
| 710 | "unknown encoder option value: '%s'", cp); |
| 711 | return -1; |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | return 0; |
| 716 | } |
| 717 | |
| 718 | /* |
| 719 | * Handler for incoming data values. We just record each leaf name and |
no test coverage detected