AccessRule.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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/Gadgets.h"
11 #include "acl/Tree.h"
12 #include "adaptation/AccessRule.h"
13 #include "adaptation/Service.h"
15 #include "ConfigParser.h"
16 #include "Debug.h"
17 
19 
20 Adaptation::AccessRule::AccessRule(const String &aGroupId): id(++LastId), groupId(aGroupId), acl(NULL)
21 {
22 }
23 
25 {
26  delete acl;
27 }
28 
29 void
31 {
32  aclParseAccessLine("adaptation_access", parser, &acl);
33 }
34 
35 void
37 {
38  if (!group()) { // no explicit group
39  debugs(93,7, HERE << "no service group: " << groupId);
40  // try to add a one-service group
41  if (FindService(groupId) != NULL) {
42  ServiceGroupPointer g = new SingleService(groupId);
43  g->finalize(); // explicit groups were finalized before rules
44  AllGroups().push_back(g);
45  }
46  }
47 
48  if (!group()) {
49  debugs(93, DBG_CRITICAL, "ERROR: Unknown adaptation service or group name: '" <<
50  groupId << "'"); // TODO: fail on failures
51  }
52 }
53 
56 {
57  return FindGroup(groupId);
58 }
59 
62 {
63  static AccessRules *TheRules = new AccessRules;
64  return *TheRules;
65 }
66 
67 // TODO: make AccessRules::find work
70 {
71  typedef AccessRules::iterator ARI;
72  for (ARI i = AllRules().begin(); i != AllRules().end(); ++i) {
73  if ((*i)->id == id)
74  return *i;
75  }
76 
77  return NULL;
78 }
79 
82 {
83  typedef AccessRules::iterator ARI;
84  for (ARI i = AllRules().begin(); i != AllRules().end(); ++i) {
85  if ((*i)->groupId == groupId)
86  return *i;
87  }
88 
89  return NULL;
90 }
91 
AccessRule * FindRuleByGroupId(const String &groupId)
Definition: AccessRule.cc:81
int i
Definition: membanger.c:49
AccessRule * FindRule(const AccessRule::Id &id)
Definition: AccessRule.cc:69
#define DBG_CRITICAL
Definition: Debug.h:44
ServiceGroupPointer FindGroup(const ServiceGroup::Id &id)
ServicePointer FindService(const Service::Id &key)
Definition: Service.cc:68
std::vector< Adaptation::AccessRule * > AccessRules
Definition: AccessRule.h:47
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
ServiceGroupPointer group()
Definition: AccessRule.cc:55
AccessRules & AllRules()
Definition: AccessRule.cc:61
std::ostream & HERE(std::ostream &s)
Definition: Debug.h:147
void parse(ConfigParser &parser)
Definition: AccessRule.cc:30
AccessRule(const String &groupId)
Definition: AccessRule.cc:20
#define NULL
Definition: types.h:166
Groups & AllGroups()
void aclParseAccessLine(const char *directive, ConfigParser &, acl_access **treep)
Definition: Gadgets.cc:145

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors