]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/AtStepData.cc
2 * Copyright (C) 1996-2023 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"
19 static inline const char *
20 StepName(const XactionStep xstep
)
22 // keep in sync with XactionStep
23 static const char *StepNames
[static_cast<int>(XactionStep::enumEnd_
)] = {
33 assert(XactionStep::enumBegin_
<= xstep
&& xstep
< XactionStep::enumEnd_
);
34 return StepNames
[static_cast<int>(xstep
)];
38 StepValue(const char *name
)
42 for (const auto step
: WholeEnum
<XactionStep
>()) {
43 if (strcasecmp(StepName(step
), name
) == 0)
44 return static_cast<XactionStep
>(step
);
47 throw TextException(ToSBuf("unknown at_step step name: ", name
), Here());
50 ACLAtStepData::ACLAtStepData()
53 ACLAtStepData::~ACLAtStepData()
58 ACLAtStepData::match(XactionStep toFind
)
60 const auto found
= std::find(values
.cbegin(), values
.cend(), toFind
);
61 return (found
!= values
.cend());
65 ACLAtStepData::dump() const
68 for (const auto value
: values
)
69 sl
.push_back(SBuf(StepName(value
)));
74 ACLAtStepData::parse()
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
);
85 ACLAtStepData::empty() const
87 return values
.empty();