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