]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/HttpHdrSc.cc
Maintenance: Remove FIXME and \todo labels (#647)
[thirdparty/squid.git] / src / HttpHdrSc.cc
index b8ea350165dcd3fe2385eb084bb619dab03e5c12..a30498230dbbad048c23114af69534d69772f181 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -10,7 +10,8 @@
 
 #include "squid.h"
 #include "base/LookupTable.h"
-#include "HttpHdrSc.h"
+//#include "HttpHdrSc.h" // pulled in by HttpHdrScTarget.h
+#include "HttpHdrScTarget.h"
 #include "HttpHeader.h"
 #include "HttpHeaderFieldStat.h"
 #include "HttpHeaderStat.h"
 #include <map>
 #include <vector>
 
-/* a row in the table used for parsing surrogate-control header and statistics */
-typedef struct {
-    const char *name;
-    http_hdr_sc_type id;
-    HttpHeaderFieldStat stat;
-} HttpHeaderScFields;
-
 /* this table is used for parsing surrogate control header */
 /* order must match that of enum http_hdr_sc_type. The constraint is verified at initialization time */
-//todo: implement constraint
+// TODO: implement constraint
 static const LookupTable<http_hdr_sc_type>::Record ScAttrs[] {
     {"no-store", SC_NO_STORE},
     {"no-store-remote", SC_NO_STORE_REMOTE},
@@ -43,20 +37,14 @@ static const LookupTable<http_hdr_sc_type>::Record ScAttrs[] {
 LookupTable<http_hdr_sc_type> scLookupTable(SC_ENUM_END, ScAttrs);
 std::vector<HttpHeaderFieldStat> scHeaderStats(SC_ENUM_END);
 
+// used when iterating over flags
 http_hdr_sc_type &operator++ (http_hdr_sc_type &aHeader)
 {
-    int tmp = (int)aHeader;
-    aHeader = (http_hdr_sc_type)(++tmp);
+    int tmp = static_cast<int>(aHeader);
+    aHeader = static_cast<http_hdr_sc_type>(++tmp);
     return aHeader;
 }
 
-int operator - (http_hdr_sc_type const &anSc, http_hdr_sc_type const &anSc2)
-{
-    return (int)anSc - (int)anSc2;
-}
-
-/* module initialization */
-
 void
 httpHdrScInitModule(void)
 {
@@ -65,11 +53,6 @@ httpHdrScInitModule(void)
         assert(i == ScAttrs[i].id);
 }
 
-void
-httpHdrScCleanModule(void)
-{
-}
-
 /* implementation */
 
 /* creates an sc object from a 0-terminating string */
@@ -115,7 +98,7 @@ HttpHdrSc::parse(const String * str)
             ++p;
         }
 
-        /* decrease ilen to still match the token for ';' qualified non '=' statments */
+        /* decrease ilen to still match the token for ';' qualified non '=' statements */
         else if ((p = strchr(item, ';')) && (p - item < ilen)) {
             ilen = p - item;
             ++p;
@@ -130,7 +113,7 @@ HttpHdrSc::parse(const String * str)
         }
 
         /* Is this a targeted directive? */
-        /* TODO: remove the temporary useage and use memrchr and the information we have instead */
+        /* TODO: remove the temporary usage and use memrchr and the information we have instead */
         temp = xstrndup (item, initiallen + 1);
 
         if (!((target = strrchr (temp, ';')) && !strchr (target, '"') && *(target + 1) != '\0'))
@@ -368,3 +351,13 @@ HttpHdrSc::getMergedTarget(const char *ourtarget)
     return NULL;
 }
 
+void
+HttpHdrSc::addTarget(HttpHdrScTarget *t) {
+    dlinkAdd(t, &t->node, &targets);
+}
+
+void
+HttpHdrSc::addTargetAtTail(HttpHdrScTarget *t) {
+    dlinkAddTail (t, &t->node, &targets);
+}
+