| 774 | } |
| 775 | |
| 776 | const char * |
| 777 | ControlBase::ProcessModifiers(matcher_line *line_info) |
| 778 | { |
| 779 | // Variables for error processing |
| 780 | const char *errBuf = nullptr; |
| 781 | mod_errors err = ME_UNKNOWN; |
| 782 | |
| 783 | int n_elts = line_info->num_el; // Element count for line. |
| 784 | |
| 785 | // No elements -> no modifiers. |
| 786 | if (0 >= n_elts) { |
| 787 | return nullptr; |
| 788 | } |
| 789 | // Can't have more modifiers than elements, so reasonable upper bound. |
| 790 | _mods.clear(); |
| 791 | _mods.reserve(n_elts); |
| 792 | |
| 793 | // As elements are consumed, the labels are nulled out and the element |
| 794 | // count decremented. So we have to scan the entire array to be sure of |
| 795 | // finding all the elements. We'll track the element count so we can |
| 796 | // escape if we've found all of the elements. |
| 797 | for (int i = 0; n_elts && ME_UNKNOWN == err && i < MATCHER_MAX_TOKENS; ++i) { |
| 798 | Modifier *mod = nullptr; |
| 799 | |
| 800 | char *label = line_info->line[0][i]; |
| 801 | char *value = line_info->line[1][i]; |
| 802 | |
| 803 | if (!label) { |
| 804 | continue; // Already use. |
| 805 | } |
| 806 | if (!value) { |
| 807 | err = ME_PARSE_FAILED; |
| 808 | break; |
| 809 | } |
| 810 | |
| 811 | if (strcasecmp(label, "port") == 0) { |
| 812 | mod = PortMod::make(value, &errBuf); |
| 813 | } else if (strcasecmp(label, "iport") == 0) { |
| 814 | mod = IPortMod::make(value, &errBuf); |
| 815 | } else if (strcasecmp(label, "scheme") == 0) { |
| 816 | mod = SchemeMod::make(value, &errBuf); |
| 817 | } else if (strcasecmp(label, "method") == 0) { |
| 818 | mod = MethodMod::make(value, &errBuf); |
| 819 | } else if (strcasecmp(label, "prefix") == 0) { |
| 820 | mod = PrefixMod::make(value, &errBuf); |
| 821 | } else if (strcasecmp(label, "suffix") == 0) { |
| 822 | mod = SuffixMod::make(value, &errBuf); |
| 823 | } else if (strcasecmp(label, "src_ip") == 0) { |
| 824 | mod = SrcIPMod::make(value, &errBuf); |
| 825 | } else if (strcasecmp(label, "time") == 0) { |
| 826 | mod = TimeMod::make(value, &errBuf); |
| 827 | } else if (strcasecmp(label, "tag") == 0) { |
| 828 | mod = TagMod::make(value, &errBuf); |
| 829 | } else if (strcasecmp(label, "internal") == 0) { |
| 830 | mod = InternalMod::make(value, &errBuf); |
| 831 | } else { |
| 832 | err = ME_BAD_MOD; |
| 833 | } |
nothing calls this directly
no test coverage detected