]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/InnerNode.cc
3 #include "acl/BoolOps.h"
4 #include "acl/Checklist.h"
5 #include "acl/Gadgets.h"
6 #include "acl/InnerNode.h"
8 #include "ConfigParser.h"
15 // "delete acl" class to use with std::for_each() in InnerNode::~InnerNode()
18 void operator()(ACL
* acl
) {
19 // Do not delete explicit ACLs; they are maintained by Config.aclList.
20 if (acl
&& !acl
->registered
)
26 Acl::InnerNode::~InnerNode()
28 std::for_each(nodes
.begin(), nodes
.end(), AclDeleter());
32 Acl::InnerNode::prepareForUse()
34 std::for_each(nodes
.begin(), nodes
.end(), std::mem_fun(&ACL::prepareForUse
));
38 Acl::InnerNode::empty() const
44 Acl::InnerNode::add(ACL
*node
)
47 nodes
.push_back(node
);
50 // one call parses one "acl name acltype name1 name2 ..." line
51 // kids use this method to handle [multiple] parse() calls correctly
53 Acl::InnerNode::lineParse()
55 // XXX: not precise, may change when looping or parsing multiple lines
57 cfgline
= xstrdup(config_input_line
);
59 // expect a list of ACL names, each possibly preceeded by '!' for negation
61 while (const char *t
= ConfigParser::strtokFile()) {
62 const bool negated
= (*t
== '!');
66 debugs(28, 3, "looking for ACL " << t
);
67 ACL
*a
= ACL::FindByName(t
);
70 debugs(28, DBG_CRITICAL
, "ACL not found: " << t
);
75 // append(negated ? new NotNode(a) : a);
86 Acl::InnerNode::dump() const
88 wordlist
*values
= NULL
;
89 for (Nodes::const_iterator i
= nodes
.begin(); i
!= nodes
.end(); ++i
)
90 wordlistAdd(&values
, (*i
)->name
);
95 Acl::InnerNode::match(ACLChecklist
*checklist
)
97 return doMatch(checklist
, nodes
.begin());
101 Acl::InnerNode::resumeMatchingAt(ACLChecklist
*checklist
, Nodes::const_iterator pos
) const
103 debugs(28, 5, "checking " << name
<< " at " << (pos
-nodes
.begin()));
104 const int result
= doMatch(checklist
, pos
);
105 const char *extra
= checklist
->asyncInProgress() ? " async" : "";
106 debugs(28, 3, "checked: " << name
<< " = " << result
<< extra
);
108 // merges async and failures (-1) into "not matched"