]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Summary: Make all Arrays typesafe.
authorrobertc <>
Tue, 15 Jul 2003 12:50:38 +0000 (12:50 +0000)
committerrobertc <>
Tue, 15 Jul 2003 12:50:38 +0000 (12:50 +0000)
Keywords:

Make all arrays typesafe.
Remove C bindinds to Array logic (we can instate new ones easily if desired later on).
Make all users of HttpHeader classes: htcpReplyData.
Ensure all class contianing HttpHeader are constructed and destructed:
  htcpReplyData, request_t, HttpReply.
rename request_t to HttpRequest.
Move htcp prototypes to htcp.h.

18 files changed:
include/Array.h
lib/Makefile.am
src/HttpHeader.cc
src/HttpHeader.h
src/HttpReply.cc
src/HttpReply.h
src/HttpRequest.cc
src/HttpRequest.h
src/client_side.cc
src/fde.h
src/htcp.cc
src/htcp.h
src/http.cc
src/main.cc
src/protos.h
src/structs.h
src/tunnel.cc
src/typedefs.h

index 32dbd6e82c9d08515f44729d7dd90323b8437fea..a07cb34889ef9e738f78a5e071fcf513e886a9b5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: Array.h,v 1.14 2003/07/12 12:42:19 robertc Exp $
+ * $Id: Array.h,v 1.15 2003/07/15 06:50:38 robertc Exp $
  *
  * AUTHOR: Alex Rousskov
  *
 #ifndef SQUID_ARRAY_H
 #define SQUID_ARRAY_H
 
-/* see Array.c for more documentation */
-#ifndef __cplusplus
-typedef struct {
-    int capacity;
-    int count;
-    void **items;
-} Array;
-#endif
+/* iterator support */
 
-#ifdef __cplusplus
+template <class C>
 
-/* iterator support */ 
-template <class C> class VectorIteratorBase {
-  public:
+class VectorIteratorBase
+{
+
+public:
     VectorIteratorBase();
     VectorIteratorBase(C &);
     VectorIteratorBase(size_t, C &);
@@ -57,31 +51,37 @@ template <class C> class VectorIteratorBase {
     VectorIteratorBase & operator ++();
     VectorIteratorBase operator ++(int);
     typename C::value_type & operator *() const
-      {
-          return theVector->items[pos];
-      }
-      typename C::value_type * operator -> () const
-      {
-          return &theVector->items[pos];
-      }
+    {
+        return theVector->items[pos];
+    }
+
+    typename C::value_type * operator -> () const
+    {
+        return &theVector->items[pos];
+    }
+
     ssize_t operator - (VectorIteratorBase const &rhs) const;
     bool incrementable() const;
-  private:
+
+private:
     size_t pos;
     C * theVector;
 };
-  
+
 template<class E>
-class Vector {
+
+class Vector
+{
+
 public:
     typedef E value_type;
     typedef E* pointer;
     typedef VectorIteratorBase<Vector<E> > iterator;
     typedef VectorIteratorBase<Vector<E> const> const_iterator;
-  
+
     void *operator new (size_t);
     void operator delete (void *);
-    
+
     Vector();
     ~Vector();
     Vector(Vector const &);
@@ -98,26 +98,13 @@ public:
     const_iterator begin () const;
     iterator end();
     const_iterator end () const;
-    
+
     /* Do not change these, until the entry C struct is removed */
     size_t capacity;
     size_t count;
     E *items;
 };
 
-typedef Vector<void *> Array;
-
-#endif
-
-SQUIDCEXTERN Array *arrayCreate(void);
-SQUIDCEXTERN void arrayInit(Array * s);
-SQUIDCEXTERN void arrayClean(Array * s);
-SQUIDCEXTERN void arrayDestroy(Array * s);
-SQUIDCEXTERN void arrayAppend(Array * s, void *obj);
-SQUIDCEXTERN void arrayPreAppend(Array * s, int app_count);
-
-#ifdef __cplusplus
-
 template<class E>
 void *
 Vector<E>::operator new(size_t size)
@@ -134,11 +121,10 @@ Vector<E>::operator delete (void *address)
 
 template<class E>
 Vector<E>::Vector() : capacity (0), count(0), items (NULL)
-{
-}
+{}
 
 template<class E>
-Vector<E>::~Vector() 
+Vector<E>::~Vector()
 {
     clean();
 }
@@ -161,20 +147,29 @@ Vector<E>::reserve(size_t min_capacity)
 {
     const int min_delta = 16;
     int delta;
+
     if (capacity >= min_capacity)
-       return;
+        return;
+
     delta = min_capacity;
+
     /* make delta a multiple of min_delta */
     delta += min_delta - 1;
+
     delta /= min_delta;
+
     delta *= min_delta;
+
     /* actual grow */
     if (delta < 0)
-       delta = min_capacity - capacity;
+        delta = min_capacity - capacity;
+
     E*newitems = new E[capacity + delta];
+
     for (size_t counter = 0; counter < size(); ++counter) {
-       newitems[counter] = items[counter];
+        newitems[counter] = items[counter];
     }
+
     capacity += delta;
     delete[]items;
     items = newitems;
@@ -185,7 +180,8 @@ void
 Vector<E>::push_back(E obj)
 {
     if (size() >= capacity)
-       reserve (size() + 1);
+        reserve (size() + 1);
+
     items[count++] = obj;
 }
 
@@ -213,7 +209,7 @@ void
 Vector<E>::preAppend(int app_count)
 {
     if (size() + app_count > capacity)
-       reserve(size() + app_count);
+        reserve(size() + app_count);
 }
 
 template<class E>
@@ -222,8 +218,10 @@ Vector<E>::operator = (Vector const &old)
 {
     clean();
     reserve (old.size());
+
     for (size_t counter = 0; counter < old.size(); ++counter)
-       push_back (old.items[counter]);
+        push_back (old.items[counter]);
+
     return *this;
 }
 
@@ -272,13 +270,11 @@ Vector<E>::end() const
 
 template<class C>
 VectorIteratorBase<C>::VectorIteratorBase() : pos(0), theVector(NULL)
-{
-}
+{}
 
 template<class C>
 VectorIteratorBase<C>::VectorIteratorBase(C &container) : pos(container.begin()), theVector(&container)
-{
-}
+{}
 
 template<class C>
 VectorIteratorBase<C>::VectorIteratorBase(size_t aPos, C &container) : pos(aPos), theVector(&container) {}
@@ -298,7 +294,7 @@ bool VectorIteratorBase<C>:: operator == (VectorIteratorBase const &rhs)
 }
 
 template<class C>
-bool 
+bool
 VectorIteratorBase<C>::incrementable() const
 {
     assert (theVector);
@@ -309,9 +305,12 @@ template<class C>
 VectorIteratorBase<C> & VectorIteratorBase<C>:: operator ++()
 {
     assert (theVector);
+
     if (!incrementable())
-       fatal ("domain error");
+        fatal ("domain error");
+
     ++pos;
+
     return *this;
 }
 
@@ -325,7 +324,8 @@ VectorIteratorBase<C> VectorIteratorBase<C>:: operator ++(int)
 
 template<class C>
 VectorIteratorBase<C>&
-VectorIteratorBase<C>::operator =(VectorIteratorBase const &old) {
+VectorIteratorBase<C>::operator =(VectorIteratorBase const &old)
+{
     pos = old.pos;
     theVector = old.theVector;
     return *this;
@@ -338,6 +338,5 @@ VectorIteratorBase<C>::operator - (VectorIteratorBase const &rhs) const
     assert(theVector == rhs.theVector);
     return pos - rhs.pos;
 }
-#endif
 
 #endif /* SQUID_ARRAY_H */
index 47288effda8a92ce2af2a24a589ae26b63615c74..ba8fb434fc67df7d0490b8681a4e4c0c7da4a2a1 100644 (file)
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 #
-#  $Id: Makefile.am,v 1.11 2003/06/19 13:12:00 robertc Exp $
+#  $Id: Makefile.am,v 1.12 2003/07/15 06:50:38 robertc Exp $
 #
 
 SUBDIRS = libTrie
@@ -39,7 +39,6 @@ EXTRA_libmiscutil_a_SOURCES = \
        snprintf.c
 libmiscutil_a_SOURCES = \
        MemPool.c \
-       Array.cc \
        base64.c \
        getfullhostname.c \
        hash.c \
index 75aa3a465bd080feca4c03c2b368ad7957c578fa..796c3c6dba2215b1c625ec18fa209efce861aff4 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHeader.cc,v 1.92 2003/07/14 14:15:56 robertc Exp $
+ * $Id: HttpHeader.cc,v 1.93 2003/07/15 06:50:39 robertc Exp $
  *
  * DEBUG: section 55    HTTP Header
  * AUTHOR: Alex Rousskov
@@ -346,15 +346,22 @@ httpHeaderStatInit(HttpHeaderStat * hs, const char *label)
  * HttpHeader Implementation
  */
 
-void
-httpHeaderInit(HttpHeader * hdr, http_hdr_owner_type owner)
+HttpHeader::HttpHeader() : owner (hoNone), len (0)
 {
-    assert(hdr);
-    assert(owner > hoNone && owner <= hoReply);
-    debug(55, 7) ("init-ing hdr: %p owner: %d\n", hdr, owner);
-    memset(hdr, 0, sizeof(*hdr));
-    hdr->owner = owner;
-    arrayInit(&hdr->entries);
+    httpHeaderMaskInit(&mask, 0);
+}
+
+HttpHeader::HttpHeader(http_hdr_owner_type const &anOwner) : owner (anOwner), len (0)
+{
+    assert(this);
+    assert(anOwner > hoNone && anOwner <= hoReply);
+    debug(55, 7) ("init-ing hdr: %p owner: %d\n", this, owner);
+    httpHeaderMaskInit(&mask, 0);
+}
+
+HttpHeader::~HttpHeader()
+{
+    httpHeaderClean (this);
 }
 
 void
@@ -384,7 +391,7 @@ httpHeaderClean(HttpHeader * hdr)
         }
     }
 
-    arrayClean(&hdr->entries);
+    hdr->entries.clean();
 }
 
 /* append entries (also see httpHeaderUpdate) */
@@ -439,7 +446,7 @@ httpHeaderReset(HttpHeader * hdr)
     assert(hdr);
     ho = hdr->owner;
     httpHeaderClean(hdr);
-    httpHeaderInit(hdr, ho);
+    *hdr = HttpHeader(ho);
     return 0;
 }
 
@@ -667,7 +674,7 @@ httpHeaderAddEntry(HttpHeader * hdr, HttpHeaderEntry * e)
     else
         CBIT_SET(hdr->mask, e->id);
 
-    arrayAppend(&hdr->entries, e);
+    hdr->entries.push_back(e);
 
     /* increment header length, allow for ": " and crlf */
     hdr->len += e->name.size() + 2 + e->value.size() + 2;
index 95d9d81f1869d6f891bb3c8d4350a45daee0fce0..0cc50961ba1fe6cf5260b9548370ea90205e9b18 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHeader.h,v 1.5 2003/07/14 14:15:56 robertc Exp $
+ * $Id: HttpHeader.h,v 1.6 2003/07/15 06:50:39 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -57,11 +57,14 @@ class HttpHeader
 {
 
 public:
+    HttpHeader();
+    HttpHeader(http_hdr_owner_type const &owner);
+    ~HttpHeader();
     /* Interface functions */
     void update (HttpHeader const *fresh, HttpHeaderMask const *denied_mask);
     void removeConnectionHeaderEntries();
     /* protected, do not use these, use interface functions instead */
-    Array entries;             /* parsed fields in raw format */
+    Vector<HttpHeaderEntry *> entries;         /* parsed fields in raw format */
     HttpHeaderMask mask;       /* bit set <=> entry present */
     http_hdr_owner_type owner; /* request or reply */
     int len;                   /* length when packed, not counting terminating '\0' */
index 3ae0b07383adb0c82862199ed7724aef6c5b2b90..679bf9b59bc1385568fdbd6a8d26cc00c41443cc 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpReply.cc,v 1.61 2003/07/14 08:21:56 robertc Exp $
+ * $Id: HttpReply.cc,v 1.62 2003/07/15 06:50:39 robertc Exp $
  *
  * DEBUG: section 58    HTTP Reply (Response)
  * AUTHOR: Alex Rousskov
@@ -60,7 +60,6 @@ HttpMsgParseState &operator++ (HttpMsgParseState &aState)
 
 
 /* local routines */
-static void httpReplyInit(HttpReply * rep);
 static void httpReplyClean(HttpReply * rep);
 static void httpReplyDoDestroy(HttpReply * rep);
 static void httpReplyHdrCacheInit(HttpReply * rep);
@@ -85,20 +84,16 @@ httpReplyCreate(void)
 {
     HttpReply *rep = new HttpReply;
     debug(58, 7) ("creating rep: %p\n", rep);
-    httpReplyInit(rep);
     return rep;
 }
 
-static void
-httpReplyInit(HttpReply * rep)
+HttpReply::HttpReply() : hdr_sz (0), content_length (0), date (0), last_modified (0), expires (0), cache_control (NULL), surrogate_control (NULL), content_range (NULL), keep_alive (0), pstate(psReadyToParseStartLine), header (hoReply)
 {
-    assert(rep);
-    rep->hdr_sz = 0;
-    rep->pstate = psReadyToParseStartLine;
-    httpBodyInit(&rep->body);
-    httpHeaderInit(&rep->header, hoReply);
-    httpReplyHdrCacheInit(rep);
-    httpStatusLineInit(&rep->sline);
+    assert(this);
+    httpBodyInit(&body);
+    httpReplyHdrCacheInit(this);
+    httpStatusLineInit(&sline);
+
 }
 
 static void
@@ -124,7 +119,7 @@ void
 httpReplyReset(HttpReply * rep)
 {
     httpReplyClean(rep);
-    httpReplyInit(rep);
+    *rep = HttpReply();
 }
 
 /* absorb: copy the contents of a new reply to the old one, destroy new one */
index 73365850e71825e8cb65f485bfa715b20a14d645..77d7c7252cc3283e3332ec244e23e8783d1e47e9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpReply.h,v 1.4 2003/07/14 14:15:56 robertc Exp $
+ * $Id: HttpReply.h,v 1.5 2003/07/15 06:50:39 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -86,6 +86,7 @@ class HttpReply
 public:
     void *operator new (size_t);
     void operator delete (void *);
+    HttpReply();
     /* unsupported, writable, may disappear/change in the future */
     int hdr_sz;                        /* sums _stored_ status-line, headers, and <CRLF> */
 
index dd9b68140033495ff8bc579cbd1fc5374c9852f5..dfd7d552b73357f8e875d3c7915ccb07f468e4bc 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpRequest.cc,v 1.39 2003/07/11 01:40:34 robertc Exp $
+ * $Id: HttpRequest.cc,v 1.40 2003/07/15 06:50:41 robertc Exp $
  *
  * DEBUG: section 73    HTTP Request
  * AUTHOR: Duane Wessels
 
 static void httpRequestHdrCacheInit(request_t * req);
 
+void *
+HttpRequest::operator new(size_t amount)
+{
+    // Todo: assign private pool.
+    return static_cast<request_t *>(memAllocate(MEM_REQUEST_T));
+}
+
+void
+HttpRequest::operator delete(void *address)
+{
+    memFree(address, MEM_REQUEST_T);
+}
+
+void
+HttpRequest::deleteSelf() const
+{
+    delete this;
+}
+
+HttpRequest::HttpRequest()  : header(hoRequest)
+{
+    /* We should initialise these ... */
+#if 0
+    method_t method;
+    protocol_t protocol;
+    char login[MAX_LOGIN_SZ];
+    char host[SQUIDHOSTNAMELEN + 1];
+    auth_user_request_t *auth_user_request;
+    u_short port;
+    String urlpath;
+    char *canonical;
+    int link_count;            /* free when zero */
+    request_flags flags;
+    HttpHdrCc *cache_control;
+    HttpHdrRange *range;
+    http_version_t http_ver;
+    time_t ims;
+    int imslen;
+    int max_forwards;
+    /* these in_addr's could probably be sockaddr_in's */
+
+    struct in_addr client_addr;
+
+    struct in_addr my_addr;
+    unsigned short my_port;
+    unsigned short client_port;
+    HttpHeader header;
+    ConnStateData::Pointer body_connection;    /* used by clientReadBody() */
+    int content_length;
+    HierarchyLogEntry hier;
+    err_type errType;
+    char *peer_login;          /* Configured peer login:password */
+    time_t lastmod;            /* Used on refreshes */
+    const char *vary_headers;  /* Used when varying entities are detected. Changes how the store key is calculated */
+    char *peer_domain;         /* Configured peer forceddomain */
+#endif
+}
+
 request_t *
 requestCreate(method_t method, protocol_t protocol, const char *aUrlpath)
 {
-    request_t *req = static_cast<request_t *>(memAllocate(MEM_REQUEST_T));
+    request_t *req = new HttpRequest;
     req->method = method;
     req->protocol = protocol;
 
@@ -58,8 +116,6 @@ requestCreate(method_t method, protocol_t protocol, const char *aUrlpath)
 
     req->my_addr = no_addr;
 
-    httpHeaderInit(&req->header, hoRequest);
-
     httpRequestHdrCacheInit(req);
 
     return req;
@@ -98,7 +154,7 @@ requestDestroy(request_t * req)
 
     req->extacl_log.clean();
 
-    memFree(req, MEM_REQUEST_T);
+    req->deleteSelf();
 }
 
 request_t *
index 34e382fd17419355d154ac000bc4125f68e6004c..c1e8214faa319e4a4586407e6a318c332220e133 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpRequest.h,v 1.3 2003/07/14 14:15:56 robertc Exp $
+ * $Id: HttpRequest.h,v 1.4 2003/07/15 06:50:41 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -52,10 +52,16 @@ extern int httpRequestHdrAllowedByName(http_hdr_type id);
 
 class HttpHdrRange;
 
-class request_t
+class HttpRequest
 {
 
 public:
+    void *operator new(size_t);
+    void operator delete(void *);
+    virtual void deleteSelf() const;
+    HttpRequest();
+    virtual ~HttpRequest() {}
+
     bool multipartRangeRequest() const;
 
     method_t method;
@@ -96,5 +102,6 @@ public:
     String extacl_log;         /* String to be used for access.log purposes */
 };
 
+typedef HttpRequest request_t;
 
 #endif /* SQUID_HTTPREQUEST_H */
index c1cd8c3aff8146fcf69432cef4a5dcd3586d31b3..23f2b8369ef6c533854d3727aef1c00397dbae6d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.650 2003/07/13 23:00:09 robertc Exp $
+ * $Id: client_side.cc,v 1.651 2003/07/15 06:50:41 robertc Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -837,7 +837,7 @@ clientPackTermBound(String boundary, MemBuf * mb)
 static void
 clientPackRangeHdr(const HttpReply * rep, const HttpHdrRangeSpec * spec, String boundary, MemBuf * mb)
 {
-    HttpHeader hdr;
+    HttpHeader hdr(hoReply);
     Packer p;
     assert(rep);
     assert(spec);
@@ -848,7 +848,6 @@ clientPackRangeHdr(const HttpReply * rep, const HttpHdrRangeSpec * spec, String
     memBufPrintf(mb, "\r\n--%s\r\n", boundary.buf());
 
     /* stuff the header with required entries and pack it */
-    httpHeaderInit(&hdr, hoReply);
 
     if (httpHeaderHas(&rep->header, HDR_CONTENT_TYPE))
         httpHeaderPutStr(&hdr, HDR_CONTENT_TYPE, httpHeaderGetStr(&rep->header, HDR_CONTENT_TYPE));
index 998455c3658e9d9b8bbce659f362b50a44446d1f..85c311e927b5beabd80a7ab622e1c137b93dd4ac 100644 (file)
--- a/src/fde.h
+++ b/src/fde.h
@@ -1,6 +1,6 @@
 
 /*
- * $Id: fde.h,v 1.4 2003/06/23 14:13:03 robertc Exp $
+ * $Id: fde.h,v 1.5 2003/07/15 06:50:42 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -39,6 +39,7 @@ class fde
 {
 
 public:
+    /* NOTE: memset is used on fdes today. 20030715 RBC */
     static void DumpStats (StoreEntry *);
 
     char const *remoteAddr() const;
index 1886d8933e47c2ed585f27268090f215ce82f59b..089f6955b393c93e15c406e646e75b5aa16bef70 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: htcp.cc,v 1.53 2003/07/14 14:16:00 robertc Exp $
+ * $Id: htcp.cc,v 1.54 2003/07/15 06:50:42 robertc Exp $
  *
  * DEBUG: section 31    Hypertext Caching Protocol
  * AUTHOR: Duane Wesssels
@@ -729,7 +729,7 @@ htcpTstReply(htcpDataHeader * dhdr, StoreEntry * e, htcpSpecifier * spec, struct
 {
     htcpStuff stuff;
     char *pkt;
-    HttpHeader hdr;
+    HttpHeader hdr(hoHtcpReply);
     MemBuf mb;
     Packer p;
     ssize_t pktlen;
@@ -750,7 +750,6 @@ htcpTstReply(htcpDataHeader * dhdr, StoreEntry * e, htcpSpecifier * spec, struct
     {
         memBufDefInit(&mb);
         packerToMemInit(&p, &mb);
-        httpHeaderInit(&hdr, hoHtcpReply);
         stuff.S.method = spec->method;
         stuff.S.uri = spec->uri;
         stuff.S.version = spec->version;
@@ -884,6 +883,9 @@ htcpHandleTst(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from)
         htcpHandleTstResponse(hdr, buf, sz, from);
 }
 
+HtcpReplyData::HtcpReplyData() : hdr(hoHtcpReply)
+{}
+
 static void
 
 htcpHandleTstResponse(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from)
@@ -899,8 +901,6 @@ htcpHandleTstResponse(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_i
         return;
     }
 
-    memset(&htcpReply, '\0', sizeof(htcpReply));
-    httpHeaderInit(&htcpReply.hdr, hoHtcpReply);
     htcpReply.msg_id = hdr->msg_id;
     debug(31, 3) ("htcpHandleTstResponse: msg_id = %d\n", (int) htcpReply.msg_id);
     htcpReply.hit = hdr->response ? 0 : 1;
@@ -1201,7 +1201,7 @@ htcpQuery(StoreEntry * e, request_t * req, peer * p)
     ssize_t pktlen;
     char vbuf[32];
     htcpStuff stuff;
-    HttpHeader hdr;
+    HttpHeader hdr(hoRequest);
     Packer pa;
     MemBuf mb;
     http_state_flags flags;
index f0cf9ddcc122d3c87fd1a409d0f1cf90c61c2ca0..4abe81cecadefce7a4e63d30bf64c586236de1cb 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: htcp.h,v 1.3 2003/07/14 14:16:00 robertc Exp $
+ * $Id: htcp.h,v 1.4 2003/07/15 06:50:42 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
 #if USE_HTCP
 #include "HttpHeader.h"
 
-struct _htcpReplyData
+class HtcpReplyData
 {
+
+public:
+    HtcpReplyData();
     int hit;
     HttpHeader hdr;
     u_int32_t msg_id;
@@ -55,6 +58,14 @@ struct _htcpReplyData
     cto;
 };
 
+typedef class HtcpReplyData htcpReplyData;
+
+SQUIDCEXTERN void neighborsHtcpReply(const cache_key *, htcpReplyData *, const struct sockaddr_in *);
+SQUIDCEXTERN void htcpInit(void);
+SQUIDCEXTERN void htcpQuery(StoreEntry * e, request_t * req, peer * p);
+SQUIDCEXTERN void htcpSocketShutdown(void);
+SQUIDCEXTERN void htcpSocketClose(void);
+
 #endif
 
 #endif /* SQUID_HTCP_H */
index d7e6c3cd12f01a42db62e9b97e22c22c5786d115..36140ab1803801a0c9bfad570fcd8a68444ef3e9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.419 2003/07/14 14:16:00 robertc Exp $
+ * $Id: http.cc,v 1.420 2003/07/15 06:50:42 robertc Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -1125,7 +1125,7 @@ httpBuildRequestHeader(request_t * request,
     const HttpHeaderEntry *e;
     String strFwd;
     HttpHeaderPos pos = HttpHeaderInitPos;
-    httpHeaderInit(hdr_out, hoRequest);
+    assert (hdr_out->owner == hoRequest);
     /* append our IMS header */
 
     if (request->lastmod > -1 && request->method == METHOD_GET)
@@ -1486,7 +1486,7 @@ httpBuildRequestPrefix(request_t * request,
                  httpver.major,httpver.minor);
     /* build and pack headers */
     {
-        HttpHeader hdr;
+        HttpHeader hdr(hoRequest);
         Packer p;
         httpBuildRequestHeader(request, orig_request, entry, &hdr, flags);
         packerToMemInit(&p, mb);
index e0b85479232ab96be47c55f716243937873b5831..b87552a1e931bd33a1dba340c150ad136fd5f1fb 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.383 2003/07/06 15:30:42 hno Exp $
+ * $Id: main.cc,v 1.384 2003/07/15 06:50:42 robertc Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -41,6 +41,7 @@
 #include "Mem.h"
 #include "ACLASN.h"
 #include "ACL.h"
+#include "htcp.h"
 
 #if USE_WIN32_SERVICE
 
index 3af3c2262ca364c40a9e08d02c75f36de73f1c99..47710d5291727ddae8d2160389241881c155b61c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.482 2003/07/14 14:16:01 robertc Exp $
+ * $Id: protos.h,v 1.483 2003/07/15 06:50:42 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -401,7 +401,6 @@ SQUIDCEXTERN void httpHeaderPutStrf();
 SQUIDCEXTERN void httpHeaderInitModule(void);
 SQUIDCEXTERN void httpHeaderCleanModule(void);
 /* init/clean */
-SQUIDCEXTERN void httpHeaderInit(HttpHeader * hdr, http_hdr_owner_type owner);
 SQUIDCEXTERN void httpHeaderClean(HttpHeader * hdr);
 /* append/update */
 SQUIDCEXTERN void httpHeaderAppend(HttpHeader * dest, const HttpHeader * src);
@@ -578,10 +577,6 @@ SQUIDCEXTERN void dump_peer_options(StoreEntry *, peer *);
 SQUIDCEXTERN int peerHTTPOkay(const peer *, request_t *);
 
 SQUIDCEXTERN peer *whichPeer(const struct sockaddr_in *from);
-#if USE_HTCP
-
-SQUIDCEXTERN void neighborsHtcpReply(const cache_key *, htcpReplyData *, const struct sockaddr_in *);
-#endif
 
 SQUIDCEXTERN void netdbInit(void);
 
@@ -948,12 +943,6 @@ SQUIDCEXTERN int getMyPort(void);
 SQUIDCEXTERN char *strwordtok(char *buf, char **t);
 SQUIDCEXTERN void strwordquote(MemBuf * mb, const char *str);
 
-#if USE_HTCP
-SQUIDCEXTERN void htcpInit(void);
-SQUIDCEXTERN void htcpQuery(StoreEntry * e, request_t * req, peer * p);
-SQUIDCEXTERN void htcpSocketShutdown(void);
-SQUIDCEXTERN void htcpSocketClose(void);
-#endif
 
 
 /*
index 8acf326ff3049829324c2230409f1745dca9087b..bbae3e78da1cf93bc55b9ab38e4126415affd3d7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.472 2003/07/14 14:16:02 robertc Exp $
+ * $Id: structs.h,v 1.473 2003/07/15 06:50:42 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -996,6 +996,7 @@ struct _HierarchyLogEntry
 
 struct _AccessLogEntry
 {
+    /* NB: memset is used on AccessLogEntries as at 20030715 RBC */
     const char *url;
 
     struct
index a7c7bdde41739fd7fc92e5e7388fa2fc93f2b194..9a2485d808a8b5b7fef4a1a83f9f59add9fa8f1a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tunnel.cc,v 1.142 2003/07/10 11:04:07 robertc Exp $
+ * $Id: tunnel.cc,v 1.143 2003/07/15 06:50:43 robertc Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -639,7 +639,7 @@ sslProxyConnected(int fd, void *data)
 {
     SslStateData *sslState = (SslStateData *)data;
     MemBuf mb;
-    HttpHeader hdr_out;
+    HttpHeader hdr_out(hoRequest);
     Packer p;
     http_state_flags flags;
     debug(26, 3) ("sslProxyConnected: FD %d sslState=%p\n", fd, sslState);
index aadfaf4eb0a5edaf35a850c19cb0811b4b154c85..90d5690112d1c328e0586f2ba9768bd91665fe60 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: typedefs.h,v 1.165 2003/07/14 14:16:02 robertc Exp $
+ * $Id: typedefs.h,v 1.166 2003/07/15 06:50:43 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -199,7 +199,7 @@ typedef struct _header_mangler header_mangler;
 
 typedef struct _body_size body_size;
 
-class request_t;
+typedef struct HttpRequest request_t;
 
 typedef struct _AccessLogEntry AccessLogEntry;
 
@@ -368,11 +368,6 @@ typedef char HttpHeaderMask[12];
 /* a common objPackInto interface; used by debugObj */
 typedef void (*ObjPackMethod) (void *obj, Packer * p);
 
-#if USE_HTCP
-
-typedef struct _htcpReplyData htcpReplyData;
-#endif
-
 typedef RemovalPolicy *REMOVALPOLICYCREATE(wordlist * args);
 
 typedef int STDIRSELECT(const StoreEntry *);