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