HasComponentData.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/HasComponentData.h"
11 #include "cache_cf.h"
12 #include "ConfigParser.h"
13 #include "sbuf/Algorithms.h"
14 
15 const SBuf ACLHasComponentData::RequestStr("request");
16 const SBuf ACLHasComponentData::ResponseStr("response");
18 
20  : componentMethods(coEnd, nullptr)
21 { }
22 
23 void
25 {
26  const char *tok = ConfigParser::NextToken();
27  if (!tok) {
28  debugs(28, DBG_CRITICAL, "FATAL: \"has\" acl argument missing");
29  self_destruct();
30  return;
31  }
33  debugs(28, DBG_CRITICAL, "FATAL: multiple components not supported for \"has\" acl");
34  self_destruct();
35  return;
36  }
37  parseComponent(tok);
38 }
39 
40 bool
42 {
43  for (const auto method: componentMethods)
44  if (method && (checklist->*method)())
45  return true;
46  return false;
47 }
48 
51 {
52  SBufList sl;
54  sl.push_back(RequestStr);
56  sl.push_back(ResponseStr);
57  if (componentMethods.at(coAle))
58  sl.push_back(AleStr);
59  return sl;
60 }
61 
62 void
64 {
65  if (RequestStr.cmp(token) == 0)
67  else if (ResponseStr.cmp(token) == 0)
69  else if (AleStr.cmp(token) == 0)
71  else {
72  debugs(28, DBG_CRITICAL, "FATAL: unsupported component '" << token << "' for 'has' acl");
73  self_destruct();
74  }
75 }
76 
79 {
80  return new ACLHasComponentData(*this);
81 }
82 
std::vector< ComponentCheck > componentMethods
component check callbacks, ordered by component kind ID
virtual void parse() override
Definition: SBuf.h:87
void parseComponent(const char *token)
void self_destruct(void)
Definition: cache_cf.cc:255
virtual ACLData< ACLChecklist * > * clone() const override
virtual bool hasAle() const =0
static char * PeekAtToken()
#define DBG_CRITICAL
Definition: Debug.h:44
virtual bool match(ACLChecklist *) override
virtual SBufList dump() const override
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
virtual bool hasRequest() const =0
static const SBuf ResponseStr
static char * NextToken()
Definition: parse.c:160
std::list< SBuf > SBufList
Definition: forward.h:26
virtual bool hasReply() const =0
size_t HttpReply *STUB StoreEntry const KeyScope scope const HttpRequestMethod & method
Definition: stub_store.cc:126
int cmp(const SBuf &S, const size_type n) const
shorthand version for compare()
Definition: SBuf.h:265
static const SBuf RequestStr
static const SBuf AleStr

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors