]> git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/MethodData.cc
Moved prototypes: snmpStatGet to stat.h and strtokFile to cache_cf.h
[thirdparty/squid.git] / src / acl / MethodData.cc
1 /*
2 * DEBUG: section 28 Access Control
3 * AUTHOR: Duane Wessels
4 *
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
7 *
8 * Squid is the result of efforts by numerous individuals from
9 * the Internet community; see the CONTRIBUTORS file for full
10 * details. Many organizations have provided support for Squid's
11 * development; see the SPONSORS file for full details. Squid is
12 * Copyrighted (C) 2001 by the Regents of the University of
13 * California; see the COPYRIGHT file for full details. Squid
14 * incorporates software developed and/or copyrighted by other
15 * sources; see the CREDITS file for full details.
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
30 *
31 *
32 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
33 */
34
35 #include "squid.h"
36 #include "acl/MethodData.h"
37 #include "acl/Checklist.h"
38 #include "cache_cf.h"
39 #include "HttpRequestMethod.h"
40 #include "protos.h"
41 #include "wordlist.h"
42
43 int ACLMethodData::ThePurgeCount = 0;
44
45 ACLMethodData::ACLMethodData() : values (NULL)
46 {}
47
48 ACLMethodData::ACLMethodData(ACLMethodData const &old) : values (NULL)
49 {
50 assert (!old.values);
51 }
52
53 ACLMethodData::~ACLMethodData()
54 {
55 if (values)
56 delete values;
57 }
58
59 /// todo make this a pass-by-reference now that HTTPRequestMethods a full class?
60 bool
61 ACLMethodData::match(HttpRequestMethod toFind)
62 {
63 return values->findAndTune(toFind);
64 }
65
66 /* explicit instantiation required for some systems */
67
68 /// \cond AUTODOCS-IGNORE
69 template cbdata_type CbDataList<HttpRequestMethod>::CBDATA_CbDataList;
70 /// \endcond
71
72 wordlist *
73 ACLMethodData::dump()
74 {
75 wordlist *W = NULL;
76 CbDataList<HttpRequestMethod> *data = values;
77
78 while (data != NULL) {
79 wordlistAdd(&W, RequestMethodStr(data->element));
80 data = data->next;
81 }
82
83 return W;
84 }
85
86 void
87 ACLMethodData::parse()
88 {
89 CbDataList<HttpRequestMethod> **Tail;
90 char *t = NULL;
91
92 for (Tail = &values; *Tail; Tail = &((*Tail)->next));
93 while ((t = strtokFile())) {
94 if (strcmp(t, "PURGE") == 0)
95 ++ThePurgeCount; // configuration code wants to know
96 CbDataList<HttpRequestMethod> *q = new CbDataList<HttpRequestMethod> (HttpRequestMethod(t, NULL));
97 *(Tail) = q;
98 Tail = &q->next;
99 }
100 }
101
102 bool
103 ACLMethodData::empty() const
104 {
105 return values == NULL;
106 }
107
108 ACLData<HttpRequestMethod> *
109 ACLMethodData::clone() const
110 {
111 assert (!values);
112 return new ACLMethodData(*this);
113 }