From: amosjeffries <> Date: Fri, 18 May 2007 12:41:21 +0000 (+0000) Subject: Add string API layer for better string handling. X-Git-Tag: SQUID_3_0_PRE7~264 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=86c0aed6f3d6225d2769d5eee25eb4d1d7eb1e44;p=thirdparty%2Fsquid.git Add string API layer for better string handling. For various reasons listed below we adopt the std::string API (but not the implementation) as the basis for string operations. This patch reverts the SquidString.h file to provide only the main API and hooks for any string implementation behind the API. For Release 3.0 the old String (now SqString) will remain the default string core. That code has been kept in this patch with some minor modifications and bug fixes as listed below. For Release 3.1 it is expected that a better string core will be developed. Reasons for these changes: The initial String implementation was incomplete and non-standard causing some risky operations at points in the code and duplicated some operations. std::string provides a better known API for string handling which is widely use amongst other string implementations beyond std::string itself and this enables std::string or a derivative to be used in squid at some future date. String as used previously is a defined alternative to std::string in some systems This patch: - moves the old String class to SqString - provides the well-known type of 'string' for general use - provides implicit conversion from char* and char[] types - migrates custom functions to well-known API: buf() -> c_str() clean() -> clear() - removes redundant functions: buf(char*) -> operator=(char*) initBuf(char*) -> operator=(char*) reset(char*) -> operator=(char*) - adds well-known API methods for safer string use: operator [] empty() operator << strcmp(), strcasecmp(), etc - May fix bug #1088 - segmentation fault after append(char*,int) - Fixes several unreported char* handling bugs in String/SqString --- diff --git a/ChangeLog b/ChangeLog index c7fa8810f9..d5638124dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,7 @@ Changes to squid-3.0 (): - Improved high-resolution profiling - Windows overlapped-IO and thread support added to the Async IO disk code - Improvements for handling large DNS replies + - Adds standard API for string handling Changes to squid-2.5 (): diff --git a/src/ACLExtUser.cc b/src/ACLExtUser.cc index 818d2cae4b..3b40b37abb 100644 --- a/src/ACLExtUser.cc +++ b/src/ACLExtUser.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLExtUser.cc,v 1.9 2007/04/28 22:26:37 hno Exp $ + * $Id: ACLExtUser.cc,v 1.10 2007/05/18 06:41:21 amosjeffries Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -79,7 +79,7 @@ int ACLExtUser::match(ACLChecklist *checklist) { if (checklist->request->extacl_user.size()) { - return data->match(checklist->request->extacl_user.buf()); + return data->match(checklist->request->extacl_user.c_str()); } else { return -1; } diff --git a/src/ACLHTTPHeaderData.cc b/src/ACLHTTPHeaderData.cc index 18bc4ec9f8..39bbbdfebc 100644 --- a/src/ACLHTTPHeaderData.cc +++ b/src/ACLHTTPHeaderData.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLHTTPHeaderData.cc,v 1.3 2007/04/28 22:26:37 hno Exp $ + * $Id: ACLHTTPHeaderData.cc,v 1.4 2007/05/18 06:41:21 amosjeffries Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -63,18 +63,18 @@ ACLHTTPHeaderData::match(HttpHeader* hdr) if (hdr == NULL) return false; - debugs(28, 3, "aclHeaderData::match: checking '" << hdrName.buf() << "'"); + debugs(28, 3, "aclHeaderData::match: checking '" << hdrName << "'"); - String value = hdrId != HDR_BAD_HDR ? hdr->getStrOrList(hdrId) : hdr->getByName(hdrName.buf()); + string value = hdrId != HDR_BAD_HDR ? hdr->getStrOrList(hdrId) : hdr->getByName(hdrName.c_str()); - return regex_rule->match(value.buf()); + return regex_rule->match(value.c_str()); } wordlist * ACLHTTPHeaderData::dump() { wordlist *W = NULL; - wordlistAdd(&W, hdrName.buf()); + wordlistAdd(&W, hdrName.c_str()); wordlist * regex_dump = regex_rule->dump(); wordlistAddWl(&W, regex_dump); wordlistDestroy(®ex_dump); @@ -87,14 +87,14 @@ ACLHTTPHeaderData::parse() char* t = strtokFile(); assert (t != NULL); hdrName = t; - hdrId = httpHeaderIdByNameDef(hdrName.buf(), strlen(hdrName.buf())); + hdrId = httpHeaderIdByNameDef(hdrName.c_str(), hdrName.size()); regex_rule->parse(); } bool ACLHTTPHeaderData::empty() const { - return (hdrId == HDR_BAD_HDR && !hdrName.buf()) || regex_rule->empty(); + return (hdrId == HDR_BAD_HDR && !hdrName.c_str()) || regex_rule->empty(); } ACLData * diff --git a/src/ACLHTTPHeaderData.h b/src/ACLHTTPHeaderData.h index 0ff42c138b..a4fadd1a3a 100644 --- a/src/ACLHTTPHeaderData.h +++ b/src/ACLHTTPHeaderData.h @@ -1,6 +1,6 @@ /* - * $Id: ACLHTTPHeaderData.h,v 1.2 2006/08/05 12:05:35 robertc Exp $ + * $Id: ACLHTTPHeaderData.h,v 1.3 2007/05/18 06:41:21 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -53,7 +53,7 @@ public: private: http_hdr_type hdrId; // set if header is known - String hdrName; // always set + string hdrName; // always set ACLData * regex_rule; }; diff --git a/src/ACLUrlPath.cc b/src/ACLUrlPath.cc index f0d173a2b2..cda3bcff8d 100644 --- a/src/ACLUrlPath.cc +++ b/src/ACLUrlPath.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLUrlPath.cc,v 1.2 2003/07/11 01:40:34 robertc Exp $ + * $Id: ACLUrlPath.cc,v 1.3 2007/05/18 06:41:21 amosjeffries Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -47,7 +47,7 @@ ACLStrategised ACLUrlPath::RegistryEntry_(new ACLRegexData, ACLUrl int ACLUrlPathStrategy::match (ACLData * &data, ACLChecklist *checklist) { - char *esc_buf = xstrdup(checklist->request->urlpath.buf()); + char *esc_buf = xstrdup(checklist->request->urlpath.c_str()); rfc1738_unescape(esc_buf); int result = data->match(esc_buf); safe_free(esc_buf); diff --git a/src/AuthUser.cc b/src/AuthUser.cc index 3b829e158f..f45ae4e1cd 100644 --- a/src/AuthUser.cc +++ b/src/AuthUser.cc @@ -1,6 +1,6 @@ /* - * $Id: AuthUser.cc,v 1.7 2007/05/09 08:26:57 wessels Exp $ + * $Id: AuthUser.cc,v 1.8 2007/05/18 06:41:21 amosjeffries Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Robert Collins @@ -143,7 +143,7 @@ AuthUser::cacheInit(void) if (!proxy_auth_username_cache) { /* First time around, 7921 should be big enough */ proxy_auth_username_cache = - hash_create((HASHCMP *) strcmp, 7921, hash_string); + hash_create((HASHCMP *) std::strcmp, 7921, hash_string); assert(proxy_auth_username_cache); eventAdd("User Cache Maintenance", cacheCleanup, NULL, Config.authenticateGCInterval, 1); } diff --git a/src/CommonPool.h b/src/CommonPool.h index 8401379a96..8b6beb57f4 100644 --- a/src/CommonPool.h +++ b/src/CommonPool.h @@ -1,6 +1,6 @@ /* - * $Id: CommonPool.h,v 1.3 2003/08/04 22:14:40 robertc Exp $ + * $Id: CommonPool.h,v 1.4 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: Robert Collins @@ -58,11 +58,11 @@ public: void *operator new(size_t); void operator delete (void *); static CommonPool *Factory (unsigned char _class, CompositePoolNode::Pointer&); - char const* theClassTypeLabel() const {return typeLabel.buf();} + char const* theClassTypeLabel() const { return typeLabel.c_str(); } protected: CommonPool(); - String typeLabel; + string typeLabel; }; #endif diff --git a/src/CompositePoolNode.h b/src/CompositePoolNode.h index 6cb057754c..97eff73d2d 100644 --- a/src/CompositePoolNode.h +++ b/src/CompositePoolNode.h @@ -1,6 +1,6 @@ /* - * $Id: CompositePoolNode.h,v 1.6 2005/04/18 21:52:41 hno Exp $ + * $Id: CompositePoolNode.h,v 1.7 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: Robert Collins @@ -78,7 +78,7 @@ public: struct IN_ADDR src_addr; AuthUserRequest *user; - String tag; + string tag; }; protected: diff --git a/src/ConfigParser.h b/src/ConfigParser.h index fde3c4b442..86bde34ede 100644 --- a/src/ConfigParser.h +++ b/src/ConfigParser.h @@ -1,6 +1,6 @@ /* - * $Id: ConfigParser.h,v 1.6 2006/05/29 00:14:59 robertc Exp $ + * $Id: ConfigParser.h,v 1.7 2007/05/18 06:41:22 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -61,7 +61,7 @@ public: static void ParseUShort(u_short *var); static void ParseBool(bool *var); static void ParseString(char **var); - static void ParseString(String *var); + static void ParseString(string &var); static void ParseWordList(wordlist **list); static char * strtokFile(); }; diff --git a/src/DelayBucket.cc b/src/DelayBucket.cc index 3c7966518a..978ba2e9c2 100644 --- a/src/DelayBucket.cc +++ b/src/DelayBucket.cc @@ -1,6 +1,6 @@ /* - * $Id: DelayBucket.cc,v 1.5 2003/03/10 20:12:43 robertc Exp $ + * $Id: DelayBucket.cc,v 1.6 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: Robert Collins @@ -54,7 +54,7 @@ #include "ConfigParser.h" #include "DelayId.h" #include "Array.h" -#include "String.h" +#include "SquidString.h" #include "CommonPool.h" #include "CompositePoolNode.h" #include "DelayPool.h" diff --git a/src/DelayTagged.cc b/src/DelayTagged.cc index 071feae159..ed2c5f4a53 100644 --- a/src/DelayTagged.cc +++ b/src/DelayTagged.cc @@ -1,6 +1,6 @@ /* - * $Id: DelayTagged.cc,v 1.5 2007/04/28 22:26:37 hno Exp $ + * $Id: DelayTagged.cc,v 1.6 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: Robert Collins @@ -77,7 +77,7 @@ int DelayTaggedCmp(DelayTaggedBucket::Pointer const &left, DelayTaggedBucket::Pointer const &right) { /* for rate limiting, case insensitive */ - return left->tag.caseCmp(right->tag.buf()); + return strcasecmp(left->tag, right->tag); } void @@ -183,7 +183,7 @@ DelayTaggedBucket::operator delete (void *address) ::operator delete (address); } -DelayTaggedBucket::DelayTaggedBucket(String &aTag) : tag (aTag) +DelayTaggedBucket::DelayTaggedBucket(string &aTag) : tag (aTag) { debugs(77, 3, "DelayTaggedBucket::DelayTaggedBucket"); } @@ -196,11 +196,11 @@ DelayTaggedBucket::~DelayTaggedBucket() void DelayTaggedBucket::stats (StoreEntry *entry) const { - storeAppendPrintf(entry, " %s:", tag.buf()); + storeAppendPrintf(entry, " %s:", tag.c_str()); theBucket.stats (entry); } -DelayTagged::Id::Id(DelayTagged::Pointer aDelayTagged, String &aTag) : theTagged(aDelayTagged) +DelayTagged::Id::Id(DelayTagged::Pointer aDelayTagged, string &aTag) : theTagged(aDelayTagged) { theBucket = new DelayTaggedBucket(aTag); DelayTaggedBucket::Pointer const *existing = theTagged->buckets.find(theBucket, DelayTaggedCmp); diff --git a/src/DelayTagged.h b/src/DelayTagged.h index 2ad149f12a..b8f09f58b3 100644 --- a/src/DelayTagged.h +++ b/src/DelayTagged.h @@ -1,6 +1,6 @@ /* - * $Id: DelayTagged.h,v 1.4 2003/08/04 22:14:40 robertc Exp $ + * $Id: DelayTagged.h,v 1.5 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: Robert Collins @@ -58,10 +58,10 @@ public: void operator delete (void *); void stats(StoreEntry *)const; - DelayTaggedBucket(String &aTag); + DelayTaggedBucket(string &aTag); ~DelayTaggedBucket(); DelayBucket theBucket; - String tag; + string tag; }; class DelayTagged : public CompositePoolNode @@ -88,7 +88,7 @@ class Id:public DelayIdComposite public: void *operator new(size_t); void operator delete (void *); - Id (RefCount, String &); + Id (RefCount, string &); ~Id(); virtual int bytesWanted (int min, int max) const; virtual void bytesIn(int qty); diff --git a/src/DiskIO/AIO/AIODiskFile.h b/src/DiskIO/AIO/AIODiskFile.h index a8b30ad1bf..01cc4ece85 100644 --- a/src/DiskIO/AIO/AIODiskFile.h +++ b/src/DiskIO/AIO/AIODiskFile.h @@ -1,6 +1,6 @@ /* - * $Id: AIODiskFile.h,v 1.2 2006/08/21 00:50:43 robertc Exp $ + * $Id: AIODiskFile.h,v 1.3 2007/05/18 06:41:27 amosjeffries Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -70,7 +70,7 @@ private: CBDATA_CLASS(AIODiskFile); void error(bool const &); int fd; - String path; + string path; AIODiskIOStrategy *strategy; RefCount ioRequestor; bool closed; diff --git a/src/ESI.cc b/src/ESI.cc index 51fc9f3e92..6c1d868e47 100644 --- a/src/ESI.cc +++ b/src/ESI.cc @@ -1,6 +1,6 @@ /* - * $Id: ESI.cc,v 1.23 2007/04/28 22:26:37 hno Exp $ + * $Id: ESI.cc,v 1.24 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -2450,7 +2450,7 @@ esiEnableProcessing (HttpReply *rep) */ return 0; - if (strstr (sctusable->content.buf(), "ESI/1.0")) + if (strstr (sctusable->content, "ESI/1.0")) rv = 1; httpHdrScTargetDestroy (sctusable); diff --git a/src/ESIAssign.cc b/src/ESIAssign.cc index 6374e63ac9..cfc0afdd53 100644 --- a/src/ESIAssign.cc +++ b/src/ESIAssign.cc @@ -1,6 +1,6 @@ /* - * $Id: ESIAssign.cc,v 1.4 2007/04/28 22:26:37 hno Exp $ + * $Id: ESIAssign.cc,v 1.5 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -83,7 +83,7 @@ ESIAssign::evaluateVariable() variable = NULL; if (unevaluatedVariable.size()) { - varState->feedData(unevaluatedVariable.buf(), unevaluatedVariable.size()); + varState->feedData(unevaluatedVariable.c_str(), unevaluatedVariable.size()); char const *result = varState->extractChar (); /* Consider activating this, when we want to evaluate variables to a @@ -117,7 +117,7 @@ ESIAssign::process (int dovars) if (!value) return ESI_PROCESS_COMPLETE; - varState->addVariable (name.buf(), name.size(), value); + varState->addVariable (name.c_str(), name.size(), value); value = NULL; @@ -181,12 +181,12 @@ ESIAssign::addElement(ESIElement::Pointer anElement) ESIVariableExpression::~ESIVariableExpression() {} -ESIVariableExpression::ESIVariableExpression (String const &aString) : expression (aString) +ESIVariableExpression::ESIVariableExpression (string const &aString) : expression (aString) {} void ESIVariableExpression::eval (ESIVarState &state, char const *subref, char const *defaultOnEmpty) const { /* XXX: Implement evaluation of the expression */ - ESISegment::ListAppend (state.getOutput(), expression.buf(), expression.size()); + ESISegment::ListAppend (state.getOutput(), expression.c_str(), expression.size()); } diff --git a/src/ESIAssign.h b/src/ESIAssign.h index 74c53a7a6d..285cfceabb 100644 --- a/src/ESIAssign.h +++ b/src/ESIAssign.h @@ -1,5 +1,5 @@ /* - * $Id: ESIAssign.h,v 1.3 2004/08/30 05:12:31 robertc Exp $ + * $Id: ESIAssign.h,v 1.4 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -49,11 +49,11 @@ class ESIVariableExpression : public ESIVarState::Variable public: ~ESIVariableExpression(); - ESIVariableExpression (String const &value); + ESIVariableExpression (string const &value); virtual void eval (ESIVarState &state, char const *, char const *) const; private: - String expression; + string expression; }; /* ESIAssign */ @@ -81,10 +81,10 @@ private: void evaluateVariable(); esiTreeParentPtr parent; ESIVarState *varState; - String name; + string name; ESIVariableExpression * value; ESIElement::Pointer variable; - String unevaluatedVariable; + string unevaluatedVariable; }; MEMPROXY_CLASS_INLINE(ESIAssign) diff --git a/src/ESICustomParser.cc b/src/ESICustomParser.cc index 7990abb5da..957448a22b 100644 --- a/src/ESICustomParser.cc +++ b/src/ESICustomParser.cc @@ -1,6 +1,6 @@ /* - * $Id: ESICustomParser.cc,v 1.8 2007/04/28 22:26:37 hno Exp $ + * $Id: ESICustomParser.cc,v 1.9 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -109,7 +109,7 @@ ESICustomParser::parse(char const *dataToParse, size_t const lengthOfData, bool } size_t openESITags (0); - char const *currentPos = content.buf(); + char const *currentPos = content.c_str(); size_t remainingCount = content.size(); char const *tag = NULL; @@ -302,7 +302,7 @@ char const * ESICustomParser::errorString() const { if (error.size()) - return error.buf(); + return error.c_str(); else return "Parsing error strings not implemented"; } diff --git a/src/ESICustomParser.h b/src/ESICustomParser.h index a1a00aaf59..96ef131ced 100644 --- a/src/ESICustomParser.h +++ b/src/ESICustomParser.h @@ -1,5 +1,5 @@ /* - * $Id: ESICustomParser.h,v 1.6 2005/07/03 15:25:08 serassio Exp $ + * $Id: ESICustomParser.h,v 1.7 2007/05/18 06:41:22 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -60,9 +60,9 @@ private: char const *findTag(char const *a, size_t b); ESIParserClient *theClient; - String error; + string error; /* cheap n dirty - buffer it all */ - String content; + string content; /* TODO: make a class of this type code */ ESITAG_t lastTag; }; diff --git a/src/ESISegment.cc b/src/ESISegment.cc index 936d997f8f..0909244577 100644 --- a/src/ESISegment.cc +++ b/src/ESISegment.cc @@ -1,6 +1,6 @@ /* - * $Id: ESISegment.cc,v 1.4 2007/04/28 22:26:37 hno Exp $ + * $Id: ESISegment.cc,v 1.5 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -234,7 +234,7 @@ ESISegment::dumpToLog() const void ESISegment::dumpOne() const { - String temp; + string temp; temp.limitInit(buf, len); - debugs(86, 9, "ESISegment::dumpOne: \"" << temp.buf() << "\""); + debugs(86, 9, "ESISegment::dumpOne: \"" << temp << "\""); } diff --git a/src/ESIVarState.cc b/src/ESIVarState.cc index c823721231..a7e8f5b45a 100644 --- a/src/ESIVarState.cc +++ b/src/ESIVarState.cc @@ -1,6 +1,6 @@ /* - * $Id: ESIVarState.cc,v 1.8 2007/04/28 22:26:37 hno Exp $ + * $Id: ESIVarState.cc,v 1.9 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -318,9 +318,9 @@ ESIVarState::ESIVarState (HttpHeader const *aHeader, char const *uri) } void -ESIVarState::removeVariable (String const &name) +ESIVarState::removeVariable (string const &name) { - Variable *candidate = static_cast (variables.find (name.buf(), name.size())); + Variable *candidate = static_cast (variables.find (name.c_str(), name.size())); if (candidate) { /* XXX: remove me */ @@ -335,7 +335,7 @@ ESIVarState::removeVariable (String const &name) void ESIVarState::addVariable(char const *name, size_t len, Variable *aVariable) { - String temp; + string temp; temp.limitInit (name, len); removeVariable (temp); variables.add(name, len, aVariable); @@ -434,10 +434,10 @@ ESIVariableCookie::eval (ESIVarState &state, char const *subref, char const *fou if (!subref) s = state.header().getStr (HDR_COOKIE); else { - String S = state.header().getListMember (HDR_COOKIE, subref, ';'); + string S = state.header().getListMember (HDR_COOKIE, subref, ';'); if (S.size()) - ESISegment::ListAppend (state.getOutput(), S.buf(), S.size()); + ESISegment::ListAppend (state.getOutput(), S.c_str(), S.size()); else if (found_default) ESISegment::ListAppend (state.getOutput(), found_default, strlen (found_default)); } @@ -470,8 +470,8 @@ ESIVariableLanguage::eval (ESIVarState &state, char const *subref, char const *f if (state.header().has(HDR_ACCEPT_LANGUAGE)) { if (!subref) { - String S (state.header().getList (HDR_ACCEPT_LANGUAGE)); - ESISegment::ListAppend (state.getOutput(), S.buf(), S.size()); + string S (state.header().getList (HDR_ACCEPT_LANGUAGE)); + ESISegment::ListAppend (state.getOutput(), S.c_str(), S.size()); } else { if (state.header().hasListMember (HDR_ACCEPT_LANGUAGE, subref, ',')) { s = "true"; @@ -885,10 +885,9 @@ ESIVarState::buildVary (HttpReply *rep) if (!tempstr[0]) return; - String strVary (rep->header.getList (HDR_VARY)); + string strVary (rep->header.getList (HDR_VARY)); - if (!strVary.size() || strVary.buf()[0] != '*') { + if (!strVary.size() || strVary[0] != '*') { rep->header.putStr (HDR_VARY, tempstr); } } - diff --git a/src/ESIVarState.h b/src/ESIVarState.h index b1106de8f0..a4cf31c2ca 100644 --- a/src/ESIVarState.h +++ b/src/ESIVarState.h @@ -1,6 +1,6 @@ /* - * $Id: ESIVarState.h,v 1.2 2003/08/04 22:14:40 robertc Exp $ + * $Id: ESIVarState.h,v 1.3 2007/05/18 06:41:22 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -64,7 +64,7 @@ public: class Variable; void addVariable (char const *, size_t, Variable *); - void removeVariable (String const &); + void removeVariable (string const &); void *operator new (size_t byteCount); void operator delete (void *address); diff --git a/src/ExternalACLEntry.h b/src/ExternalACLEntry.h index f99a0faeab..c15b6d2ffc 100644 --- a/src/ExternalACLEntry.h +++ b/src/ExternalACLEntry.h @@ -1,6 +1,6 @@ /* - * $Id: ExternalACLEntry.h,v 1.6 2006/08/21 00:50:40 robertc Exp $ + * $Id: ExternalACLEntry.h,v 1.7 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 82 External ACL * AUTHOR: Henrik Nordstrom, MARA Systems AB @@ -61,11 +61,11 @@ public: ExternalACLEntryData() : result (-1) {} int result; - String user; - String password; - String message; - String tag; - String log; + string user; + string password; + string message; + string tag; + string log; }; @@ -88,11 +88,11 @@ public: dlink_node lru; int result; time_t date; - String user; - String password; - String message; - String tag; - String log; + string user; + string password; + string message; + string tag; + string log; external_acl *def; private: diff --git a/src/HttpHdrCc.cc b/src/HttpHdrCc.cc index 346a425eb0..5a204a82bc 100644 --- a/src/HttpHdrCc.cc +++ b/src/HttpHdrCc.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpHdrCc.cc,v 1.29 2007/04/28 22:26:37 hno Exp $ + * $Id: HttpHdrCc.cc,v 1.30 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 65 HTTP Cache Control Header * AUTHOR: Alex Rousskov @@ -66,7 +66,7 @@ http_hdr_cc_type &operator++ (http_hdr_cc_type &aHeader) /* local prototypes */ -static int httpHdrCcParseInit(HttpHdrCc * cc, const String * str); +static int httpHdrCcParseInit(HttpHdrCc * cc, const string * str); /* module initialization */ @@ -96,7 +96,7 @@ httpHdrCcCreate(void) /* creates an cc object from a 0-terminating string */ HttpHdrCc * -httpHdrCcParseCreate(const String * str) +httpHdrCcParseCreate(const string * str) { HttpHdrCc *cc = httpHdrCcCreate(); @@ -110,7 +110,7 @@ httpHdrCcParseCreate(const String * str) /* parses a 0-terminating string and inits cc */ static int -httpHdrCcParseInit(HttpHdrCc * cc, const String * str) +httpHdrCcParseInit(HttpHdrCc * cc, const string * str) { const char *item; const char *p; /* '=' parameter */ @@ -131,17 +131,16 @@ httpHdrCcParseInit(HttpHdrCc * cc, const String * str) nlen = ilen; /* find type */ - type = (http_hdr_cc_type ) httpHeaderIdByName(item, nlen, - CcFieldsInfo, CC_ENUM_END); + type = (http_hdr_cc_type ) httpHeaderIdByName(item, nlen, CcFieldsInfo, CC_ENUM_END); if (type < 0) { - debugs(65, 2, "hdr cc: unknown cache-directive: near '" << item << "' in '" << str->buf() << "'"); + debugs(65, 2, "hdr cc: unknown cache-directive: near '" << item << "' in '" << *str << "'"); type = CC_OTHER; } if (EBIT_TEST(cc->mask, type)) { if (type != CC_OTHER) - debugs(65, 2, "hdr cc: ignoring duplicate cache-directive: near '" << item << "' in '" << str->buf() << "'"); + debugs(65, 2, "hdr cc: ignoring duplicate cache-directive: near '" << item << "' in '" << *str << "'"); CcFieldsInfo[type].stat.repCount++; @@ -206,8 +205,8 @@ httpHdrCcDestroy(HttpHdrCc * cc) { assert(cc); - if (cc->other.buf()) - cc->other.clean(); + if (cc->other.c_str()) + cc->other.clear(); memFree(cc, MEM_HTTP_HDR_CC); } @@ -236,7 +235,7 @@ httpHdrCcPackInto(const HttpHdrCc * cc, Packer * p) if (EBIT_TEST(cc->mask, flag) && flag != CC_OTHER) { /* print option name */ - packerPrintf(p, (pcount ? ", %s" : "%s"), CcFieldsInfo[flag].name.buf()); + packerPrintf(p, (pcount ? ", %s" : "%s"), CcFieldsInfo[flag].name.c_str()); /* handle options with values */ @@ -254,7 +253,7 @@ httpHdrCcPackInto(const HttpHdrCc * cc, Packer * p) } if (cc->other.size()) - packerPrintf(p, (pcount ? ", %s" : "%s"), cc->other.buf()); + packerPrintf(p, (pcount ? ", %s" : "%s"), cc->other.c_str()); } /* negative max_age will clean old max_Age setting */ @@ -300,7 +299,7 @@ httpHdrCcStatDumper(StoreEntry * sentry, int idx, double val, double size, int c extern const HttpHeaderStat *dump_stat; /* argh! */ const int id = (int) val; const int valid_id = id >= 0 && id < CC_ENUM_END; - const char *name = valid_id ? CcFieldsInfo[id].name.buf() : "INVALID"; + const char *name = valid_id ? CcFieldsInfo[id].name.c_str() : "INVALID"; if (count || valid_id) storeAppendPrintf(sentry, "%2d\t %-20s\t %5d\t %6.2f\n", diff --git a/src/HttpHdrRange.cc b/src/HttpHdrRange.cc index e0844e4789..2df61dd37c 100644 --- a/src/HttpHdrRange.cc +++ b/src/HttpHdrRange.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpHdrRange.cc,v 1.42 2007/04/30 16:56:09 wessels Exp $ + * $Id: HttpHdrRange.cc,v 1.43 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 64 HTTP Range Header * AUTHOR: Alex Rousskov @@ -231,7 +231,7 @@ HttpHdrRange::HttpHdrRange () : clen (HttpHdrRangeSpec::UnknownPosition) {} HttpHdrRange * -HttpHdrRange::ParseCreate(const String * range_spec) +HttpHdrRange::ParseCreate(const string * range_spec) { HttpHdrRange *r = new HttpHdrRange; @@ -245,7 +245,7 @@ HttpHdrRange::ParseCreate(const String * range_spec) /* returns true if ranges are valid; inits HttpHdrRange */ bool -HttpHdrRange::parseInit(const String * range_spec) +HttpHdrRange::parseInit(const string * range_spec) { const char *item; const char *pos = NULL; @@ -253,14 +253,14 @@ HttpHdrRange::parseInit(const String * range_spec) int count = 0; assert(this && range_spec); ++ParsedCount; - debugs(64, 8, "parsing range field: '" << range_spec->buf() << "'"); + debugs(64, 8, "parsing range field: '" << *range_spec << "'"); /* check range type */ - if (range_spec->caseCmp("bytes=", 6)) + if (strncasecmp(*range_spec,"bytes=", 6)) return 0; /* skip "bytes="; hack! */ - pos = range_spec->buf() + 5; + pos = range_spec->c_str() + 5; /* iterate through comma separated list */ while (strListGetItem(range_spec, ',', &item, &ilen, &pos)) { @@ -276,8 +276,7 @@ HttpHdrRange::parseInit(const String * range_spec) ++count; } - debugs(64, 8, "parsed range range count: " << count << ", kept " << - specs.size()); + debugs(64, 8, "parsed range range count: " << count << ", kept " << specs.size()); return specs.count != 0; } diff --git a/src/HttpHdrSc.cc b/src/HttpHdrSc.cc index abf1f4c19d..a9cade0b0e 100644 --- a/src/HttpHdrSc.cc +++ b/src/HttpHdrSc.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpHdrSc.cc,v 1.4 2007/04/28 22:26:37 hno Exp $ + * $Id: HttpHdrSc.cc,v 1.5 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 90 HTTP Cache Control Header * AUTHOR: Alex Rousskov @@ -67,7 +67,7 @@ int operator - (http_hdr_sc_type const &anSc, http_hdr_sc_type const &anSc2) /* local prototypes */ -static int httpHdrScParseInit(HttpHdrSc * sc, const String * str); +static int httpHdrScParseInit(HttpHdrSc * sc, const string * str); /* module initialization */ @@ -94,7 +94,7 @@ httpHdrScCreate(void) /* creates an sc object from a 0-terminating string */ HttpHdrSc * -httpHdrScParseCreate(const String * str) +httpHdrScParseCreate(const string * str) { HttpHdrSc *sc = httpHdrScCreate(); @@ -108,7 +108,7 @@ httpHdrScParseCreate(const String * str) /* parses a 0-terminating string and inits sc */ static int -httpHdrScParseInit(HttpHdrSc * sc, const String * str) +httpHdrScParseInit(HttpHdrSc * sc, const string * str) { const char *item; const char *p; /* '=' parameter */ @@ -135,11 +135,10 @@ httpHdrScParseInit(HttpHdrSc * sc, const String * str) ilen = p++ - item; /* find type */ - type = httpHeaderIdByName(item, ilen, - ScFieldsInfo, SC_ENUM_END); + type = httpHeaderIdByName(item, ilen, ScFieldsInfo, SC_ENUM_END); if (type < 0) { - debugs(90, 2, "hdr sc: unknown control-directive: near '" << item << "' in '" << str->buf() << "'"); + debugs(90, 2, "hdr sc: unknown control-directive: near '" << item << "' in '" << *str << "'"); type = SC_OTHER; } @@ -163,7 +162,7 @@ httpHdrScParseInit(HttpHdrSc * sc, const String * str) if (EBIT_TEST(sct->mask, type)) { if (type != SC_OTHER) - debugs(90, 2, "hdr sc: ignoring duplicate control-directive: near '" << item << "' in '" << str->buf() << "'"); + debugs(90, 2, "hdr sc: ignoring duplicate control-directive: near '" << item << "' in '" << *str << "'"); ScFieldsInfo[type].stat.repCount++; @@ -197,7 +196,7 @@ httpHdrScParseInit(HttpHdrSc * sc, const String * str) if (!p || !httpHeaderParseQuotedString(p, &sct->content)) { debugs(90, 2, "sc: invalid content= quoted string near '" << item << "'"); - sct->content.clean(); + sct->content.clear(); EBIT_CLR(sct->mask, type); } @@ -258,7 +257,7 @@ httpHdrScTargetPackInto(const HttpHdrScTarget * sc, Packer * p) if (EBIT_TEST(sc->mask, flag) && flag != SC_OTHER) { /* print option name */ - packerPrintf(p, (pcount ? ", %s" : "%s"), ScFieldsInfo[flag].name.buf()); + packerPrintf(p, (pcount ? ", %s" : "%s"), ScFieldsInfo[flag].name.c_str()); /* handle options with values */ @@ -266,14 +265,14 @@ httpHdrScTargetPackInto(const HttpHdrScTarget * sc, Packer * p) packerPrintf(p, "=%d", (int) sc->max_age); if (flag == SC_CONTENT) - packerPrintf(p, "=\"%s\"", sc->content.buf()); + packerPrintf(p, "=\"%s\"", sc->content.c_str()); pcount++; } } if (sc->target.size()) - packerPrintf (p, ";%s", sc->target.buf()); + packerPrintf (p, ";%s", sc->target.c_str()); } void @@ -340,7 +339,7 @@ httpHdrScTargetStatDumper(StoreEntry * sentry, int idx, double val, double size, extern const HttpHeaderStat *dump_stat; /* argh! */ const int id = (int) val; const int valid_id = id >= 0 && id < SC_ENUM_END; - const char *name = valid_id ? ScFieldsInfo[id].name.buf() : "INVALID"; + const char *name = valid_id ? ScFieldsInfo[id].name.c_str() : "INVALID"; if (count || valid_id) storeAppendPrintf(sentry, "%2d\t %-20s\t %5d\t %6.2f\n", @@ -353,7 +352,7 @@ httpHdrScStatDumper(StoreEntry * sentry, int idx, double val, double size, int c extern const HttpHeaderStat *dump_stat; /* argh! */ const int id = (int) val; const int valid_id = id >= 0 && id < SC_ENUM_END; - const char *name = valid_id ? ScFieldsInfo[id].name.buf() : "INVALID"; + const char *name = valid_id ? ScFieldsInfo[id].name.c_str() : "INVALID"; if (count || valid_id) storeAppendPrintf(sentry, "%2d\t %-20s\t %5d\t %6.2f\n", @@ -370,9 +369,9 @@ httpHdrScFindTarget (HttpHdrSc *sc, const char *target) while (node) { HttpHdrScTarget *sct = (HttpHdrScTarget *)node->data; - if (target && sct->target.buf() && !strcmp (target, sct->target.buf())) + if (target && !sct->target.empty() && !strcmp(target, sct->target) ) return sct; - else if (!target && !sct->target.buf()) + else if (!target && sct->target.empty()) return sct; node = node->next; diff --git a/src/HttpHdrSc.h b/src/HttpHdrSc.h index 60c66c9e27..b6bfed0666 100644 --- a/src/HttpHdrSc.h +++ b/src/HttpHdrSc.h @@ -1,6 +1,6 @@ /* - * $Id: HttpHdrSc.h,v 1.1 2006/04/22 13:25:35 robertc Exp $ + * $Id: HttpHdrSc.h,v 1.2 2007/05/18 06:41:22 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -54,7 +54,7 @@ extern void httpHdrScStatDumper(StoreEntry * sentry, int idx, double val, double extern void httpHdrScInitModule (void); extern void httpHdrScCleanModule (void); extern HttpHdrSc *httpHdrScCreate(void); -extern HttpHdrSc *httpHdrScParseCreate(String const *); +extern HttpHdrSc *httpHdrScParseCreate(string const *); extern void httpHdrScDestroy(HttpHdrSc * sc); extern HttpHdrSc *httpHdrScDup(const HttpHdrSc * sc); extern void httpHdrScPackInto(const HttpHdrSc * sc, Packer * p); diff --git a/src/HttpHdrScTarget.cc b/src/HttpHdrScTarget.cc index 4a8fd14f81..6100c65ec5 100644 --- a/src/HttpHdrScTarget.cc +++ b/src/HttpHdrScTarget.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpHdrScTarget.cc,v 1.2 2006/04/22 05:29:18 robertc Exp $ + * $Id: HttpHdrScTarget.cc,v 1.3 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 90 HTTP Cache Control Header * AUTHOR: Alex Rousskov @@ -58,8 +58,6 @@ void httpHdrScTargetDestroy(HttpHdrScTarget * sc) { assert(sc); - sc->target.clean(); - sc->content.clean(); delete sc; } @@ -68,7 +66,7 @@ httpHdrScTargetDup(const HttpHdrScTarget * sc) { HttpHdrScTarget *dup; assert(sc); - dup = httpHdrScTargetCreate(sc->target.buf()); + dup = httpHdrScTargetCreate(sc->target.c_str()); dup->mask = sc->mask; dup->max_age = sc->max_age; dup->content = sc->content; diff --git a/src/HttpHdrScTarget.h b/src/HttpHdrScTarget.h index 813e3eb928..29cad43552 100644 --- a/src/HttpHdrScTarget.h +++ b/src/HttpHdrScTarget.h @@ -1,6 +1,6 @@ /* - * $Id: HttpHdrScTarget.h,v 1.1 2006/04/22 13:25:35 robertc Exp $ + * $Id: HttpHdrScTarget.h,v 1.2 2007/05/18 06:41:22 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -47,8 +47,8 @@ public: int mask; int max_age; int max_stale; - String content; - String target; + string content; + string target; }; MEMPROXY_CLASS_INLINE(HttpHdrScTarget); diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index d55136c567..42198f56d7 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.cc,v 1.131 2007/05/07 18:12:28 wessels Exp $ + * $Id: HttpHeader.cc,v 1.132 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -256,7 +256,7 @@ static int HeaderEntryParsedCount = 0; #define assert_eid(id) assert((id) >= 0 && (id) < HDR_ENUM_END) -static void httpHeaderNoteParsedEntry(http_hdr_type id, String const &value, int error); +static void httpHeaderNoteParsedEntry(http_hdr_type id, string const &value, int error); static void httpHeaderStatInit(HttpHeaderStat * hs, const char *label); static void httpHeaderStatDump(const HttpHeaderStat * hs, StoreEntry * e); @@ -458,7 +458,7 @@ HttpHeader::update (HttpHeader const *fresh, HttpHeaderMask const *denied_mask) if (e->id != HDR_OTHER) delById(e->id); else - delByName(e->name.buf()); + delByName(e->name.c_str()); addEntry(e->clone()); } @@ -565,7 +565,7 @@ HttpHeader::parse(const char *header_start, const char *header_end) } if (e->id == HDR_CONTENT_LENGTH && (e2 = findEntry(e->id)) != NULL) { - if (e->value.cmp(e2->value.buf()) != 0) { + if (e->value.compare(e2->value) != 0) { ssize_t l1, l2; debugs(55, Config.onoff.relaxed_header_parser <= 0 ? 1 : 2, "WARNING: found two conflicting content-length headers in {" << getStringPrefix(header_start, header_end) << "}"); @@ -575,12 +575,12 @@ HttpHeader::parse(const char *header_start, const char *header_end) goto reset; } - if (!httpHeaderParseSize(e->value.buf(), &l1)) { - debugs(55, 1, "WARNING: Unparseable content-length '" << e->value.buf() << "'"); + if (!httpHeaderParseSize(e->value.c_str(), &l1)) { + debugs(55, 1, "WARNING: Unparseable content-length '" << e->value << "'"); delete e; continue; - } else if (!httpHeaderParseSize(e2->value.buf(), &l2)) { - debugs(55, 1, "WARNING: Unparseable content-length '" << e2->value.buf() << "'"); + } else if (!httpHeaderParseSize(e2->value.c_str(), &l2)) { + debugs(55, 1, "WARNING: Unparseable content-length '" << e2->value << "'"); delById(e2->id); } else if (l1 > l2) { delById(e2->id); @@ -602,7 +602,7 @@ HttpHeader::parse(const char *header_start, const char *header_end) } } - if (e->id == HDR_OTHER && stringHasWhitespace(e->name.buf())) { + if (e->id == HDR_OTHER && strpbrk(e->name, w_space) != NULL) { debugs(55, Config.onoff.relaxed_header_parser <= 0 ? 1 : 2, "WARNING: found whitespace in HTTP header name {" << getStringPrefix(field_start, field_end) << "}"); @@ -725,7 +725,7 @@ HttpHeader::delByName(const char *name) debugs(55, 9, "deleting '" << name << "' fields in hdr " << this); while ((e = getEntry(&pos))) { - if (!e->name.caseCmp(name)) + if (!strcasecmp(e->name,name)) delAt(pos, count); else CBIT_SET(mask, e->id); @@ -840,7 +840,7 @@ HttpHeader::insertEntry(HttpHeaderEntry * e) } bool -HttpHeader::getList(http_hdr_type id, String *s) const +HttpHeader::getList(http_hdr_type id, string *s) const { HttpHeaderEntry *e; HttpHeaderPos pos = HttpHeaderInitPos; @@ -853,7 +853,7 @@ HttpHeader::getList(http_hdr_type id, String *s) const while ((e = getEntry(&pos))) { if (e->id == id) - strListAdd(s, e->value.buf(), ','); + strListAdd(s, e->value.c_str(), ','); } /* @@ -871,7 +871,7 @@ HttpHeader::getList(http_hdr_type id, String *s) const } /* return a list of entries with the same id separated by ',' and ws */ -String +string HttpHeader::getList(http_hdr_type id) const { HttpHeaderEntry *e; @@ -881,13 +881,13 @@ HttpHeader::getList(http_hdr_type id) const assert(CBIT_TEST(ListHeadersMask, id)); if (!CBIT_TEST(mask, id)) - return String(); + return ""; - String s; + string s; while ((e = getEntry(&pos))) { if (e->id == id) - strListAdd(&s, e->value.buf(), ','); + strListAdd(&s, e->value.c_str(), ','); } /* @@ -905,7 +905,7 @@ HttpHeader::getList(http_hdr_type id) const } /* return a string or list of entries with the same id separated by ',' and ws */ -String +string HttpHeader::getStrOrList(http_hdr_type id) const { HttpHeaderEntry *e; @@ -916,13 +916,13 @@ HttpHeader::getStrOrList(http_hdr_type id) const if ((e = findEntry(id))) return e->value; - return String(); + return ""; } /* * Returns the value of the specified header. */ -String +string HttpHeader::getByName(const char *name) const { http_hdr_type id; @@ -937,12 +937,12 @@ HttpHeader::getByName(const char *name) const if (id != -1) return getStrOrList(id); - String result; + string result; /* Sorry, an unknown header name. Do linear search */ while ((e = getEntry(&pos))) { - if (e->id == HDR_OTHER && e->name.caseCmp(name) == 0) { - strListAdd(&result, e->value.buf(), ','); + if (e->id == HDR_OTHER && strcasecmp(e->name,name) == 0) { + strListAdd(&result, e->value.c_str(), ','); } } @@ -952,10 +952,10 @@ HttpHeader::getByName(const char *name) const /* * Returns a the value of the specified list member, if any. */ -String +string HttpHeader::getByNameListMember(const char *name, const char *member, const char separator) const { - String header; + string header; const char *pos = NULL; const char *item; int ilen; @@ -965,7 +965,7 @@ HttpHeader::getByNameListMember(const char *name, const char *member, const char header = getByName(name); - String result; + string result; while (strListGetItem(&header, separator, &item, &ilen, &pos)) { if (strncmp(item, member, mlen) == 0 && item[mlen] == '=') { @@ -980,10 +980,10 @@ HttpHeader::getByNameListMember(const char *name, const char *member, const char /* * returns a the value of the specified list member, if any. */ -String +string HttpHeader::getListMember(http_hdr_type id, const char *member, const char separator) const { - String header; + string header; const char *pos = NULL; const char *item; int ilen; @@ -992,7 +992,7 @@ HttpHeader::getListMember(http_hdr_type id, const char *member, const char separ assert(id >= 0); header = getStrOrList(id); - String result; + string result; while (strListGetItem(&header, separator, &item, &ilen, &pos)) { if (strncmp(item, member, mlen) == 0 && item[mlen] == '=') { @@ -1001,7 +1001,6 @@ HttpHeader::getListMember(http_hdr_type id, const char *member, const char separ } } - header.clean(); return result; } @@ -1165,7 +1164,7 @@ HttpHeader::getTime(http_hdr_type id) const assert(Headers[id].type == ftDate_1123); /* must be of an appropriate type */ if ((e = findEntry(id))) { - value = parse_rfc1123(e->value.buf()); + value = parse_rfc1123(e->value.c_str()); httpHeaderNoteParsedEntry(e->id, e->value, value < 0); } @@ -1182,7 +1181,7 @@ HttpHeader::getStr(http_hdr_type id) const if ((e = findEntry(id))) { httpHeaderNoteParsedEntry(e->id, e->value, 0); /* no errors are possible */ - return e->value.buf(); + return e->value.c_str(); } return NULL; @@ -1198,7 +1197,7 @@ HttpHeader::getLastStr(http_hdr_type id) const if ((e = findLastEntry(id))) { httpHeaderNoteParsedEntry(e->id, e->value, 0); /* no errors are possible */ - return e->value.buf(); + return e->value.c_str(); } return NULL; @@ -1208,7 +1207,7 @@ HttpHdrCc * HttpHeader::getCc() const { HttpHdrCc *cc; - String s; + string s; if (!CBIT_TEST(mask, HDR_CACHE_CONTROL)) return NULL; @@ -1255,7 +1254,7 @@ HttpHeader::getSc() const if (!CBIT_TEST(mask, HDR_SURROGATE_CONTROL)) return NULL; - String s; + string s; (void) getList(HDR_SURROGATE_CONTROL, &s); @@ -1278,7 +1277,7 @@ HttpHeader::getContRange() const HttpHeaderEntry *e; if ((e = findEntry(HDR_CONTENT_RANGE))) { - cr = httpHdrContRangeParseCreate(e->value.buf()); + cr = httpHdrContRangeParseCreate(e->value.c_str()); httpHeaderNoteParsedEntry(e->id, e->value, !cr); } @@ -1324,7 +1323,7 @@ HttpHeader::getETag(http_hdr_type id) const assert(Headers[id].type == ftETag); /* must be of an appropriate type */ if ((e = findEntry(id))) - etagParseInit(&etag, e->value.buf()); + etagParseInit(&etag, e->value.c_str()); return etag; } @@ -1338,7 +1337,7 @@ HttpHeader::getTimeOrTag(http_hdr_type id) const memset(&tot, 0, sizeof(tot)); if ((e = findEntry(id))) { - const char *str = e->value.buf(); + const char *str = e->value.c_str(); /* try as an ETag */ if (etagParseInit(&tot.tag, str)) { @@ -1374,19 +1373,13 @@ HttpHeaderEntry::HttpHeaderEntry(http_hdr_type anId, const char *aName, const ch Headers[id].stat.aliveCount++; - debugs(55, 9, "created HttpHeaderEntry " << this << ": '" << name.buf() << " : " << value.buf()); + debugs(55, 9, "created HttpHeaderEntry " << this << ": '" << name << " : " << value); } HttpHeaderEntry::~HttpHeaderEntry() { assert_eid(id); - debugs(55, 9, "destroying entry " << this << ": '" << name.buf() << ": " << value.buf() << "'"); - /* clean name if needed */ - - if (id == HDR_OTHER) - name.clean(); - - value.clean(); + debugs(55, 9, "destroying entry " << this << ": '" << name << ": " << value << "'"); assert(Headers[id].stat.aliveCount); @@ -1436,9 +1429,9 @@ HttpHeaderEntry::parse(const char *field_start, const char *field_end) /* is it a "known" field? */ http_hdr_type id = httpHeaderIdByName(field_start, name_len, Headers, HDR_ENUM_END); - String name; + string name; - String value; + string value; if (id < 0) id = HDR_OTHER; @@ -1460,10 +1453,10 @@ HttpHeaderEntry::parse(const char *field_start, const char *field_end) if (field_end - value_start > 65534) { /* String must be LESS THAN 64K and it adds a terminating NULL */ - debugs(55, 1, "WARNING: ignoring '" << name.buf() << "' header of " << (field_end - value_start) << " bytes"); + debugs(55, 1, "WARNING: ignoring '" << name << "' header of " << (field_end - value_start) << " bytes"); if (id == HDR_OTHER) - name.clean(); + name.clear(); return NULL; } @@ -1475,24 +1468,24 @@ HttpHeaderEntry::parse(const char *field_start, const char *field_end) Headers[id].stat.aliveCount++; - debugs(55, 9, "parsed HttpHeaderEntry: '" << name.buf() << ": " << value.buf() << "'"); + debugs(55, 9, "parsed HttpHeaderEntry: '" << name << ": " << value << "'"); - return new HttpHeaderEntry(id, name.buf(), value.buf()); + return new HttpHeaderEntry(id, name.c_str(), value.c_str()); } HttpHeaderEntry * HttpHeaderEntry::clone() const { - return new HttpHeaderEntry(id, name.buf(), value.buf()); + return new HttpHeaderEntry(id, name.c_str(), value.c_str()); } void HttpHeaderEntry::packInto(Packer * p) const { assert(p); - packerAppend(p, name.buf(), name.size()); + packerAppend(p, name.c_str(), name.size()); packerAppend(p, ": ", 2); - packerAppend(p, value.buf(), value.size()); + packerAppend(p, value.c_str(), value.size()); packerAppend(p, "\r\n", 2); } @@ -1502,7 +1495,7 @@ HttpHeaderEntry::getInt() const assert_eid (id); assert (Headers[id].type == ftInt); int val = -1; - int ok = httpHeaderParseInt(value.buf(), &val); + int ok = httpHeaderParseInt(value.c_str(), &val); httpHeaderNoteParsedEntry(id, value, !ok); /* XXX: Should we check ok - ie * return ok ? -1 : value; @@ -1511,13 +1504,13 @@ HttpHeaderEntry::getInt() const } static void -httpHeaderNoteParsedEntry(http_hdr_type id, String const &context, int error) +httpHeaderNoteParsedEntry(http_hdr_type id, string const &context, int error) { Headers[id].stat.parsCount++; if (error) { Headers[id].stat.errCount++; - debugs(55, 2, "cannot parse hdr field: '" << Headers[id].name.buf() << ": " << context.buf() << "'"); + debugs(55, 2, "cannot parse hdr field: '" << Headers[id].name << ": " << context << "'"); } } @@ -1534,7 +1527,7 @@ httpHeaderFieldStatDumper(StoreEntry * sentry, int idx, double val, double size, { const int id = (int) val; const int valid_id = id >= 0 && id < HDR_ENUM_END; - const char *name = valid_id ? Headers[id].name.buf() : "INVALID"; + const char *name = valid_id ? Headers[id].name.c_str() : "INVALID"; int visible = count > 0; /* for entries with zero count, list only those that belong to current type of message */ @@ -1612,7 +1605,7 @@ httpHeaderStoreReport(StoreEntry * e) for (ht = (http_hdr_type)0; ht < HDR_ENUM_END; ++ht) { HttpHeaderFieldInfo *f = Headers + ht; storeAppendPrintf(e, "%2d\t %-20s\t %5d\t %6.3f\t %6.3f\n", - f->id, f->name.buf(), f->stat.aliveCount, + f->id, f->name.c_str(), f->stat.aliveCount, xpercent(f->stat.errCount, f->stat.parsCount), xpercent(f->stat.repCount, f->stat.seenCount)); } @@ -1625,15 +1618,15 @@ httpHeaderStoreReport(StoreEntry * e) } http_hdr_type -httpHeaderIdByName(const char *name, int name_len, const HttpHeaderFieldInfo * info, int end) +httpHeaderIdByName(const char *name, unsigned int name_len, const HttpHeaderFieldInfo * info, int end) { int i; for (i = 0; i < end; ++i) { - if (name_len >= 0 && name_len != info[i].name.size()) + if (name_len >= 0 && name_len != (unsigned int)info[i].name.size()) continue; - if (!strncasecmp(name, info[i].name.buf(), + if (!strncasecmp(name, info[i].name, name_len < 0 ? info[i].name.size() + 1 : name_len)) return info[i].id; } @@ -1658,7 +1651,7 @@ httpHeaderNameById(int id) assert(id >= 0 && id < HDR_ENUM_END); - return Headers[id].name.buf(); + return Headers[id].name.c_str(); } int @@ -1672,7 +1665,7 @@ HttpHeader::hasListMember(http_hdr_type id, const char *member, const char separ assert(id >= 0); - String header (getStrOrList(id)); + string header (getStrOrList(id)); while (strListGetItem(&header, separator, &item, &ilen, &pos)) { if (strncmp(item, member, mlen) == 0 @@ -1696,7 +1689,7 @@ HttpHeader::hasByNameListMember(const char *name, const char *member, const char assert(name); - String header (getByName(name)); + string header (getByName(name)); while (strListGetItem(&header, separator, &item, &ilen, &pos)) { if (strncmp(item, member, mlen) == 0 @@ -1714,9 +1707,9 @@ HttpHeader::removeConnectionHeaderEntries() { if (has(HDR_CONNECTION)) { /* anything that matches Connection list member will be deleted */ - String strConnection; - - (void) getList(HDR_CONNECTION, &strConnection); + string strConnection; + + (void) getList(HDR_CONNECTION, &strConnection); const HttpHeaderEntry *e; HttpHeaderPos pos = HttpHeaderInitPos; /* @@ -1730,7 +1723,7 @@ HttpHeader::removeConnectionHeaderEntries() int headers_deleted = 0; while ((e = getEntry(&pos))) { - if (strListIsMember(&strConnection, e->name.buf(), ',')) + if (strListIsMember(&strConnection, e->name.c_str(), ',')) delAt(pos, headers_deleted); } if (headers_deleted) diff --git a/src/HttpHeader.h b/src/HttpHeader.h index 6528041043..c278631bb3 100644 --- a/src/HttpHeader.h +++ b/src/HttpHeader.h @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.h,v 1.19 2007/05/07 18:12:28 wessels Exp $ + * $Id: HttpHeader.h,v 1.20 2007/05/18 06:41:22 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -183,8 +183,8 @@ public: int getInt() const; MEMPROXY_CLASS(HttpHeaderEntry); http_hdr_type id; - String name; - String value; + string name; + string value; }; MEMPROXY_CLASS_INLINE(HttpHeaderEntry) @@ -211,12 +211,12 @@ public: void refreshMask(); void addEntry(HttpHeaderEntry * e); void insertEntry(HttpHeaderEntry * e); - String getList(http_hdr_type id) const; - bool getList(http_hdr_type id, String *s) const; - String getStrOrList(http_hdr_type id) const; - String getByName(const char *name) const; - String getByNameListMember(const char *name, const char *member, const char separator) const; - String getListMember(http_hdr_type id, const char *member, const char separator) const; + string getList(http_hdr_type id) const; + bool getList(http_hdr_type id, string *s) const; + string getStrOrList(http_hdr_type id) const; + string getByName(const char *name) const; + string getByNameListMember(const char *name, const char *member, const char separator) const; + string getListMember(http_hdr_type id, const char *member, const char separator) const; int has(http_hdr_type id) const; void putInt(http_hdr_type id, int number); void putTime(http_hdr_type id, time_t htime); @@ -258,7 +258,7 @@ private: extern void httpHeaderRegisterWithCacheManager(CacheManager & manager); -extern int httpHeaderParseQuotedString (const char *start, String *val); +extern int httpHeaderParseQuotedString (const char *start, string *val); SQUIDCEXTERN int httpHeaderHasByNameListMember(const HttpHeader * hdr, const char *name, const char *member, const char separator); SQUIDCEXTERN void httpHeaderUpdate(HttpHeader * old, const HttpHeader * fresh, const HttpHeaderMask * denied_mask); int httpMsgIsPersistent(HttpVersion const &http_ver, const HttpHeader * hdr); diff --git a/src/HttpHeaderRange.h b/src/HttpHeaderRange.h index 6e6a3cff3b..f83372281e 100644 --- a/src/HttpHeaderRange.h +++ b/src/HttpHeaderRange.h @@ -1,6 +1,6 @@ /* - * $Id: HttpHeaderRange.h,v 1.8 2006/06/06 19:22:13 hno Exp $ + * $Id: HttpHeaderRange.h,v 1.9 2007/05/18 06:41:22 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -78,7 +78,7 @@ public: static size_t ParsedCount; /* Http Range Header Field */ - static HttpHdrRange *ParseCreate(const String * range_spec); + static HttpHdrRange *ParseCreate(const string * range_spec); HttpHdrRange(); HttpHdrRange(HttpHdrRange const &); @@ -96,7 +96,7 @@ public: int canonize(size_t); int canonize(HttpReply *rep); /* returns true if ranges are valid; inits HttpHdrRange */ - bool parseInit(const String * range_spec); + bool parseInit(const string * range_spec); void packInto(Packer * p) const; /* other */ bool isComplex() const; @@ -127,7 +127,7 @@ public: ssize_t debt() const; void debt(ssize_t); ssize_t debt_size; /* bytes left to send from the current spec */ - String boundary; /* boundary for multipart responses */ + string boundary; /* boundary for multipart responses */ bool valid; }; diff --git a/src/HttpHeaderTools.cc b/src/HttpHeaderTools.cc index defcf5f0b0..8a9d249806 100644 --- a/src/HttpHeaderTools.cc +++ b/src/HttpHeaderTools.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpHeaderTools.cc,v 1.59 2007/05/07 18:12:28 wessels Exp $ + * $Id: HttpHeaderTools.cc,v 1.60 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 66 HTTP Header Tools * AUTHOR: Alex Rousskov @@ -75,7 +75,7 @@ httpHeaderDestroyFieldsInfo(HttpHeaderFieldInfo * table, int count) int i; for (i = 0; i < count; ++i) - table[i].name.clean(); + table[i].name.clear(); delete [] table; } @@ -161,7 +161,7 @@ httpHeaderAddContRange(HttpHeader * hdr, HttpHdrRangeSpec spec, ssize_t ent_len) int httpHeaderHasConnDir(const HttpHeader * hdr, const char *directive) { - String list; + string list; http_hdr_type ht; int res; /* what type of header do we have? */ @@ -177,14 +177,12 @@ httpHeaderHasConnDir(const HttpHeader * hdr, const char *directive) res = strListIsMember(&list, directive, ','); - list.clean(); - return res; } /* returns true iff "m" is a member of the list */ int -strListIsMember(const String * list, const char *m, char del) +strListIsMember(const string * list, const char *m, char del) { const char *pos = NULL; const char *item; @@ -203,7 +201,7 @@ strListIsMember(const String * list, const char *m, char del) /* returns true iff "s" is a substring of a member of the list */ int -strListIsSubstr(const String * list, const char *s, char del) +strListIsSubstr(const string * list, const char *s, char del) { assert(list && del); return list->pos(s) != 0; @@ -219,7 +217,7 @@ strListIsSubstr(const String * list, const char *s, char del) /* appends an item to the list */ void -strListAdd(String * str, const char *item, char del) +strListAdd(string * str, const char *item, char del) { assert(str && item); @@ -243,7 +241,7 @@ strListAdd(String * str, const char *item, char del) * init pos with NULL to start iteration. */ int -strListGetItem(const String * str, char del, const char **item, int *ilen, const char **pos) +strListGetItem(const string * str, char del, const char **item, int *ilen, const char **pos) { size_t len; static char delim[2][3] = { @@ -260,7 +258,7 @@ strListGetItem(const String * str, char del, const char **item, int *ilen, const else (*pos)++; } else { - *pos = str->buf(); + *pos = str->c_str(); if (!*pos) return 0; @@ -349,10 +347,10 @@ httpHeaderParseSize(const char *start, ssize_t * value) * RC TODO: This is too looose. We should honour the BNF and exclude CTL's */ int -httpHeaderParseQuotedString (const char *start, String *val) +httpHeaderParseQuotedString (const char *start, string *val) { const char *end, *pos; - val->clean(); + val->clear(); assert (*start == '"'); pos = start + 1; diff --git a/src/HttpReply.cc b/src/HttpReply.cc index d2d8e14c0c..3f847d1dc2 100644 --- a/src/HttpReply.cc +++ b/src/HttpReply.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.cc,v 1.92 2007/04/20 07:29:47 wessels Exp $ + * $Id: HttpReply.cc,v 1.93 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 58 HTTP Reply (Response) * AUTHOR: Alex Rousskov @@ -105,7 +105,7 @@ void HttpReply::reset() // virtual function instead, but it is not clear whether virtual methods // are allowed with MEMPROXY_CLASS() and whether some cbdata void* // conversions are not going to kill virtual tables - const String pfx = protoPrefix; + const string pfx = protoPrefix; clean(); init(); protoPrefix = pfx; @@ -220,7 +220,7 @@ HttpReply::setHeaders(HttpVersion ver, http_status status, const char *reason, hdr->putStr(HDR_CONTENT_TYPE, ctype); content_type = ctype; } else - content_type = String(); + content_type.clear(); if (clen >= 0) hdr->putInt(HDR_CONTENT_LENGTH, clen); @@ -262,7 +262,7 @@ HttpReply::redirect(http_status status, const char *loc) int HttpReply::validatorsMatch(HttpReply const * otherRep) const { - String one,two; + string one,two; assert (otherRep); /* Numbers first - easiest to check */ /* Content-Length */ @@ -278,9 +278,7 @@ HttpReply::validatorsMatch(HttpReply const * otherRep) const two = otherRep->header.getStrOrList(HDR_ETAG); - if (!one.buf() || !two.buf() || strcasecmp (one.buf(), two.buf())) { - one.clean(); - two.clean(); + if (one.empty() || two.empty() || strcasecmp (one, two)) { return 0; } @@ -292,9 +290,9 @@ HttpReply::validatorsMatch(HttpReply const * otherRep) const two = otherRep->header.getStrOrList(HDR_CONTENT_MD5); - if (!one.buf() || !two.buf() || strcasecmp (one.buf(), two.buf())) { - one.clean(); - two.clean(); + if (one.empty() || two.empty() || strcasecmp (one, two)) { + one.clear(); + two.clear(); return 0; } @@ -383,7 +381,7 @@ HttpReply::hdrCacheInit() if (str) content_type.limitInit(str, strcspn(str, ";\t ")); else - content_type = String(); + content_type = ""; /* be sure to set expires after date and cache-control */ expires = hdrExpirationTime(); @@ -393,7 +391,7 @@ HttpReply::hdrCacheInit() void HttpReply::hdrCacheClean() { - content_type.clean(); + content_type.clear(); if (cache_control) { httpHdrCcDestroy(cache_control); @@ -435,8 +433,8 @@ HttpReply::bodySize(method_t method) const bool HttpReply::sanityCheckStartLine(MemBuf *buf, http_status *error) { - if (buf->contentSize() >= protoPrefix.size() && protoPrefix.cmp(buf->content(), protoPrefix.size()) != 0) { - debugs(58, 3, "HttpReply::sanityCheckStartLine: missing protocol prefix (" << protoPrefix.buf() << ") in '" << buf->content() << "'"); + if (buf->contentSize() >= protoPrefix.size() && strncmp(protoPrefix, buf->content(), protoPrefix.size()) != 0) { + debugs(58, 3, "HttpReply::sanityCheckStartLine: missing protocol prefix (" << protoPrefix << ") in '" << buf->content() << "'"); *error = HTTP_INVALID_HEADER; return false; } diff --git a/src/HttpReply.h b/src/HttpReply.h index f9f4015607..cd6ddb5065 100644 --- a/src/HttpReply.h +++ b/src/HttpReply.h @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.h,v 1.18 2006/04/22 05:29:18 robertc Exp $ + * $Id: HttpReply.h,v 1.19 2007/05/18 06:41:22 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -77,7 +77,7 @@ public: time_t expires; - String content_type; + string content_type; HttpHdrSc *surrogate_control; @@ -90,7 +90,7 @@ public: HttpBody body; /* for small constant memory-resident text bodies only */ - String protoPrefix; // e.g., "HTTP/" + string protoPrefix; // e.g., "HTTP/" bool do_clean; diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index 74c0eac8f2..18acf39f13 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.cc,v 1.74 2007/05/09 09:07:38 wessels Exp $ + * $Id: HttpRequest.cc,v 1.75 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 73 HTTP Request * AUTHOR: Duane Wessels @@ -70,7 +70,7 @@ HttpRequest::init() { method = METHOD_NONE; protocol = PROTO_NONE; - urlpath = NULL; + urlpath.clear(); login[0] = '\0'; host[0] = '\0'; auth_user_request = NULL; @@ -112,7 +112,7 @@ HttpRequest::clean() safe_free(vary_headers); - urlpath.clean(); + urlpath.clear(); header.clean(); @@ -126,13 +126,13 @@ HttpRequest::clean() range = NULL; } - tag.clean(); + tag.clear(); - extacl_user.clean(); + extacl_user.clear(); - extacl_passwd.clean(); + extacl_passwd.clear(); - extacl_log.clean(); + extacl_log.clear(); } void @@ -240,7 +240,7 @@ HttpRequest::pack(Packer * p) assert(p); /* pack request-line */ packerPrintf(p, "%s %s HTTP/1.0\r\n", - RequestMethodStr[method], urlpath.buf()); + RequestMethodStr[method], urlpath.c_str()); /* headers */ header.packInto(p); /* trailer */ @@ -272,12 +272,12 @@ HttpRequest::prefixLen() * check anonymizer (aka header_access) configuration. */ int -httpRequestHdrAllowed(const HttpHeaderEntry * e, String * strConn) +httpRequestHdrAllowed(const HttpHeaderEntry * e, string * strConn) { assert(e); /* check connection header */ - if (strConn && strListIsMember(strConn, e->name.buf(), ',')) + if (strConn && strListIsMember(strConn, e->name.c_str(), ',')) return 0; return 1; @@ -351,7 +351,7 @@ const char *HttpRequest::packableURI(bool full_uri) const return urlCanonical((HttpRequest*)this); if (urlpath.size()) - return urlpath.buf(); + return urlpath.c_str(); return "/"; } diff --git a/src/HttpRequest.h b/src/HttpRequest.h index dd9c75b791..6a225e421f 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.h,v 1.27 2007/05/09 07:36:24 wessels Exp $ + * $Id: HttpRequest.h,v 1.28 2007/05/18 06:41:22 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -40,7 +40,7 @@ #include "HttpRequestMethod.h" /* Http Request */ -extern int httpRequestHdrAllowed(const HttpHeaderEntry * e, String * strConnection); +extern int httpRequestHdrAllowed(const HttpHeaderEntry * e, string * strConnection); extern int httpRequestHdrAllowedByName(http_hdr_type id); extern void httpRequestPack(void *obj, Packer *p); @@ -84,7 +84,7 @@ public: u_short port; - String urlpath; + string urlpath; char *canonical; @@ -120,13 +120,13 @@ public: char *peer_domain; /* Configured peer forceddomain */ - String tag; /* Internal tag for this request */ + string tag; /* Internal tag for this request */ - String extacl_user; /* User name returned by extacl lookup */ + string extacl_user; /* User name returned by extacl lookup */ - String extacl_passwd; /* Password returned by extacl lookup */ + string extacl_passwd; /* Password returned by extacl lookup */ - String extacl_log; /* String to be used for access.log purposes */ + string extacl_log; /* String to be used for access.log purposes */ public: bool multipartRangeRequest() const; diff --git a/src/HttpStatusLine.cc b/src/HttpStatusLine.cc index 3c2dc3d8bd..e63aa0a18f 100644 --- a/src/HttpStatusLine.cc +++ b/src/HttpStatusLine.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpStatusLine.cc,v 1.32 2007/05/04 22:12:55 wessels Exp $ + * $Id: HttpStatusLine.cc,v 1.33 2007/05/18 06:41:22 amosjeffries Exp $ * * DEBUG: section 57 HTTP Status-line * AUTHOR: Alex Rousskov @@ -82,7 +82,7 @@ httpStatusLinePackInto(const HttpStatusLine * sline, Packer * p) * so NULL-termination assumed. */ int -httpStatusLineParse(HttpStatusLine * sline, const String &protoPrefix, const char *start, const char *end) +httpStatusLineParse(HttpStatusLine * sline, const string &protoPrefix, const char *start, const char *end) { assert(sline); sline->status = HTTP_INVALID_HEADER; /* Squid header parsing error */ @@ -90,7 +90,7 @@ httpStatusLineParse(HttpStatusLine * sline, const String &protoPrefix, const cha // XXX: HttpMsg::parse() has a similar check but is using // casesensitive comparison (which is required by HTTP errata?) - if (protoPrefix.caseCmp(start, protoPrefix.size()) != 0) + if (strncasecmp(protoPrefix,start, protoPrefix.size()) != 0) return 0; start += protoPrefix.size(); diff --git a/src/HttpStatusLine.h b/src/HttpStatusLine.h index 5f49b2b542..09592554a3 100644 --- a/src/HttpStatusLine.h +++ b/src/HttpStatusLine.h @@ -1,6 +1,6 @@ /* - * $Id: HttpStatusLine.h,v 1.2 2005/09/12 23:28:57 wessels Exp $ + * $Id: HttpStatusLine.h,v 1.3 2007/05/18 06:41:22 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -56,7 +56,7 @@ SQUIDCEXTERN void httpStatusLineSet(HttpStatusLine * sline, HttpVersion version, SQUIDCEXTERN const char *httpStatusLineReason(const HttpStatusLine * sline); /* parse/pack */ /* parse a 0-terminating buffer and fill internal structires; returns true on success */ -SQUIDCEXTERN int httpStatusLineParse(HttpStatusLine * sline, const String &protoPrefix, +SQUIDCEXTERN int httpStatusLineParse(HttpStatusLine * sline, const string &protoPrefix, const char *start, const char *end); /* pack fields using Packer */ SQUIDCEXTERN void httpStatusLinePackInto(const HttpStatusLine * sline, Packer * p); diff --git a/src/ICAP/ICAPConfig.cc b/src/ICAP/ICAPConfig.cc index 60a066ea70..ce39e2aab8 100644 --- a/src/ICAP/ICAPConfig.cc +++ b/src/ICAP/ICAPConfig.cc @@ -1,6 +1,6 @@ /* - * $Id: ICAPConfig.cc,v 1.14 2007/04/28 22:26:48 hno Exp $ + * $Id: ICAPConfig.cc,v 1.15 2007/05/18 06:41:29 amosjeffries Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -48,7 +48,7 @@ ICAPConfig TheICAPConfig; ICAPServiceRep::Pointer -ICAPConfig::findService(const String& key) +ICAPConfig::findService(const string& key) { Vector::iterator iter = services.begin(); @@ -63,7 +63,7 @@ ICAPConfig::findService(const String& key) } ICAPClass * -ICAPConfig::findClass(const String& key) +ICAPConfig::findClass(const string& key) { if (!key.size()) return NULL; @@ -87,7 +87,7 @@ ICAPClass::prepare() wordlist *service_names = NULL; wordlist *iter; - ConfigParser::ParseString(&key); + ConfigParser::ParseString(key); ConfigParser::ParseWordList(&service_names); for (iter = service_names; iter; iter = iter->next) { @@ -125,7 +125,7 @@ ICAPAccessCheck::ICAPAccessCheck(ICAP::Method aMethod, candidateClasses.clean(); - matchedClass.clean(); + matchedClass.clear(); acl_checklist = NULL; @@ -159,7 +159,7 @@ ICAPAccessCheck::check() ICAPClass *c = *ci; ICAPServiceRep::Pointer service = findBestService(c, false); if (service != NULL) { - debugs(93, 3, "ICAPAccessCheck::check: class '" << c->key.buf() << "' has candidate service '" << service->key.buf() << "'"); + debugs(93, 3, "ICAPAccessCheck::check: class '" << c->key << "' has candidate service '" << service->key << "'"); candidateClasses += c->key; } } @@ -193,7 +193,7 @@ ICAPAccessCheck::checkCandidates() */ debugs(93, 3, "ICAPAccessCheck::check: NO candidates or matches found"); - matchedClass.clean(); + matchedClass.clear(); ICAPAccessCheckCallbackWrapper(1, this); @@ -207,7 +207,7 @@ ICAPAccessCheck::ICAPAccessCheckCallbackWrapper(int answer, void *data) ICAPAccessCheck *ac = (ICAPAccessCheck*)data; if (ac->matchedClass.size()) { - debugs(93, 5, "ICAPAccessCheckCallbackWrapper matchedClass = " << ac->matchedClass.buf()); + debugs(93, 5, "ICAPAccessCheckCallbackWrapper matchedClass = " << ac->matchedClass); } if (!answer) { @@ -241,7 +241,7 @@ ICAPAccessCheck::do_callback() debugs(93, 3, "ICAPAccessCheck::do_callback"); if (matchedClass.size()) { - debugs(93, 3, "ICAPAccessCheck::do_callback matchedClass = " << matchedClass.buf()); + debugs(93, 3, "ICAPAccessCheck::do_callback matchedClass = " << matchedClass); } void *validated_cbdata; @@ -351,8 +351,8 @@ ICAPConfig::dumpICAPService(StoreEntry *entry, const char *name) for (VI i = services.begin(); i != services.end(); ++i) { const ICAPServiceRep::Pointer &r = *i; - storeAppendPrintf(entry, "%s %s_%s %s %d %s\n", name, r->key.buf(), - r->methodStr(), r->vectPointStr(), r->bypass, r->uri.buf()); + storeAppendPrintf(entry, "%s %s_%s %s %d %s\n", name, r->key.c_str(), + r->methodStr(), r->vectPointStr(), r->bypass, r->uri.c_str()); } }; @@ -380,7 +380,7 @@ ICAPConfig::dumpICAPClass(StoreEntry *entry, const char *name) Vector::iterator i = classes.begin(); while (i != classes.end()) { - storeAppendPrintf(entry, "%s %s\n", name, (*i)->key.buf()); + storeAppendPrintf(entry, "%s %s\n", name, (*i)->key.c_str()); ++i; } }; @@ -388,13 +388,13 @@ ICAPConfig::dumpICAPClass(StoreEntry *entry, const char *name) void ICAPConfig::parseICAPAccess(ConfigParser &parser) { - String aKey; - ConfigParser::ParseString(&aKey); + string aKey; + ConfigParser::ParseString(aKey); ICAPClass *theClass = TheICAPConfig.findClass(aKey); if (theClass == NULL) fatalf("Did not find ICAP class '%s' referenced on line %d\n", - aKey.buf(), config_lineno); + aKey.c_str(), config_lineno); aclParseAccessLine(parser, &theClass->accessList); }; @@ -413,7 +413,7 @@ ICAPConfig::dumpICAPAccess(StoreEntry *entry, const char *name) Vector::iterator i = classes.begin(); while (i != classes.end()) { - snprintf(nom, 64, "%s %s", name, (*i)->key.buf()); + snprintf(nom, 64, "%s %s", name, (*i)->key.c_str()); dump_acl_access(entry, nom, (*i)->accessList); ++i; } diff --git a/src/ICAP/ICAPConfig.h b/src/ICAP/ICAPConfig.h index 391b199538..231d196f71 100644 --- a/src/ICAP/ICAPConfig.h +++ b/src/ICAP/ICAPConfig.h @@ -1,6 +1,6 @@ /* - * $Id: ICAPConfig.h,v 1.11 2007/04/06 04:50:07 rousskov Exp $ + * $Id: ICAPConfig.h,v 1.12 2007/05/18 06:41:29 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -47,7 +47,7 @@ class ICAPClass { public: - String key; + string key; acl_access *accessList; Vector services; @@ -73,8 +73,8 @@ private: ICAPAccessCheckCallback *callback; void *callback_data; ACLChecklist *acl_checklist; - Vector candidateClasses; - String matchedClass; + Vector candidateClasses; + string matchedClass; void do_callback(); ICAPServiceRep::Pointer findBestService(ICAPClass *c, bool preferUp); @@ -115,8 +115,8 @@ public: void parseICAPService(void); void freeICAPService(void); void dumpICAPService(StoreEntry *, const char *); - ICAPServiceRep::Pointer findService(const String&); - ICAPClass * findClass(const String& key); + ICAPServiceRep::Pointer findService(const string&); + ICAPClass * findClass(const string& key); void parseICAPClass(void); void freeICAPClass(void); diff --git a/src/ICAP/ICAPModXact.cc b/src/ICAP/ICAPModXact.cc index 1732e4026f..6625989213 100644 --- a/src/ICAP/ICAPModXact.cc +++ b/src/ICAP/ICAPModXact.cc @@ -973,8 +973,8 @@ void ICAPModXact::makeRequestHeaders(MemBuf &buf) * XXX These should use HttpHdr interfaces instead of Printfs */ const ICAPServiceRep &s = service(); - buf.Printf("%s %s ICAP/1.0\r\n", s.methodStr(), s.uri.buf()); - buf.Printf("Host: %s:%d\r\n", s.host.buf(), s.port); + buf.Printf("%s %s ICAP/1.0\r\n", s.methodStr(), s.uri.c_str()); + buf.Printf("Host: %s:%d\r\n", s.host.c_str(), s.port); buf.Printf("Date: %s\r\n", mkrfc1123(squid_curtime)); if (!TheICAPConfig.reuse_connections) @@ -995,7 +995,7 @@ void ICAPModXact::makeRequestHeaders(MemBuf &buf) // to simplify, we could assume that request is always available - String urlPath; + string urlPath; if (request) { urlPath = request->urlpath; if (ICAP::methodRespmod == m) @@ -1091,7 +1091,7 @@ void ICAPModXact::decideOnPreview() const HttpRequest *request = virgin.cause ? virgin.cause : dynamic_cast(virgin.header); - const String urlPath = request ? request->urlpath : String(); + const string urlPath = request ? request->urlpath : ""; size_t wantedSize; if (!service().wantsPreview(urlPath, wantedSize)) { debugs(93, 5, "ICAPModXact should not offer preview for " << urlPath); diff --git a/src/ICAP/ICAPOptXact.cc b/src/ICAP/ICAPOptXact.cc index da0dc719ba..dabfabf121 100644 --- a/src/ICAP/ICAPOptXact.cc +++ b/src/ICAP/ICAPOptXact.cc @@ -42,8 +42,8 @@ void ICAPOptXact::handleCommConnected() void ICAPOptXact::makeRequest(MemBuf &buf) { const ICAPServiceRep &s = service(); - buf.Printf("OPTIONS %s ICAP/1.0\r\n", s.uri.buf()); - buf.Printf("Host: %s:%d\r\n", s.host.buf(), s.port); + buf.Printf("OPTIONS %s ICAP/1.0\r\n", s.uri.c_str()); + buf.Printf("Host: %s:%d\r\n", s.host.c_str(), s.port); buf.append(ICAP::crlf, 2); } diff --git a/src/ICAP/ICAPOptions.cc b/src/ICAP/ICAPOptions.cc index c28abaec70..735a4f88a6 100644 --- a/src/ICAP/ICAPOptions.cc +++ b/src/ICAP/ICAPOptions.cc @@ -31,7 +31,7 @@ ICAPOptions::~ICAPOptions() // future optimization note: this method is called by ICAP ACL code at least // twice for each HTTP message to see if the message should be ignored. For any // non-ignored HTTP message, ICAP calls to check whether a preview is needed. -ICAPOptions::TransferKind ICAPOptions::transferKind(const String &urlPath) const +ICAPOptions::TransferKind ICAPOptions::transferKind(const string &urlPath) const { if (theTransfers.preview.matches(urlPath)) return xferPreview; @@ -122,10 +122,10 @@ void ICAPOptions::cfgMethod(ICAP::Method m) // TODO: HttpHeader should provide a general method for this type of conversion void ICAPOptions::cfgIntHeader(const HttpHeader *h, const char *fname, int &value) { - const String s = h->getByName(fname); + const string s = h->getByName(fname); - if (s.size() && xisdigit(*s.buf())) - value = atoi(s.buf()); + if (!s.empty() && xisdigit(s[0])) + value = atoi(s.c_str()); else value = -1; @@ -134,7 +134,7 @@ void ICAPOptions::cfgIntHeader(const HttpHeader *h, const char *fname, int &valu void ICAPOptions::cfgTransferList(const HttpHeader *h, TransferList &list) { - const String buf = h->getByName(list.name); + const string buf = h->getByName(list.name); bool foundStar = false; list.parse(buf, foundStar); @@ -162,7 +162,7 @@ void ICAPOptions::TransferList::add(const char *extension) { wordlistAdd(&extensions, extension); }; -bool ICAPOptions::TransferList::matches(const String &urlPath) const { +bool ICAPOptions::TransferList::matches(const string &urlPath) const { const int urlLen = urlPath.size(); for (wordlist *e = extensions; e; e = e->next) { // optimize: store extension lengths @@ -172,8 +172,8 @@ bool ICAPOptions::TransferList::matches(const String &urlPath) const { if (eLen < urlLen) { const int eOff = urlLen - eLen; // RFC 3507 examples imply that extensions come without leading '.' - if (urlPath.buf()[eOff-1] == '.' && - strcmp(urlPath.buf() + eOff, e->key) == 0) { + if (urlPath[eOff-1] == '.' && + strcmp(&urlPath[eOff], e->key) == 0) { debugs(93,7, "ICAPOptions url " << urlPath << " matches " << name << " extension " << e->key); return true; @@ -184,7 +184,7 @@ bool ICAPOptions::TransferList::matches(const String &urlPath) const { return false; } -void ICAPOptions::TransferList::parse(const String &buf, bool &foundStar) { +void ICAPOptions::TransferList::parse(const string &buf, bool &foundStar) { foundStar = false; const char *item; diff --git a/src/ICAP/ICAPOptions.h b/src/ICAP/ICAPOptions.h index d18c81ed8d..d22a4dde80 100644 --- a/src/ICAP/ICAPOptions.h +++ b/src/ICAP/ICAPOptions.h @@ -1,6 +1,6 @@ /* - * $Id: ICAPOptions.h,v 1.9 2007/04/06 04:50:07 rousskov Exp $ + * $Id: ICAPOptions.h,v 1.10 2007/05/18 06:41:29 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -62,18 +62,18 @@ public: time_t timestamp() const { return theTimestamp; }; typedef enum { xferNone, xferPreview, xferIgnore, xferComplete } TransferKind; - TransferKind transferKind(const String &urlPath) const; + TransferKind transferKind(const string &urlPath) const; public: const char *error; // human-readable information; set iff !valid() // ICAP server MUST supply this info Vector methods; - String istag; + string istag; // ICAP server MAY supply this info. If not, Squid supplies defaults. - String service; - String serviceId; + string service; + string serviceId; int max_connections; bool allow204; int preview; @@ -86,9 +86,9 @@ protected: TransferList(); ~TransferList(); - bool matches(const String &urlPath) const; + bool matches(const string &urlPath) const; - void parse(const String &buf, bool &foundStar); + void parse(const string &buf, bool &foundStar); void add(const char *extension); void report(int level, const char *prefix) const; diff --git a/src/ICAP/ICAPServiceRep.cc b/src/ICAP/ICAPServiceRep.cc index d4fd563a4c..9abce19fc2 100644 --- a/src/ICAP/ICAPServiceRep.cc +++ b/src/ICAP/ICAPServiceRep.cc @@ -80,24 +80,24 @@ ICAPServiceRep::configure(Pointer &aSelf) char *service_type = NULL; - ConfigParser::ParseString(&key); + ConfigParser::ParseString(key); ConfigParser::ParseString(&service_type); ConfigParser::ParseBool(&bypass); - ConfigParser::ParseString(&uri); + ConfigParser::ParseString(uri); - debugs(3, 5, "ICAPService::parseConfigLine (line " << config_lineno << "): " << key.buf() << " " << service_type << " " << bypass); + debugs(3, 5, "ICAPService::parseConfigLine (line " << config_lineno << "): " << key << " " << service_type << " " << bypass); method = parseMethod(service_type); point = parseVectPoint(service_type); debugs(3, 5, "ICAPService::parseConfigLine (line " << config_lineno << "): service is " << methodStr() << "_" << vectPointStr()); - if (uri.cmp("icap://", 7) != 0) { - debugs(3, 0, "ICAPService::parseConfigLine (line " << config_lineno << "): wrong uri: " << uri.buf()); + if (strncmp(uri, "icap://", 7) != 0) { + debugs(3, 0, "ICAPService::parseConfigLine (line " << config_lineno << "): wrong uri: " << uri); return false; } - const char *s = uri.buf() + 7; + const char *s = &uri[7]; const char *e; @@ -217,13 +217,13 @@ bool ICAPServiceRep::broken() const return probed() && !up(); } -bool ICAPServiceRep::wantsUrl(const String &urlPath) const +bool ICAPServiceRep::wantsUrl(const string &urlPath) const { Must(hasOptions()); return theOptions->transferKind(urlPath) != ICAPOptions::xferIgnore; } -bool ICAPServiceRep::wantsPreview(const String &urlPath, size_t &wantedSize) const +bool ICAPServiceRep::wantsPreview(const string &urlPath, size_t &wantedSize) const { Must(hasOptions()); @@ -361,7 +361,7 @@ void ICAPServiceRep::checkOptions() if (!theOptions->methods.empty()) { bool method_found = false; - String method_list; + string method_list; Vector ::iterator iter = theOptions->methods.begin(); while (iter != theOptions->methods.end()) { @@ -379,8 +379,8 @@ void ICAPServiceRep::checkOptions() if (!method_found) { debugs(93,1, "WARNING: Squid is configured to use ICAP method " << ICAP::methodStr(method) << - " for service " << uri.buf() << - " but OPTIONS response declares the methods are " << method_list.buf()); + " for service " << uri << + " but OPTIONS response declares the methods are " << method_list); } } @@ -393,7 +393,7 @@ void ICAPServiceRep::checkOptions() // TODO: If skew is negative, the option will be considered down // because of stale options. We should probably change this. debugs(93, 1, "ICAP service's clock is skewed by " << skew << - " seconds: " << uri.buf()); + " seconds: " << uri); } } diff --git a/src/ICAP/ICAPServiceRep.h b/src/ICAP/ICAPServiceRep.h index 1654fe91ce..c490de4d78 100644 --- a/src/ICAP/ICAPServiceRep.h +++ b/src/ICAP/ICAPServiceRep.h @@ -1,6 +1,6 @@ /* - * $Id: ICAPServiceRep.h,v 1.7 2007/05/08 16:32:12 rousskov Exp $ + * $Id: ICAPServiceRep.h,v 1.8 2007/05/18 06:41:30 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -91,22 +91,22 @@ public: void callWhenReady(Callback *cb, void *data); // the methods below can only be called on an up() service - bool wantsUrl(const String &urlPath) const; - bool wantsPreview(const String &urlPath, size_t &wantedSize) const; + bool wantsUrl(const string &urlPath) const; + bool wantsPreview(const string &urlPath, size_t &wantedSize) const; bool allows204() const; void noteFailure(); // called by transactions to report service failure public: - String key; + string key; ICAP::Method method; ICAP::VectPoint point; - String uri; // service URI + string uri; // service URI // URI components - String host; + string host; int port; - String resource; + string resource; // XXX: use it when selecting a service and handling ICAP errors! bool bypass; diff --git a/src/ICAP/ICAPXaction.cc b/src/ICAP/ICAPXaction.cc index 4249a62a67..37ca83d21e 100644 --- a/src/ICAP/ICAPXaction.cc +++ b/src/ICAP/ICAPXaction.cc @@ -118,13 +118,19 @@ void ICAPXaction::openConnection() disableRetries(); // we only retry pconn failures +<<<<<<< ICAPXaction.cc + if (connection < 0) { + connection = comm_open(SOCK_STREAM, 0, getOutgoingAddr(NULL), 0, + COMM_NONBLOCKING, s.uri.c_str()); +======= connection = comm_open(SOCK_STREAM, 0, getOutgoingAddr(NULL), 0, COMM_NONBLOCKING, s.uri.buf()); +>>>>>>> 1.15 if (connection < 0) dieOnConnectionFailure(); // throws - debugs(93,3, typeName << " opens connection to " << s.host.buf() << ":" << s.port); + debugs(93,3, typeName << " opens connection to " << s.host << ":" << s.port); commSetTimeout(connection, Config.Timeout.connect, &ICAPXaction_noteCommTimedout, this); @@ -133,7 +139,7 @@ void ICAPXaction::openConnection() comm_add_close_handler(connection, closer, this); connector = &ICAPXaction_noteCommConnected; - commConnectStart(connection, s.host.buf(), s.port, connector, this); + commConnectStart(connection, s.host.c_str(), s.port, connector, this); } /* @@ -167,8 +173,12 @@ void ICAPXaction::closeConnection() if (reuseConnection) { debugs(93,3, HERE << "pushing pconn" << status()); commSetTimeout(connection, -1, NULL, NULL); +<<<<<<< ICAPXaction.cc + icapPconnPool->push(connection, theService->host.c_str(), theService->port, NULL, NULL); +======= icapPconnPool->push(connection, theService->host.buf(), theService->port, NULL, NULL); disableRetries(); +>>>>>>> 1.15 } else { debugs(93,3, HERE << "closing pconn" << status()); // comm_close will clear timeout @@ -243,7 +253,7 @@ void ICAPXaction::noteCommTimedout() void ICAPXaction::handleCommTimedout() { - debugs(93, 0, HERE << "ICAP FD " << connection << " timeout to " << theService->methodStr() << " " << theService->uri.buf()); + debugs(93, 0, HERE << "ICAP FD " << connection << " timeout to " << theService->methodStr() << " " << theService->uri); reuseConnection = false; MemBuf mb; mb.init(); diff --git a/src/Makefile.am b/src/Makefile.am index 23973913ce..e8ad0f3fe4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.am,v 1.180 2007/05/08 16:32:11 rousskov Exp $ +# $Id: Makefile.am,v 1.181 2007/05/18 06:41:22 amosjeffries Exp $ # # Uncomment and customize the following to suit your needs: # @@ -556,7 +556,7 @@ squid_SOURCES = \ $(SSL_SOURCE) \ stat.cc \ StatHist.cc \ - String.cc \ + SqString.cc \ stmem.cc \ stmem.h \ store.cc \ @@ -626,7 +626,8 @@ noinst_HEADERS = ACLChecklist.cci \ MemBuf.h \ Store.cci \ StoreEntryStream.h \ - String.cci \ + SqString.cci \ + SqString.h \ SquidString.h \ SquidTime.h @@ -733,7 +734,7 @@ ufsdump_SOURCES = \ StoreMetaUnpacker.cc \ StoreMetaURL.cc \ StoreMetaVary.cc \ - String.cc \ + SqString.cc \ time.cc \ ufsdump.cc \ url.cc \ @@ -1095,6 +1096,7 @@ TESTSOURCES= \ globals.cc check_PROGRAMS+= \ + tests/testString \ tests/testAuth \ tests/testACLMaxUserIP \ tests/testBoilerplate \ @@ -1106,7 +1108,6 @@ check_PROGRAMS+= \ tests/test_http_range \ tests/testHttpRequest \ tests/testStore \ - tests/testString \ tests/testURL \ @STORE_TESTS@ @@ -1114,7 +1115,7 @@ tests_testAuth_SOURCES= tests/testAuth.cc tests/testMain.cc tests/testAuth.h $( authenticate.cc \ ConfigParser.cc \ tests/stub_acl.cc tests/stub_cache_cf.cc \ - tests/stub_helper.cc cbdata.cc String.cc \ + tests/stub_helper.cc cbdata.cc SqString.cc \ tests/stub_store.cc HttpHeaderTools.cc HttpHeader.cc acl.cc event.cc mem.cc \ MemBuf.cc HttpHdrContRange.cc Packer.cc ACLChecklist.cc HttpHdrCc.cc HttpHdrSc.cc \ HttpHdrScTarget.cc url.cc ACLProxyAuth.cc ACLRegexData.cc ACLUserData.cc \ @@ -1132,7 +1133,7 @@ tests_testAuth_SOURCES= tests/testAuth.cc tests/testMain.cc tests/testAuth.h $( URLScheme.cc \ wordlist.cc ## acl.cc cache_cf.cc tools.cc \ -## helper.cc String.cc cbdata.cc HttpHeaderTools.cc store.cc cache_manager.cc \ +## helper.cc SqString.cc cbdata.cc HttpHeaderTools.cc store.cc cache_manager.cc \ ## HttpHeader.cc url.cc mem.cc HttpRequest.cc Packer.cc access_log.cc \ ## MemBuf.cc StatHist.cc logfile.cc @@ -1168,7 +1169,7 @@ tests_testAuth_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \ ## HttpHdrScTarget.cc \ ## Packer.cc \ ## StatHist.cc \ -## String.cc \ +## SqString.cc \ tests_testACLMaxUserIP_SOURCES= \ acl.cc \ ACLChecklist.cc \ @@ -1193,7 +1194,7 @@ tests_testACLMaxUserIP_SOURCES= \ Parsing.cc \ StatHist.cc \ stmem.cc \ - String.cc \ + SqString.cc \ tests/stub_cache_cf.cc \ tests/stub_comm.cc \ tests/stub_DelayId.cc \ @@ -1241,7 +1242,7 @@ tests_testCacheManager_SOURCES = \ HttpRequest.cc \ HttpRequestMethod.cc \ mem.cc \ - String.cc \ + SqString.cc \ tests/testCacheManager.cc \ tests/testCacheManager.h \ tests/testMain.cc \ @@ -1405,7 +1406,7 @@ tests_testEvent_SOURCES = \ HttpRequestMethod.cc \ mem.cc \ RemovalPolicy.cc \ - String.cc \ + SqString.cc \ tests/CapturingStoreEntry.h \ tests/testEvent.cc \ tests/testEvent.h \ @@ -1557,7 +1558,7 @@ tests_testEventLoop_SOURCES = \ HttpRequestMethod.cc \ mem.cc \ RemovalPolicy.cc \ - String.cc \ + SqString.cc \ tests/testEventLoop.cc \ tests/testEventLoop.h \ tests/testMain.cc \ @@ -1845,7 +1846,7 @@ tests_test_http_range_SOURCES = \ StoreMetaURL.cc \ StoreMetaVary.cc \ StoreSwapLogData.cc \ - String.cc \ + SqString.cc \ SwapDir.cc \ time.cc \ tools.cc \ @@ -1887,7 +1888,7 @@ tests_testHttpRequest_SOURCES = \ HttpRequest.cc \ HttpRequestMethod.cc \ mem.cc \ - String.cc \ + SqString.cc \ tests/testHttpRequest.h \ tests/testHttpRequest.cc \ tests/testHttpRequestMethod.h \ @@ -2054,7 +2055,7 @@ STORE_TEST_SOURCES=\ SwapDir.cc \ authenticate.cc \ tests/stub_acl.cc tests/stub_cache_cf.cc \ - tests/stub_helper.cc cbdata.cc String.cc \ + tests/stub_helper.cc cbdata.cc SqString.cc \ tests/stub_comm.cc \ tests/stub_client_side_request.cc \ tests/stub_http.cc \ @@ -2107,11 +2108,10 @@ tests_testStore_LDADD= \ tests_testStore_LDFLAGS = $(LIBADD_DL) tests_testStore_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \ @SQUID_CPPUNIT_LA@ - # string needs mem.cc. tests_testString_SOURCES= \ mem.cc \ - String.cc \ + SqString.cc \ tests/testMain.cc \ tests/testString.cc \ tests/testString.h \ @@ -2223,7 +2223,7 @@ tests_testURL_SOURCES = \ HttpRequestMethod.cc \ mem.cc \ RemovalPolicy.cc \ - String.cc \ + SqString.cc \ tests/testURL.cc \ tests/testURL.h \ tests/testURLScheme.cc \ diff --git a/src/MemObject.cc b/src/MemObject.cc index 6367a89fe8..fe2620e140 100644 --- a/src/MemObject.cc +++ b/src/MemObject.cc @@ -1,6 +1,6 @@ /* - * $Id: MemObject.cc,v 1.26 2007/04/30 16:56:09 wessels Exp $ + * $Id: MemObject.cc,v 1.27 2007/05/18 06:41:23 amosjeffries Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Robert Collins @@ -168,7 +168,7 @@ MemObject::dump() const debugs(20, 1, "MemObject->nclients: " << nclients); debugs(20, 1, "MemObject->reply: " << _reply); debugs(20, 1, "MemObject->request: " << request); - debugs(20, 1, "MemObject->log_url: " << log_url << " " << checkNullString(log_url)); + debugs(20, 1, "MemObject->log_url: " << (log_url ? log_url : "(NULL)") ); } HttpReply const * diff --git a/src/PeerDigest.h b/src/PeerDigest.h index cd85a122ea..77ebcd8791 100644 --- a/src/PeerDigest.h +++ b/src/PeerDigest.h @@ -1,6 +1,6 @@ /* - * $Id: PeerDigest.h,v 1.1 2006/08/21 00:50:41 robertc Exp $ + * $Id: PeerDigest.h,v 1.2 2007/05/18 06:41:23 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -97,7 +97,7 @@ public: struct _peer *peer; /* pointer back to peer structure, argh */ CacheDigest *cd; /* actual digest structure */ - String host; /* copy of peer->host */ + string host; /* copy of peer->host */ const char *req_result; /* text status of the last request */ struct diff --git a/src/SquidString.h b/src/SquidString.h index 9dfaeb49b5..9125ea6e67 100644 --- a/src/SquidString.h +++ b/src/SquidString.h @@ -1,9 +1,9 @@ /* - * $Id: SquidString.h,v 1.8 2006/05/29 00:15:01 robertc Exp $ + * $Id: SquidString.h,v 1.9 2007/05/18 06:41:23 amosjeffries Exp $ * * DEBUG: section 67 String - * AUTHOR: Duane Wessels + * AUTHOR: Duane Wessels, Amos Jeffries * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -33,112 +33,68 @@ * */ +/** + * + * To allow for easy future updates to the string handling within squid + * We adopt the std::string API as the basis for string operations. + * Then we typedef string (due to namespacing actually ::Squid::string) + * as the preferred string handling class. + * For Release 3.0 it is intended that the old String (no SquidString) + * Will be the default string type. + * For Release 3.1 it is expected that either std::string of another + * custom managed type will be defined as default. + * + * NP: checkout http://johnpanzer.com/tsc_cuj/ToolboxOfStrings.html + * for possibly better and faster strings. + * + * This has been done for several reasons: + * + * The initial String implementation was incomplete and non-standard + * std::string provides a better known API for string handling + * std::string or a derivative may be used in future within squid + * String is a defined alternative to std::string in some systems + * + * These changes: + * - move the old String class to SquidString making the + * internal definition explicit. + * - provide the well-known type of 'string' for general use + * - migrate custom functions to well-known API: + * buf() -> c_str() + * clean() -> clear() + * - remove redundant functions: + * buf(char*) -> operator=(char*) + * initBuf(char*) -> operator=(char*) + * reset(char*) -> operator=(char*) + * - make init(char*) private for use by various assignment/costructor + * - define standard string operators + * - define debugs stream operator + * + */ + #ifndef SQUID_STRING_H #define SQUID_STRING_H -/* forward decls */ - -class CacheManager; - -#define DEBUGSTRINGS 0 -#if DEBUGSTRINGS -#include "splay.h" - -class String; - -class StringRegistry -{ - -public: - static StringRegistry &Instance(); - - void add - (String const *); - - void registerWithCacheManager(CacheManager & manager); - - void remove - (String const *); + /* Provide standard 'string' type */ + /* class defined by the #include file MUST present the basic std::string API */ + /* at least partially as not all operatios are used by squid. */ + /* API Ref: http://www.sgi.com/tech/stl/basic_string.html */ -private: - static OBJH Stat; +#include "SqString.h" +typedef SqString string; - static StringRegistry Instance_; - static SplayNode::SPLAYWALKEE Stater; + /* Overload standard C functions using the basic string API */ - Splay entries; +inline int strncasecmp(const string &lhs, const string &rhs, size_t len) { return strncasecmp(lhs.c_str(), rhs.c_str(), len); } +inline int strcasecmp(const string &lhs, const string &rhs) { return strcasecmp(lhs.c_str(), rhs.c_str()); } - bool registered; +inline int strncmp(const string &lhs, const string &rhs, size_t len) { return strncmp(lhs.c_str(), rhs.c_str(), len); } +inline int strcmp(const string &lhs, const string &rhs) { return strcmp(lhs.c_str(), rhs.c_str()); } -}; +inline const char * strpbrk(const string &lhs, const string &rhs) { return strpbrk(lhs.c_str(), rhs.c_str()); } -class StoreEntry; -#endif +inline const char * strstr(const string &lhs, const string &rhs) { return strstr(lhs.c_str(), rhs.c_str()); } -class String -{ - -public: - _SQUID_INLINE_ String(); - String (char const *); - String (String const &); - ~String(); - - String &operator =(char const *); - String &operator =(String const &); - bool operator ==(String const &) const; - bool operator !=(String const &) const; - - _SQUID_INLINE_ int size() const; - _SQUID_INLINE_ char const * buf() const; - void buf(char *); - void init (char const *); - void initBuf(size_t sz); - void limitInit(const char *str, int len); - void clean(); - void reset(char const *str); - void append(char const *buf, int len); - void append(char const *buf); - void append(char const); - void append (String const &); - void absorb(String &old); - _SQUID_INLINE_ const char * pos(char const *) const; - _SQUID_INLINE_ const char * pos(char const ch) const; - _SQUID_INLINE_ const char * rpos(char const ch) const; - _SQUID_INLINE_ int cmp (char const *) const; - _SQUID_INLINE_ int cmp (char const *, size_t count) const; - _SQUID_INLINE_ int cmp (String const &) const; - _SQUID_INLINE_ int caseCmp (char const *) const; - _SQUID_INLINE_ int caseCmp (char const *, size_t count) const; - - _SQUID_INLINE_ void set - (char const *loc, char const ch); - - _SQUID_INLINE_ void cut (size_t newLength); - - _SQUID_INLINE_ void cutPointer (char const *loc); - -#if DEBUGSTRINGS - - void stat (StoreEntry *) const; - -#endif - -private: - /* never reference these directly! */ - unsigned short int size_; /* buffer size; 64K limit */ - - unsigned short int len_; /* current length */ - - char *buf_; -}; - -_SQUID_INLINE_ std::ostream & operator<<(std::ostream& os, String const &aString); - -#ifdef _USE_INLINE_ -#include "String.cci" -#endif +inline std::ostream& operator <<(std::ostream &os, const string &s) { os << s.c_str(); return os; } #endif /* SQUID_STRING_H */ - diff --git a/src/Store.h b/src/Store.h index 0e73ad19f8..ec504634fe 100644 --- a/src/Store.h +++ b/src/Store.h @@ -1,6 +1,6 @@ /* - * $Id: Store.h,v 1.33 2007/04/21 07:14:13 wessels Exp $ + * $Id: Store.h,v 1.34 2007/05/18 06:41:23 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -258,7 +258,7 @@ public: /* TODO: imeplement the async version */ virtual void get - (String const key , STOREGETCLIENT callback, void *cbdata) = 0; + (string const key , STOREGETCLIENT callback, void *cbdata) = 0; /* prepare the store for use. The store need not be usable immediately, * it should respond to readable() and writable() with true as soon @@ -282,7 +282,7 @@ public: virtual void unlink (StoreEntry &); /* search in the store */ - virtual StoreSearch *search(String const url, HttpRequest *) = 0; + virtual StoreSearch *search(string const url, HttpRequest *) = 0; /* pulled up from SwapDir for migration.... probably do not belong here */ virtual void reference(StoreEntry &) = 0; /* Reference this object */ diff --git a/src/StoreHashIndex.h b/src/StoreHashIndex.h index ec26669658..57ed33da93 100644 --- a/src/StoreHashIndex.h +++ b/src/StoreHashIndex.h @@ -1,6 +1,6 @@ /* - * $Id: StoreHashIndex.h,v 1.2 2005/07/03 15:25:08 serassio Exp $ + * $Id: StoreHashIndex.h,v 1.3 2007/05/18 06:41:23 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -57,7 +57,7 @@ public: (const cache_key *); virtual void get - (String const, STOREGETCLIENT, void * cbdata); + (string const, STOREGETCLIENT, void * cbdata); virtual void init(); @@ -77,7 +77,7 @@ public: virtual void updateSize(size_t, int); - virtual StoreSearch *search(String const url, HttpRequest *); + virtual StoreSearch *search(string const url, HttpRequest *); private: /* migration logic */ diff --git a/src/String.cc b/src/String.cc index d2bbbd0009..e69de29bb2 100644 --- a/src/String.cc +++ b/src/String.cc @@ -1,413 +0,0 @@ - -/* - * $Id: String.cc,v 1.23 2007/04/06 12:15:51 serassio Exp $ - * - * DEBUG: section 67 String - * AUTHOR: Duane Wessels - * - * SQUID Web Proxy Cache http://www.squid-cache.org/ - * ---------------------------------------------------------- - * - * Squid is the result of efforts by numerous individuals from - * the Internet community; see the CONTRIBUTORS file for full - * details. Many organizations have provided support for Squid's - * development; see the SPONSORS file for full details. Squid is - * Copyrighted (C) 2001 by the Regents of the University of - * California; see the COPYRIGHT file for full details. Squid - * incorporates software developed and/or copyrighted by other - * sources; see the CREDITS file for full details. - * - * This program is free software; you can redistribute it and/or modify - * 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 "Store.h" - -void -String::initBuf(size_t sz) -{ - PROF_start(StringInitBuf); - buf((char *)memAllocString(sz, &sz)); - assert(sz < 65536); - size_ = sz; - PROF_stop(StringInitBuf); -} - -void -String::init(char const *str) -{ - assert(this); - - PROF_start(StringInit); - if (str) - limitInit(str, strlen(str)); - else - clean(); - PROF_stop(StringInit); -} - -String::String (char const *aString) : size_(0), len_(0), buf_(NULL) -{ - init (aString); -#if DEBUGSTRINGS - - StringRegistry::Instance().add(this); -#endif -} - -String & -String::operator =(char const *aString) -{ - clean(); - init (aString); - return *this; -} - -String & -String::operator = (String const &old) -{ - clean (); - - if (old.len_) - limitInit (old.buf(), old.len_); - - return *this; -} - -bool -String::operator == (String const &that) const -{ - if (0 == this->cmp(that)) - return true; - - return false; -} - -bool -String::operator != (String const &that) const -{ - if (0 == this->cmp(that)) - return false; - - return true; -} - -void -String::limitInit(const char *str, int len) -{ - PROF_start(StringLimitInit); - assert(this && str); - initBuf(len + 1); - len_ = len; - xmemcpy(buf_, str, len); - buf_[len] = '\0'; - PROF_stop(StringLimitInit); -} - -String::String (String const &old) : size_(0), len_(0), buf_(NULL) -{ - init (old.buf()); -#if DEBUGSTRINGS - - StringRegistry::Instance().add(this); -#endif -} - -void -String::clean() -{ - PROF_start(StringClean); - assert(this); - - if (buf()) - memFreeString(size_, buf_); - - len_ = 0; - - size_ = 0; - - buf_ = NULL; - PROF_stop(StringClean); -} - -String::~String() -{ - clean(); -#if DEBUGSTRINGS - - StringRegistry::Instance().remove(this); -#endif -} - -void -String::reset(const char *str) -{ - PROF_start(StringReset); - clean(); - init(str); - PROF_stop(StringReset); -} - -void -String::append(const char *str, int len) -{ - assert(this); - assert(str && len >= 0); - - PROF_start(StringAppend); - if (len_ + len < size_) { - strncat(buf_, str, len); - len_ += len; - } else { - String snew; - snew.len_ = len_ + len; - snew.initBuf(snew.len_ + 1); - - if (buf_) - xmemcpy(snew.buf_, buf(), len_); - - if (len) - xmemcpy(snew.buf_ + len_, str, len); - - snew.buf_[snew.len_] = '\0'; - - absorb(snew); - } - PROF_stop(StringAppend); -} - -void -String::append(char const *str) -{ - assert (str); - append (str, strlen(str)); -} - -void -String::append (char chr) -{ - char myString[2]; - myString[0]=chr; - myString[1]='\0'; - append (myString, 1); -} - -void -String::append(String const &old) -{ - append (old.buf(), old.len_); -} - -void -String::absorb(String &old) -{ - clean(); - size_ = old.size_; - buf (old.buf_); - len_ = old.len_; - old.size_ = 0; - old.buf_ = NULL; - old.len_ = 0; -} - -void -String::buf(char *newBuf) -{ - assert (buf_ == NULL); - buf_ = newBuf; -} - -#if DEBUGSTRINGS -void -String::stat(StoreEntry *entry) const -{ - storeAppendPrintf(entry, "%p : %d/%d \"%s\"\n",this,len_, size_, buf()); -} - -StringRegistry & -StringRegistry::Instance() -{ - return Instance_; -} - -template -int -ptrcmp(C const &lhs, C const &rhs) -{ - return lhs - rhs; -} - -void -StringRegistry::registerWithCacheManager(CacheManager & manager) -{ - manager.registerAction("strings", - "Strings in use in squid", Stat, 0, 1); -} - -void - -StringRegistry::add - (String const *entry) -{ - entries.insert(entry, ptrcmp); -} - -void - -StringRegistry::remove - (String const *entry) -{ - entries.remove(entry, ptrcmp); -} - -StringRegistry StringRegistry::Instance_; - -extern size_t memStringCount(); - -void -StringRegistry::Stat(StoreEntry *entry) -{ - storeAppendPrintf(entry, "%lu entries, %lu reported from MemPool\n", (unsigned long) Instance().entries.elements, (unsigned long) memStringCount()); - Instance().entries.head->walk(Stater, entry); -} - -void -StringRegistry::Stater(String const * const & nodedata, void *state) -{ - StoreEntry *entry = (StoreEntry *) state; - nodedata->stat(entry); -} - -#endif - -/* TODO: move onto String */ -int -stringHasWhitespace(const char *s) -{ - return strpbrk(s, w_space) != NULL; -} - -/* TODO: move onto String */ -int -stringHasCntl(const char *s) -{ - unsigned char c; - - while ((c = (unsigned char) *s++) != '\0') { - if (c <= 0x1f) - return 1; - - if (c >= 0x7f && c <= 0x9f) - return 1; - } - - return 0; -} - -/* - * Similar to strtok, but has some rudimentary knowledge - * of quoting - */ -char * -strwordtok(char *buf, char **t) -{ - unsigned char *word = NULL; - unsigned char *p = (unsigned char *) buf; - unsigned char *d; - unsigned char ch; - int quoted = 0; - - if (!p) - p = (unsigned char *) *t; - - if (!p) - goto error; - - while (*p && xisspace(*p)) - p++; - - if (!*p) - goto error; - - word = d = p; - - while ((ch = *p)) { - switch (ch) { - - case '\\': - p++; - - switch (*p) { - - case 'n': - ch = '\n'; - - break; - - case 'r': - ch = '\r'; - - break; - - default: - ch = *p; - - break; - - } - - *d++ = ch; - - if (ch) - p++; - - break; - - case '"': - quoted = !quoted; - - p++; - - break; - - default: - if (!quoted && xisspace(*p)) { - p++; - goto done; - } - - *d++ = *p++; - break; - } - } - -done: - *d++ = '\0'; - -error: - *t = (char *) p; - return (char *) word; -} - -const char * -checkNullString(const char *p) -{ - return p ? p : "(NULL)"; -} - -#ifndef _USE_INLINE_ -#include "String.cci" -#endif diff --git a/src/String.cci b/src/String.cci index 4a430658ad..e69de29bb2 100644 --- a/src/String.cci +++ b/src/String.cci @@ -1,169 +0,0 @@ - -/* - * $Id: String.cci,v 1.6 2006/09/01 22:57:44 robertc Exp $ - * - * DEBUG: section 67 String - * AUTHOR: Duane Wessels - * - * SQUID Web Proxy Cache http://www.squid-cache.org/ - * ---------------------------------------------------------- - * - * Squid is the result of efforts by numerous individuals from - * the Internet community; see the CONTRIBUTORS file for full - * details. Many organizations have provided support for Squid's - * development; see the SPONSORS file for full details. Squid is - * Copyrighted (C) 2001 by the Regents of the University of - * California; see the COPYRIGHT file for full details. Squid - * incorporates software developed and/or copyrighted by other - * sources; see the CREDITS file for full details. - * - * This program is free software; you can redistribute it and/or modify - * 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. - * - */ - -String::String() : size_(0), len_(0), buf_ (NULL) -{ -#if DEBUGSTRINGS - StringRegistry::Instance().add(this); -#endif -} - -int -String::size() const -{ - return len_; -} - -char const * -String::buf() const -{ - return buf_; -} - -const char * -String::pos(char const *aString) const -{ - return strstr(buf(), aString); -} - -const char * -String::pos(char const ch) const -{ - return strchr(buf(), ch); -} - -const char * -String::rpos(char const ch) const -{ - return strrchr(buf(), (ch)); -} - -int -String::cmp (char const *aString) const -{ - /* strcmp fails on NULLS */ - - if (size() == 0 && (aString == NULL || aString[0] == '\0')) - return 0; - - if (size() == 0) - return -1; - - if (aString == NULL || aString[0] == '\0') - return 1; - - return strcmp(buf(), aString); -} - -int -String::cmp (char const *aString, size_t count) const -{ - /* always the same at length 0 */ - - if (count == 0) - return 0; - - if (size() == 0 && (aString == NULL || aString[0] == '\0')) - return 0; - - if (size() == 0) - return -1; - - if (aString == NULL || aString[0] == '\0') - return 1; - - return strncmp(buf(), aString, count); -} - -int -String::cmp (String const &aString) const -{ - /* strcmp fails on NULLS */ - - if (size() == 0 && aString.size() == 0) - return 0; - - if (size() == 0) - return -1; - - if (aString.size() == 0) - return 1; - - return strcmp(buf(), aString.buf()); -} - -int -String::caseCmp (char const *aString) const -{ - return strcasecmp(buf(), aString); -} - -int -String::caseCmp (char const *aString, size_t count) const -{ - return strncasecmp(buf(), aString, count); -} - -/* FIXME: this is can perform buffer overflows and underflows! */ -void -String::set (char const *loc, char const ch) -{ - buf_[loc-buf_] = ch; -} - -/* FIXME: this is can perform buffer overflows and underflows! */ -void -String::cut (size_t newLength) -{ - len_ = newLength; - buf_[newLength] = '\0'; -} - -/* FIXME: this is can perform buffer overflows and underflows! */ -void -String::cutPointer (char const *loc) -{ - len_ = loc-buf_; - buf_[len_] = '\0'; -} - -std::ostream & -operator<<(std::ostream& os, String const &aString) -{ - os << aString.buf(); - return os; -} - - diff --git a/src/SwapDir.cc b/src/SwapDir.cc index 32a5c6d0ce..8b0eb8e4d9 100644 --- a/src/SwapDir.cc +++ b/src/SwapDir.cc @@ -1,6 +1,6 @@ /* - * $Id: SwapDir.cc,v 1.11 2007/04/30 16:56:09 wessels Exp $ + * $Id: SwapDir.cc,v 1.12 2007/05/18 06:41:23 amosjeffries Exp $ * * DEBUG: section 20 Swap Dir base object * AUTHOR: Robert Collins @@ -276,7 +276,7 @@ SwapDir::get void SwapDir::get - (String const key, STOREGETCLIENT callback, void *cbdata) + (string const key, STOREGETCLIENT callback, void *cbdata) { fatal("not implemented"); } diff --git a/src/SwapDir.h b/src/SwapDir.h index c864f25837..dcd53137b2 100644 --- a/src/SwapDir.h +++ b/src/SwapDir.h @@ -1,6 +1,6 @@ /* - * $Id: SwapDir.h,v 1.11 2006/08/21 00:50:41 robertc Exp $ + * $Id: SwapDir.h,v 1.12 2007/05/18 06:41:23 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -60,7 +60,7 @@ public: (const cache_key *); virtual void get - (String const, STOREGETCLIENT, void * cbdata); + (string const, STOREGETCLIENT, void * cbdata); virtual void init(); @@ -74,7 +74,7 @@ public: virtual void sync(); /* Sync the store prior to shutdown */ - virtual StoreSearch *search(String const url, HttpRequest *); + virtual StoreSearch *search(string const url, HttpRequest *); virtual void reference(StoreEntry &); /* Reference this object */ @@ -134,13 +134,13 @@ public: (const cache_key *); virtual void get - (String const, STOREGETCLIENT, void * cbdata); + (string const, STOREGETCLIENT, void * cbdata); virtual size_t maxSize() const { return max_size;} virtual size_t minSize() const; virtual void stat (StoreEntry &anEntry) const; - virtual StoreSearch *search(String const url, HttpRequest *) = 0; + virtual StoreSearch *search(string const url, HttpRequest *) = 0; virtual void updateSize(size_t size, int sign); diff --git a/src/access_log.cc b/src/access_log.cc index fc322bbf4f..a1fd201473 100644 --- a/src/access_log.cc +++ b/src/access_log.cc @@ -1,6 +1,6 @@ /* - * $Id: access_log.cc,v 1.124 2007/05/17 19:59:41 hno Exp $ + * $Id: access_log.cc,v 1.125 2007/05/18 06:41:23 amosjeffries Exp $ * * DEBUG: section 46 Access Log * AUTHOR: Duane Wessels @@ -518,7 +518,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log) logformat_token *fmt; static MemBuf mb; char tmp[1024]; - String sb; + string sb; mb.reset(); @@ -628,7 +628,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log) if (al->request) sb = al->request->header.getByName(fmt->data.header.header); - out = sb.buf(); + out = sb.c_str(); quote = 1; @@ -638,7 +638,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log) if (al->reply) sb = al->reply->header.getByName(fmt->data.header.header); - out = sb.buf(); + out = sb.c_str(); quote = 1; @@ -648,7 +648,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log) if (al->request) sb = al->request->header.getByNameListMember(fmt->data.header.header, fmt->data.header.element, fmt->data.header.separator); - out = sb.buf(); + out = sb.c_str(); quote = 1; @@ -658,7 +658,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log) if (al->reply) sb = al->reply->header.getByNameListMember(fmt->data.header.header, fmt->data.header.element, fmt->data.header.separator); - out = sb.buf(); + out = sb.c_str(); quote = 1; @@ -767,7 +767,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log) case LFT_REQUEST_URLPATH: if (al->request) { - out = al->request->urlpath.buf(); + out = al->request->urlpath.c_str(); quote = 1; } break; @@ -813,7 +813,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log) case LFT_TAG: if (al->request) - out = al->request->tag.buf(); + out = al->request->tag.c_str(); quote = 1; @@ -821,7 +821,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log) case LFT_EXT_LOG: if (al->request) - out = al->request->extacl_log.buf(); + out = al->request->extacl_log.c_str(); quote = 1; @@ -891,7 +891,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log) if (fmt->space) mb.append(" ", 1); - sb.clean(); + sb.clear(); if (dofree) safe_free(out); @@ -1631,8 +1631,8 @@ accessLogTime(time_t t) static void fvdbInit(void) { - via_table = hash_create((HASHCMP *) strcmp, 977, hash4); - forw_table = hash_create((HASHCMP *) strcmp, 977, hash4); + via_table = hash_create((HASHCMP *) std::strcmp, 977, hash4); + forw_table = hash_create((HASHCMP *) std::strcmp, 977, hash4); } static void @@ -1717,10 +1717,10 @@ fvdbClear(void) { hashFreeItems(via_table, fvdbFreeEntry); hashFreeMemory(via_table); - via_table = hash_create((HASHCMP *) strcmp, 977, hash4); + via_table = hash_create((HASHCMP *) std::strcmp, 977, hash4); hashFreeItems(forw_table, fvdbFreeEntry); hashFreeMemory(forw_table); - forw_table = hash_create((HASHCMP *) strcmp, 977, hash4); + forw_table = hash_create((HASHCMP *) std::strcmp, 977, hash4); } #endif diff --git a/src/auth/digest/auth_digest.cc b/src/auth/digest/auth_digest.cc index 0553f03b43..ee75fca8d8 100644 --- a/src/auth/digest/auth_digest.cc +++ b/src/auth/digest/auth_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: auth_digest.cc,v 1.55 2007/05/09 09:07:39 wessels Exp $ + * $Id: auth_digest.cc,v 1.56 2007/05/18 06:41:31 amosjeffries Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Robert Collins @@ -204,7 +204,7 @@ authenticateDigestNonceSetup(void) digest_nonce_pool = memPoolCreate("Digest Scheme nonce's", sizeof(digest_nonce_h)); if (!digest_nonce_cache) { - digest_nonce_cache = hash_create((HASHCMP *) strcmp, 7921, hash_string); + digest_nonce_cache = hash_create((HASHCMP *) std::strcmp, 7921, hash_string); assert(digest_nonce_cache); eventAdd("Digest none cache maintenance", authenticateDigestNonceCacheCleanup, NULL, digestConfig.nonceGCInterval, 1); } @@ -1089,7 +1089,7 @@ AuthDigestConfig::decode(char const *proxy_auth) while (xisspace(*proxy_auth)) proxy_auth++; - String temp(proxy_auth); + string temp(proxy_auth); while (strListGetItem(&temp, ',', &item, &ilen, &pos)) { if ((p = strchr(item, '=')) && (p - item < ilen)) @@ -1205,7 +1205,7 @@ AuthDigestConfig::decode(char const *proxy_auth) } } - temp.clean(); + temp.clear(); /* now we validate the data given to us */ diff --git a/src/auth/negotiate/auth_negotiate.cc b/src/auth/negotiate/auth_negotiate.cc index 8865b36e0c..e70c6fd662 100644 --- a/src/auth/negotiate/auth_negotiate.cc +++ b/src/auth/negotiate/auth_negotiate.cc @@ -1,6 +1,6 @@ /* - * $Id: auth_negotiate.cc,v 1.18 2007/05/09 09:07:40 wessels Exp $ + * $Id: auth_negotiate.cc,v 1.19 2007/05/18 06:41:31 amosjeffries Exp $ * * DEBUG: section 29 Negotiate Authenticator * AUTHOR: Robert Collins, Henrik Nordstrom, Francesco Chemolli @@ -180,7 +180,7 @@ AuthNegotiateConfig::init(AuthConfig * scheme) negotiateauthenticators = helperStatefulCreate("negotiateauthenticator"); if (!proxy_auth_cache) - proxy_auth_cache = hash_create((HASHCMP *) strcmp, 7921, hash_string); + proxy_auth_cache = hash_create((HASHCMP *) std::strcmp, 7921, hash_string); assert(proxy_auth_cache); diff --git a/src/auth/ntlm/auth_ntlm.cc b/src/auth/ntlm/auth_ntlm.cc index 9e7945d1e4..80dd7fcf6d 100644 --- a/src/auth/ntlm/auth_ntlm.cc +++ b/src/auth/ntlm/auth_ntlm.cc @@ -1,6 +1,6 @@ /* - * $Id: auth_ntlm.cc,v 1.68 2007/05/09 09:07:43 wessels Exp $ + * $Id: auth_ntlm.cc,v 1.69 2007/05/18 06:41:32 amosjeffries Exp $ * * DEBUG: section 29 NTLM Authenticator * AUTHOR: Robert Collins, Henrik Nordstrom, Francesco Chemolli @@ -181,7 +181,7 @@ AuthNTLMConfig::init(AuthConfig * scheme) ntlmauthenticators = helperStatefulCreate("ntlmauthenticator"); if (!proxy_auth_cache) - proxy_auth_cache = hash_create((HASHCMP *) strcmp, 7921, hash_string); + proxy_auth_cache = hash_create((HASHCMP *) std::strcmp, 7921, hash_string); assert(proxy_auth_cache); diff --git a/src/cache_cf.cc b/src/cache_cf.cc index a68ec06f93..c464f7d4c9 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.510 2007/04/28 22:26:37 hno Exp $ + * $Id: cache_cf.cc,v 1.511 2007/05/18 06:41:23 amosjeffries Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -2201,14 +2201,14 @@ ConfigParser::ParseString(char **var) } void -ConfigParser::ParseString(String *var) +ConfigParser::ParseString(string &var) { char *token = strtok(NULL, w_space); if (token == NULL) self_destruct(); - var->reset(token); + var = token; } static void diff --git a/src/client_db.cc b/src/client_db.cc index 180bf6b3bd..b536911902 100644 --- a/src/client_db.cc +++ b/src/client_db.cc @@ -1,6 +1,6 @@ /* - * $Id: client_db.cc,v 1.68 2007/04/28 22:26:37 hno Exp $ + * $Id: client_db.cc,v 1.69 2007/05/18 06:41:23 amosjeffries Exp $ * * DEBUG: section 0 Client Database * AUTHOR: Duane Wessels @@ -80,7 +80,7 @@ clientdbInit(void) if (client_table) return; - client_table = hash_create((HASHCMP *) strcmp, CLIENT_DB_HASH_SIZE, hash_string); + client_table = hash_create((HASHCMP *) std::strcmp, CLIENT_DB_HASH_SIZE, hash_string); } void diff --git a/src/client_side.cc b/src/client_side.cc index 4396227802..61af5dfedd 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.753 2007/05/09 09:07:38 wessels Exp $ + * $Id: client_side.cc,v 1.754 2007/05/18 06:41:23 amosjeffries Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -459,7 +459,7 @@ clientPrepareLogWithRequestDetails(HttpRequest * request, AccessLogEntry * aLogE aLogEntry->http.version = request->http_ver; aLogEntry->hier = request->hier; - aLogEntry->cache.extuser = request->extacl_user.buf(); + aLogEntry->cache.extuser = request->extacl_user.c_str(); if (request->auth_user_request) { @@ -481,10 +481,10 @@ ClientHttpRequest::logRequest() if (al.reply) { al.http.code = al.reply->sline.status; - al.http.content_type = al.reply->content_type.buf(); + al.http.content_type = al.reply->content_type.c_str(); } else if (loggingEntry() && loggingEntry()->mem_obj) { al.http.code = loggingEntry()->mem_obj->getReply()->sline.status; - al.http.content_type = loggingEntry()->mem_obj->getReply()->content_type.buf(); + al.http.content_type = loggingEntry()->mem_obj->getReply()->content_type.c_str(); } debugs(33, 9, "clientLogRequest: http.code='" << al.http.code << "'"); @@ -541,7 +541,7 @@ ClientHttpRequest::freeResources() safe_free(uri); safe_free(log_uri); safe_free(redirect.location); - range_iter.boundary.clean(); + range_iter.boundary.clear(); HTTPMSGUNLOCK(request); if (client_stream.tail) @@ -823,15 +823,15 @@ ClientSocketContext::sendBody(HttpReply * rep, StoreIOBuffer bodyData) /* put terminating boundary for multiparts */ static void -clientPackTermBound(String boundary, MemBuf * mb) +clientPackTermBound(string boundary, MemBuf * mb) { - mb->Printf("\r\n--%s--\r\n", boundary.buf()); + mb->Printf("\r\n--%s--\r\n", boundary.c_str()); debugs(33, 6, "clientPackTermBound: buf offset: " << mb->size); } /* appends a "part" HTTP header (as in a multi-part/range reply) to the buffer */ static void -clientPackRangeHdr(const HttpReply * rep, const HttpHdrRangeSpec * spec, String boundary, MemBuf * mb) +clientPackRangeHdr(const HttpReply * rep, const HttpHdrRangeSpec * spec, string boundary, MemBuf * mb) { HttpHeader hdr(hoReply); Packer p; @@ -839,10 +839,9 @@ clientPackRangeHdr(const HttpReply * rep, const HttpHdrRangeSpec * spec, String assert(spec); /* put boundary */ - debugs(33, 5, "clientPackRangeHdr: appending boundary: " << - boundary.buf()); + debugs(33, 5, "clientPackRangeHdr: appending boundary: " << boundary); /* rfc2046 requires to _prepend_ boundary with ! */ - mb->Printf("\r\n--%s\r\n", boundary.buf()); + mb->Printf("\r\n--%s\r\n", boundary.c_str()); /* stuff the header with required entries and pack it */ @@ -1034,12 +1033,12 @@ clientIfRangeMatch(ClientHttpRequest * http, HttpReply * rep) /* generates a "unique" boundary string for multipart responses * the caller is responsible for cleaning the string */ -String +string ClientHttpRequest::rangeBoundaryStr() const { assert(this); const char *key; - String b (full_appname_string); + string b (full_appname_string); b.append (":",1); key = storeEntry()->getMD5Text(); b.append(key, strlen(key)); @@ -1151,7 +1150,7 @@ ClientSocketContext::buildRangeHeader(HttpReply * rep) hdr->delById(HDR_CONTENT_TYPE); httpHeaderPutStrf(hdr, HDR_CONTENT_TYPE, "multipart/byteranges; boundary=\"%s\"", - http->range_iter.boundary.buf()); + http->range_iter.boundary.c_str()); /* Content-Length is not required in multipart responses * but it is always nice to have one */ actual_clen = http->mRangeCLen(); @@ -2184,11 +2183,11 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC request->flags.tproxy = conn->port->tproxy; #endif - if (internalCheck(request->urlpath.buf())) { + if (internalCheck(request->urlpath.c_str())) { if (internalHostnameIs(request->host) && request->port == getMyPort()) { http->flags.internal = 1; - } else if (Config.onoff.global_internal_static && internalStaticCheck(request->urlpath.buf())) { + } else if (Config.onoff.global_internal_static && internalStaticCheck(request->urlpath.c_str())) { xstrncpy(request->host, internalHostname(), SQUIDHOSTNAMELEN); request->port = getMyPort(); diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index c616f4292c..48d1aca03a 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.cc,v 1.126 2007/05/09 09:07:38 wessels Exp $ + * $Id: client_side_reply.cc,v 1.127 2007/05/18 06:41:23 amosjeffries Exp $ * * DEBUG: section 88 Client-side Reply Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -1262,7 +1262,7 @@ clientReplyContext::buildReplyHeader() int headers_deleted = 0; while ((e = hdr->getEntry(&pos))) { if (e->id == HDR_WWW_AUTHENTICATE || e->id == HDR_PROXY_AUTHENTICATE) { - const char *value = e->value.buf(); + const char *value = e->value.c_str(); if ((strncasecmp(value, "NTLM", 4) == 0 && (value[4] == '\0' || value[4] == ' ')) @@ -1314,7 +1314,7 @@ clientReplyContext::buildReplyHeader() /* Append VIA */ { LOCAL_ARRAY(char, bbuf, MAX_URL + 32); - String strVia; + string strVia; hdr->getList(HDR_VIA, &strVia); snprintf(bbuf, sizeof(bbuf), "%d.%d %s", reply->sline.version.major, @@ -1322,7 +1322,7 @@ clientReplyContext::buildReplyHeader() ThisCache); strListAdd(&strVia, bbuf, ','); hdr->delById(HDR_VIA); - hdr->putStr(HDR_VIA, strVia.buf()); + hdr->putStr(HDR_VIA, strVia.c_str()); } /* Signal keep-alive if needed */ hdr->putStr(http->flags.accel ? HDR_CONNECTION : HDR_PROXY_CONNECTION, diff --git a/src/client_side_request.cc b/src/client_side_request.cc index 932e474ba3..8c5d11ead1 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.cc,v 1.85 2007/05/09 09:07:39 wessels Exp $ + * $Id: client_side_request.cc,v 1.86 2007/05/18 06:41:23 amosjeffries Exp $ * * DEBUG: section 85 Client-side Request Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -628,12 +628,10 @@ clientInterpretRequestHeaders(ClientHttpRequest * http) #else if (req_hdr->has(HDR_PRAGMA)) { - String s = req_hdr->getList(HDR_PRAGMA); + string s = req_hdr->getList(HDR_PRAGMA); if (strListIsMember(&s, "no-cache", ',')) no_cache++; - - s.clean(); } if (request->cache_control) @@ -712,7 +710,7 @@ clientInterpretRequestHeaders(ClientHttpRequest * http) request->flags.auth = 1; if (req_hdr->has(HDR_VIA)) { - String s = req_hdr->getList(HDR_VIA); + string s = req_hdr->getList(HDR_VIA); /* * ThisCache cannot be a member of Via header, "1.0 ThisCache" can. * Note ThisCache2 has a space prepended to the hostname so we don't @@ -726,11 +724,11 @@ clientInterpretRequestHeaders(ClientHttpRequest * http) } #if FORW_VIA_DB - fvdbCountVia(s.buf()); + fvdbCountVia(s.c_str()); #endif - s.clean(); + s.clear(); } #if USE_USERAGENT_LOG @@ -747,9 +745,9 @@ clientInterpretRequestHeaders(ClientHttpRequest * http) #if FORW_VIA_DB if (req_hdr->has(HDR_X_FORWARDED_FOR)) { - String s = req_hdr->getList(HDR_X_FORWARDED_FOR); - fvdbCountForw(s.buf()); - s.clean(); + string s = req_hdr->getList(HDR_X_FORWARDED_FOR); + fvdbCountForw(s.c_str()); + s.clear(); } #endif diff --git a/src/client_side_request.h b/src/client_side_request.h index e95296134c..eace249c17 100644 --- a/src/client_side_request.h +++ b/src/client_side_request.h @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.h,v 1.28 2007/05/08 16:46:37 rousskov Exp $ + * $Id: client_side_request.h,v 1.29 2007/05/18 06:41:23 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -75,7 +75,7 @@ public: ClientHttpRequest(ClientHttpRequest const &); ClientHttpRequest& operator=(ClientHttpRequest const &); - String rangeBoundaryStr() const; + string rangeBoundaryStr() const; void freeResources(); void updateCounters(); void logRequest(); diff --git a/src/dns_internal.cc b/src/dns_internal.cc index 2090671fa4..f501280576 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -1,6 +1,6 @@ /* - * $Id: dns_internal.cc,v 1.98 2007/04/30 16:56:09 wessels Exp $ + * $Id: dns_internal.cc,v 1.99 2007/05/18 06:41:24 amosjeffries Exp $ * * DEBUG: section 78 DNS lookups; interacts with lib/rfc1035.c * AUTHOR: Duane Wessels @@ -1238,7 +1238,7 @@ idnsInit(void) if (!init) { memDataInit(MEM_IDNS_QUERY, "idns_query", sizeof(idns_query), 0); memset(RcodeMatrix, '\0', sizeof(RcodeMatrix)); - idns_lookup_hash = hash_create((HASHCMP *) strcmp, 103, hash_string); + idns_lookup_hash = hash_create((HASHCMP *) std::strcmp, 103, hash_string); init++; } } diff --git a/src/errorpage.cc b/src/errorpage.cc index 5bd14c4431..70f36ebdb5 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -1,6 +1,6 @@ /* - * $Id: errorpage.cc,v 1.225 2007/05/09 09:07:39 wessels Exp $ + * $Id: errorpage.cc,v 1.226 2007/05/18 06:41:24 amosjeffries Exp $ * * DEBUG: section 4 Error Generation * AUTHOR: Duane Wessels @@ -534,7 +534,7 @@ errorDump(ErrorState * err, MemBuf * mb) Packer p; str.Printf("%s %s HTTP/%d.%d\n", RequestMethodStr[r->method], - r->urlpath.size() ? r->urlpath.buf() : "/", + r->urlpath.size() ? r->urlpath.c_str() : "/", r->http_ver.major, r->http_ver.minor); packerToMemInit(&p, &str); r->header.packInto(&p); @@ -739,7 +739,7 @@ errorConvert(char token, ErrorState * err) Packer p; mb.Printf("%s %s HTTP/%d.%d\n", RequestMethodStr[r->method], - r->urlpath.size() ? r->urlpath.buf() : "/", + r->urlpath.size() ? r->urlpath.c_str() : "/", r->http_ver.major, r->http_ver.minor); packerToMemInit(&p, &mb); r->header.packInto(&p); diff --git a/src/external_acl.cc b/src/external_acl.cc index 9b319bbd61..bcd1f74fcc 100644 --- a/src/external_acl.cc +++ b/src/external_acl.cc @@ -1,6 +1,6 @@ /* - * $Id: external_acl.cc,v 1.77 2007/04/28 22:26:37 hno Exp $ + * $Id: external_acl.cc,v 1.78 2007/05/18 06:41:24 amosjeffries Exp $ * * DEBUG: section 82 External ACL * AUTHOR: Henrik Nordstrom, MARA Systems AB @@ -689,7 +689,7 @@ aclMatchExternal(external_acl_data *acl, ACLChecklist * ch) external_acl_cache_touch(acl->def, entry); result = entry->result; - external_acl_message = entry->message.buf(); + external_acl_message = entry->message.c_str(); debugs(82, 2, "aclMatchExternal: " << acl->def->name << " = " << result); @@ -759,7 +759,7 @@ makeExternalAclKey(ACLChecklist * ch, external_acl_data * acl_data) for (format = acl_data->def->format; format; format = format->next) { const char *str = NULL; - String sb; + string sb; switch (format->type) { @@ -812,7 +812,7 @@ makeExternalAclKey(ACLChecklist * ch, external_acl_data * acl_data) break; case _external_acl_format::EXT_ACL_PATH: - str = request->urlpath.buf(); + str = request->urlpath.c_str(); break; case _external_acl_format::EXT_ACL_METHOD: @@ -821,22 +821,22 @@ makeExternalAclKey(ACLChecklist * ch, external_acl_data * acl_data) case _external_acl_format::EXT_ACL_HEADER: sb = request->header.getByName(format->header); - str = sb.buf(); + str = sb.c_str(); break; case _external_acl_format::EXT_ACL_HEADER_ID: sb = request->header.getStrOrList(format->header_id); - str = sb.buf(); + str = sb.c_str(); break; case _external_acl_format::EXT_ACL_HEADER_MEMBER: sb = request->header.getByNameListMember(format->header, format->member, format->separator); - str = sb.buf(); + str = sb.c_str(); break; case _external_acl_format::EXT_ACL_HEADER_ID_MEMBER: sb = request->header.getListMember(format->header_id, format->member, format->separator); - str = sb.buf(); + str = sb.c_str(); break; #if USE_SSL @@ -886,7 +886,7 @@ makeExternalAclKey(ACLChecklist * ch, external_acl_data * acl_data) #endif case _external_acl_format::EXT_ACL_EXT_USER: - str = request->extacl_user.buf(); + str = request->extacl_user.c_str(); break; case _external_acl_format::EXT_ACL_UNKNOWN: @@ -913,7 +913,7 @@ makeExternalAclKey(ACLChecklist * ch, external_acl_data * acl_data) strwordquote(&mb, str); } - sb.clean(); + sb.clear(); first = 0; } @@ -1236,8 +1236,8 @@ ACLExternal::ExternalAclLookup(ACLChecklist * ch, ACLExternal * me, EAH * callba if (entry != NULL) { debugs(82, 4, "externalAclLookup: entry = { date=" << (long unsigned int) entry->date << ", result=" << - entry->result << ", user=" << entry->user.buf() << " tag=" << - entry->tag.buf() << " log=" << entry->log.buf() << " }"); + entry->result << ", user=" << entry->user << " tag=" << + entry->tag << " log=" << entry->log << " }"); } @@ -1270,7 +1270,7 @@ externalAclInit(void) for (p = Config.externalAclHelperList; p; p = p->next) { if (!p->cache) - p->cache = hash_create((HASHCMP *) strcmp, hashPrime(1024), hash4); + p->cache = hash_create((HASHCMP *) std::strcmp, hashPrime(1024), hash4); if (!p->theHelper) p->theHelper = helperCreate(p->name); diff --git a/src/fqdncache.cc b/src/fqdncache.cc index cdb63fa8e6..0c53c999ed 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -1,6 +1,6 @@ /* - * $Id: fqdncache.cc,v 1.171 2007/04/28 22:26:37 hno Exp $ + * $Id: fqdncache.cc,v 1.172 2007/05/18 06:41:24 amosjeffries Exp $ * * DEBUG: section 35 FQDN Cache * AUTHOR: Harvest Derived @@ -527,7 +527,7 @@ fqdncache_init(void) n = hashPrime(fqdncache_high / 4); - fqdn_table = hash_create((HASHCMP *) strcmp, n, hash4); + fqdn_table = hash_create((HASHCMP *) std::strcmp, n, hash4); memDataInit(MEM_FQDNCACHE_ENTRY, "fqdncache_entry", sizeof(fqdncache_entry), 0); diff --git a/src/fs/coss/CossSwapDir.h b/src/fs/coss/CossSwapDir.h index fdbda43fc5..9f3ca13f62 100644 --- a/src/fs/coss/CossSwapDir.h +++ b/src/fs/coss/CossSwapDir.h @@ -36,7 +36,7 @@ public: virtual void create(); virtual void dump(StoreEntry &)const; ~CossSwapDir(); - virtual StoreSearch *search(String const url, HttpRequest *); + virtual StoreSearch *search(string const url, HttpRequest *); virtual void unlink (StoreEntry &); virtual void statfs (StoreEntry &)const; virtual int canStore(StoreEntry const &)const; diff --git a/src/fs/coss/store_dir_coss.cc b/src/fs/coss/store_dir_coss.cc index ef64bbfd64..ba3cf361aa 100644 --- a/src/fs/coss/store_dir_coss.cc +++ b/src/fs/coss/store_dir_coss.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_coss.cc,v 1.73 2007/04/30 16:56:16 wessels Exp $ + * $Id: store_dir_coss.cc,v 1.74 2007/05/18 06:41:32 amosjeffries Exp $ * vim: set et : * * DEBUG: section 47 Store COSS Directory Routines @@ -1170,7 +1170,7 @@ CossSwapDir::optionBlockSizeDump(StoreEntry * e) const } StoreSearch * -CossSwapDir::search(String const url, HttpRequest *) +CossSwapDir::search(string const url, HttpRequest *) { if (url.size()) fatal ("Cannot search by url yet\n"); @@ -1182,9 +1182,9 @@ char const * CossSwapDir::stripePath() const { if (!stripe_path) { - String result = path; + string result = path; result.append("/stripe"); - const_cast(this)->stripe_path = xstrdup(result.buf()); + const_cast(this)->stripe_path = xstrdup(result.c_str()); } return stripe_path; diff --git a/src/fs/null/store_null.cc b/src/fs/null/store_null.cc index dc088cfd12..d02f07a144 100644 --- a/src/fs/null/store_null.cc +++ b/src/fs/null/store_null.cc @@ -1,6 +1,6 @@ /* - * $Id: store_null.cc,v 1.12 2006/10/08 13:34:09 serassio Exp $ + * $Id: store_null.cc,v 1.13 2007/05/18 06:41:32 amosjeffries Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -103,7 +103,7 @@ NullSwapDir::parse(int anIndex, char *aPath) } StoreSearch * -NullSwapDir::search(String const url, HttpRequest *) +NullSwapDir::search(string const url, HttpRequest *) { if (url.size()) fatal ("Cannot search by url yet\n"); diff --git a/src/fs/null/store_null.h b/src/fs/null/store_null.h index 445b578a6c..1f289df053 100644 --- a/src/fs/null/store_null.h +++ b/src/fs/null/store_null.h @@ -1,6 +1,6 @@ /* - * $Id: store_null.h,v 1.3 2006/05/23 00:48:13 wessels Exp $ + * $Id: store_null.h,v 1.4 2007/05/18 06:41:33 amosjeffries Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -49,7 +49,7 @@ public: virtual StoreIOState::Pointer openStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *); virtual void parse(int, char*); virtual void reconfigure (int, char *); - virtual StoreSearch *search(String const url, HttpRequest *); + virtual StoreSearch *search(string const url, HttpRequest *); }; class StoreSearchNull : public StoreSearch diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index f0738b9d64..6403e51de4 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_ufs.cc,v 1.82 2007/04/30 16:56:17 wessels Exp $ + * $Id: store_dir_ufs.cc,v 1.83 2007/05/18 06:41:33 amosjeffries Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -1348,7 +1348,7 @@ UFSSwapDir::sync() } StoreSearch * -UFSSwapDir::search(String const url, HttpRequest *request) +UFSSwapDir::search(string const url, HttpRequest *request) { if (url.size()) fatal ("Cannot search by url yet\n"); diff --git a/src/fs/ufs/ufscommon.h b/src/fs/ufs/ufscommon.h index 2d84685f04..2cc2ff9a3d 100644 --- a/src/fs/ufs/ufscommon.h +++ b/src/fs/ufs/ufscommon.h @@ -1,6 +1,6 @@ /* - * $Id: ufscommon.h,v 1.9 2006/09/14 00:51:12 robertc Exp $ + * $Id: ufscommon.h,v 1.10 2007/05/18 06:41:33 amosjeffries Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -63,7 +63,7 @@ public: virtual void create(); virtual void dump(StoreEntry &) const; ~UFSSwapDir(); - virtual StoreSearch *search(String const url, HttpRequest *); + virtual StoreSearch *search(string const url, HttpRequest *); virtual bool doubleCheck(StoreEntry &); virtual void unlink(StoreEntry &); virtual void statfs(StoreEntry &)const; diff --git a/src/ftp.cc b/src/ftp.cc index 0da5bbcbd3..6fb39843d9 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $Id: ftp.cc,v 1.422 2007/05/07 21:32:00 wessels Exp $ + * $Id: ftp.cc,v 1.423 2007/05/18 06:41:24 amosjeffries Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -126,9 +126,9 @@ public: int password_url; char *reply_hdr; int reply_hdr_state; - String clean_url; - String title_url; - String base_href; + string clean_url; + string title_url; + string base_href; int conn_att; int login_att; ftp_state_t state; @@ -441,9 +441,9 @@ FtpStateData::~FtpStateData() safe_free(old_filepath); - title_url.clean(); + title_url.clear(); - base_href.clean(); + base_href.clear(); safe_free(filepath); @@ -507,7 +507,7 @@ FtpStateData::listingStart() wordlist *w; char *dirup; int i, j, k; - const char *title = title_url.buf(); + const char *title = title_url.c_str(); flags.listing_started = true; printfReplyBody("\n"); printfReplyBody("\n", @@ -526,7 +526,7 @@ FtpStateData::listingStart() if (flags.need_base_href) printfReplyBody("\n", - html_quote(base_href.buf())); + html_quote(base_href.c_str())); printfReplyBody("\n"); @@ -955,7 +955,7 @@ FtpStateData::htmlifyListEntry(const char *line) if (flags.dir_slash) { url = xstrdup("./"); } else { - const char *title = title_url.buf(); + const char *title = title_url.c_str(); int k = 6 + strcspn(&title[6], "/"); char *t; url = xstrdup(title + k); @@ -1436,11 +1436,11 @@ FtpStateData::checkUrlpath() flags.isdir = 1; flags.root_dir = 1; flags.need_base_href = 1; /* Work around broken browsers */ - } else if (!request->urlpath.cmp("/%2f/")) { + } else if (!request->urlpath.compare("/%2f/")) { /* UNIX root directory */ flags.isdir = 1; flags.root_dir = 1; - } else if ((l >= 1) && (*(request->urlpath.buf() + l - 1) == '/')) { + } else if ((l >= 1) && (*(request->urlpath.c_str() + l - 1) == '/')) { /* Directory URL, ending in / */ flags.isdir = 1; @@ -1528,7 +1528,7 @@ FtpStateData::start() checkUrlpath(); buildTitleUrl(); debugs(9, 5, "ftpStart: host=" << request->host << ", path=" << - request->urlpath.buf() << ", user=" << user << ", passwd=" << + request->urlpath << ", user=" << user << ", passwd=" << password); state = BEGIN; @@ -1953,7 +1953,7 @@ ftpSendType(FtpStateData * ftpState) mode = 'A'; } else { t = ftpState->request->urlpath.rpos('/'); - filename = t ? t + 1 : ftpState->request->urlpath.buf(); + filename = t ? t + 1 : ftpState->request->urlpath.c_str(); mode = mimeGetTransferMode(filename); } @@ -1981,7 +1981,7 @@ ftpReadType(FtpStateData * ftpState) debugs(9, 3, "This is ftpReadType"); if (code == 200) { - p = path = xstrdup(ftpState->request->urlpath.buf()); + p = path = xstrdup(ftpState->request->urlpath.c_str()); if (*p == '/') p++; @@ -2202,7 +2202,7 @@ ftpReadSize(FtpStateData * ftpState) if (ftpState->size == 0) { debugs(9, 2, "ftpReadSize: SIZE reported " << ftpState->ctrl.last_reply << " on " << - ftpState->title_url.buf()); + ftpState->title_url); ftpState->size = -1; } @@ -2908,7 +2908,7 @@ ftpTrySlashHack(FtpStateData * ftpState) safe_free(ftpState->filepath); /* Build the new path (urlpath begins with /) */ - path = xstrdup(ftpState->request->urlpath.buf()); + path = xstrdup(ftpState->request->urlpath.c_str()); rfc1738_unescape(path); @@ -2959,7 +2959,7 @@ ftpFail(FtpStateData *ftpState) if (!ftpState->flags.isdir && /* Not a directory */ !ftpState->flags.try_slash_hack && /* Not in slash hack */ ftpState->mdtm <= 0 && ftpState->size < 0 && /* Not known as a file */ - ftpState->request->urlpath.caseCmp("/%2f", 4) != 0) { /* No slash encoded */ + strncasecmp(ftpState->request->urlpath, "/%2f", 4) != 0) { /* No slash encoded */ switch (ftpState->state) { @@ -3118,7 +3118,7 @@ FtpStateData::appendSuccessHeader() { const char *mime_type = NULL; const char *mime_enc = NULL; - String urlpath = request->urlpath; + string urlpath = request->urlpath; const char *filename = NULL; const char *t = NULL; StoreEntry *e = entry; @@ -3139,7 +3139,7 @@ FtpStateData::appendSuccessHeader() e->buffer(); /* released when done processing current data payload */ - filename = (t = urlpath.rpos('/')) ? t + 1 : urlpath.buf(); + filename = (t = urlpath.rpos('/')) ? t + 1 : urlpath.c_str(); if (flags.isdir) { mime_type = "text/html"; @@ -3272,7 +3272,7 @@ ftpUrlWith2f(const HttpRequest * request) request->host, portbuf, "/%2f", - request->urlpath.buf()); + request->urlpath.c_str()); if ((t = strchr(buf, '?'))) *t = '\0'; diff --git a/src/gopher.cc b/src/gopher.cc index 8fc99f290f..016513b3b6 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -1,6 +1,6 @@ /* - * $Id: gopher.cc,v 1.204 2007/04/30 16:56:09 wessels Exp $ + * $Id: gopher.cc,v 1.205 2007/05/18 06:41:24 amosjeffries Exp $ * * DEBUG: section 10 Gopher * AUTHOR: Harvest Derived @@ -230,7 +230,7 @@ gopherMimeCreate(GopherStateData * gopherState) static void gopher_request_parse(const HttpRequest * req, char *type_id, char *request) { - const char *path = req->urlpath.buf(); + const char *path = req->urlpath.c_str(); if (request) request[0] = '\0'; @@ -377,7 +377,7 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len) } inbuf[len] = '\0'; - String outbuf; + string outbuf; if (!gopherState->HTML_header_added) { if (gopherState->conversion == gopher_ds::HTML_CSO_RESULT) @@ -691,12 +691,12 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len) } /* while loop */ if (outbuf.size() > 0) { - entry->append(outbuf.buf(), outbuf.size()); + entry->append(outbuf.c_str(), outbuf.size()); /* now let start sending stuff to client */ entry->flush(); } - outbuf.clean(); + outbuf.clear(); return; } diff --git a/src/http.cc b/src/http.cc index 1924e5bbe0..4bc7eec5d3 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.521 2007/05/08 16:37:59 rousskov Exp $ + * $Id: http.cc,v 1.522 2007/05/18 06:41:24 amosjeffries Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -68,7 +68,7 @@ static const char *const crlf = "\r\n"; static PF httpStateFree; static PF httpTimeout; static void httpMaybeRemovePublic(StoreEntry *, http_status); -static void copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, String strConnection, HttpRequest * request, HttpRequest * orig_request, +static void copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, string strConnection, HttpRequest * request, HttpRequest * orig_request, HttpHeader * hdr_out, int we_do_ranges, http_state_flags); #if ICAP_CLIENT static void icapAclCheckDoneWrapper(ICAPServiceRep::Pointer service, void *data); @@ -92,7 +92,7 @@ HttpStateData::HttpStateData(FwdState *theFwdState) : ServerStateData(theFwdStat const char *url; if (_peer->options.originserver) - url = orig_request->urlpath.buf(); + url = orig_request->urlpath.c_str(); else url = entry->url(); @@ -430,9 +430,9 @@ HttpStateData::cacheableReply() /* Pragma: no-cache in _replies_ is not documented in HTTP, * but servers like "Active Imaging Webcast/2.0" sure do use it */ if (hdr->has(HDR_PRAGMA)) { - String s = hdr->getList(HDR_PRAGMA); + string s = hdr->getList(HDR_PRAGMA); const int no_cache = strListIsMember(&s, "no-cache", ','); - s.clean(); + s.clear(); if (no_cache) { if (!REFRESH_OVERRIDE(ignore_no_cache)) @@ -584,14 +584,14 @@ HttpStateData::cacheableReply() const char * httpMakeVaryMark(HttpRequest * request, HttpReply const * reply) { - String vary, hdr; + string vary, hdr; const char *pos = NULL; const char *item; const char *value; int ilen; - static String vstr; + static string vstr; - vstr.clean(); + vstr.clear(); vary = reply->header.getList(HDR_VARY); while (strListGetItem(&vary, ',', &item, &ilen, &pos)) { @@ -602,14 +602,14 @@ httpMakeVaryMark(HttpRequest * request, HttpReply const * reply) if (strcmp(name, "*") == 0) { /* Can not handle "Vary: *" withtout ETag support */ safe_free(name); - vstr.clean(); + vstr.clear(); break; } strListAdd(&vstr, name, ','); hdr = request->header.getByName(name); safe_free(name); - value = hdr.buf(); + value = hdr.c_str(); if (value) { value = rfc1738_escape_part(value); @@ -618,10 +618,10 @@ httpMakeVaryMark(HttpRequest * request, HttpReply const * reply) vstr.append("\"", 1); } - hdr.clean(); + hdr.clear(); } - vary.clean(); + vary.clear(); #if X_ACCELERATOR_VARY pos = NULL; @@ -634,7 +634,7 @@ httpMakeVaryMark(HttpRequest * request, HttpReply const * reply) strListAdd(&vstr, name, ','); hdr = request->header.getByName(name); safe_free(name); - value = hdr.buf(); + value = hdr.c_str(); if (value) { value = rfc1738_escape_part(value); @@ -643,14 +643,14 @@ httpMakeVaryMark(HttpRequest * request, HttpReply const * reply) vstr.append("\"", 1); } - hdr.clean(); + hdr.clear(); } - vary.clean(); + vary.clear(); #endif - debugs(11, 3, "httpMakeVaryMark: " << vstr.buf()); - return vstr.buf(); + debugs(11, 3, "httpMakeVaryMark: " << vstr); + return vstr.c_str(); } void @@ -1361,7 +1361,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request, LOCAL_ARRAY(char, bbuf, BBUF_SZ); const HttpHeader *hdr_in = &orig_request->header; const HttpHeaderEntry *e; - String strFwd; + string strFwd; HttpHeaderPos pos = HttpHeaderInitPos; assert (hdr_out->owner == hoRequest); /* append our IMS header */ @@ -1371,7 +1371,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request, bool we_do_ranges = decideIfWeDoRanges (orig_request); - String strConnection (hdr_in->getList(HDR_CONNECTION)); + string strConnection (hdr_in->getList(HDR_CONNECTION)); while ((e = hdr_in->getEntry(&pos))) copyOneHeaderFromClientsideRequestToUpstreamRequest(e, strConnection, request, orig_request, hdr_out, we_do_ranges, flags); @@ -1390,24 +1390,24 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request, /* append Via */ if (Config.onoff.via) { - String strVia; + string strVia; strVia = hdr_in->getList(HDR_VIA); snprintf(bbuf, BBUF_SZ, "%d.%d %s", orig_request->http_ver.major, orig_request->http_ver.minor, ThisCache); strListAdd(&strVia, bbuf, ','); - hdr_out->putStr(HDR_VIA, strVia.buf()); - strVia.clean(); + hdr_out->putStr(HDR_VIA, strVia.c_str()); + strVia.clear(); } #if ESI { /* Append Surrogate-Capabilities */ - String strSurrogate (hdr_in->getList(HDR_SURROGATE_CAPABILITY)); + string strSurrogate (hdr_in->getList(HDR_SURROGATE_CAPABILITY)); snprintf(bbuf, BBUF_SZ, "%s=\"Surrogate/1.0 ESI/1.0\"", Config.Accel.surrogate_id); strListAdd(&strSurrogate, bbuf, ','); - hdr_out->putStr(HDR_SURROGATE_CAPABILITY, strSurrogate.buf()); + hdr_out->putStr(HDR_SURROGATE_CAPABILITY, strSurrogate.c_str()); } #endif @@ -1419,9 +1419,9 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request, else strListAdd(&strFwd, "unknown", ','); - hdr_out->putStr(HDR_X_FORWARDED_FOR, strFwd.buf()); + hdr_out->putStr(HDR_X_FORWARDED_FOR, strFwd.c_str()); - strFwd.clean(); + strFwd.clear(); /* append Host if not there already */ if (!hdr_out->has(HDR_HOST)) { @@ -1455,7 +1455,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request, if (orig_request->auth_user_request) username = orig_request->auth_user_request->username(); else if (orig_request->extacl_user.size()) - username = orig_request->extacl_user.buf(); + username = orig_request->extacl_user.c_str(); snprintf(loginbuf, sizeof(loginbuf), "%s%s", username, orig_request->peer_login + 1); @@ -1464,7 +1464,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request, } else if (strcmp(orig_request->peer_login, "PASS") == 0) { if (orig_request->extacl_user.size() && orig_request->extacl_passwd.size()) { char loginbuf[256]; - snprintf(loginbuf, sizeof(loginbuf), "%s:%s", orig_request->extacl_user.buf(), orig_request->extacl_passwd.buf()); + snprintf(loginbuf, sizeof(loginbuf), "%s:%s", orig_request->extacl_user.c_str(), orig_request->extacl_passwd.c_str()); httpHeaderPutStrf(hdr_out, HDR_PROXY_AUTHORIZATION, "Basic %s", base64_encode(loginbuf)); } @@ -1491,7 +1491,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request, hdr_out->putStr(HDR_AUTHORIZATION, auth); } else if (orig_request->extacl_user.size() && orig_request->extacl_passwd.size()) { char loginbuf[256]; - snprintf(loginbuf, sizeof(loginbuf), "%s:%s", orig_request->extacl_user.buf(), orig_request->extacl_passwd.buf()); + snprintf(loginbuf, sizeof(loginbuf), "%s:%s", orig_request->extacl_user.c_str(), orig_request->extacl_passwd.c_str()); httpHeaderPutStrf(hdr_out, HDR_AUTHORIZATION, "Basic %s", base64_encode(loginbuf)); } @@ -1503,7 +1503,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request, if (orig_request->auth_user_request) username = orig_request->auth_user_request->username(); else if (orig_request->extacl_user.size()) - username = orig_request->extacl_user.buf(); + username = orig_request->extacl_user.c_str(); snprintf(loginbuf, sizeof(loginbuf), "%s%s", username, orig_request->peer_login + 1); @@ -1528,7 +1528,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request, httpHdrCcSetMaxAge(cc, getMaxAge(url)); if (request->urlpath.size()) - assert(strstr(url, request->urlpath.buf())); + assert(strstr(url, request->urlpath.c_str())); } /* Set no-cache if determined needed but not found */ @@ -1563,16 +1563,16 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request, if (Config2.onoff.mangle_request_headers) httpHdrMangleList(hdr_out, request, ROR_REQUEST); - strConnection.clean(); + strConnection.clear(); } void -copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, String strConnection, HttpRequest * request, HttpRequest * orig_request, HttpHeader * hdr_out, int we_do_ranges, http_state_flags flags) +copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, string strConnection, HttpRequest * request, HttpRequest * orig_request, HttpHeader * hdr_out, int we_do_ranges, http_state_flags flags) { - debugs(11, 5, "httpBuildRequestHeader: " << e->name.buf() << ": " << e->value.buf()); + debugs(11, 5, "httpBuildRequestHeader: " << e->name << ": " << e->value); if (!httpRequestHdrAllowed(e, &strConnection)) { - debugs(11, 2, "'" << e->name.buf() << "' header denied by anonymize_headers configuration"); + debugs(11, 2, "'" << e->name << "' header denied by anonymize_headers configuration"); return; } @@ -1731,7 +1731,7 @@ HttpStateData::buildRequestPrefix(HttpRequest * request, HttpVersion httpver(1, 0); mb->Printf("%s %s HTTP/%d.%d\r\n", RequestMethodStr[request->method], - request->urlpath.size() ? request->urlpath.buf() : "/", + request->urlpath.size() ? request->urlpath.c_str() : "/", httpver.major,httpver.minor); /* build and pack headers */ { diff --git a/src/ident.cc b/src/ident.cc index 178d875312..0f9e3ef6b7 100644 --- a/src/ident.cc +++ b/src/ident.cc @@ -1,6 +1,6 @@ /* - * $Id: ident.cc,v 1.75 2007/04/28 22:26:37 hno Exp $ + * $Id: ident.cc,v 1.76 2007/05/18 06:41:24 amosjeffries Exp $ * * DEBUG: section 30 Ident (RFC 931) * AUTHOR: Duane Wessels @@ -270,7 +270,7 @@ identStart(struct sockaddr_in *me, struct sockaddr_in *my_peer, IDCB * callback, void identInit(void) { - ident_hash = hash_create((HASHCMP *) strcmp, + ident_hash = hash_create((HASHCMP *) std::strcmp, hashPrime(Squid_MaxFD / 8), hash4); } diff --git a/src/internal.cc b/src/internal.cc index 37aa418a4b..de729e90ea 100644 --- a/src/internal.cc +++ b/src/internal.cc @@ -1,6 +1,6 @@ /* - * $Id: internal.cc,v 1.45 2007/04/28 22:26:37 hno Exp $ + * $Id: internal.cc,v 1.46 2007/05/18 06:41:24 amosjeffries Exp $ * * DEBUG: section 76 Internal Squid Object handling * AUTHOR: Duane, Alex, Henrik @@ -50,7 +50,7 @@ void internalStart(HttpRequest * request, StoreEntry * entry) { ErrorState *err; - const char *upath = request->urlpath.buf(); + const char *upath = request->urlpath.c_str(); debugs(76, 3, "internalStart: " << inet_ntoa(request->client_addr) << " requesting '" << upath << "'"); if (0 == strcmp(upath, "/squid-internal-dynamic/netdb")) { diff --git a/src/ipcache.cc b/src/ipcache.cc index d9ef0c6239..c799bfab0f 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1,6 +1,6 @@ /* - * $Id: ipcache.cc,v 1.259 2007/04/28 22:26:37 hno Exp $ + * $Id: ipcache.cc,v 1.260 2007/05/18 06:41:24 amosjeffries Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -586,7 +586,7 @@ ipcache_init(void) ipcache_low = (long) (((float) Config.ipcache.size * (float) Config.ipcache.low) / (float) 100); n = hashPrime(ipcache_high / 4); - ip_table = hash_create((HASHCMP *) strcmp, n, hash4); + ip_table = hash_create((HASHCMP *) std::strcmp, n, hash4); memDataInit(MEM_IPCACHE_ENTRY, "ipcache_entry", sizeof(ipcache_entry), 0); } diff --git a/src/net_db.cc b/src/net_db.cc index 2ad478ebd7..0a5b26a1f4 100644 --- a/src/net_db.cc +++ b/src/net_db.cc @@ -1,6 +1,6 @@ /* - * $Id: net_db.cc,v 1.194 2007/04/30 16:56:09 wessels Exp $ + * $Id: net_db.cc,v 1.195 2007/05/18 06:41:25 amosjeffries Exp $ * * DEBUG: section 38 Network Measurement Database * AUTHOR: Duane Wessels @@ -892,11 +892,11 @@ netdbInit(void) n = hashPrime(Config.Netdb.high / 4); - addr_table = hash_create((HASHCMP *) strcmp, n, hash_string); + addr_table = hash_create((HASHCMP *) std::strcmp, n, hash_string); n = hashPrime(3 * Config.Netdb.high / 4); - host_table = hash_create((HASHCMP *) strcmp, n, hash_string); + host_table = hash_create((HASHCMP *) std::strcmp, n, hash_string); eventAddIsh("netdbSaveState", netdbSaveState, NULL, 3600.0, 1); diff --git a/src/pconn.cc b/src/pconn.cc index ac4ae03cae..5a1dbcad2a 100644 --- a/src/pconn.cc +++ b/src/pconn.cc @@ -1,6 +1,6 @@ /* - * $Id: pconn.cc,v 1.51 2007/05/11 13:20:57 rousskov Exp $ + * $Id: pconn.cc,v 1.52 2007/05/18 06:41:25 amosjeffries Exp $ * * DEBUG: section 48 Persistent Connections * AUTHOR: Duane Wessels @@ -217,7 +217,7 @@ PconnPool::dumpHist(StoreEntry * e) PconnPool::PconnPool(const char *aDescr) : table(NULL), descr(aDescr) { int i; - table = hash_create((HASHCMP *) strcmp, 229, hash_string); + table = hash_create((HASHCMP *) std::strcmp, 229, hash_string); for (i = 0; i < PCONN_HIST_SZ; i++) hist[i] = 0; diff --git a/src/peer_digest.cc b/src/peer_digest.cc index 6bf642686d..bc06bb5492 100644 --- a/src/peer_digest.cc +++ b/src/peer_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: peer_digest.cc,v 1.123 2007/04/30 16:56:09 wessels Exp $ + * $Id: peer_digest.cc,v 1.124 2007/05/18 06:41:25 amosjeffries Exp $ * * DEBUG: section 72 Peer Digest Routines * AUTHOR: Alex Rousskov @@ -112,7 +112,7 @@ peerDigestClean(PeerDigest * pd) if (pd->cd) cacheDigestDestroy(pd->cd); - pd->host.clean(); + pd->host.clear(); } CBDATA_CLASS_INIT(PeerDigest); @@ -231,7 +231,7 @@ peerDigestSetCheck(PeerDigest * pd, time_t delay) { eventAdd("peerDigestCheck", peerDigestCheck, pd, (double) delay, 1); pd->times.next_check = squid_curtime + delay; - debugs(72, 3, "peerDigestSetCheck: will check peer " << pd->host.buf() << " in " << delay << " secs"); + debugs(72, 3, "peerDigestSetCheck: will check peer " << pd->host << " in " << delay << " secs"); } /* @@ -241,10 +241,10 @@ void peerDigestNotePeerGone(PeerDigest * pd) { if (pd->flags.requested) { - debugs(72, 2, "peerDigest: peer " << pd->host.buf() << " gone, will destroy after fetch."); + debugs(72, 2, "peerDigest: peer " << pd->host << " gone, will destroy after fetch."); /* do nothing now, the fetching chain will notice and take action */ } else { - debugs(72, 2, "peerDigest: peer " << pd->host.buf() << " is gone, destroying now."); + debugs(72, 2, "peerDigest: peer " << pd->host << " is gone, destroying now."); peerDigestDestroy(pd); } } @@ -279,7 +279,7 @@ peerDigestCheck(void *data) /* per-peer limit */ if (req_time - pd->times.received < PeerDigestReqMinGap) { - debugs(72, 2, "peerDigestCheck: " << pd->host.buf() << + debugs(72, 2, "peerDigestCheck: " << pd->host << ", avoiding close peer requests (" << (int) (req_time - pd->times.received) << " < " << (int) PeerDigestReqMinGap << " secs)."); @@ -289,7 +289,7 @@ peerDigestCheck(void *data) /* global limit */ if (req_time - pd_last_req_time < GlobDigestReqMinGap) { - debugs(72, 2, "peerDigestCheck: " << pd->host.buf() << + debugs(72, 2, "peerDigestCheck: " << pd->host << ", avoiding close requests (" << (int) (req_time - pd_last_req_time) << " < " << (int) GlobDigestReqMinGap << " secs)."); @@ -546,7 +546,7 @@ peerDigestFetchReply(void *data, char *buf, ssize_t size) assert(reply); assert (reply->sline.status != 0); status = reply->sline.status; - debugs(72, 3, "peerDigestFetchReply: " << pd->host.buf() << " status: " << status << + debugs(72, 3, "peerDigestFetchReply: " << pd->host << " status: " << status << ", expires: " << (long int) reply->expires << " (" << std::showpos << (int) (reply->expires - squid_curtime) << ")"); @@ -636,7 +636,7 @@ peerDigestSwapInHeaders(void *data, char *buf, ssize_t size) assert (fetch->entry->getReply()->sline.status != 0); if (fetch->entry->getReply()->sline.status != HTTP_OK) { - debugs(72, 1, "peerDigestSwapInHeaders: " << fetch->pd->host.buf() << + debugs(72, 1, "peerDigestSwapInHeaders: " << fetch->pd->host << " status " << fetch->entry->getReply()->sline.status << " got cached!"); @@ -764,7 +764,7 @@ peerDigestFetchedEnough(DigestFetchState * fetch, char *buf, ssize_t size, const #endif else - host = pd->host.buf(); + host = pd->host.c_str(); } debugs(72, 6, step_name << ": peer " << host << ", offset: " << @@ -815,7 +815,7 @@ static void peerDigestFetchStop(DigestFetchState * fetch, char *buf, const char *reason) { assert(reason); - debugs(72, 2, "peerDigestFetchStop: peer " << fetch->pd->host.buf() << ", reason: " << reason); + debugs(72, 2, "peerDigestFetchStop: peer " << fetch->pd->host << ", reason: " << reason); peerDigestReqFinish(fetch, buf, 1, 1, 1, reason, 0); } @@ -824,7 +824,7 @@ static void peerDigestFetchAbort(DigestFetchState * fetch, char *buf, const char *reason) { assert(reason); - debugs(72, 2, "peerDigestFetchAbort: peer " << fetch->pd->host.buf() << ", reason: " << reason); + debugs(72, 2, "peerDigestFetchAbort: peer " << fetch->pd->host << ", reason: " << reason); peerDigestReqFinish(fetch, buf, 1, 1, 1, reason, 1); } @@ -874,7 +874,7 @@ static void peerDigestPDFinish(DigestFetchState * fetch, int pcb_valid, int err) { PeerDigest *pd = fetch->pd; - const char *host = pd->host.buf(); + const char *host = pd->host.c_str(); pd->times.received = squid_curtime; pd->times.req_delay = fetch->resp_time; @@ -988,7 +988,7 @@ peerDigestSetCBlock(PeerDigest * pd, const char *buf) { StoreDigestCBlock cblock; int freed_size = 0; - const char *host = pd->host.buf(); + const char *host = pd->host.c_str(); xmemcpy(&cblock, buf, sizeof(cblock)); /* network -> host conversions */ @@ -1082,7 +1082,7 @@ peerDigestUseful(const PeerDigest * pd) const int bit_util = cacheDigestBitUtil(pd->cd); if (bit_util > 65) { - debugs(72, 0, "Warning: " << pd->host.buf() << + debugs(72, 0, "Warning: " << pd->host << " peer digest has too many bits on (" << bit_util << "%%)."); return 0; @@ -1108,7 +1108,7 @@ peerDigestStatsReport(const PeerDigest * pd, StoreEntry * e) assert(pd); - const char *host = pd->host.buf(); + const char *host = pd->host.c_str(); storeAppendPrintf(e, "\npeer digest from %s\n", host); cacheDigestGuessStatsReport(&pd->stats.guess, e, host); diff --git a/src/protos.h b/src/protos.h index fb240b6196..66816a5470 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.542 2007/04/20 23:53:41 wessels Exp $ + * $Id: protos.h,v 1.543 2007/05/18 06:41:25 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -222,7 +222,7 @@ SQUIDCEXTERN void httpBodyPackInto(const HttpBody * body, Packer * p); SQUIDCEXTERN void httpHdrCcInitModule(void); SQUIDCEXTERN void httpHdrCcCleanModule(void); SQUIDCEXTERN HttpHdrCc *httpHdrCcCreate(void); -SQUIDCEXTERN HttpHdrCc *httpHdrCcParseCreate(const String * str); +SQUIDCEXTERN HttpHdrCc *httpHdrCcParseCreate(const string * str); SQUIDCEXTERN void httpHdrCcDestroy(HttpHdrCc * cc); SQUIDCEXTERN HttpHdrCc *httpHdrCcDup(const HttpHdrCc * cc); SQUIDCEXTERN void httpHdrCcPackInto(const HttpHdrCc * cc, Packer * p); @@ -234,14 +234,14 @@ SQUIDCEXTERN void httpHdrCcStatDumper(StoreEntry * sentry, int idx, double val, /* Http Header Tools */ SQUIDCEXTERN HttpHeaderFieldInfo *httpHeaderBuildFieldsInfo(const HttpHeaderFieldAttrs * attrs, int count); SQUIDCEXTERN void httpHeaderDestroyFieldsInfo(HttpHeaderFieldInfo * info, int count); -SQUIDCEXTERN http_hdr_type httpHeaderIdByName(const char *name, int name_len, const HttpHeaderFieldInfo * attrs, int end); +SQUIDCEXTERN http_hdr_type httpHeaderIdByName(const char *name, unsigned int name_len, const HttpHeaderFieldInfo * attrs, int end); SQUIDCEXTERN http_hdr_type httpHeaderIdByNameDef(const char *name, int name_len); SQUIDCEXTERN const char *httpHeaderNameById(int id); SQUIDCEXTERN int httpHeaderHasConnDir(const HttpHeader * hdr, const char *directive); -SQUIDCEXTERN void strListAdd(String * str, const char *item, char del); -SQUIDCEXTERN int strListIsMember(const String * str, const char *item, char del); -SQUIDCEXTERN int strListIsSubstr(const String * list, const char *s, char del); -SQUIDCEXTERN int strListGetItem(const String * str, char del, const char **item, int *ilen, const char **pos); +SQUIDCEXTERN void strListAdd(string * str, const char *item, char del); +SQUIDCEXTERN int strListIsMember(const string * str, const char *item, char del); +SQUIDCEXTERN int strListIsSubstr(const string * list, const char *s, char del); +SQUIDCEXTERN int strListGetItem(const string * str, char del, const char **item, int *ilen, const char **pos); SQUIDCEXTERN const char *getStringPrefix(const char *str, const char *end); SQUIDCEXTERN int httpHeaderParseInt(const char *start, int *val); SQUIDCEXTERN int httpHeaderParseSize(const char *start, ssize_t * sz); diff --git a/src/redirect.cc b/src/redirect.cc index 7cbf66314b..d44611523d 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -1,6 +1,6 @@ /* - * $Id: redirect.cc,v 1.118 2007/05/07 18:38:40 wessels Exp $ + * $Id: redirect.cc,v 1.119 2007/05/18 06:41:25 amosjeffries Exp $ * * DEBUG: section 61 Redirector * AUTHOR: Duane Wessels @@ -135,8 +135,8 @@ redirectStart(ClientHttpRequest * http, RH * handler, void *data) if (http->request->auth_user_request) r->client_ident = http->request->auth_user_request->username(); - else if (http->request->extacl_user.buf() != NULL) { - r->client_ident = http->request->extacl_user.buf(); + else if (!http->request->extacl_user.empty()) { + r->client_ident = http->request->extacl_user.c_str(); } if (!r->client_ident && (conn != NULL && conn->rfc931[0])) diff --git a/src/stat.cc b/src/stat.cc index 06bb8c9764..2d64dde2b2 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,5 +1,5 @@ /* - * $Id: stat.cc,v 1.405 2007/04/28 22:26:37 hno Exp $ + * $Id: stat.cc,v 1.406 2007/05/18 06:41:25 amosjeffries Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -1692,8 +1692,8 @@ statClientRequests(StoreEntry * s) if (http->request->auth_user_request) p = http->request->auth_user_request->username(); - else if (http->request->extacl_user.buf() != NULL) { - p = http->request->extacl_user.buf(); + else if (!http->request->extacl_user.empty()) { + p = http->request->extacl_user.c_str(); } if (!p && (conn != NULL && conn->rfc931[0])) diff --git a/src/store.cc b/src/store.cc index b5f3898b3c..dd067d547d 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.613 2007/05/10 22:40:12 hno Exp $ + * $Id: store.cc,v 1.614 2007/05/18 06:41:25 amosjeffries Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -685,7 +685,7 @@ StoreEntry::setPublicKey() if (mem_obj->vary_headers && !storeGetPublic(mem_obj->url, mem_obj->method)) { /* Create "vary" base object */ - String vary; + string vary; StoreEntry *pe = storeCreateEntry(mem_obj->url, mem_obj->log_url, request->flags, request->method); HttpVersion version(1, 0); /* We are allowed to do this typecast */ @@ -693,19 +693,19 @@ StoreEntry::setPublicKey() rep->setHeaders(version, HTTP_OK, "Internal marker object", "x-squid-internal/vary", -1, -1, squid_curtime + 100000); vary = mem_obj->getReply()->header.getList(HDR_VARY); - if (vary.size()) { + if (!vary.empty()) { /* Again, we own this structure layout */ - rep->header.putStr(HDR_VARY, vary.buf()); - vary.clean(); + rep->header.putStr(HDR_VARY, vary.c_str()); + vary.clear(); } #if X_ACCELERATOR_VARY vary = mem_obj->getReply()->header.getList(HDR_X_ACCELERATOR_VARY); - if (vary.buf()) { + if (!vary.empty()) { /* Again, we own this structure layout */ - rep->header.putStr(HDR_X_ACCELERATOR_VARY, vary.buf()); - vary.clean(); + rep->header.putStr(HDR_X_ACCELERATOR_VARY, vary.c_str()); + vary.clear(); } #endif diff --git a/src/store_dir.cc b/src/store_dir.cc index 83359b3680..f6635cccfe 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir.cc,v 1.159 2007/04/28 22:26:38 hno Exp $ + * $Id: store_dir.cc,v 1.160 2007/05/18 06:41:25 amosjeffries Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -502,7 +502,7 @@ storeDirWriteCleanLogs(int reopen) } StoreSearch * -StoreController::search(String const url, HttpRequest *request) +StoreController::search(string const url, HttpRequest *request) { /* cheat, for now you can't search the memory hot cache */ return swapDir->search(url, request); @@ -700,7 +700,7 @@ StoreController::get void StoreController::get - (String const key, STOREGETCLIENT callback, void *cbdata) + (string const key, STOREGETCLIENT callback, void *cbdata) { fatal("not implemented"); } @@ -775,7 +775,7 @@ StoreHashIndex::get void StoreHashIndex::get - (String const key, STOREGETCLIENT callback, void *cbdata) + (string const key, STOREGETCLIENT callback, void *cbdata) { fatal("not implemented"); } @@ -891,7 +891,7 @@ StoreHashIndex::sync() } StoreSearch * -StoreHashIndex::search(String const url, HttpRequest *) +StoreHashIndex::search(string const url, HttpRequest *) { if (url.size()) fatal ("Cannot search by url yet\n"); diff --git a/src/store_log.cc b/src/store_log.cc index 6e57e95e9f..79480c5444 100644 --- a/src/store_log.cc +++ b/src/store_log.cc @@ -1,6 +1,6 @@ /* - * $Id: store_log.cc,v 1.32 2007/04/28 22:26:38 hno Exp $ + * $Id: store_log.cc,v 1.33 2007/05/18 06:41:25 amosjeffries Exp $ * * DEBUG: section 20 Storage Manager Logging Functions * AUTHOR: Duane Wessels @@ -87,7 +87,7 @@ storeLog(int tag, const StoreEntry * e) (int) reply->date, (int) reply->last_modified, (int) reply->expires, - reply->content_type.size() ? reply->content_type.buf() : "unknown", + !reply->content_type.empty() ? reply->content_type.c_str() : "unknown", reply->content_length, e->contentLen(), RequestMethodStr[mem->method], diff --git a/src/structs.h b/src/structs.h index 42dd7e37a0..a170e231a4 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.555 2007/04/16 17:43:27 rousskov Exp $ + * $Id: structs.h,v 1.556 2007/05/18 06:41:25 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -842,8 +842,8 @@ struct _HttpBody class HttpHdrExtField { - String name; /* field-name from HTTP/1.1 (no column after name) */ - String value; /* field-value from HTTP/1.1 */ + string name; /* field-name from HTTP/1.1 (no column after name) */ + string value; /* field-value from HTTP/1.1 */ }; /* http cache control header field */ @@ -856,7 +856,7 @@ public: int max_age; int s_maxage; int max_stale; - String other; + string other; }; /* some fields can hold either time or etag specs (e.g. If-Range) */ @@ -892,7 +892,7 @@ public: HttpHeaderFieldInfo() : id (HDR_ACCEPT), type (ftInvalid){} http_hdr_type id; - String name; + string name; field_type type; HttpHeaderFieldStat stat; }; diff --git a/src/tests/CapturingStoreEntry.h b/src/tests/CapturingStoreEntry.h index b992020482..00ff198640 100644 --- a/src/tests/CapturingStoreEntry.h +++ b/src/tests/CapturingStoreEntry.h @@ -14,7 +14,7 @@ public: CapturingStoreEntry() : _buffer_calls(0), _flush_calls(0) {} - String _appended_text; + string _appended_text; int _buffer_calls; int _flush_calls; diff --git a/src/tests/TestSwapDir.cc b/src/tests/TestSwapDir.cc index c24fb83ad4..872afba371 100644 --- a/src/tests/TestSwapDir.cc +++ b/src/tests/TestSwapDir.cc @@ -46,7 +46,7 @@ TestSwapDir::parse(int, char*) {} StoreSearch * -TestSwapDir::search(String, HttpRequest *) +TestSwapDir::search(string, HttpRequest *) { return NULL; } diff --git a/src/tests/TestSwapDir.h b/src/tests/TestSwapDir.h index d93fcd6dbc..ff334a0dcb 100644 --- a/src/tests/TestSwapDir.h +++ b/src/tests/TestSwapDir.h @@ -21,7 +21,7 @@ public: virtual StoreIOState::Pointer createStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *); virtual StoreIOState::Pointer openStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *); virtual void parse(int, char*); - virtual StoreSearch *search(String, HttpRequest *); + virtual StoreSearch *search(string, HttpRequest *); }; typedef RefCount TestSwapDirPointer; diff --git a/src/tests/testCacheManager.cc b/src/tests/testCacheManager.cc index 252f327f28..e09e75b4f3 100644 --- a/src/tests/testCacheManager.cc +++ b/src/tests/testCacheManager.cc @@ -47,8 +47,8 @@ testCacheManager::testRegister() CacheManager manager; manager.registerAction("sample", "my sample", &dummy_action, false, false); CacheManagerAction *anAction = manager.findAction("sample"); - CPPUNIT_ASSERT_EQUAL(String("sample"), String(anAction->action)); - CPPUNIT_ASSERT_EQUAL(String("my sample"), String(anAction->desc)); + CPPUNIT_ASSERT_EQUAL( (string)"sample", (string)anAction->action ); + CPPUNIT_ASSERT_EQUAL( (string)"my sample", (string)anAction->desc ); CPPUNIT_ASSERT_EQUAL(&dummy_action, anAction->handler); CPPUNIT_ASSERT_EQUAL(0, (int)anAction->flags.pw_req); CPPUNIT_ASSERT_EQUAL(0, (int)anAction->flags.atomic); diff --git a/src/tests/testEvent.cc b/src/tests/testEvent.cc index 2317a687bc..979f69750e 100644 --- a/src/tests/testEvent.cc +++ b/src/tests/testEvent.cc @@ -104,13 +104,12 @@ testEvent::testDump() scheduler.schedule("test event", CalledEvent::Handler, &event, 0, 0, false); scheduler.schedule("test event2", CalledEvent::Handler, &event2, 0, 0, false); scheduler.dump(anEntry); - CPPUNIT_ASSERT_EQUAL(String( - "Last event to run: last event\n" + string expect = "Last event to run: last event\n" "\n" "Operation\tNext Execution\tWeight\tCallback Valid?\n" "test event\t0.000000 seconds\t0\tN/A\n" - "test event2\t0.000000 seconds\t0\tN/A\n" - ), anEntry->_appended_text); + "test event2\t0.000000 seconds\t0\tN/A\n"; + CPPUNIT_ASSERT_EQUAL( expect, anEntry->_appended_text); delete anEntry; } diff --git a/src/tests/testHttpRequest.cc b/src/tests/testHttpRequest.cc index d32dbc95a5..eb4b98ffbb 100644 --- a/src/tests/testHttpRequest.cc +++ b/src/tests/testHttpRequest.cc @@ -38,10 +38,10 @@ testHttpRequest::testCreateFromUrlAndMethod() HttpRequest *nullRequest = NULL; CPPUNIT_ASSERT_EQUAL(expected_port, aRequest->port); CPPUNIT_ASSERT_EQUAL(METHOD_GET, aRequest->method); - CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->host)); - CPPUNIT_ASSERT_EQUAL(String("/bar"), aRequest->urlpath); + CPPUNIT_ASSERT_EQUAL((string)"foo", (string)aRequest->host); + CPPUNIT_ASSERT_EQUAL((string)"/bar", aRequest->urlpath); CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); - CPPUNIT_ASSERT_EQUAL(String("http://foo:90/bar"), String(url)); + CPPUNIT_ASSERT_EQUAL((string)"http://foo:90/bar", (string)url); xfree(url); /* vanilla url, different method */ url = xstrdup("http://foo/bar"); @@ -49,10 +49,10 @@ testHttpRequest::testCreateFromUrlAndMethod() expected_port = 80; CPPUNIT_ASSERT_EQUAL(expected_port, aRequest->port); CPPUNIT_ASSERT_EQUAL(METHOD_PUT, aRequest->method); - CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->host)); - CPPUNIT_ASSERT_EQUAL(String("/bar"), aRequest->urlpath); + CPPUNIT_ASSERT_EQUAL((string)"foo", (string)aRequest->host); + CPPUNIT_ASSERT_EQUAL((string)"/bar", aRequest->urlpath); CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); - CPPUNIT_ASSERT_EQUAL(String("http://foo/bar"), String(url)); + CPPUNIT_ASSERT_EQUAL((string)"http://foo/bar", (string)url); /* a connect url with non-CONNECT data */ url = xstrdup(":foo/bar"); aRequest = HttpRequest::CreateFromUrlAndMethod(url, METHOD_CONNECT); @@ -64,10 +64,10 @@ testHttpRequest::testCreateFromUrlAndMethod() expected_port = 45; CPPUNIT_ASSERT_EQUAL(expected_port, aRequest->port); CPPUNIT_ASSERT_EQUAL(METHOD_CONNECT, aRequest->method); - CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->host)); - CPPUNIT_ASSERT_EQUAL(String(""), aRequest->urlpath); + CPPUNIT_ASSERT_EQUAL((string)"foo", (string)aRequest->host); + CPPUNIT_ASSERT_EQUAL((string)"", aRequest->urlpath); CPPUNIT_ASSERT_EQUAL(PROTO_NONE, aRequest->protocol); - CPPUNIT_ASSERT_EQUAL(String("foo:45"), String(url)); + CPPUNIT_ASSERT_EQUAL((string)"foo:45", (string)url); xfree(url); } @@ -84,9 +84,9 @@ testHttpRequest::testCreateFromUrl() expected_port = 90; CPPUNIT_ASSERT_EQUAL(expected_port, aRequest->port); CPPUNIT_ASSERT_EQUAL(METHOD_GET, aRequest->method); - CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->host)); - CPPUNIT_ASSERT_EQUAL(String("/bar"), aRequest->urlpath); + CPPUNIT_ASSERT_EQUAL((string)"foo", (string)aRequest->host); + CPPUNIT_ASSERT_EQUAL((string)"/bar", aRequest->urlpath); CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); - CPPUNIT_ASSERT_EQUAL(String("http://foo:90/bar"), String(url)); + CPPUNIT_ASSERT_EQUAL((string)"http://foo:90/bar", (string)url); xfree(url); } diff --git a/src/tests/testHttpRequestMethod.cc b/src/tests/testHttpRequestMethod.cc index 7b479ebbe1..38bbe75270 100644 --- a/src/tests/testHttpRequestMethod.cc +++ b/src/tests/testHttpRequestMethod.cc @@ -79,7 +79,7 @@ testHttpRequestMethod::testConstructmethod_t() void testHttpRequestMethod::testConst_str() { - CPPUNIT_ASSERT_EQUAL(String("POST"), String(HttpRequestMethod("post").const_str())); + CPPUNIT_ASSERT_EQUAL((string)"POST", (string)HttpRequestMethod("post").const_str()); } /* @@ -115,5 +115,5 @@ testHttpRequestMethod::testStream() { std::ostringstream buffer; buffer << HttpRequestMethod("get"); - CPPUNIT_ASSERT_EQUAL(String("GET"), String(buffer.str().c_str())); + CPPUNIT_ASSERT_EQUAL((string)"GET", (string)buffer.str().c_str() ); } diff --git a/src/tests/testStore.cc b/src/tests/testStore.cc index 71d6781ccd..fd7231bdbe 100644 --- a/src/tests/testStore.cc +++ b/src/tests/testStore.cc @@ -21,7 +21,7 @@ TestStore::get void TestStore::get - (String, void (*)(StoreEntry*, void*), void*) + (string, void (*)(StoreEntry*, void*), void*) {} void @@ -48,7 +48,7 @@ TestStore::stat(StoreEntry &) const } StoreSearch * -TestStore::search(String const url, HttpRequest *) +TestStore::search(string const url, HttpRequest *) { return NULL; } diff --git a/src/tests/testStore.h b/src/tests/testStore.h index b148f60b3f..84a1f4cac5 100644 --- a/src/tests/testStore.h +++ b/src/tests/testStore.h @@ -49,7 +49,7 @@ public: (const cache_key*); virtual void get - (String, void (*)(StoreEntry*, void*), void*); + (string, void (*)(StoreEntry*, void*), void*); virtual void init(); @@ -67,7 +67,7 @@ virtual void maintain() {}; virtual void updateSize(size_t size, int sign) {} - virtual StoreSearch *search(String const url, HttpRequest *); + virtual StoreSearch *search(string const url, HttpRequest *); }; typedef RefCount TestStorePointer; diff --git a/src/tests/testStoreController.cc b/src/tests/testStoreController.cc index 76bd65ee30..e7ac34bff0 100644 --- a/src/tests/testStoreController.cc +++ b/src/tests/testStoreController.cc @@ -78,10 +78,9 @@ testStoreController::testMaxSize() static StoreEntry * addedEntry(StorePointer hashStore, StorePointer aStore, - String name, - String varySpec, - String varyKey - + string name, + string varySpec, + string varyKey ) { StoreEntry *e = new StoreEntry(); @@ -109,7 +108,7 @@ addedEntry(StorePointer hashStore, EBIT_CLR(e->flags, KEY_PRIVATE); e->ping_status = PING_NONE; EBIT_CLR(e->flags, ENTRY_VALIDATED); - e->hashInsert((const cache_key *)name.buf()); /* do it after we clear KEY_PRIVATE */ + e->hashInsert((const cache_key *)name.c_str()); /* do it after we clear KEY_PRIVATE */ return e; } diff --git a/src/tests/testStoreEntryStream.cc b/src/tests/testStoreEntryStream.cc index 69d51ab171..db1c7e41c4 100644 --- a/src/tests/testStoreEntryStream.cc +++ b/src/tests/testStoreEntryStream.cc @@ -39,7 +39,7 @@ testStoreEntryStream::testGetStream() stream.flush(); CPPUNIT_ASSERT_EQUAL(1, anEntry->_buffer_calls); CPPUNIT_ASSERT_EQUAL(1, anEntry->_flush_calls); - CPPUNIT_ASSERT_EQUAL(String("some text !"), anEntry->_appended_text); + CPPUNIT_ASSERT_EQUAL((string)"some text !", (string)anEntry->_appended_text); } delete anEntry; diff --git a/src/tests/testStoreHashIndex.cc b/src/tests/testStoreHashIndex.cc index 766483eaa7..16c0e3370e 100644 --- a/src/tests/testStoreHashIndex.cc +++ b/src/tests/testStoreHashIndex.cc @@ -59,9 +59,9 @@ testStoreHashIndex::testMaxSize() StoreEntry * addedEntry(StorePointer hashStore, StorePointer aStore, - String name, - String varySpec, - String varyKey + string name, + string varySpec, + string varyKey ) { @@ -90,7 +90,7 @@ addedEntry(StorePointer hashStore, EBIT_CLR(e->flags, KEY_PRIVATE); e->ping_status = PING_NONE; EBIT_CLR(e->flags, ENTRY_VALIDATED); - e->hashInsert((const cache_key *)name.buf()); /* do it after we clear KEY_PRIVATE */ + e->hashInsert((const cache_key *)name.c_str()); /* do it after we clear KEY_PRIVATE */ return e; } diff --git a/src/tests/testString.cc b/src/tests/testString.cc index 09659ddd2b..083693ae36 100644 --- a/src/tests/testString.cc +++ b/src/tests/testString.cc @@ -20,42 +20,169 @@ struct Initer static Initer ensure_mempools; +void +testString::testDefaults() +{ + string aStr; + + /* check this reports as empty */ + CPPUNIT_ASSERT( aStr.empty() ); + CPPUNIT_ASSERT_EQUAL( (const char*)NULL, aStr.c_str() ); + CPPUNIT_ASSERT_EQUAL( 0, aStr.size() ); + + string bStr("foo bar"); + + /* check copy constructor */ + CPPUNIT_ASSERT( !bStr.empty() ); + CPPUNIT_ASSERT_EQUAL( 7, bStr.size() ); + CPPUNIT_ASSERT( NULL != bStr.c_str() ); + CPPUNIT_ASSERT( memcmp(bStr.c_str(), "foo bar", 8) == 0 ); +} + +void +testString::testBooleans() +{ + const string smStr("bar"); + const string bgStr("foo"); + const string eqStr("foo"); + const string nqStr("food"); + + /* mathematical boolean operators */ + CPPUNIT_ASSERT(!(bgStr == smStr )); + CPPUNIT_ASSERT( bgStr != smStr ); + CPPUNIT_ASSERT( bgStr > smStr ); + CPPUNIT_ASSERT(!(bgStr < smStr )); + CPPUNIT_ASSERT( bgStr >= smStr ); + CPPUNIT_ASSERT(!(bgStr <= smStr )); + + /* reverse order to catch corners */ + CPPUNIT_ASSERT(!(smStr == bgStr )); + CPPUNIT_ASSERT( smStr != bgStr ); + CPPUNIT_ASSERT(!(smStr > bgStr )); + CPPUNIT_ASSERT( smStr < bgStr ); + CPPUNIT_ASSERT(!(smStr >= bgStr )); + CPPUNIT_ASSERT( smStr <= bgStr ); + + /* check identical to catch corners */ + CPPUNIT_ASSERT( bgStr == eqStr ); + CPPUNIT_ASSERT(!(bgStr != eqStr )); + CPPUNIT_ASSERT(!(bgStr > eqStr )); + CPPUNIT_ASSERT(!(bgStr < eqStr )); + CPPUNIT_ASSERT( bgStr >= eqStr ); + CPPUNIT_ASSERT( bgStr <= eqStr ); + + /* check _almost_ identical to catch corners */ + CPPUNIT_ASSERT(!(bgStr == nqStr )); + CPPUNIT_ASSERT( bgStr != nqStr ); + CPPUNIT_ASSERT(!(bgStr > nqStr )); + CPPUNIT_ASSERT( bgStr < nqStr ); + CPPUNIT_ASSERT(!(bgStr >= nqStr )); + CPPUNIT_ASSERT( bgStr <= nqStr ); +} + +void +testString::testAppend() +{ + // FIXME: make tests for this. + string aStr("hello"); + + aStr.append(" world"); + CPPUNIT_ASSERT_EQUAL( (string)"hello world", aStr ); + aStr.append(" howsit", 7); + CPPUNIT_ASSERT_EQUAL( (string)"hello world howsit", aStr ); + + string bStr; + string cStr("hello"); + + /* corner cases */ + bStr.append(NULL, 2); + CPPUNIT_ASSERT( bStr.empty() ); + CPPUNIT_ASSERT_EQUAL( 0, bStr.size() ); + CPPUNIT_ASSERT_EQUAL( (string)"", bStr ); + + bStr.append("hello", 5); + CPPUNIT_ASSERT( !bStr.empty() ); + CPPUNIT_ASSERT_EQUAL( 5, bStr.size() ); + CPPUNIT_ASSERT_EQUAL( (string)"hello", bStr ); + + bStr.append(NULL, 2); + CPPUNIT_ASSERT( !bStr.empty() ); + CPPUNIT_ASSERT_EQUAL( 5, bStr.size() ); + CPPUNIT_ASSERT_EQUAL( (string)"hello", bStr ); + + bStr.append(" world untroubled by things such as null termination", 6); + CPPUNIT_ASSERT( !bStr.empty() ); + CPPUNIT_ASSERT_EQUAL( 11, bStr.size() ); + CPPUNIT_ASSERT_EQUAL( (string)"hello world", bStr ); + + cStr.append(" wo"); + CPPUNIT_ASSERT( !cStr.empty() ); + CPPUNIT_ASSERT_EQUAL( 8, cStr.size() ); + CPPUNIT_ASSERT_EQUAL( (string)"hello wo", cStr ); + + cStr.append("rld\0 untroubled by things such as null termination", 10); + CPPUNIT_ASSERT( !cStr.empty() ); + CPPUNIT_ASSERT_EQUAL( 18, cStr.size() ); + CPPUNIT_ASSERT_EQUAL( (string)"hello world\0 untr", cStr ); +} + +void +testString::testAssignments() +{ + // FIXME: make tests for this. +} + +void +testString::testCstrMethods() +{ + // FIXME: make tests for this. + // strcmp, strncmp, etc.... +} + +void +testString::testSearch() +{ + // FIXME: make tests for this. + +// pos, rpos, find, rfind, etc... +} + void testString::testCmpDefault() { - String left, right; + string left, right; /* two default strings are equal */ - CPPUNIT_ASSERT(!left.cmp(right)); - CPPUNIT_ASSERT(!left.cmp(NULL)); - CPPUNIT_ASSERT(!left.cmp(NULL, 1)); + CPPUNIT_ASSERT(!left.compare(right)); + CPPUNIT_ASSERT(!left.compare(NULL)); + CPPUNIT_ASSERT(!left.compare(NULL, 1)); } void testString::testCmpEmptyString() { - String left(""); - String right; + string left(""); + string right; /* an empty string ("") is equal to a default string */ - CPPUNIT_ASSERT(!left.cmp(right)); - CPPUNIT_ASSERT(!left.cmp(NULL)); - CPPUNIT_ASSERT(!left.cmp(NULL, 1)); + CPPUNIT_ASSERT(!left.compare(right)); + CPPUNIT_ASSERT(!left.compare(NULL)); + CPPUNIT_ASSERT(!left.compare(NULL, 1)); /* reverse the order to catch corners */ - CPPUNIT_ASSERT(!right.cmp(left)); - CPPUNIT_ASSERT(!right.cmp("")); - CPPUNIT_ASSERT(!right.cmp("", 1)); + CPPUNIT_ASSERT(!right.compare(left)); + CPPUNIT_ASSERT(!right.compare("")); + CPPUNIT_ASSERT(!right.compare("", 1)); } void testString::testCmpNotEmptyDefault() { - String left("foo"); - String right; + string left("foo"); + string right; /* empty string sorts before everything */ - CPPUNIT_ASSERT(left.cmp(right) > 0); - CPPUNIT_ASSERT(left.cmp(NULL) > 0); - CPPUNIT_ASSERT(left.cmp(NULL, 1) > 0); + CPPUNIT_ASSERT(left.compare(right) > 0); + CPPUNIT_ASSERT(left.compare(NULL) > 0); + CPPUNIT_ASSERT(left.compare(NULL, 1) > 0); /* reverse for symmetry tests */ - CPPUNIT_ASSERT(right.cmp(left) < 0); - CPPUNIT_ASSERT(right.cmp("foo") < 0); - CPPUNIT_ASSERT(right.cmp("foo", 1) < 0); + CPPUNIT_ASSERT(right.compare(left) < 0); + CPPUNIT_ASSERT(right.compare("foo") < 0); + CPPUNIT_ASSERT(right.compare("foo", 1) < 0); } diff --git a/src/tests/testString.h b/src/tests/testString.h index e5d545d6ca..69cdd42b09 100644 --- a/src/tests/testString.h +++ b/src/tests/testString.h @@ -11,18 +11,33 @@ class testString : public CPPUNIT_NS::TestFixture { CPPUNIT_TEST_SUITE( testString ); + CPPUNIT_TEST( testDefaults ); + /* boolean helper tests */ CPPUNIT_TEST( testCmpDefault ); CPPUNIT_TEST( testCmpEmptyString ); CPPUNIT_TEST( testCmpNotEmptyDefault ); + + CPPUNIT_TEST( testBooleans ); + CPPUNIT_TEST( testAppend ); + CPPUNIT_TEST( testAssignments ); + CPPUNIT_TEST( testCstrMethods ); + CPPUNIT_TEST( testSearch ); CPPUNIT_TEST_SUITE_END(); public: protected: + + /* std::string API */ + void testDefaults(); void testCmpDefault(); void testCmpEmptyString(); void testCmpNotEmptyDefault(); + void testBooleans(); + void testAppend(); + void testAssignments(); + void testCstrMethods(); + void testSearch(); }; #endif - diff --git a/src/tests/testURLScheme.cc b/src/tests/testURLScheme.cc index 1ec0d0133f..892eb9bd0c 100644 --- a/src/tests/testURLScheme.cc +++ b/src/tests/testURLScheme.cc @@ -104,9 +104,9 @@ testURLScheme::testConstructprotocol_t() void testURLScheme::testConst_str() { - String lhs("wais"); + string lhs("wais"); URLScheme wais(PROTO_WAIS); - String rhs(wais.const_str()); + string rhs(wais.const_str()); CPPUNIT_ASSERT_EQUAL(lhs, rhs); } @@ -143,7 +143,7 @@ testURLScheme::testStream() { std::ostringstream buffer; buffer << URLScheme(PROTO_HTTP); - String http_str("http"); - String from_buf(buffer.str().c_str()); + string http_str("http"); + string from_buf(buffer.str().c_str()); CPPUNIT_ASSERT_EQUAL(http_str, from_buf); } diff --git a/src/tests/test_http_range.cc b/src/tests/test_http_range.cc index 0680402036..a00c30ccaf 100644 --- a/src/tests/test_http_range.cc +++ b/src/tests/test_http_range.cc @@ -1,6 +1,6 @@ /* - * $Id: test_http_range.cc,v 1.1 2006/05/21 14:35:11 robertc Exp $ + * $Id: test_http_range.cc,v 1.2 2007/05/18 06:41:33 amosjeffries Exp $ * * DEBUG: section 64 HTTP Range Header * AUTHOR: Alex Rousskov @@ -56,10 +56,10 @@ SQUIDCEXTERN HttpHeaderEntry *httpHeaderGetEntry(const HttpHeader * hdr, HttpHea return NULL; } -extern String httpHeaderGetList(const HttpHeader * hdr, http_hdr_type id) +extern string httpHeaderGetList(const HttpHeader * hdr, http_hdr_type id) { fatal ("dummy function\n"); - return String(); + return ""; } SQUIDCEXTERN int httpHeaderHas(const HttpHeader * hdr, http_hdr_type type) @@ -76,7 +76,7 @@ SQUIDCEXTERN void httpHeaderPutContRange(HttpHeader * hdr, const HttpHdrContRang void testRangeParser(char const *rangestring) { - String aString (rangestring); + string aString (rangestring); HttpHdrRange *range = HttpHdrRange::ParseCreate (&aString); if (!range) @@ -96,7 +96,7 @@ testRangeParser(char const *rangestring) HttpHdrRange * rangeFromString(char const *rangestring) { - String aString (rangestring); + string aString (rangestring); HttpHdrRange *range = HttpHdrRange::ParseCreate (&aString); if (!range) diff --git a/src/url.cc b/src/url.cc index e4788fce9d..de85758c89 100644 --- a/src/url.cc +++ b/src/url.cc @@ -1,6 +1,6 @@ /* - * $Id: url.cc,v 1.157 2007/04/28 22:26:38 hno Exp $ + * $Id: url.cc,v 1.158 2007/05/18 06:41:25 amosjeffries Exp $ * * DEBUG: section 23 URL Parsing * AUTHOR: Duane Wessels @@ -268,7 +268,7 @@ urlParse(method_t method, char *url, HttpRequest *request) for (t = host; *t; t++) *t = xtolower(*t); - if (stringHasWhitespace(host)) { + if (strpbrk(host, w_space) != NULL) { if (URI_WHITESPACE_STRIP == Config.uri_whitespace) { t = q = host; @@ -316,7 +316,7 @@ urlParse(method_t method, char *url, HttpRequest *request) } #endif - if (stringHasWhitespace(urlpath)) { + if (strpbrk(urlpath, w_space) != NULL) { debugs(23, 2, "urlParse: URI has whitespace: {" << url << "}"); switch (Config.uri_whitespace) { @@ -381,7 +381,7 @@ urlCanonical(HttpRequest * request) return request->canonical; if (request->protocol == PROTO_URN) { - snprintf(urlbuf, MAX_URL, "urn:%s", request->urlpath.buf()); + snprintf(urlbuf, MAX_URL, "urn:%s", request->urlpath.c_str()); } else { switch (request->method) { @@ -401,7 +401,7 @@ urlCanonical(HttpRequest * request) *request->login ? "@" : null_string, request->host, portbuf, - request->urlpath.buf()); + request->urlpath.c_str()); break; } @@ -410,6 +410,22 @@ urlCanonical(HttpRequest * request) return (request->canonical = xstrdup(urlbuf)); } +int +stringHasCntl(const char *s) +{ + unsigned char c; + + while ((c = (unsigned char) *s++) != '\0') { + if (c <= 0x1f) + return 1; + + if (c >= 0x7f && c <= 0x9f) + return 1; + } + + return 0; +} + char * urlCanonicalClean(const HttpRequest * request) { @@ -419,7 +435,7 @@ urlCanonicalClean(const HttpRequest * request) char *t; if (request->protocol == PROTO_URN) { - snprintf(buf, MAX_URL, "urn:%s", request->urlpath.buf()); + snprintf(buf, MAX_URL, "urn:%s", request->urlpath.c_str()); } else { switch (request->method) { @@ -449,7 +465,7 @@ urlCanonicalClean(const HttpRequest * request) loginbuf, request->host, portbuf, - request->urlpath.buf()); + request->urlpath.c_str()); /* * strip arguments AFTER a question-mark */ diff --git a/src/urn.cc b/src/urn.cc index 94e7755a5a..699f160b01 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -1,6 +1,6 @@ /* - * $Id: urn.cc,v 1.105 2007/04/28 22:26:38 hno Exp $ + * $Id: urn.cc,v 1.106 2007/05/18 06:41:26 amosjeffries Exp $ * * DEBUG: section 52 URN Parsing * AUTHOR: Kostas Anagnostakis @@ -53,11 +53,11 @@ public: void *operator new (size_t byteCount); void operator delete (void *address); void start (HttpRequest *, StoreEntry *); - char *getHost (String &urlpath); + char *getHost (string &urlpath); void setUriResFromRequest(HttpRequest *); bool RequestNeedsMenu(HttpRequest *r); void updateRequestURL(HttpRequest *r, char const *newPath); - void createUriResRequest (String &uri); + void createUriResRequest (string &uri); virtual ~UrnState(); @@ -174,17 +174,17 @@ urnFindMinRtt(url_entry * urls, method_t m, int *rtt_ret) } char * -UrnState::getHost (String &urlpath) +UrnState::getHost (string &urlpath) { char * result; char const *t; if ((t = urlpath.pos(':')) != NULL) { urlpath.set(t, '\0'); - result = xstrdup(urlpath.buf()); + result = xstrdup(urlpath.c_str()); urlpath.set(t, ':'); } else { - result = xstrdup(urlpath.buf()); + result = xstrdup(urlpath.c_str()); } return result; @@ -193,7 +193,7 @@ UrnState::getHost (String &urlpath) bool UrnState::RequestNeedsMenu(HttpRequest *r) { - return strncasecmp(r->urlpath.buf(), "menu.", 5) == 0; + return strncasecmp(r->urlpath, "menu.", 5) == 0; } void @@ -205,11 +205,11 @@ UrnState::updateRequestURL(HttpRequest *r, char const *newPath) } void -UrnState::createUriResRequest (String &uri) +UrnState::createUriResRequest (string &uri) { LOCAL_ARRAY(char, local_urlres, 4096); char *host = getHost (uri); - snprintf(local_urlres, 4096, "http://%s/uri-res/N2L?urn:%s", host, uri.buf()); + snprintf(local_urlres, 4096, "http://%s/uri-res/N2L?urn:%s", host, uri.c_str()); safe_free (host); safe_free (urlres); urlres = xstrdup (local_urlres); @@ -220,7 +220,7 @@ void UrnState::setUriResFromRequest(HttpRequest *r) { if (RequestNeedsMenu(r)) { - updateRequestURL(r, r->urlpath.buf() + 5); + updateRequestURL(r, r->urlpath.c_str() + 5); flags.force_menu = 1; } diff --git a/src/whois.cc b/src/whois.cc index 02d01ff384..d8f948aaea 100644 --- a/src/whois.cc +++ b/src/whois.cc @@ -1,6 +1,6 @@ /* - * $Id: whois.cc,v 1.43 2007/04/30 16:56:09 wessels Exp $ + * $Id: whois.cc,v 1.44 2007/05/18 06:41:26 amosjeffries Exp $ * * DEBUG: section 75 WHOIS protocol * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -100,7 +100,7 @@ whoisStart(FwdState * fwd) buf = (char *)xmalloc(l); - snprintf(buf, l, "%s\r\n", p->request->urlpath.buf() + 1); + snprintf(buf, l, "%s\r\n", p->request->urlpath.c_str() + 1); comm_write(fd, buf, strlen(buf), whoisWriteComplete, p, NULL); comm_read(fd, p->buf, BUFSIZ, whoisReadReply, p);