AtStepData.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/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
19static inline const char *
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
37static XactionStep
38StepValue(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
57bool
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
73void
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
84bool
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:17
bool empty() const override
Definition: AtStepData.cc:85
bool match(XactionStep) override
Definition: AtStepData.cc:58
void parse() override
Definition: AtStepData.cc:74
SBufList dump() const override
Definition: AtStepData.cc:65
std::list< XactionStep > values
Definition: AtStepData.h:29
~ACLAtStepData() override
Definition: AtStepData.cc:53
static char * strtokFile()
Definition: ConfigParser.cc:65
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:23

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors