]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ACL.h
Cleanup: zap CVS Id tags
[thirdparty/squid.git] / src / ACL.h
1 /*
2 * $Id$
3 *
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 #ifndef SQUID_ACL_H
36 #define SQUID_ACL_H
37
38 #include "Array.h"
39 #include "cbdata.h"
40 #include "dlink.h"
41 /**
42 \todo FIXME: finish splitting out the dependencies here
43 * - typedefs should not be needed to parse this.
44 */
45 #include "typedefs.h"
46
47 class ConfigParser;
48
49 /* acl.c */
50
51 /// \ingroup ACLAPI
52 SQUIDCEXTERN void aclDestroyAccessList(acl_access **list);
53 /// \ingroup ACLAPI
54 SQUIDCEXTERN void aclDestroyAcls(ACL **);
55 /// \ingroup ACLAPI
56 SQUIDCEXTERN void aclDestroyAclList(ACLList **);
57 /// \ingroup ACLAPI
58 SQUIDCEXTERN void aclParseAccessLine(ConfigParser &parser, acl_access **);
59 /// \ingroup ACLAPI
60 SQUIDCEXTERN void aclParseAclList(ConfigParser &parser, ACLList **);
61 /// \ingroup ACLAPI
62 SQUIDCEXTERN int aclIsProxyAuth(const char *name);
63 /// \ingroup ACLAPI
64 SQUIDCEXTERN err_type aclGetDenyInfoPage(acl_deny_info_list ** head, const char *name, int redirect_allowed);
65
66 /// \ingroup ACLAPI
67 SQUIDCEXTERN void aclParseDenyInfoLine(struct acl_deny_info_list **);
68
69 /// \ingroup ACLAPI
70 SQUIDCEXTERN void aclDestroyDenyInfoList(struct acl_deny_info_list **);
71 /// \ingroup ACLAPI
72 SQUIDCEXTERN wordlist *aclDumpGeneric(const ACL *);
73 /// \ingroup ACLAPI
74 SQUIDCEXTERN void aclCacheMatchFlush(dlink_list * cache);
75 /// \ingroup ACLAPI
76 extern void dump_acl_access(StoreEntry * entry, const char *name, acl_access * head);
77 /// \ingroup ACLAPI
78 int aclPurgeMethodInUse(acl_access * a);
79 /// \ingroup ACLAPI
80 extern const char *AclMatchedName; /* NULL */
81
82 /// \ingroup ACLAPI
83 class ACL
84 {
85
86 public:
87 void *operator new(size_t);
88 void operator delete(void *);
89
90 static ACL *Factory (char const *);
91 static void ParseAclLine(ConfigParser &parser, ACL ** head);
92 static void Initialize();
93 static ACL* FindByName(const char *name);
94
95 ACL();
96 virtual ~ACL();
97 virtual ACL *clone()const = 0;
98 virtual void parse() = 0;
99 virtual char const *typeString() const = 0;
100 virtual bool isProxyAuth() const;
101 virtual bool requiresRequest() const;
102 virtual bool requiresReply() const;
103 virtual int match(ACLChecklist * checklist) = 0;
104 virtual wordlist *dump() const = 0;
105 virtual bool empty () const = 0;
106 virtual bool valid () const;
107 int checklistMatches(ACLChecklist *);
108
109 int cacheMatchAcl(dlink_list * cache, ACLChecklist *);
110 virtual int matchForCache(ACLChecklist *checklist);
111
112 virtual void prepareForUse() {}
113
114 char name[ACL_NAME_SZ];
115 char *cfgline;
116 ACL *next;
117
118 public:
119
120 class Prototype
121 {
122
123 public:
124 Prototype ();
125 Prototype (ACL const *, char const *);
126 ~Prototype();
127 static bool Registered(char const *);
128 static ACL *Factory (char const *);
129
130 private:
131 ACL const*prototype;
132 char const *typeString;
133
134 private:
135 static Vector<Prototype const *> * Registry;
136 static void *Initialized;
137 typedef Vector<Prototype const*>::iterator iterator;
138 typedef Vector<Prototype const*>::const_iterator const_iterator;
139 void registerMe();
140 };
141 };
142
143 /// \ingroup ACLAPI
144 class acl_access
145 {
146
147 public:
148 void *operator new(size_t);
149 void operator delete(void *);
150 bool containsPURGE() const;
151 allow_t allow;
152 ACLList *aclList;
153 char *cfgline;
154 acl_access *next;
155
156 private:
157 CBDATA_CLASS(acl_access);
158 };
159
160 /// \ingroup ACLAPI
161 class ACLList
162 {
163
164 public:
165 MEMPROXY_CLASS(ACLList);
166
167 ACLList();
168 void negated(bool isNegated);
169 bool matches (ACLChecklist *)const;
170 int op;
171 ACL *_acl;
172 ACLList *next;
173 };
174
175 MEMPROXY_CLASS_INLINE(ACLList);
176
177 /// \ingroup ACLAPI
178 class acl_proxy_auth_match_cache
179 {
180
181 public:
182 MEMPROXY_CLASS(acl_proxy_auth_match_cache);
183 dlink_node link;
184 int matchrv;
185 void *acl_data;
186 };
187
188 MEMPROXY_CLASS_INLINE(acl_proxy_auth_match_cache);
189
190 #endif /* SQUID_ACL_H */