]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/StoreMeta.cc
bda815620764f1296075c1af923cdb49a618ca32
5 * DEBUG: section 20 Storage Manager Swapfile Metadata
6 * AUTHOR: Kostas Anagnostakis
8 * SQUID Web Proxy Cache http://www.squid-cache.org/
9 * ----------------------------------------------------------
11 * Squid is the result of efforts by numerous individuals from
12 * the Internet community; see the CONTRIBUTORS file for full
13 * details. Many organizations have provided support for Squid's
14 * development; see the SPONSORS file for full details. Squid is
15 * Copyrighted (C) 2001 by the Regents of the University of
16 * California; see the COPYRIGHT file for full details. Squid
17 * incorporates software developed and/or copyrighted by other
18 * sources; see the CREDITS file for full details.
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
36 #include "squid-old.h"
37 #include "StoreMeta.h"
39 #include "MemObject.h"
40 #include "StoreMetaMD5.h"
41 #include "StoreMetaURL.h"
42 #include "StoreMetaSTD.h"
43 #include "StoreMetaSTDLFS.h"
44 #include "StoreMetaVary.h"
45 #include "StoreMetaObjSize.h"
48 StoreMeta::validType(char type
)
50 /* VOID is reserved, and new types have to be added as classes */
51 if (type
<= STORE_META_VOID
|| type
>= STORE_META_END
+ 10) {
52 debugs(20, 0, "storeSwapMetaUnpack: bad type (" << type
<< ")!");
56 /* Not yet implemented */
57 if (type
>= STORE_META_END
||
58 type
== STORE_META_STOREURL
||
59 type
== STORE_META_VARY_ID
) {
60 debugs(20, 3, "storeSwapMetaUnpack: Not yet implemented (" << type
<< ") in disk metadata");
64 /* Unused in any current squid code */
65 if (type
== STORE_META_KEY_URL
||
66 type
== STORE_META_KEY_SHA
||
67 type
== STORE_META_HITMETERING
||
68 type
== STORE_META_VALID
) {
69 debugs(20, 0, "Obsolete and unused type (" << type
<< ") in disk metadata");
80 IntRange (int minimum
, int maximum
) : _min (minimum
), _max (maximum
) {
88 bool includes (int anInt
) const {
89 if (anInt
< _min
|| anInt
> _max
)
100 const int StoreMeta::MinimumTLVLength
= 0;
101 const int StoreMeta::MaximumTLVLength
= 1 << 16;
104 StoreMeta::validLength(int aLength
) const
106 if (!IntRange (MinimumTLVLength
, MaximumTLVLength
).includes(aLength
)) {
107 debugs(20, 0, "storeSwapMetaUnpack: insane length (" << aLength
<< ")!");
116 StoreMeta::Factory (char type
, size_t len
, void const *value
)
118 if (!validType(type
))
126 result
= new StoreMetaMD5
;
130 result
= new StoreMetaURL
;
134 result
= new StoreMetaSTD
;
137 case STORE_META_STD_LFS
:
138 result
= new StoreMetaSTDLFS
;
141 case STORE_META_OBJSIZE
:
142 result
= new StoreMetaObjSize
;
145 case STORE_META_VARY_HEADERS
:
146 result
= new StoreMetaVary
;
150 debugs(20, 0, "Attempt to create unknown concrete StoreMeta");
154 if (!result
->validLength(len
)) {
159 result
->length
= len
;
160 result
->value
= xmalloc(len
);
161 memcpy(result
->value
, value
, len
);
166 StoreMeta::FreeList(StoreMeta
**head
)
170 while ((node
= *head
) != NULL
) {
178 StoreMeta::Add(StoreMeta
**tail
, StoreMeta
*aNode
)
180 assert (*tail
== NULL
);
182 return &aNode
->next
; /* return new tail pointer */
186 StoreMeta::checkConsistency(StoreEntry
*e
) const
194 case STORE_META_VARY_HEADERS
:
201 case STORE_META_STD_LFS
:
204 case STORE_META_OBJSIZE
:
208 debugs(20, 1, "WARNING: got unused STORE_META type " << getType());