]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
5b74111a | 2 | * Copyright (C) 1996-2018 The Squid Software Foundation and contributors |
bbc27441 AJ |
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 | ||
582c2af2 | 9 | #include "squid.h" |
bbaf2685 | 10 | #include "acl/Checklist.h" |
602d9612 | 11 | #include "acl/HierCodeData.h" |
16c5ad96 | 12 | #include "ConfigParser.h" |
ed6e9fb9 | 13 | #include "fatal.h" |
bbaf2685 | 14 | #include "hier_code.h" |
bbaf2685 AJ |
15 | |
16 | ACLHierCodeData::ACLHierCodeData() | |
17 | { | |
18 | // initialize mask to NULL | |
19 | memset(values, 0, sizeof(values)); | |
20 | } | |
21 | ||
22 | ACLHierCodeData::ACLHierCodeData(ACLHierCodeData const &old) | |
23 | { | |
24 | memcpy(values, old.values, sizeof(values) ); | |
25 | } | |
26 | ||
27 | ACLHierCodeData::~ACLHierCodeData() | |
28 | { } | |
29 | ||
30 | bool | |
31 | ACLHierCodeData::match(hier_code toFind) | |
32 | { | |
33 | return values[toFind]; | |
34 | } | |
35 | ||
8966008b | 36 | SBufList |
4f8ca96e | 37 | ACLHierCodeData::dump() const |
bbaf2685 | 38 | { |
8966008b | 39 | SBufList sl; |
bbaf2685 AJ |
40 | |
41 | for (hier_code iter=HIER_NONE; iter<HIER_MAX; ++iter) { | |
42 | if (!values[iter]) continue; | |
8966008b | 43 | sl.push_back(SBuf(hier_code_str[iter])); |
bbaf2685 AJ |
44 | } |
45 | ||
8966008b | 46 | return sl; |
bbaf2685 AJ |
47 | } |
48 | ||
49 | void | |
50 | ACLHierCodeData::parse() | |
51 | { | |
52 | char *t = NULL; | |
53 | ||
16c5ad96 | 54 | while ((t = ConfigParser::strtokFile())) { |
bbaf2685 AJ |
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 | } | |
4b981814 | 60 | if (strcmp(hier_code_str[iter],t) == 0) { |
bbaf2685 AJ |
61 | values[iter] = true; |
62 | break; // back to while-loop | |
63 | } | |
64 | } | |
65 | } | |
66 | } | |
67 | ||
68 | bool | |
69 | ACLHierCodeData::empty() const | |
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 | ||
77 | ACLData<hier_code> * | |
78 | ACLHierCodeData::clone() const | |
79 | { | |
80 | return new ACLHierCodeData(*this); | |
81 | } | |
f53969cc | 82 |