]> git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/MethodData.cc
Merged from trunk
[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 "wordlist.h"
41
42 int ACLMethodData::ThePurgeCount = 0;
43
44 ACLMethodData::ACLMethodData() : values (NULL)
45 {}
46
47 ACLMethodData::ACLMethodData(ACLMethodData const &old) : values (NULL)
48 {
49 assert (!old.values);
50 }
51
52 ACLMethodData::~ACLMethodData()
53 {
54 if (values)
55 delete values;
56 }
57
58 /// todo make this a pass-by-reference now that HTTPRequestMethods a full class?
59 bool
60 ACLMethodData::match(HttpRequestMethod toFind)
61 {
62 return values->findAndTune(toFind);
63 }
64
65 /* explicit instantiation required for some systems */
66
67 /// \cond AUTODOCS-IGNORE
68 template cbdata_type CbDataList<HttpRequestMethod>::CBDATA_CbDataList;
69 /// \endcond
70
71 wordlist *
72 ACLMethodData::dump()
73 {
74 wordlist *W = NULL;
75 CbDataList<HttpRequestMethod> *data = values;
76
77 while (data != NULL) {
78 wordlistAdd(&W, RequestMethodStr(data->element));
79 data = data->next;
80 }
81
82 return W;
83 }
84
85 void
86 ACLMethodData::parse()
87 {
88 CbDataList<HttpRequestMethod> **Tail;
89 char *t = NULL;
90
91 for (Tail = &values; *Tail; Tail = &((*Tail)->next));
92 while ((t = strtokFile())) {
93 if (strcmp(t, "PURGE") == 0)
94 ++ThePurgeCount; // configuration code wants to know
95 CbDataList<HttpRequestMethod> *q = new CbDataList<HttpRequestMethod> (HttpRequestMethod(t, NULL));
96 *(Tail) = q;
97 Tail = &q->next;
98 }
99 }
100
101 bool
102 ACLMethodData::empty() const
103 {
104 return values == NULL;
105 }
106
107 ACLData<HttpRequestMethod> *
108 ACLMethodData::clone() const
109 {
110 assert (!values);
111 return new ACLMethodData(*this);
112 }