]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/HasComponentData.cc
2 * Copyright (C) 1996-2019 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/HasComponentData.h"
12 #include "ConfigParser.h"
13 #include "sbuf/Algorithms.h"
15 const SBuf
ACLHasComponentData::RequestStr("request");
16 const SBuf
ACLHasComponentData::ResponseStr("response");
17 const SBuf
ACLHasComponentData::AleStr("ALE");
19 ACLHasComponentData::ACLHasComponentData()
20 : componentMethods(coEnd
, nullptr)
24 ACLHasComponentData::parse()
26 const char *tok
= ConfigParser::NextToken();
28 debugs(28, DBG_CRITICAL
, "FATAL: \"has\" acl argument missing");
32 if (ConfigParser::PeekAtToken()) {
33 debugs(28, DBG_CRITICAL
, "FATAL: multiple components not supported for \"has\" acl");
41 ACLHasComponentData::match(ACLChecklist
*checklist
)
43 for (const auto method
: componentMethods
)
44 if (method
&& (checklist
->*method
)())
50 ACLHasComponentData::dump() const
53 if (componentMethods
.at(coRequest
))
54 sl
.push_back(RequestStr
);
55 if (componentMethods
.at(coResponse
))
56 sl
.push_back(ResponseStr
);
57 if (componentMethods
.at(coAle
))
63 ACLHasComponentData::parseComponent(const char *token
)
65 if (RequestStr
.cmp(token
) == 0)
66 componentMethods
[coRequest
] = &ACLChecklist::hasRequest
;
67 else if (ResponseStr
.cmp(token
) == 0)
68 componentMethods
[coResponse
] = &ACLChecklist::hasReply
;
69 else if (AleStr
.cmp(token
) == 0)
70 componentMethods
[coAle
] = &ACLChecklist::hasAle
;
72 debugs(28, DBG_CRITICAL
, "FATAL: unsupported component '" << token
<< "' for 'has' acl");
77 ACLData
<ACLChecklist
*> *
78 ACLHasComponentData::clone() const
80 return new ACLHasComponentData(*this);