]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/BoolOps.cc
2 #include "acl/BoolOps.h"
3 #include "acl/Checklist.h"
9 Acl::NotNode::NotNode(ACL
*acl
)
13 strncat(&name
[1], acl
->name
, sizeof(name
)-1-1);
20 // Not implemented: by the time an upper level parser discovers
21 // an '!' operator, there is nothing left for us to parse.
26 Acl::NotNode::doMatch(ACLChecklist
*checklist
, Nodes::const_iterator start
) const
28 assert(start
== nodes
.begin()); // we only have one node
30 if (checklist
->matchChild(this, start
, *start
))
31 return 0; // converting match into mismatch
33 if (!checklist
->keepMatching())
34 return -1; // suspend on async calls and stop on failures
36 return 1; // converting mismatch into match
40 Acl::NotNode::typeString() const
46 Acl::NotNode::clone() const
48 // Not implemented: we are not a named ACL type in squid.conf so nobody
49 // should try to create a NotNode instance by ACL type name (which is
50 // what clone() API is for -- it does not really clone anything).
56 Acl::NotNode::dump() const
58 wordlist
*text
= NULL
;
59 wordlistAdd(&text
, name
);
66 Acl::AndNode::typeString() const
72 Acl::AndNode::clone() const
78 Acl::AndNode::doMatch(ACLChecklist
*checklist
, Nodes::const_iterator start
) const
80 // find the first node that does not match
81 for (Nodes::const_iterator i
= start
; i
!= nodes
.end(); ++i
) {
82 if (!checklist
->matchChild(this, i
, *i
))
83 return checklist
->keepMatching() ? 0 : -1;
86 // one and not zero on empty because in math empty product equals identity
87 return 1; // no mismatches found (i.e., all kids matched)
93 // Not implemented: AndNode cannot be configured directly. See Acl::AllOf.
100 Acl::OrNode::typeString() const
106 Acl::OrNode::clone() const
112 Acl::OrNode::doMatch(ACLChecklist
*checklist
, Nodes::const_iterator start
) const
114 lastMatch_
= nodes
.end();
116 // find the first node that matches, but stop if things go wrong
117 for (Nodes::const_iterator i
= start
; i
!= nodes
.end(); ++i
) {
118 if (checklist
->matchChild(this, i
, *i
)) {
123 if (!checklist
->keepMatching())
124 return -1; // suspend on async calls and stop on failures
127 // zero and not one on empty because in math empty sum equals zero
128 return 0; // all nodes mismatched
134 // Not implemented: OrNode cannot be configured directly. See Acl::AnyOf.