From: Amos Jeffries Date: Tue, 26 May 2015 09:18:13 +0000 (-0700) Subject: Cleanu: Remove dead Packer API X-Git-Tag: merge-candidate-3-v1~101^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0a647ffb7aae884369aeba0f1701a3b67a9b028c;p=thirdparty%2Fsquid.git Cleanu: Remove dead Packer API Also includes some Packable API polishing. No logical changes. --- diff --git a/src/HttpHdrContRange.cc b/src/HttpHdrContRange.cc index c89c20f0a4..1e4fc9849b 100644 --- a/src/HttpHdrContRange.cc +++ b/src/HttpHdrContRange.cc @@ -9,6 +9,7 @@ /* DEBUG: section 68 HTTP Content-Range Header */ #include "squid.h" +#include "base/Packable.h" #include "Debug.h" #include "enums.h" #include "HttpHdrContRange.h" diff --git a/src/HttpHeaderRange.h b/src/HttpHeaderRange.h index 448e0ebf45..6e9e2a0fc7 100644 --- a/src/HttpHeaderRange.h +++ b/src/HttpHeaderRange.h @@ -10,13 +10,14 @@ #define SQUID_HTTPHEADERRANGE_H #include "mem/forward.h" -#include "Packer.h" #include "Range.h" #include "SquidString.h" #include class HttpReply; +class Packable; + /* http byte-range-spec */ class HttpHdrRangeSpec diff --git a/src/Makefile.am b/src/Makefile.am index cf73fe2f99..349fcae9d9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -440,8 +440,6 @@ squid_SOURCES = \ neighbors.cc \ Notes.h \ Notes.cc \ - Packer.cc \ - Packer.h \ Parsing.cc \ Parsing.h \ $(XPROF_STATS_SOURCE) \ @@ -1146,8 +1144,6 @@ tests_testHttpReply_SOURCES=\ mime_header.cc \ Notes.h \ Notes.cc \ - Packer.cc \ - Packer.h \ SquidString.h \ SquidTime.h \ $(SBUF_SOURCE) \ @@ -1253,7 +1249,6 @@ tests_testACLMaxUserIP_SOURCES= \ SquidList.h \ SquidList.cc \ mem_node.cc \ - Packer.cc \ Parsing.cc \ SquidMath.cc \ StatCounters.cc \ @@ -1496,7 +1491,6 @@ tests_testCacheManager_SOURCES = \ neighbors.cc \ Notes.cc \ Notes.h \ - Packer.cc \ Parsing.cc \ pconn.cc \ peer_digest.cc \ @@ -1676,7 +1670,6 @@ tests_testDiskIO_SOURCES = \ mem_node.cc \ Notes.h \ Notes.cc \ - Packer.cc \ Parsing.cc \ refresh.h \ refresh.cc \ @@ -1937,7 +1930,6 @@ tests_testEvent_SOURCES = \ neighbors.cc \ Notes.cc \ Notes.h \ - Packer.cc \ Parsing.cc \ pconn.cc \ peer_digest.cc \ @@ -2184,7 +2176,6 @@ tests_testEventLoop_SOURCES = \ neighbors.cc \ Notes.cc \ Notes.h \ - Packer.cc \ Parsing.cc \ pconn.cc \ peer_digest.cc \ @@ -2426,7 +2417,6 @@ tests_test_http_range_SOURCES = \ neighbors.cc \ Notes.cc \ Notes.h \ - Packer.cc \ Parsing.cc \ peer_digest.cc \ peer_proxy_negotiate_auth.h \ @@ -2722,7 +2712,6 @@ tests_testHttpRequest_SOURCES = \ neighbors.cc \ Notes.cc \ Notes.h \ - Packer.cc \ Parsing.cc \ pconn.cc \ peer_digest.cc \ @@ -2894,7 +2883,6 @@ tests_testStore_SOURCES= \ MemObject.cc \ Notes.h \ Notes.cc \ - Packer.cc \ Parsing.cc \ RemovalPolicy.cc \ refresh.h \ @@ -3176,7 +3164,6 @@ tests_testUfs_SOURCES = \ ClientInfo.h \ MemBuf.cc \ HttpHdrContRange.cc \ - Packer.cc \ HttpHeaderFieldStat.h \ HttpHdrCc.h \ HttpHdrCc.cc \ @@ -3313,7 +3300,6 @@ tests_testRock_SOURCES = \ mem_node.cc \ Notes.h \ Notes.cc \ - Packer.cc \ Parsing.cc \ RemovalPolicy.cc \ RequestFlags.cc \ @@ -3544,7 +3530,6 @@ tests_testURL_SOURCES = \ neighbors.cc \ Notes.h \ Notes.cc \ - Packer.cc \ Parsing.cc \ pconn.cc \ peer_digest.cc \ diff --git a/src/Packer.cc b/src/Packer.cc deleted file mode 100644 index 55778ccfc9..0000000000 --- a/src/Packer.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 1996-2015 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -/* DEBUG: section 60 Generic Data Packer */ - -#include "squid.h" -#include "Packer.h" -#include "Store.h" - -/* - * We do have one potential problem here. Both append_f and vprintf_f types - * cannot match real functions precisely (at least because of the difference in - * the type of the first parameter). Thus, we have to use type cast. If somebody - * changes the prototypes of real functions, Packer will not notice that because - * of the type cast. - * - * Solution: we use the constants below to *hard code* current prototypes of - * real functions. If real prototypes change, these constants will produce a - * warning (e.g., "warning: assignment from incompatible pointer type"). - */ - -static void -storeEntryAppend(StoreEntry *e, const char *buf, int len) -{ - e->append(buf, len); -} - -/* append()'s */ -static void (*const store_append) (StoreEntry *, const char *, int) = &storeEntryAppend; - -/* vprintf()'s */ -static void (*const store_vprintf) (StoreEntry *, const char *, va_list ap) = &storeAppendVPrintf; - -/* init/clean */ - -/* init with this to forward data to StoreEntry */ -void -packerToStoreInit(Packer * p, StoreEntry * e) -{ - assert(p && e); - p->append_ = (append_f) store_append; - p->packer_vprintf = (vprintf_f) store_vprintf; - p->real_handler = e; - e->buffer(); -} - -Packer::~Packer() -{ - if (append_ == (append_f) store_append && real_handler) - static_cast(real_handler)->flush(); - - /* it is not really necessary to do this, but, just in case... */ - append_ = NULL; - packer_vprintf = NULL; - real_handler = NULL; -} - -void -Packer::append(const char *buf, int sz) -{ - assert(real_handler && append_); - append_(real_handler, buf, sz); -} - -void -Packer::vappendf(const char *fmt, va_list args) -{ - assert(real_handler && packer_vprintf); - packer_vprintf(real_handler, fmt, args); -} - diff --git a/src/Packer.h b/src/Packer.h deleted file mode 100644 index c8b55eb400..0000000000 --- a/src/Packer.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 1996-2015 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_PACKER_H -#define SQUID_PACKER_H - -#include "base/Packable.h" - -/* see Packer.cc for description */ -class Packer; - -/* a common objPackInto interface; used by debugObj */ -typedef void (*ObjPackMethod) (void *obj, Packable * p); - -/* append/vprintf's for Packer */ -typedef void (*append_f) (void *, const char *buf, int size); -typedef void (*vprintf_f) (void *, const char *fmt, va_list args); - -class Packer : public Packable -{ - -public: - virtual ~Packer(); - - /* Packable API */ - virtual void append(const char *buf, int size); - virtual void vappendf(const char *fmt, va_list ap); - - /* protected, use interface functions instead */ - append_f append_; - vprintf_f packer_vprintf; - void *real_handler; /* first parameter to real append and vprintf */ -}; - -#endif /* SQUID_PACKER_H */ - diff --git a/src/base/Packable.h b/src/base/Packable.h index fd1dc01ad0..16e7770388 100644 --- a/src/base/Packable.h +++ b/src/base/Packable.h @@ -42,7 +42,7 @@ * storeAppend. Packable buffer objects retain the data such that it can be * flushed later to Comm::Write. * - * Thus, one can write just one function that will take a Packer* pointer + * Thus, one can write just one function that will take a Packable object * and either "pack" things for Comm::Write or "append" things to Store, * depending on actual Packable object supplied. */ @@ -60,19 +60,6 @@ public: vappendf(fmt, args); va_end(args); } -#if 0 - /* - * \note we use Printf instead of printf so the compiler won't - * think we're calling the libc printf() - */ - void Printf(const char *fmt,...) PRINTF_FORMAT_ARG2 - { - va_list args; - va_start(args, fmt); - vappendf(fmt, args); - va_end(args); - } -#endif /** Append operation, with vsprintf(3)-style arguments. * diff --git a/src/http/StatusLine.cc b/src/http/StatusLine.cc index 4671dfda5c..f561ebce94 100644 --- a/src/http/StatusLine.cc +++ b/src/http/StatusLine.cc @@ -9,9 +9,9 @@ /* DEBUG: section 57 HTTP Status-line */ #include "squid.h" +#include "base/Packable.h" #include "Debug.h" #include "http/StatusLine.h" -#include "Packer.h" void Http::StatusLine::init() diff --git a/src/http/StatusLine.h b/src/http/StatusLine.h index 608c8173aa..c34c76fa1a 100644 --- a/src/http/StatusLine.h +++ b/src/http/StatusLine.h @@ -43,8 +43,8 @@ public: /// retrieve the reason string for this status line const char *reason() const; - /// pack fields using Packer - void packInto(Packable * p) const; + /// pack fields into a Packable object + void packInto(Packable *) const; /** * Parse a buffer and fill internal structures; diff --git a/src/tests/stub_store.cc b/src/tests/stub_store.cc index 6427a80087..b6713a8e9f 100644 --- a/src/tests/stub_store.cc +++ b/src/tests/stub_store.cc @@ -143,6 +143,5 @@ void storeFsInit(void) STUB void storeFsDone(void) STUB void storeReplAdd(const char *, REMOVALPOLICYCREATE *) STUB void destroyStoreEntry(void *) STUB -// in Packer.cc !? void packerToStoreInit(Packer * p, StoreEntry * e) STUB void storeGetMemSpace(int size) STUB diff --git a/src/tools.h b/src/tools.h index 7dd11670ae..af185be442 100644 --- a/src/tools.h +++ b/src/tools.h @@ -11,7 +11,6 @@ #ifndef SQUID_TOOLS_H_ #define SQUID_TOOLS_H_ -#include "Packer.h" #include "SBuf.h" #include "SquidString.h" #include "typedefs.h" @@ -30,6 +29,11 @@ int getMyPort(void); void setUmask(mode_t mask); void strwordquote(MemBuf * mb, const char *str); +class Packable; + +/* a common objPackInto interface; used by debugObj */ +typedef void (*ObjPackMethod) (void *obj, Packable * p); + /* packs, then prints an object using debugs() */ void debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm);