]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/Config.cc
3 * $Id: ICAPConfig.cc,v 1.21 2008/02/12 23:12:45 rousskov Exp $
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
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.
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.
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.
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.
36 #include "ConfigParser.h"
39 #include "Array.h" // really Vector
40 #include "adaptation/Config.h"
41 #include "adaptation/Service.h"
42 #include "adaptation/AccessRule.h"
43 #include "adaptation/ServiceGroups.h"
47 Adaptation::Config::parseService()
49 ServiceConfig
*cfg
= new ServiceConfig
;
51 serviceConfigs
.push_back(cfg
);
55 Adaptation::Config::freeService()
57 while (!serviceConfigs
.empty()) {
58 delete serviceConfigs
.back();
59 serviceConfigs
.pop_back();
64 Adaptation::Config::dumpService(StoreEntry
*entry
, const char *name
) const
66 typedef Services::iterator SCI
;
67 for (SCI i
= AllServices().begin(); i
!= AllServices().end(); ++i
) {
68 const ServiceConfig
&cfg
= (*i
)->cfg();
69 storeAppendPrintf(entry
, "%s %s_%s %s %d %s\n", name
, cfg
.key
.buf(),
70 cfg
.methodStr(), cfg
.vectPointStr(), cfg
.bypass
, cfg
.uri
.buf());
75 Adaptation::Config::finalize()
77 // create service reps from service configs
78 typedef Vector
<ServiceConfig
*>::const_iterator VISCI
;
79 const Vector
<ServiceConfig
*> &configs
= serviceConfigs
;
80 debugs(93,3, "Found " << configs
.size() << " service configs.");
81 for (VISCI i
= configs
.begin(); i
!= configs
.end(); ++i
) {
82 ServicePointer s
= createService(**i
);
84 AllServices().push_back(s
);
87 debugs(93,3, "Created " << configs
.size() <<
88 " message adaptation services.");
92 template <class Collection
>
94 FinalizeEach(Collection
&collection
, const char *label
)
96 typedef typename
Collection::iterator CI
;
97 for (CI i
= collection
.begin(); i
!= collection
.end(); ++i
)
100 debugs(93,2, "Initialized " << collection
.size() << ' ' << label
);
104 Adaptation::Config::Finalize()
106 FinalizeEach(AllServices(), "message adaptation services");
107 FinalizeEach(AllGroups(), "message adaptation service groups");
108 FinalizeEach(AllRules(), "message adaptation access rules");
112 Adaptation::Config::ParseServiceSet()
114 ServiceSet
*g
= new ServiceSet();
116 AllGroups().push_back(g
);
120 Adaptation::Config::FreeServiceSet()
122 while (!AllGroups().empty()) {
123 delete AllGroups().back();
124 AllGroups().pop_back();
129 Adaptation::Config::DumpServiceSet(StoreEntry
*entry
, const char *name
)
131 typedef Groups::iterator GI
;
132 for (GI i
= AllGroups().begin(); i
!= AllGroups().end(); ++i
)
133 storeAppendPrintf(entry
, "%s %s\n", name
, (*i
)->id
.buf());
137 Adaptation::Config::ParseAccess(ConfigParser
&parser
)
139 AccessRule
*r
= new AccessRule
;
141 AllRules().push_back(r
);
145 Adaptation::Config::FreeAccess()
147 while (!AllRules().empty()) {
148 delete AllRules().back();
149 AllRules().pop_back();
154 Adaptation::Config::DumpAccess(StoreEntry
*entry
, const char *name
)
156 LOCAL_ARRAY(char, nom
, 64);
158 typedef AccessRules::iterator CI
;
159 for (CI i
= AllRules().begin(); i
!= AllRules().end(); ++i
) {
160 snprintf(nom
, 64, "%s %s", name
, (*i
)->groupId
.buf());
161 dump_acl_access(entry
, nom
, (*i
)->acl
);
165 Adaptation::Config::Config()
167 // XXX: should we init members?
170 // XXX: this is called for ICAP and eCAP configs, but deals mostly
171 // with global arrays shared by those individual configs
172 Adaptation::Config::~Config()
177 // invalidate each service so that it can be deleted when refcount=0
178 while (!AllServices().empty()) {
179 AllServices().back()->invalidate();
180 AllServices().pop_back();