HierCodeData.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 #include "squid.h"
10 #include "acl/Checklist.h"
11 #include "acl/HierCodeData.h"
12 #include "ConfigParser.h"
13 #include "fatal.h"
14 #include "hier_code.h"
15 
17 {
18  // initialize mask to NULL
19  memset(values, 0, sizeof(values));
20 }
21 
23 {
24  memcpy(values, old.values, sizeof(values) );
25 }
26 
28 { }
29 
30 bool
32 {
33  return values[toFind];
34 }
35 
38 {
39  SBufList sl;
40 
41  for (hier_code iter=HIER_NONE; iter<HIER_MAX; ++iter) {
42  if (!values[iter]) continue;
43  sl.push_back(SBuf(hier_code_str[iter]));
44  }
45 
46  return sl;
47 }
48 
49 void
51 {
52  char *t = NULL;
53 
54  while ((t = ConfigParser::strtokFile())) {
55  for (hier_code iter = HIER_NONE; iter <= HIER_MAX; ++iter) {
56  if (iter == HIER_MAX) {
57  fatalf("ERROR: No such hier_code '%s'",t);
58  return;
59  }
60  if (strcmp(hier_code_str[iter],t) == 0) {
61  values[iter] = true;
62  break; // back to while-loop
63  }
64  }
65  }
66 }
67 
68 bool
70 {
71  for (hier_code iter = HIER_NONE; iter <= HIER_MAX; ++iter) {
72  if (values[iter]) return false; // not empty.
73  }
74  return true;
75 }
76 
79 {
80  return new ACLHierCodeData(*this);
81 }
82 
bool values[HIER_MAX]
mask of codes this ACL might match.
Definition: HierCodeData.h:32
virtual SBufList dump() const
Definition: HierCodeData.cc:37
Definition: SBuf.h:87
virtual ~ACLHierCodeData()
Definition: HierCodeData.cc:27
void fatalf(const char *fmt,...)
Definition: fatal.cc:79
std::list< SBuf > SBufList
Definition: forward.h:26
bool match(hier_code)
Definition: HierCodeData.cc:31
virtual ACLData< hier_code > * clone() const
Definition: HierCodeData.cc:78
hier_code
Definition: hier_code.h:12
static char * strtokFile()
Definition: ConfigParser.cc:82
bool empty() const
Definition: HierCodeData.cc:69
const char * hier_code_str[]
#define NULL
Definition: types.h:166

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors