]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/AtStepData.cc
cc3bb80d208fece7a328d83678efe232fb36d82d
2 * Copyright (C) 1996-2025 The Squid Software Foundation and contributors
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.
10 #include "acl/AtStepData.h"
11 #include "acl/Checklist.h"
12 #include "base/EnumIterator.h"
14 #include "ConfigParser.h"
15 #include "debug/Stream.h"
16 #include "sbuf/Stream.h"
21 static inline const char *
22 StepName(const XactionStep xstep
)
24 // keep in sync with XactionStep
25 static const char *StepNames
[static_cast<int>(XactionStep::enumEnd_
)] = {
35 assert(XactionStep::enumBegin_
<= xstep
&& xstep
< XactionStep::enumEnd_
);
36 return StepNames
[static_cast<int>(xstep
)];
40 StepValue(const char *name
)
44 for (const auto step
: WholeEnum
<XactionStep
>()) {
45 if (strcasecmp(StepName(step
), name
) == 0)
46 return static_cast<XactionStep
>(step
);
49 throw TextException(ToSBuf("unknown at_step step name: ", name
), Here());
52 ACLAtStepData::ACLAtStepData()
55 ACLAtStepData::~ACLAtStepData()
60 ACLAtStepData::match(XactionStep toFind
)
62 const auto found
= std::find(values
.cbegin(), values
.cend(), toFind
);
63 return (found
!= values
.cend());
67 ACLAtStepData::dump() const
70 for (const auto value
: values
)
71 sl
.push_back(SBuf(StepName(value
)));
76 ACLAtStepData::parse()
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
);
87 ACLAtStepData::empty() const
89 return values
.empty();