=== modified file 'configure.ac' --- configure.ac 2011-02-22 23:39:33 +0000 +++ configure.ac 2011-02-25 09:16:25 +0000 @@ -3366,6 +3366,7 @@ lib/smblib/Makefile \ scripts/Makefile \ src/Makefile \ + src/anyp/Makefile \ src/base/Makefile \ src/acl/Makefile \ src/fs/Makefile \ === modified file 'src/AclRegs.cc' --- src/AclRegs.cc 2011-02-07 10:27:53 +0000 +++ src/AclRegs.cc 2011-02-14 09:56:16 +0000 @@ -110,7 +110,7 @@ ACL::Prototype ACLPeerName::RegistryProtoype(&ACLPeerName::RegistryEntry_, "peername"); ACLStrategised ACLPeerName::RegistryEntry_(new ACLStringData, ACLPeerNameStrategy::Instance(), "peername"); ACL::Prototype ACLProtocol::RegistryProtoype(&ACLProtocol::RegistryEntry_, "proto"); -ACLStrategised ACLProtocol::RegistryEntry_(new ACLProtocolData, ACLProtocolStrategy::Instance(), "proto"); +ACLStrategised ACLProtocol::RegistryEntry_(new ACLProtocolData, ACLProtocolStrategy::Instance(), "proto"); ACL::Prototype ACLRandom::RegistryProtoype(&ACLRandom::RegistryEntry_, "random"); ACLRandom ACLRandom::RegistryEntry_("random"); ACL::Prototype ACLReferer::RegistryProtoype(&ACLReferer::RegistryEntry_, "referer_regex"); === modified file 'src/HttpMsg.cc' --- src/HttpMsg.cc 2011-01-25 08:55:40 +0000 +++ src/HttpMsg.cc 2011-02-14 09:56:16 +0000 @@ -38,7 +38,7 @@ #include "MemBuf.h" HttpMsg::HttpMsg(http_hdr_owner_type owner): header(owner), - cache_control(NULL), hdr_sz(0), content_length(0), protocol(PROTO_NONE), + cache_control(NULL), hdr_sz(0), content_length(0), protocol(AnyP::PROTO_NONE), pstate(psReadyToParseStartLine), lock_count(0) {} === modified file 'src/HttpMsg.h' --- src/HttpMsg.h 2011-02-21 05:06:20 +0000 +++ src/HttpMsg.h 2011-02-25 09:16:25 +0000 @@ -89,7 +89,7 @@ int64_t content_length; - protocol_t protocol; + AnyP::ProtocolType protocol; HttpMsgParseState pstate; /* the current parsing state */ === modified file 'src/HttpRequest.cc' --- src/HttpRequest.cc 2011-02-07 10:27:53 +0000 +++ src/HttpRequest.cc 2011-02-14 10:51:08 +0000 @@ -53,7 +53,7 @@ init(); } -HttpRequest::HttpRequest(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath) : HttpMsg(hoRequest) +HttpRequest::HttpRequest(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath) : HttpMsg(hoRequest) { static unsigned int id = 1; debugs(93,7, HERE << "constructed, this=" << this << " id=" << ++id); @@ -68,7 +68,7 @@ } void -HttpRequest::initHTTP(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath) +HttpRequest::initHTTP(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath) { method = aMethod; protocol = aProtocol; @@ -79,7 +79,7 @@ HttpRequest::init() { method = METHOD_NONE; - protocol = PROTO_NONE; + protocol = AnyP::PROTO_NONE; urlpath = NULL; login[0] = '\0'; host[0] = '\0'; @@ -565,7 +565,7 @@ bool HttpRequest::cacheable() const { - if (protocol == PROTO_HTTP) + if (protocol == AnyP::PROTO_HTTP) return httpCachable(method); /* @@ -580,10 +580,10 @@ * XXX POST may be cached sometimes.. ignored * for now */ - if (protocol == PROTO_GOPHER) + if (protocol == AnyP::PROTO_GOPHER) return gopherCachable(this); - if (protocol == PROTO_CACHEOBJ) + if (protocol == AnyP::PROTO_CACHEOBJ) return false; return true; === modified file 'src/HttpRequest.h' --- src/HttpRequest.h 2011-02-24 10:18:58 +0000 +++ src/HttpRequest.h 2011-02-25 09:16:25 +0000 @@ -73,7 +73,7 @@ MEMPROXY_CLASS(HttpRequest); HttpRequest(); - HttpRequest(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath); + HttpRequest(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath); ~HttpRequest(); virtual void reset(); @@ -82,7 +82,7 @@ return static_cast(HttpMsg::_lock()); }; - void initHTTP(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath); + void initHTTP(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath); virtual HttpRequest *clone() const; === modified file 'src/HttpStatusLine.cc' --- src/HttpStatusLine.cc 2009-11-03 01:12:56 +0000 +++ src/HttpStatusLine.cc 2011-02-14 09:56:17 +0000 @@ -60,7 +60,7 @@ httpStatusLineSet(HttpStatusLine * sline, HttpVersion version, http_status status, const char *reason) { assert(sline); - sline->protocol = PROTO_HTTP; + sline->protocol = AnyP::PROTO_HTTP; sline->version = version; sline->status = status; /* Note: no xstrdup for 'reason', assumes constant 'reasons' */ @@ -77,7 +77,7 @@ assert(sline && p); /* handle ICY protocol status line specially. Pass on the bad format. */ - if (sline->protocol == PROTO_ICY) { + if (sline->protocol == AnyP::PROTO_ICY) { debugs(57, 9, "packing sline " << sline << " using " << p << ":"); debugs(57, 9, "FORMAT=" << IcyStatusLineFormat ); debugs(57, 9, "ICY " << sline->status << " " << (sline->reason ? sline->reason : httpStatusString(sline->status)) ); @@ -108,7 +108,7 @@ if (protoPrefix.cmp("ICY", 3) == 0) { debugs(57, 3, "httpStatusLineParse: Invalid HTTP identifier. Detected ICY protocol istead."); - sline->protocol = PROTO_ICY; + sline->protocol = AnyP::PROTO_ICY; start += protoPrefix.size(); } else if (protoPrefix.caseCmp(start, protoPrefix.size()) == 0) { === modified file 'src/HttpStatusLine.h' --- src/HttpStatusLine.h 2010-11-21 04:40:05 +0000 +++ src/HttpStatusLine.h 2011-02-14 09:56:17 +0000 @@ -36,10 +36,9 @@ class Packer; class String; -/* for http_status and protocol_t */ -#include "enums.h" - +#include "HttpStatusCode.h" #include "HttpVersion.h" +#include "anyp/ProtocolType.h" #include "SquidString.h" /** @@ -54,10 +53,10 @@ /** * By rights protocol name should be a constant "HTTP", with no need for this field to exist. - * However there are protocols which violate HTTP by sending their wn custom formats - * back with other protocol names (ICY streaming format being the current major problem) + * However there are protocols which violate HTTP by sending their own custom formats + * back with other protocol names (ICY streaming format being the current major problem). */ - protocol_t protocol; + AnyP::ProtocolType protocol; HttpVersion version; ///< breakdown of protocol version labels: 0.9 1.0 1.1 http_status status; ///< status code. ie 200 404 === modified file 'src/Makefile.am' --- src/Makefile.am 2011-02-18 23:11:19 +0000 +++ src/Makefile.am 2011-03-01 11:12:43 +0000 @@ -30,8 +30,8 @@ LoadableModules.h \ LoadableModules.cc -SUBDIRS = base comm eui acl fs repl -DIST_SUBDIRS = base comm eui acl fs repl +SUBDIRS = base anyp comm eui acl fs repl +DIST_SUBDIRS = base anyp comm eui acl fs repl if ENABLE_AUTH SUBDIRS += auth @@ -554,6 +554,7 @@ squid_LDADD = \ $(COMMON_LIBS) \ + anyp/libanyp.la \ comm/libcomm.la \ eui/libeui.la \ icmp/libicmp.la icmp/libicmp-core.la \ @@ -1044,6 +1045,7 @@ tests_testAuth_LDADD= \ $(COMMON_LIBS) \ + anyp/libanyp.la \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ @@ -1310,6 +1312,7 @@ $(ADAPTATION_LIBS) \ $(ESI_LIBS) \ $(SSL_LIBS) \ + anyp/libanyp.la \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ @@ -1341,6 +1344,7 @@ SquidMath.h \ swap_log_op.cc tests_testDiskIO_LDADD = \ + anyp/libanyp.la \ SquidConfig.o \ CommCalls.o \ DnsLookupDetails.o \ @@ -1513,6 +1517,7 @@ $(BUILT_SOURCES) tests_testEvent_LDADD = \ $(COMMON_LIBS) \ + anyp/libanyp.la \ $(SNMP_LIBS) \ icmp/libicmp.la icmp/libicmp-core.la \ comm/libcomm.la \ @@ -1674,6 +1679,7 @@ $(BUILT_SOURCES) tests_testEventLoop_LDADD = \ $(COMMON_LIBS) \ + anyp/libanyp.la \ $(SNMP_LIBS) \ icmp/libicmp.la icmp/libicmp-core.la \ comm/libcomm.la \ @@ -1830,6 +1836,7 @@ $(BUILT_SOURCES) tests_test_http_range_LDADD = \ $(COMMON_LIBS) \ + anyp/libanyp.la \ $(SNMP_LIBS) \ icmp/libicmp.la icmp/libicmp-core.la \ comm/libcomm.la \ @@ -1991,6 +1998,7 @@ $(BUILT_SOURCES) tests_testHttpRequest_LDADD = \ $(COMMON_LIBS) \ + anyp/libanyp.la \ $(SNMP_LIBS) \ icmp/libicmp.la icmp/libicmp-core.la \ comm/libcomm.la \ @@ -2089,6 +2097,7 @@ tests_testStore_LDADD= \ $(COMMON_LIBS) \ + anyp/libanyp.la \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ @@ -2191,6 +2200,7 @@ SquidMath.h \ swap_log_op.cc tests_testUfs_LDADD = \ + anyp/libanyp.la \ CommCalls.o \ DnsLookupDetails.o \ $(COMMON_LIBS) \ @@ -2405,6 +2415,7 @@ nodist_tests_testURL_SOURCES = \ $(BUILT_SOURCES) tests_testURL_LDADD = \ + anyp/libanyp.la \ $(COMMON_LIBS) \ $(SNMP_LIBS) \ icmp/libicmp.la icmp/libicmp-core.la \ === modified file 'src/URLScheme.cc' --- src/URLScheme.cc 2009-11-02 04:43:19 +0000 +++ src/URLScheme.cc 2011-03-01 05:38:54 +0000 @@ -33,25 +33,24 @@ * */ -#include "squid.h" +#include "config.h" #include "URLScheme.h" #include "wordlist.h" -const char *ProtocolStr[] = { - "NONE", - "http", - "ftp", - "gopher", - "wais", - "cache_object", - "icp", -#if USE_HTCP - "htcp", -#endif - "urn", - "whois", - "internal", - "https", - "icy", - "TOTAL" -}; +char const * +URLScheme::const_str() const +{ + if (theScheme_ == AnyP::PROTO_UNKNOWN) + return "(unknown)"; + + static char out[BUFSIZ]; + int p = 0; + + if (theScheme_ > AnyP::PROTO_NONE && theScheme_ < AnyP::PROTO_MAX) { + const char *in = AnyP::ProtocolType_str[theScheme_]; + for (; p < (BUFSIZ-1) && in[p] != '\0'; ++p) + out[p] = xtolower(in[p]); + } + out[p] = '\0'; + return out; +} === modified file 'src/URLScheme.h' --- src/URLScheme.h 2009-01-21 03:47:47 +0000 +++ src/URLScheme.h 2011-03-01 01:43:30 +0000 @@ -34,40 +34,36 @@ #ifndef SQUID_URLSCHEME_H #define SQUID_URLSCHEME_H -/* For the definition of NULL and protocol_t */ -#include "squid.h" - +#include "anyp/ProtocolType.h" +#if HAVE_IOSFWD #include - -extern const char *ProtocolStr[]; - -/* This class represents a URL Scheme such as HTTPS, HTTP, WAIS etc. +#endif + +/** This class represents a URL Scheme such as HTTPS, HTTP, WAIS etc. * It does not represent the PROTOCOL that such schemes refer to. */ - class URLScheme { public: - URLScheme() : theScheme(PROTO_NONE) {} - - URLScheme(protocol_t const aScheme) : theScheme(aScheme) {} - - operator protocol_t() const { return theScheme; } - - bool operator != (protocol_t const & aProtocol) const { return theScheme != aProtocol;} - - /* Get a char string representation of the scheme. */ - char const *const_str() const { return ProtocolStr[theScheme]; } + URLScheme() : theScheme_(AnyP::PROTO_NONE) {} + URLScheme(AnyP::ProtocolType const aScheme) : theScheme_(aScheme) {} + ~URLScheme() {} + + operator AnyP::ProtocolType() const { return theScheme_; } + + bool operator != (AnyP::ProtocolType const & aProtocol) const { return theScheme_ != aProtocol; } + + /** Get a char string representation of the scheme. + * An upper bound length of BUFSIZ bytes converted. Remainder will be truncated. + * The result of this call will remain usable only until any subsequest call + * and must be copied if persistence is needed. + */ + char const *const_str() const; private: - /* This is a typecode for now - TODO make the varying methods virtual - * Doing that without doubling the storage size will require having - * something like a flyweight. perhaps the strategy pattern is appropiate: - * one strategy per scheme, and an object that is nothing but a pointer - * into the registry of schemes. - */ - protocol_t theScheme; + /// This is a typecode pointer into the enum/registry of protocols handled. + AnyP::ProtocolType theScheme_; }; inline std::ostream & === modified file 'src/acl/Protocol.cc' --- src/acl/Protocol.cc 2009-03-17 02:04:14 +0000 +++ src/acl/Protocol.cc 2011-02-14 09:56:17 +0000 @@ -41,14 +41,14 @@ /* explicit template instantiation required for some systems */ -template class ACLStrategised; +template class ACLStrategised; int ACLProtocolStrategy::match (ACLData * &data, ACLFilledChecklist *checklist) { - return data->match (checklist->request->protocol); + return data->match(checklist->request->protocol); } ACLProtocolStrategy * === modified file 'src/acl/Protocol.h' --- src/acl/Protocol.h 2009-03-08 21:53:27 +0000 +++ src/acl/Protocol.h 2011-02-14 09:56:17 +0000 @@ -35,10 +35,12 @@ #ifndef SQUID_ACLPROTOCOL_H #define SQUID_ACLPROTOCOL_H + #include "acl/Strategy.h" #include "acl/Strategised.h" +#include "anyp/ProtocolType.h" -class ACLProtocolStrategy : public ACLStrategy +class ACLProtocolStrategy : public ACLStrategy { public: @@ -63,7 +65,7 @@ private: static ACL::Prototype RegistryProtoype; - static ACLStrategised RegistryEntry_; + static ACLStrategised RegistryEntry_; }; #endif /* SQUID_ACLPROTOCOL_H */ === modified file 'src/acl/ProtocolData.cc' --- src/acl/ProtocolData.cc 2009-03-08 19:34:36 +0000 +++ src/acl/ProtocolData.cc 2011-02-28 23:05:38 +0000 @@ -55,7 +55,7 @@ } bool -ACLProtocolData::match(protocol_t toFind) +ACLProtocolData::match(AnyP::ProtocolType toFind) { return values->findAndTune (toFind); } @@ -63,17 +63,17 @@ /* explicit instantiation required for some systems */ /// \cond AUTODOCS-IGNORE -template cbdata_type CbDataList::CBDATA_CbDataList; +template cbdata_type CbDataList::CBDATA_CbDataList; /// \endcond wordlist * ACLProtocolData::dump() { wordlist *W = NULL; - CbDataList *data = values; + CbDataList *data = values; while (data != NULL) { - wordlistAdd(&W, ProtocolStr[data->element]); + wordlistAdd(&W, AnyP::ProtocolType_str[data->element]); data = data->next; } @@ -83,14 +83,21 @@ void ACLProtocolData::parse() { - CbDataList **Tail; + CbDataList **Tail; char *t = NULL; for (Tail = &values; *Tail; Tail = &((*Tail)->next)); while ((t = strtokFile())) { - CbDataList *q = new CbDataList (urlParseProtocol(t)); - *(Tail) = q; - Tail = &q->next; + for (int p = AnyP::PROTO_NONE; p < AnyP::PROTO_UNKNOWN; ++p) { + if (strcasecmp(t, AnyP::ProtocolType_str[p]) != 0) { + CbDataList *q = new CbDataList(static_cast(p)); + *(Tail) = q; + Tail = &q->next; + break; + } else { + debugs(28, DBG_IMPORTANT, "WARNING: Ignoring unknown protocol '" << t << "' in the ACL named '" << AclMatchedName << "'"); + } + } } } @@ -100,7 +107,7 @@ return values == NULL; } -ACLData * +ACLData * ACLProtocolData::clone() const { /* Splay trees don't clone yet. */ === modified file 'src/acl/ProtocolData.h' --- src/acl/ProtocolData.h 2009-03-08 19:34:36 +0000 +++ src/acl/ProtocolData.h 2011-02-14 09:56:17 +0000 @@ -35,11 +35,13 @@ #ifndef SQUID_ACLPROTOCOLDATA_H #define SQUID_ACLPROTOCOLDATA_H + #include "acl/Acl.h" #include "acl/Data.h" +#include "anyp/ProtocolType.h" #include "CbDataList.h" -class ACLProtocolData : public ACLData +class ACLProtocolData : public ACLData { public: @@ -49,13 +51,13 @@ ACLProtocolData(ACLProtocolData const &); ACLProtocolData &operator= (ACLProtocolData const &); virtual ~ACLProtocolData(); - bool match(protocol_t); + bool match(AnyP::ProtocolType); wordlist *dump(); void parse(); bool empty() const; - virtual ACLData *clone() const; + virtual ACLData *clone() const; - CbDataList *values; + CbDataList *values; }; MEMPROXY_CLASS_INLINE(ACLProtocolData); === added directory 'src/anyp' === added file 'src/anyp/Makefile.am' --- src/anyp/Makefile.am 1970-01-01 00:00:00 +0000 +++ src/anyp/Makefile.am 2011-02-14 09:57:21 +0000 @@ -0,0 +1,13 @@ +include $(top_srcdir)/src/Common.am +include $(top_srcdir)/src/TestHeaders.am + +noinst_LTLIBRARIES = libanyp.la + +libanyp_la_SOURCES = \ + ProtocolType.cc \ + ProtocolType.h + +ProtocolType.cc: ProtocolType.h $(top_srcdir)/src/mk-string-arrays.awk + ($(AWK) -f $(top_srcdir)/src/mk-string-arrays.awk <$(srcdir)/ProtocolType.h | sed -e 's%PROTO_%%' >$@) || ($(RM) -f $@ && exit 1) + +CLEANFILES += ProtocolType.cc === added file 'src/anyp/ProtocolType.h' --- src/anyp/ProtocolType.h 1970-01-01 00:00:00 +0000 +++ src/anyp/ProtocolType.h 2011-03-02 01:45:36 +0000 @@ -0,0 +1,53 @@ +#ifndef _SQUID_SRC_ANYP_PROTOCOLTYPE_H +#define _SQUID_SRC_ANYP_PROTOCOLTYPE_H + +#if HAVE_OSTREAM +#include +#endif + +namespace AnyP { + +/** + * List of all protocols known and supported. + * This is a combined list. It is used as type-codes where needed and + * the AnyP::ProtocolType_Str array of strings may be used for display + */ +typedef enum { + PROTO_NONE = 0, + PROTO_HTTP, + PROTO_FTP, + PROTO_HTTPS, + PROTO_GOPHER, + PROTO_WAIS, + PROTO_CACHEOBJ, + PROTO_ICP, +#if USE_HTCP + PROTO_HTCP, +#endif + PROTO_URN, + PROTO_WHOIS, + PROTO_INTERNAL, + PROTO_ICY, + PROTO_UNKNOWN, + PROTO_MAX +} ProtocolType; + +extern const char *ProtocolType_str[]; + +/** Display the registered Protocol Type (in upper case). + * If the protocol is not a registered AnyP::ProtocolType nothing will be displayed. + * The caller is responsible for any alternative text. + */ +inline std::ostream & +operator <<(std::ostream &os, ProtocolType const &p) +{ + if (PROTO_NONE <= p && p < PROTO_MAX) + os << ProtocolType_str[p]; + else + os << static_cast(p); + return os; +} + +} // namespace AnyP + +#endif /* _SQUID_SRC_ANYP_PROTOCOLTYPE_H */ === modified file 'src/client_db.cc' --- src/client_db.cc 2010-12-12 12:51:33 +0000 +++ src/client_db.cc 2011-02-14 09:56:17 +0000 @@ -143,7 +143,7 @@ } #endif void -clientdbUpdate(const Ip::Address &addr, log_type ltype, protocol_t p, size_t size) +clientdbUpdate(const Ip::Address &addr, log_type ltype, AnyP::ProtocolType p, size_t size) { char key[MAX_IPSTRLEN]; ClientInfo *c; @@ -161,14 +161,14 @@ if (c == NULL) debug_trap("clientdbUpdate: Failed to add entry"); - if (p == PROTO_HTTP) { + if (p == AnyP::PROTO_HTTP) { c->Http.n_requests++; c->Http.result_hist[ltype]++; kb_incr(&c->Http.kbytes_out, size); if (logTypeIsATcpHit(ltype)) kb_incr(&c->Http.hit_kbytes_out, size); - } else if (p == PROTO_ICP) { + } else if (p == AnyP::PROTO_ICP) { c->Icp.n_requests++; c->Icp.result_hist[ltype]++; kb_incr(&c->Icp.kbytes_out, size); === modified file 'src/client_side.cc' --- src/client_side.cc 2011-02-24 10:18:58 +0000 +++ src/client_side.cc 2011-02-25 09:16:25 +0000 @@ -679,7 +679,7 @@ updateCounters(); if (getConn() != NULL) - clientdbUpdate(getConn()->peer, logType, PROTO_HTTP, out.size); + clientdbUpdate(getConn()->peer, logType, AnyP::PROTO_HTTP, out.size); } delete checklist; @@ -2485,7 +2485,7 @@ } if (http->flags.internal) { - request->protocol = PROTO_HTTP; + request->protocol = AnyP::PROTO_HTTP; request->login[0] = '\0'; } === modified file 'src/client_side_reply.cc' --- src/client_side_reply.cc 2011-02-18 09:57:53 +0000 +++ src/client_side_reply.cc 2011-02-18 13:51:45 +0000 @@ -551,7 +551,7 @@ */ http->logType = LOG_TCP_CLIENT_REFRESH_MISS; processMiss(); - } else if (r->protocol == PROTO_HTTP) { + } else if (r->protocol == AnyP::PROTO_HTTP) { /* * Object needs to be revalidated * XXX This could apply to FTP as well, if Last-Modified is known. @@ -658,7 +658,7 @@ /** Check for internal requests. Update Protocol info if so. */ if (http->flags.internal) - r->protocol = PROTO_INTERNAL; + r->protocol = AnyP::PROTO_INTERNAL; r->clientConnection = http->getConn(); @@ -1504,7 +1504,7 @@ reply = HTTPMSGLOCK(rep); - if (reply->sline.protocol == PROTO_HTTP) { + if (reply->sline.protocol == AnyP::PROTO_HTTP) { /* RFC 2616 requires us to advertise our 1.1 version (but only on real HTTP traffic) */ reply->sline.version = HttpVersion(1,1); } @@ -2148,7 +2148,7 @@ */ if (http->request == NULL) - http->request = HTTPMSGLOCK(new HttpRequest(m, PROTO_NONE, null_string)); + http->request = HTTPMSGLOCK(new HttpRequest(m, AnyP::PROTO_NONE, null_string)); StoreEntry *e = storeCreateEntry(http->uri, http->log_uri, reqFlags, m); === modified file 'src/client_side_request.cc' --- src/client_side_request.cc 2011-02-07 10:27:53 +0000 +++ src/client_side_request.cc 2011-02-28 22:53:33 +0000 @@ -763,19 +763,18 @@ if (request->flags.loopdetect) return 0; - if (request->protocol == PROTO_HTTP) + if (request->protocol == AnyP::PROTO_HTTP) return httpCachable(method); - if (request->protocol == PROTO_GOPHER) + if (request->protocol == AnyP::PROTO_GOPHER) return gopherCachable(request); - if (request->protocol == PROTO_CACHEOBJ) + if (request->protocol == AnyP::PROTO_CACHEOBJ) return 0; return 1; } - static void clientCheckPinning(ClientHttpRequest * http) { === modified file 'src/enums.h' --- src/enums.h 2011-01-28 07:58:53 +0000 +++ src/enums.h 2011-02-14 09:56:17 +0000 @@ -143,25 +143,6 @@ STORE_DISK_CLIENT } store_client_t; -typedef enum { - PROTO_NONE, - PROTO_HTTP, - PROTO_FTP, - PROTO_GOPHER, - PROTO_WAIS, - PROTO_CACHEOBJ, - PROTO_ICP, -#if USE_HTCP - PROTO_HTCP, -#endif - PROTO_URN, - PROTO_WHOIS, - PROTO_INTERNAL, - PROTO_HTTPS, - PROTO_ICY, - PROTO_MAX -} protocol_t; - /* * These are for StoreEntry->flag, which is defined as a SHORT * === modified file 'src/errorpage.cc' --- src/errorpage.cc 2011-02-07 10:27:53 +0000 +++ src/errorpage.cc 2011-02-14 11:37:40 +0000 @@ -808,7 +808,7 @@ case 'P': if (request) { - p = ProtocolStr[request->protocol]; + p = AnyP::ProtocolType_str[request->protocol]; } else if (!building_deny_info_url) { p = "[unknown protocol]"; } === modified file 'src/external_acl.cc' --- src/external_acl.cc 2011-02-16 01:12:34 +0000 +++ src/external_acl.cc 2011-02-16 10:49:56 +0000 @@ -954,7 +954,7 @@ break; case _external_acl_format::EXT_ACL_PROTO: - str = ProtocolStr[request->protocol]; + str = AnyP::ProtocolType_str[request->protocol]; break; case _external_acl_format::EXT_ACL_PORT: === modified file 'src/forward.cc' --- src/forward.cc 2011-01-10 09:43:43 +0000 +++ src/forward.cc 2011-02-14 09:56:17 +0000 @@ -203,7 +203,7 @@ */ if ( Config.accessList.miss && !request->client_addr.IsNoAddr() && - request->protocol != PROTO_INTERNAL && request->protocol != PROTO_CACHEOBJ) { + request->protocol != AnyP::PROTO_INTERNAL && request->protocol != AnyP::PROTO_CACHEOBJ) { /** * Check if this host is allowed to fetch MISSES from us (miss_access) */ @@ -247,15 +247,15 @@ switch (request->protocol) { - case PROTO_INTERNAL: + case AnyP::PROTO_INTERNAL: internalStart(request, entry); return; - case PROTO_CACHEOBJ: + case AnyP::PROTO_CACHEOBJ: CacheManager::GetInstance()->Start(client_fd, request, entry); return; - case PROTO_URN: + case AnyP::PROTO_URN: urnStart(request, entry); return; @@ -752,7 +752,7 @@ #if USE_SSL if ((fs->_peer && fs->_peer->use_ssl) || - (!fs->_peer && request->protocol == PROTO_HTTPS)) { + (!fs->_peer && request->protocol == AnyP::PROTO_HTTPS)) { initiateSSL(); return; } @@ -1069,36 +1069,36 @@ switch (request->protocol) { #if USE_SSL - case PROTO_HTTPS: + case AnyP::PROTO_HTTPS: httpStart(this); break; #endif - case PROTO_HTTP: + case AnyP::PROTO_HTTP: httpStart(this); break; - case PROTO_GOPHER: + case AnyP::PROTO_GOPHER: gopherStart(this); break; - case PROTO_FTP: + case AnyP::PROTO_FTP: ftpStart(this); break; - case PROTO_CACHEOBJ: - - case PROTO_INTERNAL: - - case PROTO_URN: + case AnyP::PROTO_CACHEOBJ: + + case AnyP::PROTO_INTERNAL: + + case AnyP::PROTO_URN: fatal_dump("Should never get here"); break; - case PROTO_WHOIS: + case AnyP::PROTO_WHOIS: whoisStart(this); break; - case PROTO_WAIS: /* Not implemented */ + case AnyP::PROTO_WAIS: /* Not implemented */ default: debugs(17, 1, "fwdDispatch: Cannot retrieve '" << entry->url() << "'" ); === modified file 'src/ftp.cc' --- src/ftp.cc 2011-01-26 03:47:13 +0000 +++ src/ftp.cc 2011-02-14 10:49:39 +0000 @@ -1471,7 +1471,7 @@ title_url.append(request->GetHost()); - if (request->port != urlDefaultPort(PROTO_FTP)) { + if (request->port != urlDefaultPort(AnyP::PROTO_FTP)) { title_url.append(":"); title_url.append(xitoa(request->port)); } @@ -1493,7 +1493,7 @@ base_href.append(request->GetHost()); - if (request->port != urlDefaultPort(PROTO_FTP)) { + if (request->port != urlDefaultPort(AnyP::PROTO_FTP)) { base_href.append(":"); base_href.append(xitoa(request->port)); } @@ -3773,7 +3773,7 @@ { String newbuf = "%2f"; - if (request->protocol != PROTO_FTP) + if (request->protocol != AnyP::PROTO_FTP) return NULL; if ( request->urlpath[0]=='/' ) { === modified file 'src/http.cc' --- src/http.cc 2011-02-07 10:27:53 +0000 +++ src/http.cc 2011-02-14 09:56:17 +0000 @@ -717,14 +717,14 @@ newrep->removeStaleWarnings(); - if (newrep->sline.protocol == PROTO_HTTP && newrep->sline.status >= 100 && newrep->sline.status < 200) { + if (newrep->sline.protocol == AnyP::PROTO_HTTP && newrep->sline.status >= 100 && newrep->sline.status < 200) { handle1xx(newrep); ctx_exit(ctx); return; } flags.chunked = 0; - if (newrep->sline.protocol == PROTO_HTTP && newrep->header.chunked()) { + if (newrep->sline.protocol == AnyP::PROTO_HTTP && newrep->header.chunked()) { flags.chunked = 1; httpChunkDecoder = new ChunkedCodingParser; } @@ -1816,7 +1816,7 @@ /* append Front-End-Https */ if (flags.front_end_https) { - if (flags.front_end_https == 1 || request->protocol == PROTO_HTTPS) + if (flags.front_end_https == 1 || request->protocol == AnyP::PROTO_HTTPS) hdr_out->putStr(HDR_FRONT_END_HTTPS, "On"); } === modified file 'src/icp_v2.cc' --- src/icp_v2.cc 2011-01-10 09:43:43 +0000 +++ src/icp_v2.cc 2011-02-14 09:56:17 +0000 @@ -214,7 +214,7 @@ if (LOG_ICP_QUERY == logcode) return; - clientdbUpdate(caddr, logcode, PROTO_ICP, len); + clientdbUpdate(caddr, logcode, AnyP::PROTO_ICP, len); if (!Config.onoff.log_udp) return; @@ -425,7 +425,7 @@ * count this DENIED query in the clientdb, even though * we're not sending an ICP reply... */ - clientdbUpdate(from, LOG_UDP_DENIED, PROTO_ICP, 0); + clientdbUpdate(from, LOG_UDP_DENIED, AnyP::PROTO_ICP, 0); } else { icpCreateAndSend(ICP_DENIED, 0, url, reqnum, 0, fd, from); } === modified file 'src/internal.cc' --- src/internal.cc 2010-07-25 08:10:12 +0000 +++ src/internal.cc 2011-02-14 10:51:47 +0000 @@ -125,7 +125,7 @@ mb.Printf("http://%s", lc_host); /* append port if not default */ - if (port && port != urlDefaultPort(PROTO_HTTP)) + if (port && port != urlDefaultPort(AnyP::PROTO_HTTP)) mb.Printf(":%d", port); if (dir) === modified file 'src/neighbors.cc' --- src/neighbors.cc 2011-02-11 11:48:28 +0000 +++ src/neighbors.cc 2011-02-14 09:56:17 +0000 @@ -1093,14 +1093,14 @@ if (p == NULL) { neighborIgnoreNonPeer(from, opcode); } else { - mem->ping_reply_callback(p, ntype, PROTO_ICP, header, mem->ircb_data); + mem->ping_reply_callback(p, ntype, AnyP::PROTO_ICP, header, mem->ircb_data); } } else if (opcode == ICP_HIT) { if (p == NULL) { neighborIgnoreNonPeer(from, opcode); } else { header->opcode = ICP_HIT; - mem->ping_reply_callback(p, ntype, PROTO_ICP, header, mem->ircb_data); + mem->ping_reply_callback(p, ntype, AnyP::PROTO_ICP, header, mem->ircb_data); } } else if (opcode == ICP_DECHO) { if (p == NULL) { @@ -1109,7 +1109,7 @@ debug_trap("neighborsUdpAck: Found non-ICP cache as SIBLING\n"); debug_trap("neighborsUdpAck: non-ICP neighbors must be a PARENT\n"); } else { - mem->ping_reply_callback(p, ntype, PROTO_ICP, header, mem->ircb_data); + mem->ping_reply_callback(p, ntype, AnyP::PROTO_ICP, header, mem->ircb_data); } } else if (opcode == ICP_SECHO) { if (p) { @@ -1132,7 +1132,7 @@ } } } else if (opcode == ICP_MISS_NOFETCH) { - mem->ping_reply_callback(p, ntype, PROTO_ICP, header, mem->ircb_data); + mem->ping_reply_callback(p, ntype, AnyP::PROTO_ICP, header, mem->ircb_data); } else { debugs(15, 0, "neighborsUdpAck: Unexpected ICP reply: " << opcode_d); } @@ -1523,7 +1523,7 @@ } static void -peerCountHandleIcpReply(peer * p, peer_t type, protocol_t proto, void *hdrnotused, void *data) +peerCountHandleIcpReply(peer * p, peer_t type, AnyP::ProtocolType proto, void *hdrnotused, void *data) { int rtt_av_factor; @@ -1531,7 +1531,7 @@ StoreEntry *fake = psstate->entry; MemObject *mem = fake->mem_obj; int rtt = tvSubMsec(mem->start_ping, current_time); - assert(proto == PROTO_ICP); + assert(proto == AnyP::PROTO_ICP); assert(fake); assert(mem); psstate->ping.n_recv++; @@ -1838,7 +1838,7 @@ } debugs(15, 3, "neighborsHtcpReply: e = " << e); - mem->ping_reply_callback(p, ntype, PROTO_HTCP, htcp, mem->ircb_data); + mem->ping_reply_callback(p, ntype, AnyP::PROTO_HTCP, htcp, mem->ircb_data); } /* === modified file 'src/peer_select.cc' --- src/peer_select.cc 2011-02-07 10:27:53 +0000 +++ src/peer_select.cc 2011-02-14 09:56:17 +0000 @@ -497,7 +497,7 @@ return; /* WAIS is not implemented natively */ - if (ps->request->protocol == PROTO_WAIS) + if (ps->request->protocol == AnyP::PROTO_WAIS) return; peerAddFwdServer(&ps->servers, NULL, HIER_DIRECT); @@ -745,20 +745,20 @@ #endif static void -peerHandlePingReply(peer * p, peer_t type, protocol_t proto, void *pingdata, void *data) +peerHandlePingReply(peer * p, peer_t type, AnyP::ProtocolType proto, void *pingdata, void *data) { - if (proto == PROTO_ICP) + if (proto == AnyP::PROTO_ICP) peerHandleIcpReply(p, type, (icp_common_t *)pingdata, data); #if USE_HTCP - else if (proto == PROTO_HTCP) + else if (proto == AnyP::PROTO_HTCP) peerHandleHtcpReply(p, type, (htcpReplyData *)pingdata, data); #endif else - debugs(44, 1, "peerHandlePingReply: unknown protocol_t " << proto); + debugs(44, 1, "peerHandlePingReply: unknown protocol " << proto); } static void === modified file 'src/protos.h' --- src/protos.h 2011-02-07 10:27:53 +0000 +++ src/protos.h 2011-02-14 10:27:57 +0000 @@ -84,7 +84,8 @@ SQUIDCEXTERN void clientdbInit(void); -SQUIDCEXTERN void clientdbUpdate(const Ip::Address &, log_type, protocol_t, size_t); +#include "anyp/ProtocolType.h" +SQUIDCEXTERN void clientdbUpdate(const Ip::Address &, log_type, AnyP::ProtocolType, size_t); SQUIDCEXTERN int clientdbCutoffDenied(const Ip::Address &); void clientdbDump(StoreEntry *); @@ -614,7 +615,7 @@ SQUIDCEXTERN void unlinkdUnlink(const char *); #endif -SQUIDCEXTERN protocol_t urlParseProtocol(const char *, const char *e = NULL); +SQUIDCEXTERN AnyP::ProtocolType urlParseProtocol(const char *, const char *e = NULL); SQUIDCEXTERN void urlInitialize(void); SQUIDCEXTERN HttpRequest *urlParse(const HttpRequestMethod&, char *, HttpRequest *request = NULL); SQUIDCEXTERN const char *urlCanonical(HttpRequest *); @@ -626,7 +627,7 @@ SQUIDCEXTERN char *urlInternal(const char *dir, const char *name); SQUIDCEXTERN int matchDomainName(const char *host, const char *domain); SQUIDCEXTERN int urlCheckRequest(const HttpRequest *); -SQUIDCEXTERN int urlDefaultPort(protocol_t p); +SQUIDCEXTERN int urlDefaultPort(AnyP::ProtocolType p); SQUIDCEXTERN char *urlHostname(const char *url); SQUIDCEXTERN void urlExtMethodConfigure(void); === modified file 'src/tests/stub_HttpRequest.cc' --- src/tests/stub_HttpRequest.cc 2009-07-26 09:08:24 +0000 +++ src/tests/stub_HttpRequest.cc 2011-02-14 11:48:18 +0000 @@ -41,7 +41,7 @@ fatal("Not implemented"); } -HttpRequest::HttpRequest(const HttpRequestMethod& method, protocol_t protocol, const char *aUrlpath) : HttpMsg(hoRequest) +HttpRequest::HttpRequest(const HttpRequestMethod& method, AnyP::ProtocolType protocol, const char *aUrlpath) : HttpMsg(hoRequest) { fatal("Not implemented"); } @@ -82,7 +82,7 @@ } void -HttpRequest::initHTTP(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath) +HttpRequest::initHTTP(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath) { fatal("Not implemented"); } === modified file 'src/tests/testHttpRequest.cc' --- src/tests/testHttpRequest.cc 2010-09-29 07:25:36 +0000 +++ src/tests/testHttpRequest.cc 2011-02-15 01:55:54 +0000 @@ -42,7 +42,7 @@ CPPUNIT_ASSERT(aRequest->method == METHOD_GET); CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/bar"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); CPPUNIT_ASSERT_EQUAL(String("http://foo:90/bar"), String(url)); xfree(url); @@ -54,7 +54,7 @@ CPPUNIT_ASSERT(aRequest->method == METHOD_PUT); CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/bar"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); CPPUNIT_ASSERT_EQUAL(String("http://foo/bar"), String(url)); /* a connect url with non-CONNECT data */ @@ -71,7 +71,7 @@ CPPUNIT_ASSERT(aRequest->method == METHOD_CONNECT); CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String(""), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(PROTO_NONE, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_NONE, aRequest->protocol); CPPUNIT_ASSERT_EQUAL(String("foo:45"), String(url)); xfree(url); } @@ -91,7 +91,7 @@ CPPUNIT_ASSERT(aRequest->method == METHOD_GET); CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/bar"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); CPPUNIT_ASSERT_EQUAL(String("http://foo:90/bar"), String(url)); xfree(url); } @@ -114,7 +114,7 @@ CPPUNIT_ASSERT(aRequest->method == METHOD_GET); CPPUNIT_ASSERT_EQUAL(String("[2000:800::45]"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/foo"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); CPPUNIT_ASSERT_EQUAL(String("http://[2000:800::45]/foo"), String(url)); xfree(url); @@ -126,7 +126,7 @@ CPPUNIT_ASSERT(aRequest->method == METHOD_GET); CPPUNIT_ASSERT_EQUAL(String("[2000:800::45]"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/foo"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); CPPUNIT_ASSERT_EQUAL(String("http://[2000:800::45]:90/foo"), String(url)); xfree(url); @@ -138,7 +138,7 @@ CPPUNIT_ASSERT(aRequest->method == METHOD_GET); CPPUNIT_ASSERT_EQUAL(String("[2000:800::45]"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/foo"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); CPPUNIT_ASSERT_EQUAL(String("http://2000:800::45/foo"), String(url)); xfree(url); } === modified file 'src/tests/testURL.cc' --- src/tests/testURL.cc 2010-08-16 14:47:39 +0000 +++ src/tests/testURL.cc 2011-02-15 03:06:46 +0000 @@ -29,11 +29,11 @@ testURL::testConstructScheme() { URLScheme empty_scheme; - URL protoless_url(PROTO_NONE); + URL protoless_url(AnyP::PROTO_NONE); CPPUNIT_ASSERT_EQUAL(empty_scheme, protoless_url.getScheme()); - URLScheme ftp_scheme(PROTO_FTP); - URL ftp_url(PROTO_FTP); + URLScheme ftp_scheme(AnyP::PROTO_FTP); + URL ftp_url(AnyP::PROTO_FTP); CPPUNIT_ASSERT_EQUAL(ftp_scheme, ftp_url.getScheme()); } === modified file 'src/tests/testURLScheme.cc' --- src/tests/testURLScheme.cc 2009-05-03 13:02:50 +0000 +++ src/tests/testURLScheme.cc 2011-03-01 22:04:16 +0000 @@ -55,11 +55,11 @@ { URLScheme empty_scheme; URLScheme scheme; - scheme = PROTO_NONE; + scheme = AnyP::PROTO_NONE; CPPUNIT_ASSERT_EQUAL(empty_scheme, scheme); - URLScheme https_scheme(PROTO_HTTPS); - scheme = PROTO_HTTPS; + URLScheme https_scheme(AnyP::PROTO_HTTPS); + scheme = AnyP::PROTO_HTTPS; CPPUNIT_ASSERT_EQUAL(https_scheme, scheme); } @@ -71,21 +71,21 @@ testURLScheme::testCastToprotocol_t() { /* explicit cast */ - protocol_t protocol = (protocol_t) URLScheme(); - CPPUNIT_ASSERT_EQUAL(PROTO_NONE, protocol); + AnyP::ProtocolType protocol = static_cast(URLScheme()); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_NONE, protocol); /* and implicit */ - protocol = URLScheme(PROTO_HTTP); - CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, protocol); + protocol = URLScheme(AnyP::PROTO_HTTP); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, protocol); } /* - * a default constructed URLScheme is == PROTO_NONE + * a default constructed URLScheme is == AnyP::PROTO_NONE */ void testURLScheme::testDefaultConstructor() { URLScheme lhs; - URLScheme rhs(PROTO_NONE); + URLScheme rhs(AnyP::PROTO_NONE); CPPUNIT_ASSERT_EQUAL(lhs, rhs); } @@ -95,10 +95,10 @@ void testURLScheme::testConstructprotocol_t() { - URLScheme lhs_none(PROTO_NONE), rhs_none(PROTO_NONE); + URLScheme lhs_none(AnyP::PROTO_NONE), rhs_none(AnyP::PROTO_NONE); CPPUNIT_ASSERT_EQUAL(lhs_none, rhs_none); - URLScheme lhs_cacheobj(PROTO_CACHEOBJ), rhs_cacheobj(PROTO_CACHEOBJ); + URLScheme lhs_cacheobj(AnyP::PROTO_CACHEOBJ), rhs_cacheobj(AnyP::PROTO_CACHEOBJ); CPPUNIT_ASSERT_EQUAL(lhs_cacheobj, rhs_cacheobj); CPPUNIT_ASSERT(lhs_none != rhs_cacheobj); } @@ -110,7 +110,7 @@ testURLScheme::testConst_str() { String lhs("wais"); - URLScheme wais(PROTO_WAIS); + URLScheme wais(AnyP::PROTO_WAIS); String rhs(wais.const_str()); CPPUNIT_ASSERT_EQUAL(lhs, rhs); } @@ -122,10 +122,10 @@ void testURLScheme::testEqualprotocol_t() { - CPPUNIT_ASSERT(URLScheme() == PROTO_NONE); - CPPUNIT_ASSERT(not (URLScheme(PROTO_WAIS) == PROTO_HTTP)); - CPPUNIT_ASSERT(PROTO_HTTP == URLScheme(PROTO_HTTP)); - CPPUNIT_ASSERT(not (PROTO_CACHEOBJ == URLScheme(PROTO_HTTP))); + CPPUNIT_ASSERT(URLScheme() == AnyP::PROTO_NONE); + CPPUNIT_ASSERT(not (URLScheme(AnyP::PROTO_WAIS) == AnyP::PROTO_HTTP)); + CPPUNIT_ASSERT(AnyP::PROTO_HTTP == URLScheme(AnyP::PROTO_HTTP)); + CPPUNIT_ASSERT(not (AnyP::PROTO_CACHEOBJ == URLScheme(AnyP::PROTO_HTTP))); } /* @@ -134,10 +134,10 @@ void testURLScheme::testNotEqualprotocol_t() { - CPPUNIT_ASSERT(URLScheme(PROTO_NONE) != PROTO_HTTP); - CPPUNIT_ASSERT(not (URLScheme(PROTO_HTTP) != PROTO_HTTP)); - CPPUNIT_ASSERT(PROTO_NONE != URLScheme(PROTO_HTTP)); - CPPUNIT_ASSERT(not (PROTO_WAIS != URLScheme(PROTO_WAIS))); + CPPUNIT_ASSERT(URLScheme(AnyP::PROTO_NONE) != AnyP::PROTO_HTTP); + CPPUNIT_ASSERT(not (URLScheme(AnyP::PROTO_HTTP) != AnyP::PROTO_HTTP)); + CPPUNIT_ASSERT(AnyP::PROTO_NONE != URLScheme(AnyP::PROTO_HTTP)); + CPPUNIT_ASSERT(not (AnyP::PROTO_WAIS != URLScheme(AnyP::PROTO_WAIS))); } /* @@ -147,7 +147,7 @@ testURLScheme::testStream() { std::ostringstream buffer; - buffer << URLScheme(PROTO_HTTP); + buffer << URLScheme(AnyP::PROTO_HTTP); String http_str("http"); String from_buf(buffer.str().c_str()); CPPUNIT_ASSERT_EQUAL(http_str, from_buf); === modified file 'src/typedefs.h' --- src/typedefs.h 2011-01-20 10:13:05 +0000 +++ src/typedefs.h 2011-02-14 09:56:17 +0000 @@ -154,7 +154,9 @@ typedef void FQDNH(const char *, const DnsLookupDetails &details, void *); typedef void IDCB(const char *ident, void *data); typedef void IPH(const ipcache_addrs *, const DnsLookupDetails &details, void *); -typedef void IRCB(struct peer *, peer_t, protocol_t, void *, void *data); + +#include "anyp/ProtocolType.h" +typedef void IRCB(struct peer *, peer_t, AnyP::ProtocolType, void *, void *data); class FwdServer; typedef void PSC(FwdServer *, void *); === modified file 'src/url.cc' --- src/url.cc 2010-12-13 11:31:14 +0000 +++ src/url.cc 2011-03-01 03:22:30 +0000 @@ -40,7 +40,7 @@ #include "rfc1738.h" static HttpRequest *urlParseFinish(const HttpRequestMethod& method, - const protocol_t protocol, + const AnyP::ProtocolType protocol, const char *const urlpath, const char *const host, const char *const login, @@ -65,9 +65,9 @@ { debugs(23, 5, "urlInitialize: Initializing..."); /* this ensures that the number of protocol strings is the same as - * the enum slots allocated because the last enum is always 'TOTAL'. + * the enum slots allocated because the last enum is always 'MAX'. */ - assert(strcmp(ProtocolStr[PROTO_MAX], "TOTAL") == 0); + assert(strcmp(AnyP::ProtocolType_str[AnyP::PROTO_MAX], "MAX") == 0); /* * These test that our matchDomainName() function works the * way we expect it to. @@ -97,7 +97,7 @@ * backwards compatibility, e defaults to NULL, in which case we * assume b is NULL-terminated. */ -protocol_t +AnyP::ProtocolType urlParseProtocol(const char *b, const char *e) { /* @@ -114,64 +114,64 @@ /* test common stuff first */ if (strncasecmp(b, "http", len) == 0) - return PROTO_HTTP; + return AnyP::PROTO_HTTP; if (strncasecmp(b, "ftp", len) == 0) - return PROTO_FTP; + return AnyP::PROTO_FTP; if (strncasecmp(b, "https", len) == 0) - return PROTO_HTTPS; + return AnyP::PROTO_HTTPS; if (strncasecmp(b, "file", len) == 0) - return PROTO_FTP; + return AnyP::PROTO_FTP; if (strncasecmp(b, "gopher", len) == 0) - return PROTO_GOPHER; + return AnyP::PROTO_GOPHER; if (strncasecmp(b, "wais", len) == 0) - return PROTO_WAIS; + return AnyP::PROTO_WAIS; if (strncasecmp(b, "cache_object", len) == 0) - return PROTO_CACHEOBJ; + return AnyP::PROTO_CACHEOBJ; if (strncasecmp(b, "urn", len) == 0) - return PROTO_URN; + return AnyP::PROTO_URN; if (strncasecmp(b, "whois", len) == 0) - return PROTO_WHOIS; + return AnyP::PROTO_WHOIS; if (strncasecmp(b, "internal", len) == 0) - return PROTO_INTERNAL; + return AnyP::PROTO_INTERNAL; - return PROTO_NONE; + return AnyP::PROTO_NONE; } int -urlDefaultPort(protocol_t p) +urlDefaultPort(AnyP::ProtocolType p) { switch (p) { - case PROTO_HTTP: + case AnyP::PROTO_HTTP: return 80; - case PROTO_HTTPS: + case AnyP::PROTO_HTTPS: return 443; - case PROTO_FTP: + case AnyP::PROTO_FTP: return 21; - case PROTO_GOPHER: + case AnyP::PROTO_GOPHER: return 70; - case PROTO_WAIS: + case AnyP::PROTO_WAIS: return 210; - case PROTO_CACHEOBJ: + case AnyP::PROTO_CACHEOBJ: - case PROTO_INTERNAL: + case AnyP::PROTO_INTERNAL: return CACHE_HTTP_PORT; - case PROTO_WHOIS: + case AnyP::PROTO_WHOIS: return 43; default: @@ -210,7 +210,7 @@ char *t = NULL; char *q = NULL; int port; - protocol_t protocol = PROTO_NONE; + AnyP::ProtocolType protocol = AnyP::PROTO_NONE; int l; int i; const char *src; @@ -232,7 +232,7 @@ } else if ((method == METHOD_OPTIONS || method == METHOD_TRACE) && strcmp(url, "*") == 0) { - protocol = PROTO_HTTP; + protocol = AnyP::PROTO_HTTP; port = urlDefaultPort(protocol); return urlParseFinish(method, protocol, url, host, login, port, request); } else if (!strncmp(url, "urn:", 4)) { @@ -425,7 +425,7 @@ */ static HttpRequest * urlParseFinish(const HttpRequestMethod& method, - const protocol_t protocol, + const AnyP::ProtocolType protocol, const char *const urlpath, const char *const host, const char *const login, @@ -448,7 +448,7 @@ urnParse(const HttpRequestMethod& method, char *urn) { debugs(50, 5, "urnParse: " << urn); - return new HttpRequest(method, PROTO_URN, urn + 4); + return new HttpRequest(method, AnyP::PROTO_URN, urn + 4); } const char * @@ -461,7 +461,7 @@ if (request->canonical) return request->canonical; - if (request->protocol == PROTO_URN) { + if (request->protocol == AnyP::PROTO_URN) { snprintf(urlbuf, MAX_URL, "urn:" SQUIDSTRINGPH, SQUIDSTRINGPRINT(request->urlpath)); } else { @@ -478,8 +478,9 @@ if (request->port != urlDefaultPort(request->protocol)) snprintf(portbuf, 32, ":%d", request->port); + URLScheme sch = request->protocol; // temporary, until bug 1961 URL handling is fixed. snprintf(urlbuf, MAX_URL, "%s://%s%s%s%s" SQUIDSTRINGPH, - ProtocolStr[request->protocol], + sch.const_str(), request->login, *request->login ? "@" : null_string, request->GetHost(), @@ -505,7 +506,7 @@ LOCAL_ARRAY(char, loginbuf, MAX_LOGIN_SZ + 1); char *t; - if (request->protocol == PROTO_URN) { + if (request->protocol == AnyP::PROTO_URN) { snprintf(buf, MAX_URL, "urn:" SQUIDSTRINGPH, SQUIDSTRINGPRINT(request->urlpath)); } else { @@ -535,8 +536,9 @@ strcat(loginbuf, "@"); } + URLScheme sch = request->protocol; // temporary, until bug 1961 URL handling is fixed. snprintf(buf, MAX_URL, "%s://%s%s%s" SQUIDSTRINGPH, - ProtocolStr[request->protocol], + sch.const_str(), loginbuf, request->GetHost(), portbuf, @@ -630,7 +632,7 @@ char *urlbuf = (char *)xmalloc(MAX_URL * sizeof(char)); - if (req->protocol == PROTO_URN) { + if (req->protocol == AnyP::PROTO_URN) { snprintf(urlbuf, MAX_URL, "urn:" SQUIDSTRINGPH, SQUIDSTRINGPRINT(req->urlpath)); return (urlbuf); @@ -638,9 +640,10 @@ size_t urllen; + URLScheme sch = req->protocol; // temporary, until bug 1961 URL handling is fixed. if (req->port != urlDefaultPort(req->protocol)) { urllen = snprintf(urlbuf, MAX_URL, "%s://%s%s%s:%d", - ProtocolStr[req->protocol], + sch.const_str(), req->login, *req->login ? "@" : null_string, req->GetHost(), @@ -648,7 +651,7 @@ ); } else { urllen = snprintf(urlbuf, MAX_URL, "%s://%s%s%s", - ProtocolStr[req->protocol], + sch.const_str(), req->login, *req->login ? "@" : null_string, req->GetHost() @@ -808,24 +811,24 @@ /* does method match the protocol? */ switch (r->protocol) { - case PROTO_URN: - - case PROTO_HTTP: - - case PROTO_CACHEOBJ: + case AnyP::PROTO_URN: + + case AnyP::PROTO_HTTP: + + case AnyP::PROTO_CACHEOBJ: rc = 1; break; - case PROTO_FTP: + case AnyP::PROTO_FTP: if (r->method == METHOD_PUT) rc = 1; - case PROTO_GOPHER: - - case PROTO_WAIS: - - case PROTO_WHOIS: + case AnyP::PROTO_GOPHER: + + case AnyP::PROTO_WAIS: + + case AnyP::PROTO_WHOIS: if (r->method == METHOD_GET) rc = 1; else if (r->method == METHOD_HEAD) @@ -833,7 +836,7 @@ break; - case PROTO_HTTPS: + case AnyP::PROTO_HTTPS: #if USE_SSL rc = 1;