AtStepData.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2022 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/AtStepData.h"
11 #include "acl/Checklist.h"
12 #include "base/EnumIterator.h"
13 #include "cache_cf.h"
14 #include "ConfigParser.h"
15 #include "debug/Stream.h"
16 #include "sbuf/Stream.h"
17 #include "wordlist.h"
18 
19 static inline const char *
20 StepName(const XactionStep xstep)
21 {
22  // keep in sync with XactionStep
23  static const char *StepNames[static_cast<int>(XactionStep::enumEnd_)] = {
24  "[unknown step]"
25  ,"GeneratingCONNECT"
26 #if USE_OPENSSL
27  ,"SslBump1"
28  ,"SslBump2"
29  ,"SslBump3"
30 #endif
31  };
32 
34  return StepNames[static_cast<int>(xstep)];
35 }
36 
37 static XactionStep
38 StepValue(const char *name)
39 {
40  assert(name);
41 
42  for (const auto step: WholeEnum<XactionStep>()) {
43  if (strcasecmp(StepName(step), name) == 0)
44  return static_cast<XactionStep>(step);
45  }
46 
47  throw TextException(ToSBuf("unknown at_step step name: ", name), Here());
48 }
49 
51 {}
52 
54 {
55 }
56 
57 bool
59 {
60  const auto found = std::find(values.cbegin(), values.cend(), toFind);
61  return (found != values.cend());
62 }
63 
66 {
67  SBufList sl;
68  for (const auto value : values)
69  sl.push_back(SBuf(StepName(value)));
70  return sl;
71 }
72 
73 void
75 {
76  while (const auto name = ConfigParser::strtokFile()) {
77  const auto step = StepValue(name);
78  if (step == XactionStep::unknown)
79  throw TextException(ToSBuf("prohibited at_step step name: ", name), Here());
80  values.push_back(step);
81  }
82 }
83 
84 bool
86 {
87  return values.empty();
88 }
89 
static XactionStep StepValue(const char *name)
Definition: AtStepData.cc:38
static const char * StepName(const XactionStep xstep)
Definition: AtStepData.cc:20
#define Here()
source code location of the caller
Definition: Here.h:15
XactionStep
Definition: XactionStep.h:12
#define assert(EX)
Definition: assert.h:19
virtual ~ACLAtStepData()
Definition: AtStepData.cc:53
virtual SBufList dump() const
Definition: AtStepData.cc:65
bool match(XactionStep)
Definition: AtStepData.cc:58
bool empty() const
Definition: AtStepData.cc:85
void parse()
Definition: AtStepData.cc:74
std::list< XactionStep > values
Definition: AtStepData.h:29
static char * strtokFile()
Definition: ConfigParser.cc:64
Definition: SBuf.h:94
an std::runtime_error with thrower location info
Definition: TextException.h:21
SBuf ToSBuf(Args &&... args)
slowly stream-prints all arguments into a freshly allocated SBuf
Definition: Stream.h:63
std::list< SBuf > SBufList
Definition: forward.h:22

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors