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
21static inline const char *
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
36 return StepNames[static_cast<int>(xstep)];
37}
38
39static XactionStep
40StepValue(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
54
58
59bool
61{
62 const auto found = std::find(values.cbegin(), values.cend(), toFind);
63 return (found != values.cend());
64}
65
68{
69 SBufList sl;
70 for (const auto value : values)
71 sl.push_back(SBuf(StepName(value)));
72 return sl;
73}
74
75void
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
86bool
88{
89 return values.empty();
90}
91
static XactionStep StepValue(const char *name)
Definition AtStepData.cc:40
static const char * StepName(const XactionStep xstep)
Definition AtStepData.cc:22
#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:87
bool match(XactionStep) override
Definition AtStepData.cc:60
void parse() override
Definition AtStepData.cc:76
SBufList dump() const override
Definition AtStepData.cc:67
std::list< XactionStep > values
Definition AtStepData.h:29
~ACLAtStepData() override
Definition AtStepData.cc:55
static char * strtokFile()
Definition SBuf.h:94
an std::runtime_error with thrower location info
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