]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/BoolOps.cc
661f9318b179e7d5a6bb8a50febc74578e30a863
2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
10 #include "acl/BoolOps.h"
11 #include "acl/Checklist.h"
13 #include "sbuf/SBuf.h"
17 Acl::NotNode::NotNode(ACL
*acl
)
22 strncat(&name
[1], acl
->name
, sizeof(name
)-1-1);
29 // Not implemented: by the time an upper level parser discovers
30 // an '!' operator, there is nothing left for us to parse.
35 Acl::NotNode::doMatch(ACLChecklist
*checklist
, Nodes::const_iterator start
) const
37 assert(start
== nodes
.begin()); // we only have one node
39 if (checklist
->matchChild(this, start
, *start
))
40 return 0; // converting match into mismatch
42 if (!checklist
->keepMatching())
43 return -1; // suspend on async calls and stop on failures
45 return 1; // converting mismatch into match
49 Acl::NotNode::typeString() const
55 Acl::NotNode::clone() const
57 // Not implemented: we are not a named ACL type in squid.conf so nobody
58 // should try to create a NotNode instance by ACL type name (which is
59 // what clone() API is for -- it does not really clone anything).
65 Acl::NotNode::dump() const
68 text
.push_back(SBuf(name
));
75 Acl::AndNode::typeString() const
81 Acl::AndNode::clone() const
87 Acl::AndNode::doMatch(ACLChecklist
*checklist
, Nodes::const_iterator start
) const
89 // find the first node that does not match
90 for (Nodes::const_iterator i
= start
; i
!= nodes
.end(); ++i
) {
91 if (!checklist
->matchChild(this, i
, *i
))
92 return checklist
->keepMatching() ? 0 : -1;
95 // one and not zero on empty because in math empty product equals identity
96 return 1; // no mismatches found (i.e., all kids matched)
100 Acl::AndNode::parse()
102 // Not implemented: AndNode cannot be configured directly. See Acl::AllOf.
109 Acl::OrNode::typeString() const
115 Acl::OrNode::clone() const
121 Acl::OrNode::bannedAction(ACLChecklist
*, Nodes::const_iterator
) const
127 Acl::OrNode::doMatch(ACLChecklist
*checklist
, Nodes::const_iterator start
) const
129 lastMatch_
= nodes
.end();
131 // find the first node that matches, but stop if things go wrong
132 for (Nodes::const_iterator i
= start
; i
!= nodes
.end(); ++i
) {
133 if (bannedAction(checklist
, i
))
135 if (checklist
->matchChild(this, i
, *i
)) {
140 if (!checklist
->keepMatching())
141 return -1; // suspend on async calls and stop on failures
144 // zero and not one on empty because in math empty sum equals zero
145 return 0; // all nodes mismatched
151 // Not implemented: OrNode cannot be configured directly. See Acl::AnyOf.