]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/StoreMeta.cc
3 * $Id: StoreMeta.cc,v 1.6 2007/09/19 08:54:51 hno Exp $
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.
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 */
52 if (type
<= STORE_META_VOID
|| type
>= STORE_META_END
) {
53 debugs(20, 0, "storeSwapMetaUnpack: bad type (" << type
<< ")!");
57 /* Unused in any current squid code */
58 if (type
== STORE_META_KEY_URL
||
59 type
== STORE_META_KEY_SHA
||
60 type
== STORE_META_HITMETERING
||
61 type
== STORE_META_VALID
) {
62 debugs(20, 0, "Obsolete and unused type (" << type
<< ") in disk metadata");
73 IntRange (int minimum
, int maximum
) : _min (minimum
), _max (maximum
)
82 bool includes (int anInt
) const
84 if (anInt
< _min
|| anInt
> _max
)
95 const int StoreMeta::MinimumTLVLength
= 0;
96 const int StoreMeta::MaximumTLVLength
= 1 << 16;
99 StoreMeta::validLength(int length
) const
101 if (!IntRange (MinimumTLVLength
, MaximumTLVLength
).includes(length
)) {
102 debugs(20, 0, "storeSwapMetaUnpack: insane length (" << length
<< ")!");
111 StoreMeta::Factory (char type
, size_t len
, void const *value
)
113 if (!validType(type
))
121 result
= new StoreMetaMD5
;
125 result
= new StoreMetaURL
;
129 result
= new StoreMetaSTD
;
132 case STORE_META_STD_LFS
:
133 result
= new StoreMetaSTDLFS
;
136 case STORE_META_OBJSIZE
:
137 result
= new StoreMetaObjSize
;
140 case STORE_META_VARY_HEADERS
:
141 result
= new StoreMetaVary
;
145 debugs(20, 0, "Attempt to create unknown concrete StoreMeta");
149 if (!result
->validLength(len
)) {
154 result
->length
= len
;
155 result
->value
= xmalloc(len
);
156 xmemcpy(result
->value
, value
, len
);
161 StoreMeta::FreeList(StoreMeta
**head
)
165 while ((node
= *head
) != NULL
) {
173 StoreMeta::Add(StoreMeta
**tail
, StoreMeta
*aNode
)
175 assert (*tail
== NULL
);
177 return &aNode
->next
; /* return new tail pointer */
181 StoreMeta::checkConsistency(StoreEntry
*e
) const
189 case STORE_META_VARY_HEADERS
:
196 case STORE_META_STD_LFS
:
199 case STORE_META_OBJSIZE
:
203 debugs(20, 1, "WARNING: got unused STORE_META type " << getType());