HasComponentData.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/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 auto tok = ConfigParser::strtokFile();
27  if (!tok) {
28  debugs(28, DBG_CRITICAL, "FATAL: \"has\" acl argument missing");
29  self_destruct();
30  return;
31  }
32 
34 
36  debugs(28, DBG_CRITICAL, "FATAL: multiple components not supported for \"has\" acl");
37  self_destruct();
38  return;
39  }
40 }
41 
42 bool
44 {
45  for (const auto method: componentMethods)
46  if (method && (checklist->*method)())
47  return true;
48  return false;
49 }
50 
53 {
54  SBufList sl;
56  sl.push_back(RequestStr);
58  sl.push_back(ResponseStr);
59  if (componentMethods.at(coAle))
60  sl.push_back(AleStr);
61  return sl;
62 }
63 
64 void
66 {
67  if (RequestStr.cmp(token) == 0)
69  else if (ResponseStr.cmp(token) == 0)
71  else if (AleStr.cmp(token) == 0)
73  else {
74  debugs(28, DBG_CRITICAL, "FATAL: unsupported component '" << token << "' for 'has' acl");
75  self_destruct();
76  }
77 }
78 
static const SBuf AleStr
#define DBG_CRITICAL
Definition: Stream.h:37
static char * strtokFile()
Definition: ConfigParser.cc:65
std::list< SBuf > SBufList
Definition: forward.h:22
Definition: SBuf.h:93
bool match(ACLChecklist *) override
void parseComponent(const char *token)
virtual bool hasAle() const =0
static const SBuf RequestStr
void self_destruct(void)
Definition: cache_cf.cc:276
static const SBuf ResponseStr
std::vector< ComponentCheck > componentMethods
component check callbacks, ordered by component kind ID
SBufList dump() const override
virtual bool hasRequest() const =0
virtual bool hasReply() const =0
Definition: parse.c:160
int cmp(const SBuf &S, const size_type n) const
shorthand version for compare()
Definition: SBuf.h:279
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:192
void parse() override

 

Introduction

Documentation

Support

Miscellaneous