]> git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/HierCodeData.cc
Removed inclusion of protos.h from most clients.
[thirdparty/squid.git] / src / acl / HierCodeData.cc
1 #include "squid.h"
2 #include "acl/HierCodeData.h"
3 #include "acl/Checklist.h"
4 #include "cache_cf.h"
5 #include "hier_code.h"
6 #include "wordlist.h"
7
8 ACLHierCodeData::ACLHierCodeData()
9 {
10 // initialize mask to NULL
11 memset(values, 0, sizeof(values));
12 }
13
14 ACLHierCodeData::ACLHierCodeData(ACLHierCodeData const &old)
15 {
16 memcpy(values, old.values, sizeof(values) );
17 }
18
19 ACLHierCodeData::~ACLHierCodeData()
20 { }
21
22 bool
23 ACLHierCodeData::match(hier_code toFind)
24 {
25 return values[toFind];
26 }
27
28 wordlist *
29 ACLHierCodeData::dump()
30 {
31 wordlist *W = NULL;
32
33 for (hier_code iter=HIER_NONE; iter<HIER_MAX; ++iter) {
34 if (!values[iter]) continue;
35 wordlistAdd(&W, hier_code_str[iter]);
36 }
37
38 return W;
39 }
40
41 void
42 ACLHierCodeData::parse()
43 {
44 char *t = NULL;
45
46 while ((t = strtokFile())) {
47 for (hier_code iter = HIER_NONE; iter <= HIER_MAX; ++iter) {
48 if (iter == HIER_MAX) {
49 fatalf("ERROR: No such hier_code '%s'",t);
50 return;
51 }
52 if (strcmp(hier_code_str[iter],t) == 0) {
53 values[iter] = true;
54 break; // back to while-loop
55 }
56 }
57 }
58 }
59
60 bool
61 ACLHierCodeData::empty() const
62 {
63 for (hier_code iter = HIER_NONE; iter <= HIER_MAX; ++iter) {
64 if (values[iter]) return false; // not empty.
65 }
66 return true;
67 }
68
69 ACLData<hier_code> *
70 ACLHierCodeData::clone() const
71 {
72 return new ACLHierCodeData(*this);
73 }