Tree.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9#include "squid.h"
10#include "acl/Checklist.h"
11#include "acl/Tree.h"
12#include "wordlist.h"
13
15
18{
19 return actionAt(lastMatch_ - nodes.begin());
20}
21
24{
25 if (actions.empty())
26 return ACCESS_DUNNO;
27 return actions.back();
28}
29
32Acl::Tree::actionAt(const Nodes::size_type pos) const
33{
34 assert(pos < nodes.size());
35 if (actions.size()) {
36 assert(actions.size() == nodes.size());
37 return actions[pos];
38 }
39 // default for matched rules in trees without actions
40 return ACCESS_ALLOWED;
41}
42
43void
45{
46 // either all rules have actions or none
47 assert(nodes.size() == actions.size());
48 InnerNode::add(rule);
49 actions.push_back(action);
50}
51
52void
54{
55 // either all rules have actions or none
56 assert(actions.empty());
57 InnerNode::add(rule);
58}
59
60bool
61Acl::Tree::bannedAction(ACLChecklist *checklist, Nodes::const_iterator node) const
62{
63 if (actions.size()) {
64 assert(actions.size() == nodes.size());
65 const Nodes::size_type pos = node - nodes.begin();
66 return checklist->bannedAction(actions.at(pos));
67 }
68 return false;
69}
70
CBDATA_NAMESPACED_CLASS_INIT(Acl, Tree)
#define assert(EX)
Definition: assert.h:17
bool bannedAction(const Acl::Answer &action) const
whether the action is banned or not
Definition: Checklist.cc:387
Definition: Acl.h:46
std::vector< ACL * > nodes
children nodes of this intermediate node
Definition: InnerNode.h:53
void add(ACL *node)
appends the node to the collection and takes control over it
Definition: InnerNode.cc:35
Nodes::const_iterator lastMatch_
Definition: BoolOps.h:72
void add(ACL *rule, const Answer &action)
appends and takes control over the rule with a given action
Definition: Tree.cc:44
bool bannedAction(ACLChecklist *, Nodes::const_iterator) const override
Acl::OrNode API.
Definition: Tree.cc:61
Answer actionAt(const Nodes::size_type pos) const
computes action that corresponds to the position of the matched rule
Definition: Tree.cc:32
Answer winningAction() const
Returns the corresponding action after a successful tree match.
Definition: Tree.cc:17
Answer lastAction() const
what action to use if no nodes matched
Definition: Tree.cc:23
@ ACCESS_ALLOWED
Definition: Acl.h:116
@ ACCESS_DUNNO
Definition: Acl.h:117
Definition: Acl.cc:31
static bool action(int fd, size_t metasize, const char *fn, const char *url, const SquidMetaList &meta)
Definition: purge.cc:315
Definition: parse.c:104

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors