]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/AllOf.cc
d46b8e86f84e229640b5069d50182bc64a83a567
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/AllOf.h"
11 #include "acl/BoolOps.h"
12 #include "acl/Checklist.h"
17 Acl::AllOf::typeString() const
23 Acl::AllOf::clone() const
29 Acl::AllOf::dump() const
31 return empty() ? SBufList() : nodes
.front()->dump();
35 Acl::AllOf::doMatch(ACLChecklist
*checklist
, Nodes::const_iterator start
) const
37 assert(start
== nodes
.begin()); // we only have one node
39 // avoid dereferencing invalid start
41 return 1; // not 0 because in math empty product equals identity
43 if (checklist
->matchChild(this, start
, *start
))
46 return checklist
->keepMatching() ? 0 : -1;
49 // called once per "acl name all-of name1 name2 ...." line
53 Acl::InnerNode
*whole
= NULL
;
54 ACL
*oldNode
= empty() ? NULL
: nodes
.front();
56 // optimization: this logic reduces subtree hight (number of tree levels)
57 if (Acl::OrNode
*oldWhole
= dynamic_cast<Acl::OrNode
*>(oldNode
)) {
58 // this acl saw multiple lines before; add another one to the old node
61 // this acl saw a single line before; create a new OR inner node
65 wholeCtx
.appendf("(%s lines)", name
);
68 Acl::OrNode
*newWhole
= new Acl::OrNode
;
69 newWhole
->context(wholeCtx
.content(), oldNode
->cfgline
);
70 newWhole
->add(oldNode
); // old (i.e. first) line
71 nodes
.front() = whole
= newWhole
;
73 // this is the first line for this acl; just use it as is
78 const int lineId
= whole
->childrenCount() + 1;
82 lineCtx
.appendf("(%s line #%d)", name
, lineId
);
85 Acl::AndNode
*line
= new AndNode
;
86 line
->context(lineCtx
.content(), config_input_line
);