HierCodeData.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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 
25 bool
27 {
28  return values[toFind];
29 }
30 
33 {
34  SBufList sl;
35 
36  for (hier_code iter=HIER_NONE; iter<HIER_MAX; ++iter) {
37  if (!values[iter]) continue;
38  sl.push_back(SBuf(hier_code_str[iter]));
39  }
40 
41  return sl;
42 }
43 
44 void
46 {
47  char *t = nullptr;
48 
49  while ((t = ConfigParser::strtokFile())) {
50  for (hier_code iter = HIER_NONE; iter <= HIER_MAX; ++iter) {
51  if (iter == HIER_MAX) {
52  fatalf("ERROR: No such hier_code '%s'",t);
53  return;
54  }
55  if (strcmp(hier_code_str[iter],t) == 0) {
56  values[iter] = true;
57  break; // back to while-loop
58  }
59  }
60  }
61 }
62 
63 bool
65 {
66  for (hier_code iter = HIER_NONE; iter <= HIER_MAX; ++iter) {
67  if (values[iter]) return false; // not empty.
68  }
69  return true;
70 }
71 
~ACLHierCodeData() override
Definition: HierCodeData.cc:22
static char * strtokFile()
Definition: ConfigParser.cc:65
std::list< SBuf > SBufList
Definition: forward.h:22
Definition: SBuf.h:93
SBufList dump() const override
Definition: HierCodeData.cc:32
bool match(hier_code) override
Definition: HierCodeData.cc:26
@ HIER_MAX
Definition: hier_code.h:38
@ HIER_NONE
Definition: hier_code.h:13
void fatalf(const char *fmt,...)
Definition: fatal.cc:68
void parse() override
Definition: HierCodeData.cc:45
const char * hier_code_str[]
bool values[HIER_MAX]
mask of codes this ACL might match.
Definition: HierCodeData.h:29
hier_code
Definition: hier_code.h:12
bool empty() const override
Definition: HierCodeData.cc:64

 

Introduction

Documentation

Support

Miscellaneous