ProtocolData.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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.h"
16 #include "wordlist.h"
17 
19 {
20  assert(old.values.empty());
21 }
22 
24 {
25  values.clear();
26 }
27 
28 bool
30 {
31  for (auto itr = values.begin(); itr != values.end(); ++itr) {
32  if (*itr == toFind) {
33  // tune the list for LRU ordering
34  values.erase(itr);
35  values.push_front(toFind);
36  return true;
37  }
38  }
39  return false;
40 }
41 
44 {
45  SBufList sl;
46  for (std::list<AnyP::ProtocolType>::const_iterator itr = values.begin(); itr != values.end(); ++itr) {
47  sl.push_back(SBuf(AnyP::ProtocolType_str[*itr]));
48  }
49 
50  return sl;
51 }
52 
53 void
55 {
56  while (char *t = ConfigParser::strtokFile()) {
57  int p = AnyP::PROTO_NONE;
58  for (; p < AnyP::PROTO_UNKNOWN; ++p) {
59  if (strcasecmp(t, AnyP::ProtocolType_str[p]) == 0) {
60  values.push_back(static_cast<AnyP::ProtocolType>(p));
61  break;
62  }
63  }
64  if (p == AnyP::PROTO_UNKNOWN) {
65  debugs(28, DBG_IMPORTANT, "WARNING: Ignoring unknown protocol '" << t << "' in the ACL named '" << AclMatchedName << "'");
66  // XXX: store the text pattern of this protocol name for live comparisons
67  }
68  }
69 }
70 
73 {
74  /* Splay trees don't clone yet. */
75  assert(values.empty());
76  return new ACLProtocolData(*this);
77 }
78 
bool match(AnyP::ProtocolType)
Definition: ProtocolData.cc:29
#define assert(EX)
Definition: assert.h:17
Definition: SBuf.h:87
char * p
Definition: membanger.c:43
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
#define DBG_IMPORTANT
Definition: Debug.h:45
const char * AclMatchedName
Definition: Acl.cc:30
virtual ~ACLProtocolData()
Definition: ProtocolData.cc:23
std::list< SBuf > SBufList
Definition: forward.h:26
static char * strtokFile()
Definition: ConfigParser.cc:82
virtual ACLData< AnyP::ProtocolType > * clone() const
Definition: ProtocolData.cc:72
ProtocolType
Definition: ProtocolType.h:22
virtual SBufList dump() const
Definition: ProtocolData.cc:43
const char * ProtocolType_str[]
std::list< AnyP::ProtocolType > values
Definition: ProtocolData.h:33

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors