| 73 | } |
| 74 | |
| 75 | bool |
| 76 | RuleSet::add_operator(Parser &p, const char *filename, int lineno) |
| 77 | { |
| 78 | Operator *op = operator_factory(p.get_op()); |
| 79 | |
| 80 | if (nullptr != op) { |
| 81 | Dbg(pi_dbg_ctl, " Adding operator: %s(%s)=\"%s\"", p.get_op().c_str(), p.get_arg().c_str(), p.get_value().c_str()); |
| 82 | op->initialize(p); |
| 83 | if (!op->set_hook(_hook)) { |
| 84 | delete op; |
| 85 | Dbg(pi_dbg_ctl, "in %s:%d: can't use this operator in hook=%s: %s(%s)", filename, lineno, TSHttpHookNameLookup(_hook), |
| 86 | p.get_op().c_str(), p.get_arg().c_str()); |
| 87 | TSError("[%s] in %s:%d: can't use this operator in hook=%s: %s(%s)", PLUGIN_NAME, filename, lineno, |
| 88 | TSHttpHookNameLookup(_hook), p.get_op().c_str(), p.get_arg().c_str()); |
| 89 | return false; |
| 90 | } |
| 91 | |
| 92 | // Work on the appropriate operator list |
| 93 | OperatorPair &ops = _is_else ? _operators[1] : _operators[0]; |
| 94 | |
| 95 | if (nullptr == ops.oper) { |
| 96 | ops.oper = op; |
| 97 | } else { |
| 98 | ops.oper->append(op); |
| 99 | } |
| 100 | |
| 101 | // Update some ruleset state based on this new operator |
| 102 | ops.oper_mods = static_cast<OperModifiers>(ops.oper_mods | ops.oper->get_oper_modifiers()); |
| 103 | _ids = static_cast<ResourceIDs>(_ids | ops.oper->get_resource_ids()); |
| 104 | |
| 105 | return true; |
| 106 | } |
| 107 | |
| 108 | return false; |
| 109 | } |
| 110 | |
| 111 | ResourceIDs |
| 112 | RuleSet::get_all_resource_ids() const |
no test coverage detected