]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/BoolOps.cc
2 #include "acl/BoolOps.h"
3 #include "acl/Checklist.h"
8 Acl::NotNode::NotNode(ACL
*acl
)
12 strncat(&name
[1], acl
->name
, sizeof(name
)-1-1);
19 // Not implemented: by the time an upper level parser discovers
20 // an '!' operator, there is nothing left for us to parse.
25 Acl::NotNode::doMatch(ACLChecklist
*checklist
, Nodes::const_iterator start
) const
27 assert(start
== nodes
.begin()); // we only have one node
29 if (checklist
->matchChild(this, start
, *start
))
30 return 0; // converting match into mismatch
32 if (!checklist
->keepMatching())
33 return -1; // suspend on async calls and stop on failures
35 return 1; // converting mismatch into match
39 Acl::NotNode::typeString() const
45 Acl::NotNode::clone() const
47 // Not implemented: we are not a named ACL type in squid.conf so nobody
48 // should try to create a NotNode instance by ACL type name (which is
49 // what clone() API is for -- it does not really clone anything).
55 Acl::NotNode::dump() const
58 text
.push_back(SBuf(name
));
65 Acl::AndNode::typeString() const
71 Acl::AndNode::clone() const
77 Acl::AndNode::doMatch(ACLChecklist
*checklist
, Nodes::const_iterator start
) const
79 // find the first node that does not match
80 for (Nodes::const_iterator i
= start
; i
!= nodes
.end(); ++i
) {
81 if (!checklist
->matchChild(this, i
, *i
))
82 return checklist
->keepMatching() ? 0 : -1;
85 // one and not zero on empty because in math empty product equals identity
86 return 1; // no mismatches found (i.e., all kids matched)
92 // Not implemented: AndNode cannot be configured directly. See Acl::AllOf.
99 Acl::OrNode::typeString() const
105 Acl::OrNode::clone() const
111 Acl::OrNode::doMatch(ACLChecklist
*checklist
, Nodes::const_iterator start
) const
113 lastMatch_
= nodes
.end();
115 // find the first node that matches, but stop if things go wrong
116 for (Nodes::const_iterator i
= start
; i
!= nodes
.end(); ++i
) {
117 if (checklist
->matchChild(this, i
, *i
)) {
122 if (!checklist
->keepMatching())
123 return -1; // suspend on async calls and stop on failures
126 // zero and not one on empty because in math empty sum equals zero
127 return 0; // all nodes mismatched
133 // Not implemented: OrNode cannot be configured directly. See Acl::AnyOf.