]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/StoreMeta.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / StoreMeta.cc
index 538aa3b6c59cf92cfe584da51deec42f43ec2705..801092f2cf54f897486c438ae217327a5ed1469e 100644 (file)
@@ -1,7 +1,5 @@
 
 /*
- * $Id: StoreMeta.cc,v 1.5 2007/08/13 17:20:51 hno Exp $
- *
  * DEBUG: section 20    Storage Manager Swapfile Metadata
  * AUTHOR: Kostas Anagnostakis
  *
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
  */
 
 #include "squid.h"
-#include "StoreMeta.h"
-#include "Store.h"
 #include "MemObject.h"
+#include "Store.h"
+#include "StoreMeta.h"
 #include "StoreMetaMD5.h"
-#include "StoreMetaURL.h"
+#include "StoreMetaObjSize.h"
 #include "StoreMetaSTD.h"
 #include "StoreMetaSTDLFS.h"
+#include "StoreMetaURL.h"
 #include "StoreMetaVary.h"
 
 bool
 StoreMeta::validType(char type)
 {
     /* VOID is reserved, and new types have to be added as classes */
+    if (type <= STORE_META_VOID || type >= STORE_META_END + 10) {
+        debugs(20, DBG_CRITICAL, "storeSwapMetaUnpack: bad type (" << type << ")!");
+        return false;
+    }
 
-    if (type <= STORE_META_VOID || type >= STORE_META_END) {
-        debugs(20, 0, "storeSwapMetaUnpack: bad type (" << type << ")!");
+    /* Not yet implemented */
+    if (type >= STORE_META_END ||
+            type == STORE_META_STOREURL ||
+            type == STORE_META_VARY_ID) {
+        debugs(20, 3, "storeSwapMetaUnpack: Not yet implemented (" << type << ") in disk metadata");
         return false;
     }
 
@@ -58,7 +64,7 @@ StoreMeta::validType(char type)
             type == STORE_META_KEY_SHA ||
             type == STORE_META_HITMETERING ||
             type == STORE_META_VALID) {
-        debugs(20, 0, "Obsolete and unused type (" << type << ") in disk metadata");
+        debugs(20, DBG_CRITICAL, "Obsolete and unused type (" << type << ") in disk metadata");
         return false;
     }
 
@@ -69,8 +75,7 @@ class IntRange
 {
 
 public:
-    IntRange (int minimum, int maximum) : _min (minimum), _max (maximum)
-    {
+    IntRange (int minimum, int maximum) : _min (minimum), _max (maximum) {
         if (_min > _max) {
             int temp = _min;
             _min = _max;
@@ -78,8 +83,7 @@ public:
         }
     }
 
-    bool includes (int anInt) const
-    {
+    bool includes (int anInt) const {
         if (anInt < _min || anInt > _max)
             return false;
 
@@ -95,17 +99,16 @@ const int StoreMeta::MinimumTLVLength = 0;
 const int StoreMeta::MaximumTLVLength = 1 << 16;
 
 bool
-StoreMeta::validLength(int length) const
+StoreMeta::validLength(int aLength) const
 {
-    if (!IntRange (MinimumTLVLength, MaximumTLVLength).includes(length)) {
-        debugs(20, 0, "storeSwapMetaUnpack: insane length (" << length << ")!");
+    if (!IntRange (MinimumTLVLength, MaximumTLVLength).includes(aLength)) {
+        debugs(20, DBG_CRITICAL, "storeSwapMetaUnpack: insane length (" << aLength << ")!");
         return false;
     }
 
     return true;
 }
 
-
 StoreMeta *
 StoreMeta::Factory (char type, size_t len, void const *value)
 {
@@ -132,12 +135,16 @@ StoreMeta::Factory (char type, size_t len, void const *value)
         result = new StoreMetaSTDLFS;
         break;
 
+    case STORE_META_OBJSIZE:
+        result = new StoreMetaObjSize;
+        break;
+
     case STORE_META_VARY_HEADERS:
         result = new StoreMetaVary;
         break;
 
     default:
-        debugs(20, 0, "Attempt to create unknown concrete StoreMeta");
+        debugs(20, DBG_CRITICAL, "Attempt to create unknown concrete StoreMeta");
         return NULL;
     }
 
@@ -148,7 +155,7 @@ StoreMeta::Factory (char type, size_t len, void const *value)
 
     result->length = len;
     result->value = xmalloc(len);
-    xmemcpy(result->value, value, len);
+    memcpy(result->value, value, len);
     return result;
 }
 
@@ -192,10 +199,10 @@ StoreMeta::checkConsistency(StoreEntry *e) const
         break;
 
     case STORE_META_OBJSIZE:
-       break;
+        break;
 
     default:
-        debugs(20, 1, "WARNING: got unused STORE_META type " << getType());
+        debugs(20, DBG_IMPORTANT, "WARNING: got unused STORE_META type " << getType());
         break;
     }