ProtocolData.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2022 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 /* DEBUG: section 28 Access Control */
10 
11 #include "squid.h"
12 #include "acl/Checklist.h"
13 #include "acl/ProtocolData.h"
14 #include "ConfigParser.h"
15 #include "debug/Stream.h"
16 #include "wordlist.h"
17 
19 {
20  values.clear();
21 }
22 
23 bool
25 {
26  for (auto itr = values.begin(); itr != values.end(); ++itr) {
27  if (*itr == toFind) {
28  // tune the list for LRU ordering
29  values.erase(itr);
30  values.push_front(toFind);
31  return true;
32  }
33  }
34  return false;
35 }
36 
39 {
40  SBufList sl;
41  for (std::list<AnyP::ProtocolType>::const_iterator itr = values.begin(); itr != values.end(); ++itr) {
42  sl.push_back(SBuf(AnyP::ProtocolType_str[*itr]));
43  }
44 
45  return sl;
46 }
47 
48 void
50 {
51  while (char *t = ConfigParser::strtokFile()) {
52  int p = AnyP::PROTO_NONE;
53  for (; p < AnyP::PROTO_UNKNOWN; ++p) {
54  if (strcasecmp(t, AnyP::ProtocolType_str[p]) == 0) {
55  values.push_back(static_cast<AnyP::ProtocolType>(p));
56  break;
57  }
58  }
59  if (p == AnyP::PROTO_UNKNOWN) {
60  debugs(28, DBG_IMPORTANT, "WARNING: Ignoring unknown protocol '" << t << "' in the ACL named '" << AclMatchedName << "'");
61  // XXX: store the text pattern of this protocol name for live comparisons
62  }
63  }
64 }
65 
std::list< AnyP::ProtocolType > values
Definition: ProtocolData.h:30
virtual ~ACLProtocolData()
Definition: ProtocolData.cc:18
virtual SBufList dump() const
Definition: ProtocolData.cc:38
bool match(AnyP::ProtocolType)
Definition: ProtocolData.cc:24
static char * strtokFile()
Definition: ConfigParser.cc:64
Definition: SBuf.h:94
#define DBG_IMPORTANT
Definition: Stream.h:41
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:196
const char * AclMatchedName
Definition: Acl.cc:29
const char * ProtocolType_str[]
ProtocolType
Definition: ProtocolType.h:23
@ PROTO_NONE
Definition: ProtocolType.h:24
@ PROTO_UNKNOWN
Definition: ProtocolType.h:43
std::list< SBuf > SBufList
Definition: forward.h:22

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors