]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ACL.h
Bug #1166: Configuration confusing when empty acls are encountered
[thirdparty/squid.git] / src / ACL.h
1
2 /*
3 * $Id: ACL.h,v 1.13 2005/05/06 01:57:55 hno Exp $
4 *
5 *
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
8 *
9 * Squid is the result of efforts by numerous individuals from
10 * the Internet community; see the CONTRIBUTORS file for full
11 * details. Many organizations have provided support for Squid's
12 * development; see the SPONSORS file for full details. Squid is
13 * Copyrighted (C) 2001 by the Regents of the University of
14 * California; see the COPYRIGHT file for full details. Squid
15 * incorporates software developed and/or copyrighted by other
16 * sources; see the CREDITS file for full details.
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
31 *
32 *
33 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
34 */
35
36 #ifndef SQUID_ACL_H
37 #define SQUID_ACL_H
38 #include "Array.h"
39
40 /* acl.c */
41 SQUIDCEXTERN void aclDestroyAccessList(acl_access **list);
42 SQUIDCEXTERN void aclDestroyAcls(ACL **);
43 SQUIDCEXTERN void aclDestroyAclList(acl_list **);
44 SQUIDCEXTERN void aclParseAccessLine(acl_access **);
45 SQUIDCEXTERN void aclParseAclList(acl_list **);
46 SQUIDCEXTERN int aclIsProxyAuth(const char *name);
47 SQUIDCEXTERN err_type aclGetDenyInfoPage(acl_deny_info_list ** head, const char *name);
48
49 SQUIDCEXTERN void aclParseDenyInfoLine(struct _acl_deny_info_list **);
50
51 SQUIDCEXTERN void aclDestroyDenyInfoList(struct _acl_deny_info_list **);
52 SQUIDCEXTERN wordlist *aclDumpGeneric(const ACL *);
53 SQUIDCEXTERN void aclCacheMatchFlush(dlink_list * cache);
54 extern void dump_acl_access(StoreEntry * entry, const char *name, acl_access * head);
55 int aclPurgeMethodInUse(acl_access * a);
56 extern const char *AclMatchedName; /* NULL */
57
58 class ACL
59 {
60
61 public:
62 void *operator new(size_t);
63 void operator delete(void *);
64
65 static ACL *Factory (char const *);
66 static void ParseAclLine(ACL ** head);
67 static void Initialize();
68 static ACL* FindByName(const char *name);
69
70 ACL();
71 virtual ~ACL();
72 virtual ACL *clone()const = 0;
73 virtual void parse() = 0;
74 virtual char const *typeString() const = 0;
75 virtual bool isProxyAuth() const;
76 virtual bool requiresRequest() const;
77 virtual bool requiresReply() const;
78 virtual int match(ACLChecklist * checklist) = 0;
79 virtual wordlist *dumpGeneric() const;
80 virtual wordlist *dump() const = 0;
81 virtual bool empty () const = 0;
82 virtual bool valid () const;
83 int checklistMatches(ACLChecklist *);
84
85 int cacheMatchAcl(dlink_list * cache, ACLChecklist *);
86 virtual int matchForCache(ACLChecklist *checklist);
87
88 virtual void prepareForUse() {}
89
90 char name[ACL_NAME_SZ];
91 char *cfgline;
92 ACL *next;
93
94 public:
95
96 class Prototype
97 {
98
99 public:
100 Prototype ();
101 Prototype (ACL const *, char const *);
102 ~Prototype();
103 static bool Registered(char const *);
104 static ACL *Factory (char const *);
105
106 private:
107 ACL const*prototype;
108 char const *typeString;
109
110 private:
111 static Vector<Prototype const *> * Registry;
112 static void *Initialized;
113 typedef Vector<Prototype const*>::iterator iterator;
114 typedef Vector<Prototype const*>::const_iterator const_iterator;
115 void registerMe();
116 };
117 };
118
119 class acl_access
120 {
121
122 public:
123 void *operator new(size_t);
124 void operator delete(void *);
125 bool containsPURGE() const;
126 allow_t allow;
127 acl_list *aclList;
128 char *cfgline;
129 acl_access *next;
130
131 private:
132 CBDATA_CLASS(acl_access);
133 };
134
135 class ACLList
136 {
137
138 public:
139 MEMPROXY_CLASS(ACLList);
140
141 ACLList();
142 void negated(bool isNegated);
143 bool matches (ACLChecklist *)const;
144 int op;
145 ACL *_acl;
146 ACLList *next;
147 };
148
149 MEMPROXY_CLASS_INLINE(ACLList)
150
151 typedef ACLList acl_list;
152 #endif /* SQUID_ACL_H */