]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Rollback String API changes. Delayed to 3.1.
authoramosjeffries <>
Tue, 29 May 2007 19:31:36 +0000 (19:31 +0000)
committeramosjeffries <>
Tue, 29 May 2007 19:31:36 +0000 (19:31 +0000)
114 files changed:
ChangeLog
src/ACLExtUser.cc
src/ACLHTTPHeaderData.cc
src/ACLHTTPHeaderData.h
src/ACLUrlPath.cc
src/AuthUser.cc
src/CommonPool.h
src/CompositePoolNode.h
src/ConfigParser.h
src/DelayBucket.cc
src/DelayTagged.cc
src/DelayTagged.h
src/DiskIO/AIO/AIODiskFile.cc
src/DiskIO/AIO/AIODiskFile.h
src/ESI.cc
src/ESIAssign.cc
src/ESIAssign.h
src/ESICustomParser.cc
src/ESICustomParser.h
src/ESISegment.cc
src/ESIVarState.cc
src/ESIVarState.h
src/ExternalACLEntry.h
src/HttpHdrCc.cc
src/HttpHdrRange.cc
src/HttpHdrSc.cc
src/HttpHdrSc.h
src/HttpHdrScTarget.cc
src/HttpHdrScTarget.h
src/HttpHeader.cc
src/HttpHeader.h
src/HttpHeaderRange.h
src/HttpHeaderTools.cc
src/HttpReply.cc
src/HttpReply.h
src/HttpRequest.cc
src/HttpRequest.h
src/HttpStatusLine.cc
src/HttpStatusLine.h
src/ICAP/ICAPConfig.cc
src/ICAP/ICAPConfig.h
src/ICAP/ICAPModXact.cc
src/ICAP/ICAPOptXact.cc
src/ICAP/ICAPOptions.cc
src/ICAP/ICAPOptions.h
src/ICAP/ICAPServiceRep.cc
src/ICAP/ICAPServiceRep.h
src/ICAP/ICAPXaction.cc
src/Makefile.am
src/MemObject.cc
src/PeerDigest.h
src/SqString.h [deleted file]
src/SquidString.h
src/Store.h
src/StoreHashIndex.h
src/String.cc [moved from src/SqString.cc with 60% similarity]
src/String.cci [moved from src/SqString.cci with 63% similarity]
src/SwapDir.cc
src/SwapDir.h
src/access_log.cc
src/auth/digest/auth_digest.cc
src/auth/negotiate/auth_negotiate.cc
src/auth/ntlm/auth_ntlm.cc
src/cache_cf.cc
src/client_db.cc
src/client_side.cc
src/client_side_reply.cc
src/client_side_request.cc
src/client_side_request.h
src/dns_internal.cc
src/errorpage.cc
src/external_acl.cc
src/fqdncache.cc
src/fs/coss/CossSwapDir.h
src/fs/coss/store_dir_coss.cc
src/fs/null/store_null.cc
src/fs/null/store_null.h
src/fs/ufs/store_dir_ufs.cc
src/fs/ufs/ufscommon.h
src/ftp.cc
src/gopher.cc
src/http.cc
src/ident.cc
src/internal.cc
src/ipcache.cc
src/net_db.cc
src/pconn.cc
src/peer_digest.cc
src/protos.h
src/redirect.cc
src/stat.cc
src/store.cc
src/store_dir.cc
src/store_log.cc
src/structs.h
src/tests/CapturingStoreEntry.h
src/tests/TestSwapDir.cc
src/tests/TestSwapDir.h
src/tests/testCacheManager.cc
src/tests/testEvent.cc
src/tests/testHttpRequest.cc
src/tests/testHttpRequestMethod.cc
src/tests/testStore.cc
src/tests/testStore.h
src/tests/testStoreController.cc
src/tests/testStoreEntryStream.cc
src/tests/testStoreHashIndex.cc
src/tests/testString.cc
src/tests/testString.h
src/tests/testURLScheme.cc
src/tests/test_http_range.cc
src/url.cc
src/urn.cc
src/whois.cc

index d5638124dd76e78249d76b12348382418be78e80..c7fa8810f9f32b01dc529d6a1e8dab5155cf3986 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,7 +28,6 @@ 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 ():
 
index 3b40b37abb50046495e0c6717ca64eedc3bea044..18936f214b318f8781c724344afd8a6d76345235 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ACLExtUser.cc,v 1.10 2007/05/18 06:41:21 amosjeffries Exp $
+ * $Id: ACLExtUser.cc,v 1.11 2007/05/29 13:31:36 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.c_str());
+        return data->match(checklist->request->extacl_user.buf());
     } else {
         return -1;
     }
index 39bbbdfebc459cb2b77bb8007cf2a918edce39ff..9cd09df1aea352d3656b5dba5d85879c3bde61f3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ACLHTTPHeaderData.cc,v 1.4 2007/05/18 06:41:21 amosjeffries Exp $
+ * $Id: ACLHTTPHeaderData.cc,v 1.5 2007/05/29 13:31:36 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 << "'");
+    debugs(28, 3, "aclHeaderData::match: checking '" << hdrName.buf() << "'");
 
-    string value = hdrId != HDR_BAD_HDR ? hdr->getStrOrList(hdrId) : hdr->getByName(hdrName.c_str());
+    String value = hdrId != HDR_BAD_HDR ? hdr->getStrOrList(hdrId) : hdr->getByName(hdrName.buf());
 
-    return regex_rule->match(value.c_str());
+    return regex_rule->match(value.buf());
 }
 
 wordlist *
 ACLHTTPHeaderData::dump()
 {
     wordlist *W = NULL;
-    wordlistAdd(&W, hdrName.c_str());
+    wordlistAdd(&W, hdrName.buf());
     wordlist * regex_dump = regex_rule->dump();
     wordlistAddWl(&W, regex_dump);
     wordlistDestroy(&regex_dump);
@@ -87,14 +87,14 @@ ACLHTTPHeaderData::parse()
     char* t = strtokFile();
     assert (t != NULL);
     hdrName = t;
-    hdrId = httpHeaderIdByNameDef(hdrName.c_str(), hdrName.size());
+    hdrId = httpHeaderIdByNameDef(hdrName.buf(), strlen(hdrName.buf()));
     regex_rule->parse();
 }
 
 bool
 ACLHTTPHeaderData::empty() const
 {
-    return (hdrId == HDR_BAD_HDR && !hdrName.c_str()) || regex_rule->empty();
+    return (hdrId == HDR_BAD_HDR && !hdrName.buf()) || regex_rule->empty();
 }
 
 ACLData<HttpHeader*> *
index a4fadd1a3a1129becfab7ab0dcf1881d5f210f29..fe7a10f5fcaa7232f4cd29f9def6e42285582391 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ACLHTTPHeaderData.h,v 1.3 2007/05/18 06:41:21 amosjeffries Exp $
+ * $Id: ACLHTTPHeaderData.h,v 1.4 2007/05/29 13:31:36 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<char const *> * regex_rule;
 };
 
index cda3bcff8d6fede4adfaaf5b42151be733be9b11..24099bf6bd9f4a8e340e4d61cae2d7b041a31f59 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ACLUrlPath.cc,v 1.3 2007/05/18 06:41:21 amosjeffries Exp $
+ * $Id: ACLUrlPath.cc,v 1.4 2007/05/29 13:31:36 amosjeffries Exp $
  *
  * DEBUG: section 28    Access Control
  * AUTHOR: Duane Wessels
@@ -47,7 +47,7 @@ ACLStrategised<char const *> ACLUrlPath::RegistryEntry_(new ACLRegexData, ACLUrl
 int
 ACLUrlPathStrategy::match (ACLData<char const *> * &data, ACLChecklist *checklist)
 {
-    char *esc_buf = xstrdup(checklist->request->urlpath.c_str());
+    char *esc_buf = xstrdup(checklist->request->urlpath.buf());
     rfc1738_unescape(esc_buf);
     int result = data->match(esc_buf);
     safe_free(esc_buf);
index f45ae4e1cd26cb7e6a7b3e42c0404548881703bd..81cbe22d900b7b4ca6c3cd61c827b54ae59b5f36 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: AuthUser.cc,v 1.8 2007/05/18 06:41:21 amosjeffries Exp $
+ * $Id: AuthUser.cc,v 1.9 2007/05/29 13:31:36 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 *) std::strcmp, 7921, hash_string);
+            hash_create((HASHCMP *) strcmp, 7921, hash_string);
         assert(proxy_auth_username_cache);
         eventAdd("User Cache Maintenance", cacheCleanup, NULL, Config.authenticateGCInterval, 1);
     }
index 8b6beb57f4712498bafb014b7b69401d4fe5e631..9cfdbcce5e3b9c3e8f05750566ff7f89c6d8eba3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: CommonPool.h,v 1.4 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: CommonPool.h,v 1.5 2007/05/29 13:31:36 amosjeffries Exp $
  *
  * DEBUG: section 77    Delay Pools
  * AUTHOR: Robert Collins <robertc@squid-cache.org>
@@ -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.c_str(); }
+    char const* theClassTypeLabel() const {return typeLabel.buf();}
 
 protected:
     CommonPool();
-    string typeLabel;
+    String typeLabel;
 };
 
 #endif
index 97eff73d2df65ea603e9967dedcf3199047350d5..cdc7936d8de76f17d47b5ae34b4abde42f62c4ab 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: CompositePoolNode.h,v 1.7 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: CompositePoolNode.h,v 1.8 2007/05/29 13:31:36 amosjeffries Exp $
  *
  * DEBUG: section 77    Delay Pools
  * AUTHOR: Robert Collins <robertc@squid-cache.org>
@@ -78,7 +78,7 @@ public:
 
         struct IN_ADDR src_addr;
         AuthUserRequest *user;
-        string tag;
+        String tag;
     };
 
 protected:
index 86bde34edea089ec3e757dcab4c3b842040847c4..7e12eb6ecbb386dc036c14157ac80e560a4a36dc 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ConfigParser.h,v 1.7 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: ConfigParser.h,v 1.8 2007/05/29 13:31:36 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();
 };
index 978ba2e9c2060ea58eb1bf357565519753cb8ea5..41083c824068fbd18ea2a5ffe6d69462197bfc16 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: DelayBucket.cc,v 1.6 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: DelayBucket.cc,v 1.7 2007/05/29 13:31:36 amosjeffries Exp $
  *
  * DEBUG: section 77    Delay Pools
  * AUTHOR: Robert Collins <robertc@squid-cache.org>
@@ -54,7 +54,7 @@
 #include "ConfigParser.h"
 #include "DelayId.h"
 #include "Array.h"
-#include "SquidString.h"
+#include "String.h"
 #include "CommonPool.h"
 #include "CompositePoolNode.h"
 #include "DelayPool.h"
index ed2c5f4a534caad723dca9732b27d2e9c5df4966..c39cc4ff2c2a48cea045b01de2587c14afaaa560 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: DelayTagged.cc,v 1.6 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: DelayTagged.cc,v 1.7 2007/05/29 13:31:36 amosjeffries Exp $
  *
  * DEBUG: section 77    Delay Pools
  * AUTHOR: Robert Collins <robertc@squid-cache.org>
@@ -77,7 +77,7 @@ int
 DelayTaggedCmp(DelayTaggedBucket::Pointer const &left, DelayTaggedBucket::Pointer const &right)
 {
     /* for rate limiting, case insensitive */
-    return strcasecmp(left->tag, right->tag);
+    return left->tag.caseCmp(right->tag.buf());
 }
 
 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.c_str());
+    storeAppendPrintf(entry, " %s:", tag.buf());
     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);
index b8f09f58b3c2ab6a64264a11ff21a86b415be2c2..590d71cb71a40c2e8906d229fc525c7957c497e6 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: DelayTagged.h,v 1.5 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: DelayTagged.h,v 1.6 2007/05/29 13:31:36 amosjeffries Exp $
  *
  * DEBUG: section 77    Delay Pools
  * AUTHOR: Robert Collins <robertc@squid-cache.org>
@@ -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<DelayTagged>, string &);
+        Id (RefCount<DelayTagged>, String &);
         ~Id();
         virtual int bytesWanted (int min, int max) const;
         virtual void bytesIn(int qty);
index 4b8804775847d1b3a74ca6877224454166ba6c7e..636f4d7efdbb7fcad08df2e7f37d5b743eee338c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: AIODiskFile.cc,v 1.5 2007/05/19 05:03:48 amosjeffries Exp $
+ * $Id: AIODiskFile.cc,v 1.6 2007/05/29 13:31:43 amosjeffries Exp $
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
  * ----------------------------------------------------------
@@ -85,10 +85,10 @@ AIODiskFile::open (int flags, mode_t mode, IORequestor::Pointer callback)
 {
     /* Simulate async calls */
 #ifdef _SQUID_WIN32_
-    fd = aio_open(path.c_str(), flags);
+    fd = aio_open(path.buf(), flags);
 #else
 
-    fd = file_open(path.c_str() , flags);
+    fd = file_open(path.buf() , flags);
 #endif
 
     ioRequestor = callback;
index 01cc4ece85d44fe0622e5044f87adfa62dbbaa32..7c3ee530edea07744a96b4cae9dd32e0a8696ad1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: AIODiskFile.h,v 1.3 2007/05/18 06:41:27 amosjeffries Exp $
+ * $Id: AIODiskFile.h,v 1.4 2007/05/29 13:31:43 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> ioRequestor;
     bool closed;
index 6c1d868e477f9b1d6b50efebd875959c9b74c196..dfa177a180206d75e54655f8bef6e2cb954cb5a4 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ESI.cc,v 1.24 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: ESI.cc,v 1.25 2007/05/29 13:31:36 amosjeffries Exp $
  *
  * DEBUG: section 86    ESI processing
  * AUTHOR: Robert Collins
@@ -2450,7 +2450,7 @@ esiEnableProcessing (HttpReply *rep)
              */
             return 0;
 
-        if (strstr (sctusable->content, "ESI/1.0"))
+        if (strstr (sctusable->content.buf(), "ESI/1.0"))
             rv = 1;
 
         httpHdrScTargetDestroy (sctusable);
index cfc0afdd5385e1a2e25b2f9eb413d0bb57539d15..dbf04abd46e638372e090bf7c82389b69208d723 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ESIAssign.cc,v 1.5 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: ESIAssign.cc,v 1.6 2007/05/29 13:31:37 amosjeffries Exp $
  *
  * DEBUG: section 86    ESI processing
  * AUTHOR: Robert Collins
@@ -83,7 +83,7 @@ ESIAssign::evaluateVariable()
     variable = NULL;
 
     if (unevaluatedVariable.size()) {
-        varState->feedData(unevaluatedVariable.c_str(), unevaluatedVariable.size());
+        varState->feedData(unevaluatedVariable.buf(), 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.c_str(), name.size(), value);
+    varState->addVariable (name.buf(), 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.c_str(), expression.size());
+    ESISegment::ListAppend (state.getOutput(), expression.buf(), expression.size());
 }
index 285cfceabbf2cde3743137e0c468a15a5e3f6f0b..46277620731314c1e76c94758c59ace6523c0aea 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ESIAssign.h,v 1.4 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: ESIAssign.h,v 1.5 2007/05/29 13:31:37 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)
index 957448a22b6ee4d9ba0d931d491ba8d0950d2815..de3a0a36af4c25c4cca729a1ad220105caceae30 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ESICustomParser.cc,v 1.9 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: ESICustomParser.cc,v 1.10 2007/05/29 13:31:37 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.c_str();
+    char const *currentPos = content.buf();
     size_t remainingCount = content.size();
     char const *tag = NULL;
 
@@ -302,7 +302,7 @@ char const *
 ESICustomParser::errorString() const
 {
     if (error.size())
-        return error.c_str();
+        return error.buf();
     else
         return "Parsing error strings not implemented";
 }
index 96ef131cedb21709d3efcb6659affe492246cc45..9aa007ee657952ce9228120ac780b46cc62c9abf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ESICustomParser.h,v 1.7 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: ESICustomParser.h,v 1.8 2007/05/29 13:31:37 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;
 };
index 0909244577d633c62056c3d8541223e6e0f5a694..206e1595b67e7ada071bc0e1e1f952e3b89dc5a0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ESISegment.cc,v 1.5 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: ESISegment.cc,v 1.6 2007/05/29 13:31:37 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 << "\"");
+    debugs(86, 9, "ESISegment::dumpOne: \"" << temp.buf() << "\"");
 }
index a7e8f5b45ad1b7735087de6b264d795c79c99b56..eb11470a2125fcf41e6dca2fe45664fe83c05cb6 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ESIVarState.cc,v 1.9 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: ESIVarState.cc,v 1.10 2007/05/29 13:31:37 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 <Variable *>(variables.find (name.c_str(), name.size()));
+    Variable *candidate = static_cast <Variable *>(variables.find (name.buf(), 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.c_str(), S.size());
+                ESISegment::ListAppend (state.getOutput(), S.buf(), 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.c_str(), S.size());
+            String S (state.header().getList (HDR_ACCEPT_LANGUAGE));
+            ESISegment::ListAppend (state.getOutput(), S.buf(), S.size());
         } else {
             if (state.header().hasListMember (HDR_ACCEPT_LANGUAGE, subref, ',')) {
                 s = "true";
@@ -885,9 +885,10 @@ 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[0] != '*') {
+    if (!strVary.size() || strVary.buf()[0] != '*') {
         rep->header.putStr (HDR_VARY, tempstr);
     }
 }
+
index a4cf31c2ca4a44d87bdeea6cf1ecc35099488f96..f33fbfb3d30703dc815353e7b850f577fd559405 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ESIVarState.h,v 1.3 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: ESIVarState.h,v 1.4 2007/05/29 13:31:37 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);
index c15b6d2ffc35d6846a79328cd315834c3b860c08..f54a017c0adad299cab7734a5e4784ff783b4a8e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ExternalACLEntry.h,v 1.7 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: ExternalACLEntry.h,v 1.8 2007/05/29 13:31:37 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:
index 5a204a82bcff25fb3f6eb93849dd9103345a1aab..289f6ea957d65a028624bc923d6abd1f2c8363f7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHdrCc.cc,v 1.30 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: HttpHdrCc.cc,v 1.31 2007/05/29 13:31:37 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,16 +131,17 @@ 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 << "'");
+            debugs(65, 2, "hdr cc: unknown cache-directive: near '" << item << "' in '" << str->buf() << "'");
             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 << "'");
+                debugs(65, 2, "hdr cc: ignoring duplicate cache-directive: near '" << item << "' in '" << str->buf() << "'");
 
             CcFieldsInfo[type].stat.repCount++;
 
@@ -205,8 +206,8 @@ httpHdrCcDestroy(HttpHdrCc * cc)
 {
     assert(cc);
 
-    if (cc->other.c_str())
-        cc->other.clear();
+    if (cc->other.buf())
+        cc->other.clean();
 
     memFree(cc, MEM_HTTP_HDR_CC);
 }
@@ -235,7 +236,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.c_str());
+            packerPrintf(p, (pcount ? ", %s" : "%s"), CcFieldsInfo[flag].name.buf());
 
             /* handle options with values */
 
@@ -253,7 +254,7 @@ httpHdrCcPackInto(const HttpHdrCc * cc, Packer * p)
     }
 
     if (cc->other.size())
-        packerPrintf(p, (pcount ? ", %s" : "%s"), cc->other.c_str());
+        packerPrintf(p, (pcount ? ", %s" : "%s"), cc->other.buf());
 }
 
 /* negative max_age will clean old max_Age setting */
@@ -299,7 +300,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.c_str() : "INVALID";
+    const char *name = valid_id ? CcFieldsInfo[id].name.buf() : "INVALID";
 
     if (count || valid_id)
         storeAppendPrintf(sentry, "%2d\t %-20s\t %5d\t %6.2f\n",
index 2df61dd37c2f5f15be41e369ae9f8fed6cb8a7b9..2aafc49f9cc5696f349a4854e8ce36f8fe551494 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHdrRange.cc,v 1.43 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: HttpHdrRange.cc,v 1.44 2007/05/29 13:31:37 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 << "'");
+    debugs(64, 8, "parsing range field: '" << range_spec->buf() << "'");
     /* check range type */
 
-    if (strncasecmp(*range_spec,"bytes=", 6))
+    if (range_spec->caseCmp("bytes=", 6))
         return 0;
 
     /* skip "bytes="; hack! */
-    pos = range_spec->c_str() + 5;
+    pos = range_spec->buf() + 5;
 
     /* iterate through comma separated list */
     while (strListGetItem(range_spec, ',', &item, &ilen, &pos)) {
@@ -276,7 +276,8 @@ 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;
 }
 
index a9cade0b0ecca5eae3af170f58ec419454119088..2091304050fd5c49adc00d52ac17744d40e6e13f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHdrSc.cc,v 1.5 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: HttpHdrSc.cc,v 1.6 2007/05/29 13:31:37 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,10 +135,11 @@ 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 << "'");
+            debugs(90, 2, "hdr sc: unknown control-directive: near '" << item << "' in '" << str->buf() << "'");
             type = SC_OTHER;
         }
 
@@ -162,7 +163,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 << "'");
+                debugs(90, 2, "hdr sc: ignoring duplicate control-directive: near '" << item << "' in '" << str->buf() << "'");
 
             ScFieldsInfo[type].stat.repCount++;
 
@@ -196,7 +197,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.clear();
+                sct->content.clean();
                 EBIT_CLR(sct->mask, type);
             }
 
@@ -257,7 +258,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.c_str());
+            packerPrintf(p, (pcount ? ", %s" : "%s"), ScFieldsInfo[flag].name.buf());
 
             /* handle options with values */
 
@@ -265,14 +266,14 @@ httpHdrScTargetPackInto(const HttpHdrScTarget * sc, Packer * p)
                 packerPrintf(p, "=%d", (int) sc->max_age);
 
             if (flag == SC_CONTENT)
-                packerPrintf(p, "=\"%s\"", sc->content.c_str());
+                packerPrintf(p, "=\"%s\"", sc->content.buf());
 
             pcount++;
         }
     }
 
     if (sc->target.size())
-        packerPrintf (p, ";%s", sc->target.c_str());
+        packerPrintf (p, ";%s", sc->target.buf());
 }
 
 void
@@ -339,7 +340,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.c_str() : "INVALID";
+    const char *name = valid_id ? ScFieldsInfo[id].name.buf() : "INVALID";
 
     if (count || valid_id)
         storeAppendPrintf(sentry, "%2d\t %-20s\t %5d\t %6.2f\n",
@@ -352,7 +353,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.c_str() : "INVALID";
+    const char *name = valid_id ? ScFieldsInfo[id].name.buf() : "INVALID";
 
     if (count || valid_id)
         storeAppendPrintf(sentry, "%2d\t %-20s\t %5d\t %6.2f\n",
@@ -369,9 +370,9 @@ httpHdrScFindTarget (HttpHdrSc *sc, const char *target)
     while (node) {
         HttpHdrScTarget *sct = (HttpHdrScTarget *)node->data;
 
-        if (target && !sct->target.empty() && !strcmp(target, sct->target) )
+        if (target && sct->target.buf() && !strcmp (target, sct->target.buf()))
             return sct;
-        else if (!target && sct->target.empty())
+        else if (!target && !sct->target.buf())
             return sct;
 
         node = node->next;
index b6bfed06664bfeadf56dc1fe220daf6f16c61c88..c6f008edb8790e0189bad5a107eaad9a43b834ab 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHdrSc.h,v 1.2 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: HttpHdrSc.h,v 1.3 2007/05/29 13:31:37 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);
index 6100c65ec50222fea090b7d72f0f00b06ea818be..f79e176f67143a83e910b5efeca3d238f6830768 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHdrScTarget.cc,v 1.3 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: HttpHdrScTarget.cc,v 1.4 2007/05/29 13:31:37 amosjeffries Exp $
  *
  * DEBUG: section 90    HTTP Cache Control Header
  * AUTHOR: Alex Rousskov
@@ -58,6 +58,8 @@ void
 httpHdrScTargetDestroy(HttpHdrScTarget * sc)
 {
     assert(sc);
+    sc->target.clean();
+    sc->content.clean();
     delete sc;
 }
 
@@ -66,7 +68,7 @@ httpHdrScTargetDup(const HttpHdrScTarget * sc)
 {
     HttpHdrScTarget *dup;
     assert(sc);
-    dup = httpHdrScTargetCreate(sc->target.c_str());
+    dup = httpHdrScTargetCreate(sc->target.buf());
     dup->mask = sc->mask;
     dup->max_age = sc->max_age;
     dup->content = sc->content;
index 29cad435524fe7807152519b92246fa02ea6a791..4c3fa4d8e033e06f78d1c51b6f22a1afe17e7159 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHdrScTarget.h,v 1.2 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: HttpHdrScTarget.h,v 1.3 2007/05/29 13:31:37 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);
index 42198f56d7f108b019b72e184aa6dfa1692eb559..c4a34ac740deb1ebd7301f7b79a68244634b09a4 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHeader.cc,v 1.132 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: HttpHeader.cc,v 1.133 2007/05/29 13:31:37 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.c_str());
+            delByName(e->name.buf());
 
         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.compare(e2->value) != 0) {
+            if (e->value.cmp(e2->value.buf()) != 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.c_str(), &l1)) {
-                    debugs(55, 1, "WARNING: Unparseable content-length '" << e->value << "'");
+                if (!httpHeaderParseSize(e->value.buf(), &l1)) {
+                    debugs(55, 1, "WARNING: Unparseable content-length '" << e->value.buf() << "'");
                     delete e;
                     continue;
-                } else if (!httpHeaderParseSize(e2->value.c_str(), &l2)) {
-                    debugs(55, 1, "WARNING: Unparseable content-length '" << e2->value << "'");
+                } else if (!httpHeaderParseSize(e2->value.buf(), &l2)) {
+                    debugs(55, 1, "WARNING: Unparseable content-length '" << e2->value.buf() << "'");
                     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 && strpbrk(e->name, w_space) != NULL) {
+        if (e->id == HDR_OTHER && stringHasWhitespace(e->name.buf())) {
             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 (!strcasecmp(e->name,name))
+        if (!e->name.caseCmp(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.c_str(), ',');
+            strListAdd(s, e->value.buf(), ',');
     }
 
     /*
@@ -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 "";
+        return String();
 
-    string s;
+    String s;
 
     while ((e = getEntry(&pos))) {
         if (e->id == id)
-            strListAdd(&s, e->value.c_str(), ',');
+            strListAdd(&s, e->value.buf(), ',');
     }
 
     /*
@@ -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 "";
+    return String();
 }
 
 /*
  * 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 && strcasecmp(e->name,name) == 0) {
-            strListAdd(&result, e->value.c_str(), ',');
+        if (e->id == HDR_OTHER && e->name.caseCmp(name) == 0) {
+            strListAdd(&result, e->value.buf(), ',');
         }
     }
 
@@ -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,6 +1001,7 @@ HttpHeader::getListMember(http_hdr_type id, const char *member, const char separ
         }
     }
 
+    header.clean();
     return result;
 }
 
@@ -1164,7 +1165,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.c_str());
+        value = parse_rfc1123(e->value.buf());
         httpHeaderNoteParsedEntry(e->id, e->value, value < 0);
     }
 
@@ -1181,7 +1182,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.c_str();
+        return e->value.buf();
     }
 
     return NULL;
@@ -1197,7 +1198,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.c_str();
+        return e->value.buf();
     }
 
     return NULL;
@@ -1207,7 +1208,7 @@ HttpHdrCc *
 HttpHeader::getCc() const
 {
     HttpHdrCc *cc;
-    string s;
+    String s;
 
     if (!CBIT_TEST(mask, HDR_CACHE_CONTROL))
         return NULL;
@@ -1254,7 +1255,7 @@ HttpHeader::getSc() const
     if (!CBIT_TEST(mask, HDR_SURROGATE_CONTROL))
         return NULL;
 
-    string s;
+    String s;
    
     (void) getList(HDR_SURROGATE_CONTROL, &s);
 
@@ -1277,7 +1278,7 @@ HttpHeader::getContRange() const
     HttpHeaderEntry *e;
 
     if ((e = findEntry(HDR_CONTENT_RANGE))) {
-        cr = httpHdrContRangeParseCreate(e->value.c_str());
+        cr = httpHdrContRangeParseCreate(e->value.buf());
         httpHeaderNoteParsedEntry(e->id, e->value, !cr);
     }
 
@@ -1323,7 +1324,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.c_str());
+        etagParseInit(&etag, e->value.buf());
 
     return etag;
 }
@@ -1337,7 +1338,7 @@ HttpHeader::getTimeOrTag(http_hdr_type id) const
     memset(&tot, 0, sizeof(tot));
 
     if ((e = findEntry(id))) {
-        const char *str = e->value.c_str();
+        const char *str = e->value.buf();
         /* try as an ETag */
 
         if (etagParseInit(&tot.tag, str)) {
@@ -1373,13 +1374,19 @@ HttpHeaderEntry::HttpHeaderEntry(http_hdr_type anId, const char *aName, const ch
 
     Headers[id].stat.aliveCount++;
 
-    debugs(55, 9, "created HttpHeaderEntry " << this << ": '" << name << " : " << value);
+    debugs(55, 9, "created HttpHeaderEntry " << this << ": '" << name.buf() << " : " << value.buf());
 }
 
 HttpHeaderEntry::~HttpHeaderEntry()
 {
     assert_eid(id);
-    debugs(55, 9, "destroying entry " << this << ": '" << name << ": " << value << "'");
+    debugs(55, 9, "destroying entry " << this << ": '" << name.buf() << ": " << value.buf() << "'");
+    /* clean name if needed */
+
+    if (id == HDR_OTHER)
+        name.clean();
+
+    value.clean();
 
     assert(Headers[id].stat.aliveCount);
 
@@ -1429,9 +1436,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;
@@ -1453,10 +1460,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 << "' header of " << (field_end - value_start) << " bytes");
+        debugs(55, 1, "WARNING: ignoring '" << name.buf() << "' header of " << (field_end - value_start) << " bytes");
 
         if (id == HDR_OTHER)
-            name.clear();
+            name.clean();
 
         return NULL;
     }
@@ -1468,24 +1475,24 @@ HttpHeaderEntry::parse(const char *field_start, const char *field_end)
 
     Headers[id].stat.aliveCount++;
 
-    debugs(55, 9, "parsed HttpHeaderEntry: '" << name << ": " << value << "'");
+    debugs(55, 9, "parsed HttpHeaderEntry: '" << name.buf() << ": " << value.buf() << "'");
 
-    return new HttpHeaderEntry(id, name.c_str(), value.c_str());
+    return new HttpHeaderEntry(id, name.buf(), value.buf());
 }
 
 HttpHeaderEntry *
 HttpHeaderEntry::clone() const
 {
-    return new HttpHeaderEntry(id, name.c_str(), value.c_str());
+    return new HttpHeaderEntry(id, name.buf(), value.buf());
 }
 
 void
 HttpHeaderEntry::packInto(Packer * p) const
 {
     assert(p);
-    packerAppend(p, name.c_str(), name.size());
+    packerAppend(p, name.buf(), name.size());
     packerAppend(p, ": ", 2);
-    packerAppend(p, value.c_str(), value.size());
+    packerAppend(p, value.buf(), value.size());
     packerAppend(p, "\r\n", 2);
 }
 
@@ -1495,7 +1502,7 @@ HttpHeaderEntry::getInt() const
     assert_eid (id);
     assert (Headers[id].type == ftInt);
     int val = -1;
-    int ok = httpHeaderParseInt(value.c_str(), &val);
+    int ok = httpHeaderParseInt(value.buf(), &val);
     httpHeaderNoteParsedEntry(id, value, !ok);
     /* XXX: Should we check ok - ie
      * return ok ? -1 : value;
@@ -1504,13 +1511,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 << ": " << context << "'");
+        debugs(55, 2, "cannot parse hdr field: '" << Headers[id].name.buf() << ": " << context.buf() << "'");
     }
 }
 
@@ -1527,7 +1534,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.c_str() : "INVALID";
+    const char *name = valid_id ? Headers[id].name.buf() : "INVALID";
     int visible = count > 0;
     /* for entries with zero count, list only those that belong to current type of message */
 
@@ -1605,7 +1612,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.c_str(), f->stat.aliveCount,
+                          f->id, f->name.buf(), f->stat.aliveCount,
                           xpercent(f->stat.errCount, f->stat.parsCount),
                           xpercent(f->stat.repCount, f->stat.seenCount));
     }
@@ -1618,15 +1625,15 @@ httpHeaderStoreReport(StoreEntry * e)
 }
 
 http_hdr_type
-httpHeaderIdByName(const char *name, unsigned int name_len, const HttpHeaderFieldInfo * info, int end)
+httpHeaderIdByName(const char *name, int name_len, const HttpHeaderFieldInfo * info, int end)
 {
     int i;
 
     for (i = 0; i < end; ++i) {
-        if (name_len >= 0 && name_len != (unsigned int)info[i].name.size())
+        if (name_len >= 0 && name_len != info[i].name.size())
             continue;
 
-        if (!strncasecmp(name, info[i].name,
+        if (!strncasecmp(name, info[i].name.buf(),
                          name_len < 0 ? info[i].name.size() + 1 : name_len))
             return info[i].id;
     }
@@ -1651,7 +1658,7 @@ httpHeaderNameById(int id)
 
     assert(id >= 0 && id < HDR_ENUM_END);
 
-    return Headers[id].name.c_str();
+    return Headers[id].name.buf();
 }
 
 int
@@ -1665,7 +1672,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
@@ -1689,7 +1696,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
@@ -1707,9 +1714,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;
         /*
@@ -1723,7 +1730,7 @@ HttpHeader::removeConnectionHeaderEntries()
 
         int headers_deleted = 0;
         while ((e = getEntry(&pos))) {
-            if (strListIsMember(&strConnection, e->name.c_str(), ','))
+            if (strListIsMember(&strConnection, e->name.buf(), ','))
                 delAt(pos, headers_deleted);
         }
         if (headers_deleted)
index c278631bb3ac81d3e4c04080225cb492920d90b8..8b0351c8f457a7446e2fb32120bde327994613d7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHeader.h,v 1.20 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: HttpHeader.h,v 1.21 2007/05/29 13:31:37 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);
index f83372281ebcc9a8db42b01544a0450abc2d86e5..d1576938a931c5ee7d30f17d319883b413694fc3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHeaderRange.h,v 1.9 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: HttpHeaderRange.h,v 1.10 2007/05/29 13:31:37 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;
 };
 
index 8a9d249806f23a529dd0f87ef86dbec14d61889e..5f208b0cd33b880dca6234358c47ce66c754d4a3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHeaderTools.cc,v 1.60 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: HttpHeaderTools.cc,v 1.61 2007/05/29 13:31:37 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.clear();
+        table[i].name.clean();
 
     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,12 +177,14 @@ 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;
@@ -201,7 +203,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;
@@ -217,7 +219,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);
 
@@ -241,7 +243,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] = {
@@ -258,7 +260,7 @@ strListGetItem(const string * str, char del, const char **item, int *ilen, const
         else
             (*pos)++;
     } else {
-        *pos = str->c_str();
+        *pos = str->buf();
 
         if (!*pos)
             return 0;
@@ -347,10 +349,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->clear();
+    val->clean();
     assert (*start == '"');
     pos = start + 1;
 
index 04acd852dbd42c047bf774f11f6f014133612ea6..709d420a0454b5d6fd6a48dbe93e9ee4c12d21b7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpReply.cc,v 1.94 2007/05/22 16:37:26 rousskov Exp $
+ * $Id: HttpReply.cc,v 1.95 2007/05/29 13:31:37 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.clear();
+        content_type = String();
 
     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,7 +278,9 @@ HttpReply::validatorsMatch(HttpReply const * otherRep) const
 
     two = otherRep->header.getStrOrList(HDR_ETAG);
 
-    if (one.empty() || two.empty() || strcasecmp (one, two)) {
+    if (!one.buf() || !two.buf() || strcasecmp (one.buf(), two.buf())) {
+        one.clean();
+        two.clean();
         return 0;
     }
 
@@ -290,9 +292,9 @@ HttpReply::validatorsMatch(HttpReply const * otherRep) const
 
     two = otherRep->header.getStrOrList(HDR_CONTENT_MD5);
 
-    if (one.empty() || two.empty() || strcasecmp (one, two)) {
-        one.clear();
-        two.clear();
+    if (!one.buf() || !two.buf() || strcasecmp (one.buf(), two.buf())) {
+        one.clean();
+        two.clean();
         return 0;
     }
 
@@ -381,7 +383,7 @@ HttpReply::hdrCacheInit()
     if (str)
         content_type.limitInit(str, strcspn(str, ";\t "));
     else
-        content_type = "";
+        content_type = String();
 
     /* be sure to set expires after date and cache-control */
     expires = hdrExpirationTime();
@@ -391,7 +393,7 @@ HttpReply::hdrCacheInit()
 void
 HttpReply::hdrCacheClean()
 {
-    content_type.clear();
+    content_type.clean();
 
     if (cache_control) {
         httpHdrCcDestroy(cache_control);
@@ -433,8 +435,8 @@ HttpReply::bodySize(method_t method) const
 
 bool HttpReply::sanityCheckStartLine(MemBuf *buf, http_status *error)
 {
-    if (buf->contentSize() >= protoPrefix.size() && protoPrefix.compare(buf->content(), protoPrefix.size()) != 0) {
-        debugs(58, 3, "HttpReply::sanityCheckStartLine: missing protocol prefix (" << protoPrefix << ") in '" << buf->content() << "'");
+    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() << "'");
         *error = HTTP_INVALID_HEADER;
         return false;
     }
index cd6ddb50651b9954767af70f06d4a940641001df..29962625c2fa95a436ba4fd16afbbdc829d61d5a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpReply.h,v 1.19 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: HttpReply.h,v 1.20 2007/05/29 13:31:37 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;
 
index 18acf39f136512de2900a089ee63db0bfde5dbfe..5f9333f0b6d54217b119662182aad5d8eb21ba12 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpRequest.cc,v 1.75 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: HttpRequest.cc,v 1.76 2007/05/29 13:31:37 amosjeffries Exp $
  *
  * DEBUG: section 73    HTTP Request
  * AUTHOR: Duane Wessels
@@ -70,7 +70,7 @@ HttpRequest::init()
 {
     method = METHOD_NONE;
     protocol = PROTO_NONE;
-    urlpath.clear();
+    urlpath = NULL;
     login[0] = '\0';
     host[0] = '\0';
     auth_user_request = NULL;
@@ -112,7 +112,7 @@ HttpRequest::clean()
 
     safe_free(vary_headers);
 
-    urlpath.clear();
+    urlpath.clean();
 
     header.clean();
 
@@ -126,13 +126,13 @@ HttpRequest::clean()
         range = NULL;
     }
 
-    tag.clear();
+    tag.clean();
 
-    extacl_user.clear();
+    extacl_user.clean();
 
-    extacl_passwd.clear();
+    extacl_passwd.clean();
 
-    extacl_log.clear();
+    extacl_log.clean();
 }
 
 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.c_str());
+                 RequestMethodStr[method], urlpath.buf());
     /* 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.c_str(), ','))
+    if (strConn && strListIsMember(strConn, e->name.buf(), ','))
         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.c_str();
+        return urlpath.buf();
 
     return "/";
 }
index 6a225e421f424953bf3ad80d62a4a564bc062e58..cfa1c389ba88998d5c745aa52f62377e7c673008 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpRequest.h,v 1.28 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: HttpRequest.h,v 1.29 2007/05/29 13:31:38 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;
index e63aa0a18f7b200075a8a670bc03ef0fe20c7c38..12de28635b6b067c226d989426b0f71b0e3cf328 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpStatusLine.cc,v 1.33 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: HttpStatusLine.cc,v 1.34 2007/05/29 13:31:38 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 (strncasecmp(protoPrefix,start, protoPrefix.size()) != 0)
+    if (protoPrefix.caseCmp(start, protoPrefix.size()) != 0)
         return 0;
 
     start += protoPrefix.size();
index 09592554a3b62e235f1b749b35de7232af83932f..699ff135992c7bd68d2f2e5c7f28be4fef3c99b1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpStatusLine.h,v 1.3 2007/05/18 06:41:22 amosjeffries Exp $
+ * $Id: HttpStatusLine.h,v 1.4 2007/05/29 13:31:38 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);
index ce39e2aab848aa41956b28c009886c77a9d3a564..8eec11a00f457be4b84a471c0c17a1eaaf42580f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ICAPConfig.cc,v 1.15 2007/05/18 06:41:29 amosjeffries Exp $
+ * $Id: ICAPConfig.cc,v 1.16 2007/05/29 13:31:43 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<ICAPServiceRep::Pointer>::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.clear();
+    matchedClass.clean();
 
     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 << "' has candidate service '" << service->key << "'");
+            debugs(93, 3, "ICAPAccessCheck::check: class '" << c->key.buf() << "' has candidate service '" << service->key.buf() << "'");
             candidateClasses += c->key;
         }
     }
@@ -193,7 +193,7 @@ ICAPAccessCheck::checkCandidates()
      */
     debugs(93, 3, "ICAPAccessCheck::check: NO candidates or matches found");
 
-    matchedClass.clear();
+    matchedClass.clean();
 
     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);
+        debugs(93, 5, "ICAPAccessCheckCallbackWrapper matchedClass = " << ac->matchedClass.buf());
     }
 
     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);
+        debugs(93, 3, "ICAPAccessCheck::do_callback matchedClass = " << matchedClass.buf());
     }
 
     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.c_str(),
-                          r->methodStr(), r->vectPointStr(), r->bypass, r->uri.c_str());
+        storeAppendPrintf(entry, "%s %s_%s %s %d %s\n", name, r->key.buf(),
+                          r->methodStr(), r->vectPointStr(), r->bypass, r->uri.buf());
     }
 };
 
@@ -380,7 +380,7 @@ ICAPConfig::dumpICAPClass(StoreEntry *entry, const char *name)
     Vector<ICAPClass*>::iterator i = classes.begin();
 
     while (i != classes.end()) {
-        storeAppendPrintf(entry, "%s %s\n", name, (*i)->key.c_str());
+        storeAppendPrintf(entry, "%s %s\n", name, (*i)->key.buf());
         ++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.c_str(), config_lineno);
+               aKey.buf(), config_lineno);
 
     aclParseAccessLine(parser, &theClass->accessList);
 };
@@ -413,7 +413,7 @@ ICAPConfig::dumpICAPAccess(StoreEntry *entry, const char *name)
     Vector<ICAPClass*>::iterator i = classes.begin();
 
     while (i != classes.end()) {
-        snprintf(nom, 64, "%s %s", name, (*i)->key.c_str());
+        snprintf(nom, 64, "%s %s", name, (*i)->key.buf());
         dump_acl_access(entry, nom, (*i)->accessList);
         ++i;
     }
index 231d196f715252fa6576cc8aca6ab21dd5011db1..7741d85ed3bf53c0d998da164ac987ab89b70b87 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ICAPConfig.h,v 1.12 2007/05/18 06:41:29 amosjeffries Exp $
+ * $Id: ICAPConfig.h,v 1.13 2007/05/29 13:31:44 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<ICAPServiceRep::Pointer> services;
@@ -73,8 +73,8 @@ private:
     ICAPAccessCheckCallback *callback;
     void *callback_data;
     ACLChecklist *acl_checklist;
-    Vector<string> candidateClasses;
-    string matchedClass;
+    Vector<String> 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);
index 66259892138bce18590bdad545e99c1cc0c37ed9..1732e4026f12a852a66d5cff2dc4ca70f07b1336 100644 (file)
@@ -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.c_str());
-    buf.Printf("Host: %s:%d\r\n", s.host.c_str(), s.port);
+    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("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<const HttpRequest*>(virgin.header);
-    const string urlPath = request ? request->urlpath : "";
+    const String urlPath = request ? request->urlpath : String();
     size_t wantedSize;
     if (!service().wantsPreview(urlPath, wantedSize)) {
         debugs(93, 5, "ICAPModXact should not offer preview for " << urlPath);
index dabfabf121a3e10763ae23a11f5c3caa6ff92376..da0dc719ba495ab8e41a4124f1bd3c43b7bdb2cc 100644 (file)
@@ -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.c_str());
-    buf.Printf("Host: %s:%d\r\n", s.host.c_str(), s.port);
+    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.append(ICAP::crlf, 2);
 }
 
index 735a4f88a6b4c3ac187537104c0768f7b915c3cb..c28abaec70e2eb68a1d75653d5549e5b0996a6b2 100644 (file)
@@ -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.empty() && xisdigit(s[0]))
-        value = atoi(s.c_str());
+    if (s.size() && xisdigit(*s.buf()))
+        value = atoi(s.buf());
     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[eOff-1] == '.' &&
-                strcmp(&urlPath[eOff], e->key) == 0) {
+            if (urlPath.buf()[eOff-1] == '.' &&
+                strcmp(urlPath.buf() + 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;
index d22a4dde80acaffe6d2eeec53a9fafd3c797fd70..0187cc02340155177f091e29c12f111a0049bff0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ICAPOptions.h,v 1.10 2007/05/18 06:41:29 amosjeffries Exp $
+ * $Id: ICAPOptions.h,v 1.11 2007/05/29 13:31:44 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<ICAP::Method> 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;
 
index 9abce19fc2ac64be2858bf538e3cde7725608195..d4fd563a4c7265342600325f65a27be8079fb2bb 100644 (file)
@@ -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 << " " << service_type << " " << bypass);
+    debugs(3, 5, "ICAPService::parseConfigLine (line " << config_lineno << "): " << key.buf() << " " << service_type << " " << bypass);
 
     method = parseMethod(service_type);
     point = parseVectPoint(service_type);
 
     debugs(3, 5, "ICAPService::parseConfigLine (line " << config_lineno << "): service is " << methodStr() << "_" << vectPointStr());
 
-    if (strncmp(uri, "icap://", 7) != 0) {
-        debugs(3, 0, "ICAPService::parseConfigLine (line " << config_lineno << "): wrong uri: " << uri);
+    if (uri.cmp("icap://", 7) != 0) {
+        debugs(3, 0, "ICAPService::parseConfigLine (line " << config_lineno << "): wrong uri: " << uri.buf());
         return false;
     }
 
-    const char *s = &uri[7];
+    const char *s = uri.buf() + 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 <ICAP::Method>::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 <<
-                   " but OPTIONS response declares the methods are " << method_list);
+                   " for service " << uri.buf() <<
+                   " but OPTIONS response declares the methods are " << method_list.buf());
         }
     }
 
@@ -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);
+            " seconds: " << uri.buf());
     }
 }
 
index c490de4d7817cc4d1e88089ac41ea0e8e1b745dd..128ea76c7819f05fd2bb2eb57c4a2513231fb546 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ICAPServiceRep.h,v 1.8 2007/05/18 06:41:30 amosjeffries Exp $
+ * $Id: ICAPServiceRep.h,v 1.9 2007/05/29 13:31:44 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;
index f0460dbd474accbd46073378a2826361ef1827c6..90b4f4403fedd7b81d13a934c53a4b091a2eee1c 100644 (file)
@@ -107,7 +107,7 @@ void ICAPXaction::openConnection()
         disableRetries(); // this will also safely drain pconn pool
 
     // TODO: check whether NULL domain is appropriate here
-    connection = icapPconnPool->pop(s.host.c_str(), s.port, NULL, NULL, isRetriable);
+    connection = icapPconnPool->pop(s.host.buf(), s.port, NULL, NULL, isRetriable);
     if (connection >= 0) {
         debugs(93,3, HERE << "reused pconn FD " << connection);
         connector = &ICAPXaction_noteCommConnected; // make doneAll() false
@@ -123,12 +123,12 @@ void ICAPXaction::openConnection()
     disableRetries(); // we only retry pconn failures
 
     connection = comm_open(SOCK_STREAM, 0, getOutgoingAddr(NULL), 0,
-                           COMM_NONBLOCKING, s.uri.c_str());
+        COMM_NONBLOCKING, s.uri.buf());
 
     if (connection < 0)
         dieOnConnectionFailure(); // throws
 
-    debugs(93,3, typeName << " opens connection to " << s.host << ":" << s.port);
+    debugs(93,3, typeName << " opens connection to " << s.host.buf() << ":" << s.port);
 
     commSetTimeout(connection, Config.Timeout.connect,
                    &ICAPXaction_noteCommTimedout, this);
@@ -137,7 +137,7 @@ void ICAPXaction::openConnection()
     comm_add_close_handler(connection, closer, this);
 
     connector = &ICAPXaction_noteCommConnected;
-    commConnectStart(connection, s.host.c_str(), s.port, connector, this);
+    commConnectStart(connection, s.host.buf(), s.port, connector, this);
 }
 
 /*
@@ -171,7 +171,7 @@ void ICAPXaction::closeConnection()
         if (reuseConnection) {
             debugs(93,3, HERE << "pushing pconn" << status());
             commSetTimeout(connection, -1, NULL, NULL);
-            icapPconnPool->push(connection, theService->host.c_str(), theService->port, NULL, NULL);
+            icapPconnPool->push(connection, theService->host.buf(), theService->port, NULL, NULL);
             disableRetries();
         } else {
             debugs(93,3, HERE << "closing pconn" << status());
@@ -247,7 +247,7 @@ void ICAPXaction::noteCommTimedout()
 
 void ICAPXaction::handleCommTimedout()
 {
-    debugs(93, 0, HERE << "ICAP FD " << connection << " timeout to " << theService->methodStr() << " " << theService->uri);
+    debugs(93, 0, HERE << "ICAP FD " << connection << " timeout to " << theService->methodStr() << " " << theService->uri.buf());
     reuseConnection = false;
     MemBuf mb;
     mb.init();
index e8ad0f3fe4ac6212dcc6669d1310b89426fb1df3..9b28e4f3ef5e0da80203b16df6587ee7a346e0a9 100644 (file)
@@ -1,7 +1,7 @@
 #
 #  Makefile for the Squid Object Cache server
 #
-#  $Id: Makefile.am,v 1.181 2007/05/18 06:41:22 amosjeffries Exp $
+#  $Id: Makefile.am,v 1.182 2007/05/29 13:31:38 amosjeffries Exp $
 #
 #  Uncomment and customize the following to suit your needs:
 #
@@ -556,7 +556,7 @@ squid_SOURCES = \
        $(SSL_SOURCE) \
        stat.cc \
        StatHist.cc \
-       SqString.cc \
+       String.cc \
        stmem.cc \
        stmem.h \
        store.cc \
@@ -626,8 +626,7 @@ noinst_HEADERS = ACLChecklist.cci \
        MemBuf.h \
        Store.cci \
        StoreEntryStream.h \
-       SqString.cci \
-       SqString.h \
+       String.cci \
        SquidString.h \
        SquidTime.h
 
@@ -734,7 +733,7 @@ ufsdump_SOURCES = \
        StoreMetaUnpacker.cc \
        StoreMetaURL.cc \
        StoreMetaVary.cc \
-       SqString.cc \
+       String.cc \
        time.cc \
        ufsdump.cc \
        url.cc \
@@ -1096,7 +1095,6 @@ TESTSOURCES= \
        globals.cc
 
 check_PROGRAMS+= \
-       tests/testString \
        tests/testAuth \
        tests/testACLMaxUserIP \
        tests/testBoilerplate \
@@ -1108,6 +1106,7 @@ check_PROGRAMS+= \
        tests/test_http_range \
        tests/testHttpRequest \
        tests/testStore \
+       tests/testString \
        tests/testURL \
        @STORE_TESTS@
 
@@ -1115,7 +1114,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 SqString.cc \
+       tests/stub_helper.cc cbdata.cc String.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 \
@@ -1133,7 +1132,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 SqString.cc cbdata.cc HttpHeaderTools.cc store.cc cache_manager.cc \
+##     helper.cc String.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
 
@@ -1169,7 +1168,7 @@ tests_testAuth_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
 ##     HttpHdrScTarget.cc \
 ##     Packer.cc \
 ##     StatHist.cc \
-##     SqString.cc \
+##     String.cc \
 tests_testACLMaxUserIP_SOURCES= \
        acl.cc \
        ACLChecklist.cc \
@@ -1194,7 +1193,7 @@ tests_testACLMaxUserIP_SOURCES= \
        Parsing.cc \
        StatHist.cc \
        stmem.cc \
-       SqString.cc \
+       String.cc \
        tests/stub_cache_cf.cc \
        tests/stub_comm.cc \
        tests/stub_DelayId.cc \
@@ -1242,7 +1241,7 @@ tests_testCacheManager_SOURCES = \
        HttpRequest.cc \
        HttpRequestMethod.cc \
        mem.cc \
-       SqString.cc \
+       String.cc \
        tests/testCacheManager.cc \
        tests/testCacheManager.h \
        tests/testMain.cc \
@@ -1406,7 +1405,7 @@ tests_testEvent_SOURCES = \
        HttpRequestMethod.cc \
        mem.cc \
        RemovalPolicy.cc \
-       SqString.cc \
+       String.cc \
        tests/CapturingStoreEntry.h \
        tests/testEvent.cc \
        tests/testEvent.h \
@@ -1558,7 +1557,7 @@ tests_testEventLoop_SOURCES = \
        HttpRequestMethod.cc \
        mem.cc \
        RemovalPolicy.cc \
-       SqString.cc \
+       String.cc \
        tests/testEventLoop.cc \
        tests/testEventLoop.h \
        tests/testMain.cc \
@@ -1846,7 +1845,7 @@ tests_test_http_range_SOURCES = \
        StoreMetaURL.cc \
        StoreMetaVary.cc \
        StoreSwapLogData.cc \
-       SqString.cc \
+       String.cc \
        SwapDir.cc \
        time.cc \
        tools.cc \
@@ -1888,7 +1887,7 @@ tests_testHttpRequest_SOURCES = \
        HttpRequest.cc \
        HttpRequestMethod.cc \
        mem.cc \
-       SqString.cc \
+       String.cc \
        tests/testHttpRequest.h \
        tests/testHttpRequest.cc \
        tests/testHttpRequestMethod.h \
@@ -2055,7 +2054,7 @@ STORE_TEST_SOURCES=\
        SwapDir.cc \
        authenticate.cc \
        tests/stub_acl.cc tests/stub_cache_cf.cc \
-       tests/stub_helper.cc cbdata.cc SqString.cc \
+       tests/stub_helper.cc cbdata.cc String.cc \
        tests/stub_comm.cc \
        tests/stub_client_side_request.cc \
        tests/stub_http.cc \
@@ -2108,10 +2107,11 @@ 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 \
-       SqString.cc \
+       String.cc \
        tests/testMain.cc \
        tests/testString.cc \
        tests/testString.h \
@@ -2223,7 +2223,7 @@ tests_testURL_SOURCES = \
        HttpRequestMethod.cc \
        mem.cc \
        RemovalPolicy.cc \
-       SqString.cc \
+       String.cc \
        tests/testURL.cc \
        tests/testURL.h \
        tests/testURLScheme.cc \
index fe2620e140efd0f277a8fd962df94757236e46d2..cc3be90ffdb5ab8f7b0aedca663fc9ab67474fda 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: MemObject.cc,v 1.27 2007/05/18 06:41:23 amosjeffries Exp $
+ * $Id: MemObject.cc,v 1.28 2007/05/29 13:31:38 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 ? log_url : "(NULL)") );
+    debugs(20, 1, "MemObject->log_url: " << log_url << " " << checkNullString(log_url));
 }
 
 HttpReply const *
index 77ebcd8791d4732c422689b707803a974f1c9414..3ddf70f2a32f96adfdf65da710ad4768a98e98e9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: PeerDigest.h,v 1.2 2007/05/18 06:41:23 amosjeffries Exp $
+ * $Id: PeerDigest.h,v 1.3 2007/05/29 13:31:38 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/SqString.h b/src/SqString.h
deleted file mode 100644 (file)
index c330bb4..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-
-/*
- * $Id: SqString.h,v 1.3 2007/05/20 08:29:44 amosjeffries 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.
- *
- */
-
-#ifndef SQSTRING_H
-#define SQSTRING_H
-
-/* forward decls */
-
-class CacheManager;
-
-#define DEBUGSTRINGS 0
-#if DEBUGSTRINGS
-#include "splay.h"
-
-class SqString;
-
-class SqStringRegistry
-{
-
-public:
-    static StringRegistry &Instance();
-
-    void add
-        (SqString const *);
-
-    void registerWithCacheManager(CacheManager & manager);
-
-    void remove
-        (SqString const *);
-
-private:
-    static OBJH Stat;
-
-    static StringRegistry Instance_;
-
-    static SplayNode<SqString const *>::SPLAYWALKEE Stater;
-
-    Splay<SqString const *> entries;
-
-    bool registered;
-
-};
-
-class StoreEntry;
-#endif
-
-class SqString
-{
-
-public:
-
-    /* std::string API available */
-    _SQUID_INLINE_ SqString();
-    SqString (char const *);
-    SqString (SqString const &);
-    ~SqString();
-
-    SqString &operator =(char const *);
-    SqString &operator =(SqString const &);
-    bool operator ==(SqString const &) const;
-    bool operator !=(SqString const &) const;
-    bool operator >=(SqString const &) const;
-    bool operator <=(SqString const &) const;
-    bool operator >(SqString const &) const;
-    bool operator <(SqString const &) const;
-
-    _SQUID_INLINE_ int size() const;
-    _SQUID_INLINE_ char const * c_str() const;
-
-    const char& operator [](unsigned int) const;
-    char& operator [](unsigned int);
-
-    void clear();
-
-    void append(char const *buf, int len);
-    void append(char const *buf);
-    void append(char const);
-    void append(SqString const &);
-
-    _SQUID_INLINE_ bool empty() const;
-    _SQUID_INLINE_ int compare(char const *) const;
-    _SQUID_INLINE_ int compare(char const *, size_t count) const;
-    _SQUID_INLINE_ int compare(SqString const &) const;
-
-/* Custom Squid Operations available */
-    /// Super-efficient string assignment. Moves internal content from one object to another.
-    /// then resets the initial pobject to empty.
-    _SQUID_INLINE_ void absorb(SqString &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_ 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
-
-    void limitInit(const char *str, unsigned int len);
-private:
-    void initBuf(size_t sz);
-    void init (char const *);
-
-    /* never reference these directly! */
-    unsigned short int size_;  /* buffer size; 64K limit */
-
-    unsigned short int len_;   /* current length  */
-
-    char *buf_;
-};
-
-#ifdef _USE_INLINE_
-#include "SqString.cci"
-#endif
-
-#endif /* SQSTRING_H */
-
index 9125ea6e67c997d34747ffda69a0e0104a102a86..198637fcf526aefe2c7d9e78be77b852adfe2189 100644 (file)
@@ -1,9 +1,9 @@
 
 /*
- * $Id: SquidString.h,v 1.9 2007/05/18 06:41:23 amosjeffries Exp $
+ * $Id: SquidString.h,v 1.10 2007/05/29 13:31:38 amosjeffries Exp $
  *
  * DEBUG: section 67    String
- * AUTHOR: Duane Wessels, Amos Jeffries
+ * AUTHOR: Duane Wessels
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
  * ----------------------------------------------------------
  *
  */
 
-/**
- *
- *  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
 
-    /* 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                       */
+/* 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 *);
+
+private:
+    static OBJH Stat;
 
-#include "SqString.h"
-typedef SqString string;
+    static StringRegistry Instance_;
 
+    static SplayNode<String const *>::SPLAYWALKEE Stater;
 
-    /* Overload standard C functions using the basic string API */
+    Splay<String const *> 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
+{
 
-inline std::ostream& operator <<(std::ostream &os, const string &s) { os << s.c_str(); return os; }
+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
 
 #endif /* SQUID_STRING_H */
+
+
index ec504634fe47151a83c334f6086eb6ca1c5a7fcf..a501719675c63c9584656059e6ecbb51e7da3e0f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: Store.h,v 1.34 2007/05/18 06:41:23 amosjeffries Exp $
+ * $Id: Store.h,v 1.35 2007/05/29 13:31:38 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 */
index 57ed33da9314866f11730c12c403c351b86fdfe6..8c9c647eb0dd9cf9a1d6c4bb3ed90795adaabef3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: StoreHashIndex.h,v 1.3 2007/05/18 06:41:23 amosjeffries Exp $
+ * $Id: StoreHashIndex.h,v 1.4 2007/05/29 13:31:38 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 */
similarity index 60%
rename from src/SqString.cc
rename to src/String.cc
index 69ad2e7928e7d078ae4e7d7e294ef364e04dfe2b..5fa2e5c3a5812344179c447dcc735f0ae1add0f1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: SqString.cc,v 1.7 2007/05/22 01:15:55 hno Exp $
+ * $Id: String.cc,v 1.26 2007/05/29 13:31:38 amosjeffries Exp $
  *
  * DEBUG: section 67    String
  * AUTHOR: Duane Wessels
  */
 
 #include "squid.h"
-#include "SqString.h"
 #include "Store.h"
 
 void
-SqString::initBuf(size_t sz)
+String::initBuf(size_t sz)
 {
-    size_t bsz;
     PROF_start(StringInitBuf);
-    clear();
+    buf((char *)memAllocString(sz, &sz));
     assert(sz < 65536);
-    buf_ = (char *)memAllocString(sz, &bsz);
-    assert(bsz < 65536);
-    assert(bsz >= sz);
-    size_ = bsz;
+    size_ = sz;
     PROF_stop(StringInitBuf);
 }
 
 void
-SqString::limitInit(const char *str, unsigned int len)
-{
-    PROF_start(StringLimitInit);
-    assert(this && str);
-    initBuf(len + 1);
-    len_ = len;
-    xmemcpy(buf_, str, len);
-    buf_[len] = '\0';
-    PROF_stop(StringLimitInit);
-}
-
-void
-SqString::init(char const *str)
+String::init(char const *str)
 {
     assert(this);
 
     PROF_start(StringInit);
-
     if (str)
         limitInit(str, strlen(str));
     else
-        clear();
+        clean();
     PROF_stop(StringInit);
 }
 
-void
-SqString::clear()
+String::String (char const *aString) : size_(0), len_(0), buf_(NULL)
 {
-    PROF_start(StringClean);
-    assert(this);
-
-    if (buf_)
-        memFreeString(size_, buf_);
-
-    len_ = 0;
-    size_ = 0;
-    buf_ = NULL;
-    PROF_stop(StringClean);
-}
-
-SqString::~SqString()
-{
-    clear();
-#if DEBUGSTRINGS
-
-    SqStringRegistry::Instance().remove(this);
-#endif
-}
-
-SqString::SqString (char const *aString)
-{
-    memset(this, 0, sizeof(SqString));
-
-    init(aString);
+    init (aString);
 #if DEBUGSTRINGS
 
-    SqStringRegistry::Instance().add(this);
+    StringRegistry::Instance().add(this);
 #endif
 }
 
-SqString &
-SqString::operator =(char const *aString)
+String &
+String::operator =(char const *aString)
 {
-    assert(this);
-    init(aString);
+    clean();
+    init (aString);
     return *this;
 }
 
-SqString &
-SqString::operator = (SqString const &old)
+String &
+String::operator = (String const &old)
 {
-    if (old.size())
-        limitInit(old.c_str(), old.size());
-    else
-        clear();
+    clean ();
+
+    if (old.len_)
+        limitInit (old.buf(), old.len_);
 
     return *this;
 }
 
 bool
-SqString::operator == (SqString const &that) const
+String::operator == (String const &that) const
 {
-    return (this->compare(that) == 0);
-}
+    if (0 == this->cmp(that))
+        return true;
 
-bool
-SqString::operator != (SqString const &that) const
-{
-    return (this->compare(that) != 0);
+    return false;
 }
 
 bool
-SqString::operator >= (SqString const &that) const
+String::operator != (String const &that) const
 {
-    return (this->compare(that) >= 0);
+    if (0 == this->cmp(that))
+        return false;
+
+    return true;
 }
 
-bool
-SqString::operator <= (SqString const &that) const
+void
+String::limitInit(const char *str, int len)
 {
-    return (this->compare(that) <= 0);
+    PROF_start(StringLimitInit);
+    assert(this && str);
+    initBuf(len + 1);
+    len_ = len;
+    xmemcpy(buf_, str, len);
+    buf_[len] = '\0';
+    PROF_stop(StringLimitInit);
 }
 
-bool
-SqString::operator > (SqString const &that) const
+String::String (String const &old) : size_(0), len_(0), buf_(NULL)
 {
-    return (this->compare(that) > 0);
+    init (old.buf());
+#if DEBUGSTRINGS
+
+    StringRegistry::Instance().add(this);
+#endif
 }
 
-bool
-SqString::operator < (SqString const &that) const
+void
+String::clean()
 {
-    return (this->compare(that) < 0);
+    PROF_start(StringClean);
+    assert(this);
+
+    if (buf())
+        memFreeString(size_, buf_);
+
+    len_ = 0;
+
+    size_ = 0;
+
+    buf_ = NULL;
+    PROF_stop(StringClean);
 }
 
-SqString::SqString (SqString const &old)
+String::~String()
 {
-    memset(this, 0, sizeof(SqString));
-
-    operator=(old);
+    clean();
 #if DEBUGSTRINGS
 
-    SqStringRegistry::Instance().add(this);
+    StringRegistry::Instance().remove(this);
 #endif
 }
 
 void
-SqString::append(const char *str, int len)
+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 < 1 || str == NULL)
-        return;
-
-    if ( (len_ + len +1) < size_) {
-        operator[](len_+len) = '\0';
-        xmemcpy(buf_+len_, str, len);
+    if (len_ + len < size_) {
+        strncat(buf_, str, len);
         len_ += len;
     } else {
-        size_t ssz = len_ + len;
-        size_t bsz = len_ + len + 1;
-        char* tmp = (char *)memAllocString(bsz, &bsz);
-        assert(bsz < 65536);
-        assert(bsz > ssz);
+        String snew;
+        snew.len_ = len_ + len;
+        snew.initBuf(snew.len_ + 1);
 
         if (buf_)
-            xmemcpy(tmp, buf_, len_);
+            xmemcpy(snew.buf_, buf(), len_);
 
         if (len)
-            xmemcpy(tmp + len_, str, len);
-
-        tmp[ssz] = '\0';
+            xmemcpy(snew.buf_ + len_, str, len);
 
-        clear();
+        snew.buf_[snew.len_] = '\0';
 
-        size_ = bsz;
-        len_ = ssz;
-        buf_ = tmp;
-        tmp = NULL;
+        absorb(snew);
     }
     PROF_stop(StringAppend);
 }
 
 void
-SqString::append(char const *str)
+String::append(char const *str)
 {
-    if(!str) return;
+    assert (str);
     append (str, strlen(str));
 }
 
 void
-SqString::append (char chr)
+String::append (char chr)
 {
     char myString[2];
     myString[0]=chr;
@@ -234,36 +206,39 @@ SqString::append (char chr)
 }
 
 void
-SqString::append(SqString const &old)
+String::append(String const &old)
 {
-    append (old.c_str(), old.size());
+    append (old.buf(), old.len_);
 }
 
-const char&
-SqString::operator [](unsigned int pos) const
+void
+String::absorb(String &old)
 {
-    assert(pos < size_ );
-
-    return buf_[pos];
+    clean();
+    size_ = old.size_;
+    buf (old.buf_);
+    len_ = old.len_;
+    old.size_ = 0;
+    old.buf_ = NULL;
+    old.len_ = 0;
 }
 
-char&
-SqString::operator [](unsigned int pos)
+void
+String::buf(char *newBuf)
 {
-    assert(pos < size_ );
-
-    return buf_[pos];
+    assert (buf_ == NULL);
+    buf_ = newBuf;
 }
 
 #if DEBUGSTRINGS
 void
-SqString::stat(StoreEntry *entry) const
+String::stat(StoreEntry *entry) const
 {
-    storeAppendPrintf(entry, "%p : %d/%d \"%s\"\n",this,len_, size_, c_str());
+    storeAppendPrintf(entry, "%p : %d/%d \"%s\"\n",this,len_, size_, buf());
 }
 
-SqStringRegistry &
-SqStringRegistry::Instance()
+StringRegistry &
+StringRegistry::Instance()
 {
     return Instance_;
 }
@@ -276,37 +251,41 @@ ptrcmp(C const &lhs, C const &rhs)
 }
 
 void
-SqStringRegistry::registerWithCacheManager(CacheManager & manager)
+StringRegistry::registerWithCacheManager(CacheManager & manager)
 {
     manager.registerAction("strings",
                            "Strings in use in squid", Stat, 0, 1);
 }
 
 void
-SqStringRegistry::add(SqString const *entry)
+
+StringRegistry::add
+    (String const *entry)
 {
     entries.insert(entry, ptrcmp);
 }
 
 void
-SqStringRegistry::remove(SqString const *entry)
+
+StringRegistry::remove
+    (String const *entry)
 {
     entries.remove(entry, ptrcmp);
 }
 
-SqStringRegistry SqStringRegistry::Instance_;
+StringRegistry StringRegistry::Instance_;
 
 extern size_t memStringCount();
 
 void
-SqStringRegistry::Stat(StoreEntry *entry)
+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
-SqStringRegistry::Stater(SqString const * const & nodedata, void *state)
+StringRegistry::Stater(String const * const & nodedata, void *state)
 {
     StoreEntry *entry = (StoreEntry *) state;
     nodedata->stat(entry);
@@ -314,6 +293,30 @@ SqStringRegistry::Stater(SqString const * const & nodedata, void *state)
 
 #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
@@ -399,6 +402,12 @@ error:
     return (char *) word;
 }
 
+const char *
+checkNullString(const char *p)
+{
+    return p ? p : "(NULL)";
+}
+
 #ifndef _USE_INLINE_
-#include "SqString.cci"
+#include "String.cci"
 #endif
similarity index 63%
rename from src/SqString.cci
rename to src/String.cci
index 2031b2874fb7b9f056e9462d4eadcd03e293a595..e1995e46bc6e4eb1d18a73748fd1607e0d617f1d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: SqString.cci,v 1.2 2007/05/19 06:49:12 amosjeffries Exp $
+ * $Id: String.cci,v 1.9 2007/05/29 13:31:38 amosjeffries Exp $
  *
  * DEBUG: section 67    String
  * AUTHOR: Duane Wessels
  *
  */
 
-SqString::SqString() : size_(0), len_(0), buf_ (NULL)
+String::String() : size_(0), len_(0), buf_ (NULL)
 {
 #if DEBUGSTRINGS
-    SqStringRegistry::Instance().add(this);
+    StringRegistry::Instance().add(this);
 #endif
 }
 
-void
-SqString::absorb(SqString &old)
-{
-    clear();
-    size_ = old.size_;
-    buf_ = old.buf_;
-    len_ = old.len_;
-    old.size_ = 0;
-    old.buf_ = NULL;
-    old.len_ = 0;
-}
-
 int
-SqString::size() const
+String::size() const
 {
     return len_;
 }
 
 char const *
-SqString::c_str() const
+String::buf() const
 {
     return buf_;
 }
 
 const char *
-SqString::pos(char const *aString) const
+String::pos(char const *aString) const
 {
-    return strstr(c_str(), aString);
+    return strstr(buf(), aString);
 }
 
 const char *
-SqString::pos(char const ch) const
+String::pos(char const ch) const
 {
-    return strchr(c_str(), ch);
+    return strchr(buf(), ch);
 }
 
 const char *
-SqString::rpos(char const ch) const
-{
-    return strrchr(c_str(), ch);
-}
-
-bool
-SqString::empty() const
+String::rpos(char const ch) const
 {
-    return (buf_ == NULL || len_ == 0);
+    return strrchr(buf(), (ch));
 }
 
 int
-SqString::compare(char const *aString) const
+String::cmp (char const *aString) const
 {
     /* strcmp fails on NULLS */
 
@@ -102,11 +84,11 @@ SqString::compare(char const *aString) const
     if (aString == NULL || aString[0] == '\0')
         return 1;
 
-    return strcmp(c_str(), aString);
+    return strcmp(buf(), aString);
 }
 
 int
-SqString::compare(char const *aString, size_t count) const
+String::cmp (char const *aString, size_t count) const
 {
     /* always the same at length 0 */
 
@@ -122,11 +104,11 @@ SqString::compare(char const *aString, size_t count) const
     if (aString == NULL || aString[0] == '\0')
         return 1;
 
-    return strncmp(c_str(), aString, count);
+    return strncmp(buf(), aString, count);
 }
 
 int
-SqString::compare(SqString const &aString) const
+String::cmp (String const &aString) const
 {
     /* strcmp fails on NULLS */
 
@@ -139,25 +121,49 @@ SqString::compare(SqString const &aString) const
     if (aString.size() == 0)
         return 1;
 
-    return strcmp(c_str(), aString.c_str());
+    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
-SqString::set (char const *loc, char const ch)
+String::set (char const *loc, char const ch)
 {
-    operator[](loc-buf_) = ch;
+    buf_[loc-buf_] = ch;
 }
 
+/* FIXME: this is can perform buffer overflows and underflows! */
 void
-SqString::cut (size_t newLength)
+String::cut (size_t newLength)
 {
-    operator[](newLength) = '\0';
     len_ = newLength;
+    buf_[newLength] = '\0';
 }
 
+/* FIXME: this is can perform buffer overflows and underflows! */
 void
-SqString::cutPointer (char const *loc)
+String::cutPointer (char const *loc)
 {
-    operator[](loc-buf_) = '\0';
     len_ = loc-buf_;
+    buf_[len_] = '\0';
 }
+
+std::ostream &
+operator<<(std::ostream& os, String const &aString)
+{
+    os << aString.buf();
+    return os;
+}
+
+
index 8b0eb8e4d98ce3f6f60f313ed67199ab3d17059b..d23999c054c15e4f18bfaf98a4698248f73363ab 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: SwapDir.cc,v 1.12 2007/05/18 06:41:23 amosjeffries Exp $
+ * $Id: SwapDir.cc,v 1.13 2007/05/29 13:31:38 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");
 }
index dcd53137b220dffc319c095e905afc68edcd8f78..a76f04d655d147b0d5edf17031719188596dda66 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: SwapDir.h,v 1.12 2007/05/18 06:41:23 amosjeffries Exp $
+ * $Id: SwapDir.h,v 1.13 2007/05/29 13:31:38 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);
 
index a1fd201473a113a752573a689a0b18fabb86f2f3..48d4bf08bb6eba097a649ae52e58c56b0cd5935b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: access_log.cc,v 1.125 2007/05/18 06:41:23 amosjeffries Exp $
+ * $Id: access_log.cc,v 1.126 2007/05/29 13:31:38 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.c_str();
+            out = sb.buf();
 
             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.c_str();
+            out = sb.buf();
 
             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.c_str();
+            out = sb.buf();
 
             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.c_str();
+            out = sb.buf();
 
             quote = 1;
 
@@ -767,7 +767,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log)
 
         case LFT_REQUEST_URLPATH:
            if (al->request) {
-               out = al->request->urlpath.c_str();
+               out = al->request->urlpath.buf();
                quote = 1;
            }
             break;
@@ -813,7 +813,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log)
 
         case LFT_TAG:
             if (al->request)
-                out = al->request->tag.c_str();
+                out = al->request->tag.buf();
 
             quote = 1;
 
@@ -821,7 +821,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log)
 
         case LFT_EXT_LOG:
             if (al->request)
-                out = al->request->extacl_log.c_str();
+                out = al->request->extacl_log.buf();
 
             quote = 1;
 
@@ -891,7 +891,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log)
         if (fmt->space)
             mb.append(" ", 1);
 
-        sb.clear();
+        sb.clean();
 
         if (dofree)
             safe_free(out);
@@ -1631,8 +1631,8 @@ accessLogTime(time_t t)
 static void
 fvdbInit(void)
 {
-    via_table = hash_create((HASHCMP *) std::strcmp, 977, hash4);
-    forw_table = hash_create((HASHCMP *) std::strcmp, 977, hash4);
+    via_table = hash_create((HASHCMP *) strcmp, 977, hash4);
+    forw_table = hash_create((HASHCMP *) strcmp, 977, hash4);
 }
 
 static void
@@ -1717,10 +1717,10 @@ fvdbClear(void)
 {
     hashFreeItems(via_table, fvdbFreeEntry);
     hashFreeMemory(via_table);
-    via_table = hash_create((HASHCMP *) std::strcmp, 977, hash4);
+    via_table = hash_create((HASHCMP *) strcmp, 977, hash4);
     hashFreeItems(forw_table, fvdbFreeEntry);
     hashFreeMemory(forw_table);
-    forw_table = hash_create((HASHCMP *) std::strcmp, 977, hash4);
+    forw_table = hash_create((HASHCMP *) strcmp, 977, hash4);
 }
 
 #endif
index ee75fca8d8183f2d37b65dafcbcb6da2e70acda6..4b377cb04402329f3d15a0400a41f5078b5a13fc 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: auth_digest.cc,v 1.56 2007/05/18 06:41:31 amosjeffries Exp $
+ * $Id: auth_digest.cc,v 1.57 2007/05/29 13:31:46 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 *) std::strcmp, 7921, hash_string);
+        digest_nonce_cache = hash_create((HASHCMP *) 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.clear();
+    temp.clean();
 
 
     /* now we validate the data given to us */
index e70c6fd6620bdd3b83b7487d43d0e1407aa9a8df..ffd7ffdc78cc82470e40f3c348562193327cce58 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: auth_negotiate.cc,v 1.19 2007/05/18 06:41:31 amosjeffries Exp $
+ * $Id: auth_negotiate.cc,v 1.20 2007/05/29 13:31:46 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 *) std::strcmp, 7921, hash_string);
+            proxy_auth_cache = hash_create((HASHCMP *) strcmp, 7921, hash_string);
 
         assert(proxy_auth_cache);
 
index 80dd7fcf6d377a0ea496d3a5ce57d95c0948a8da..86d403e587b5391c89d7dced53104c9e81e204c6 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: auth_ntlm.cc,v 1.69 2007/05/18 06:41:32 amosjeffries Exp $
+ * $Id: auth_ntlm.cc,v 1.70 2007/05/29 13:31:46 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 *) std::strcmp, 7921, hash_string);
+            proxy_auth_cache = hash_create((HASHCMP *) strcmp, 7921, hash_string);
 
         assert(proxy_auth_cache);
 
index c464f7d4c9da6e8bcd371b94b3048aeb7cab3def..25b86e97e8ab521bce9baf01f493c7f0c1fa9b0f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.511 2007/05/18 06:41:23 amosjeffries Exp $
+ * $Id: cache_cf.cc,v 1.512 2007/05/29 13:31:38 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 = token;
+    var->reset(token);
 }
 
 static void
index b5369119029c2316fce9cf6cf6910f915d99a0e9..ee77f5d48afddd10787b2dde3c7530a92422461b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_db.cc,v 1.69 2007/05/18 06:41:23 amosjeffries Exp $
+ * $Id: client_db.cc,v 1.70 2007/05/29 13:31:39 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 *) std::strcmp, CLIENT_DB_HASH_SIZE, hash_string);
+    client_table = hash_create((HASHCMP *) strcmp, CLIENT_DB_HASH_SIZE, hash_string);
 }
 
 void
index 309a2734017b721d8c962aff7022f6b559750ca4..ebe6838b4cea0305c7c2040f9604bc3fa93132c1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.755 2007/05/18 18:30:41 wessels Exp $
+ * $Id: client_side.cc,v 1.756 2007/05/29 13:31:39 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.c_str();
+    aLogEntry->cache.extuser = request->extacl_user.buf();
 
     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.c_str();
+            al.http.content_type = al.reply->content_type.buf();
         } 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.c_str();
+            al.http.content_type = loggingEntry()->mem_obj->getReply()->content_type.buf();
         }
 
         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.clear();
+    range_iter.boundary.clean();
     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.c_str());
+    mb->Printf("\r\n--%s--\r\n", boundary.buf());
     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,9 +839,10 @@ clientPackRangeHdr(const HttpReply * rep, const HttpHdrRangeSpec * spec, string
     assert(spec);
 
     /* put boundary */
-    debugs(33, 5, "clientPackRangeHdr: appending boundary: " << boundary);
+    debugs(33, 5, "clientPackRangeHdr: appending boundary: " <<
+           boundary.buf());
     /* rfc2046 requires to _prepend_ boundary with <crlf>! */
-    mb->Printf("\r\n--%s\r\n", boundary.c_str());
+    mb->Printf("\r\n--%s\r\n", boundary.buf());
 
     /* stuff the header with required entries and pack it */
 
@@ -1033,12 +1034,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));
@@ -1150,7 +1151,7 @@ ClientSocketContext::buildRangeHeader(HttpReply * rep)
             hdr->delById(HDR_CONTENT_TYPE);
             httpHeaderPutStrf(hdr, HDR_CONTENT_TYPE,
                               "multipart/byteranges; boundary=\"%s\"",
-                              http->range_iter.boundary.c_str());
+                              http->range_iter.boundary.buf());
             /* Content-Length is not required in multipart responses
              * but it is always nice to have one */
             actual_clen = http->mRangeCLen();
@@ -2183,11 +2184,11 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC
     request->flags.tproxy = conn->port->tproxy;
 #endif
 
-    if (internalCheck(request->urlpath.c_str())) {
+    if (internalCheck(request->urlpath.buf())) {
         if (internalHostnameIs(request->host) &&
                 request->port == getMyPort()) {
             http->flags.internal = 1;
-        } else if (Config.onoff.global_internal_static && internalStaticCheck(request->urlpath.c_str())) {
+        } else if (Config.onoff.global_internal_static && internalStaticCheck(request->urlpath.buf())) {
             xstrncpy(request->host, internalHostname(),
                      SQUIDHOSTNAMELEN);
             request->port = getMyPort();
index cbd61075cc1c72e8ca7c7a0899ebd6e66324e890..aeda2da45e0095c9ebb7686e8e3ae88f9feec018 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side_reply.cc,v 1.128 2007/05/18 18:30:41 wessels Exp $
+ * $Id: client_side_reply.cc,v 1.129 2007/05/29 13:31:39 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.c_str();
+                const char *value = e->value.buf();
 
                 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.c_str());
+        hdr->putStr(HDR_VIA, strVia.buf());
     }
     /* Signal keep-alive if needed */
     hdr->putStr(http->flags.accel ? HDR_CONNECTION : HDR_PROXY_CONNECTION,
index 08d269c30daa8756e103f5fddb186b867f5c4a8a..8601ccda695cc2de4495508bb34c645d991fdbf2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side_request.cc,v 1.88 2007/05/26 06:38:04 wessels Exp $
+ * $Id: client_side_request.cc,v 1.89 2007/05/29 13:31:39 amosjeffries Exp $
  * 
  * DEBUG: section 85    Client-side Request Routines
  * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c)
@@ -628,10 +628,12 @@ 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)
@@ -710,7 +712,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
@@ -724,11 +726,11 @@ clientInterpretRequestHeaders(ClientHttpRequest * http)
         }
 
 #if FORW_VIA_DB
-        fvdbCountVia(s.c_str());
+        fvdbCountVia(s.buf());
 
 #endif
 
-        s.clear();
+        s.clean();
     }
 
 #if USE_USERAGENT_LOG
@@ -745,9 +747,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.c_str());
-        s.clear();
+        String s = req_hdr->getList(HDR_X_FORWARDED_FOR);
+        fvdbCountForw(s.buf());
+        s.clean();
     }
 
 #endif
index eace249c17fbf75cf16d5cd62c9e43a563397f11..1f3c26ef2368f29e6b29b2a888730f843558f915 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side_request.h,v 1.29 2007/05/18 06:41:23 amosjeffries Exp $
+ * $Id: client_side_request.h,v 1.30 2007/05/29 13:31:39 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();
index f5012805767a9a9396c9149d9e639bd9259e4b36..b65a959c6be30de662d3e672da5244a72b7f1748 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: dns_internal.cc,v 1.99 2007/05/18 06:41:24 amosjeffries Exp $
+ * $Id: dns_internal.cc,v 1.100 2007/05/29 13:31:39 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 *) std::strcmp, 103, hash_string);
+        idns_lookup_hash = hash_create((HASHCMP *) strcmp, 103, hash_string);
         init++;
     }
 }
index 70f36ebdb51165a8f2683cefda86806b5978a400..22d07f3e0dff9b9f16571ed5069a8a14e0acea49 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: errorpage.cc,v 1.226 2007/05/18 06:41:24 amosjeffries Exp $
+ * $Id: errorpage.cc,v 1.227 2007/05/29 13:31:39 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.c_str() : "/",
+                   r->urlpath.size() ? r->urlpath.buf() : "/",
                    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.c_str() : "/",
+                      r->urlpath.size() ? r->urlpath.buf() : "/",
                       r->http_ver.major, r->http_ver.minor);
             packerToMemInit(&p, &mb);
             r->header.packInto(&p);
index 2066b1599611782bfcb3dc22541d47be96583c82..81b979cfe9be2d8fa10341046397d600430f0f30 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: external_acl.cc,v 1.79 2007/05/22 01:16:40 hno Exp $
+ * $Id: external_acl.cc,v 1.80 2007/05/29 13:31:39 amosjeffries Exp $
  *
  * DEBUG: section 82    External ACL
  * AUTHOR: Henrik Nordstrom, MARA Systems AB
@@ -693,7 +693,7 @@ aclMatchExternal(external_acl_data *acl, ACLChecklist * ch)
 
     external_acl_cache_touch(acl->def, entry);
     result = entry->result;
-    external_acl_message = entry->message.c_str();
+    external_acl_message = entry->message.buf();
 
     debugs(82, 2, "aclMatchExternal: " << acl->def->name << " = " << result);
 
@@ -763,7 +763,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) {
 
@@ -820,7 +820,7 @@ makeExternalAclKey(ACLChecklist * ch, external_acl_data * acl_data)
             break;
 
         case _external_acl_format::EXT_ACL_PATH:
-            str = request->urlpath.c_str();
+            str = request->urlpath.buf();
             break;
 
         case _external_acl_format::EXT_ACL_METHOD:
@@ -829,22 +829,22 @@ makeExternalAclKey(ACLChecklist * ch, external_acl_data * acl_data)
 
         case _external_acl_format::EXT_ACL_HEADER:
             sb = request->header.getByName(format->header);
-            str = sb.c_str();
+            str = sb.buf();
             break;
 
         case _external_acl_format::EXT_ACL_HEADER_ID:
             sb = request->header.getStrOrList(format->header_id);
-            str = sb.c_str();
+            str = sb.buf();
             break;
 
         case _external_acl_format::EXT_ACL_HEADER_MEMBER:
             sb = request->header.getByNameListMember(format->header, format->member, format->separator);
-            str = sb.c_str();
+            str = sb.buf();
             break;
 
         case _external_acl_format::EXT_ACL_HEADER_ID_MEMBER:
             sb = request->header.getListMember(format->header_id, format->member, format->separator);
-            str = sb.c_str();
+            str = sb.buf();
             break;
 #if USE_SSL
 
@@ -894,7 +894,7 @@ makeExternalAclKey(ACLChecklist * ch, external_acl_data * acl_data)
 #endif
 
         case _external_acl_format::EXT_ACL_EXT_USER:
-            str = request->extacl_user.c_str();
+            str = request->extacl_user.buf();
             break;
 
         case _external_acl_format::EXT_ACL_UNKNOWN:
@@ -921,7 +921,7 @@ makeExternalAclKey(ACLChecklist * ch, external_acl_data * acl_data)
             strwordquote(&mb, str);
         }
 
-        sb.clear();
+        sb.clean();
 
         first = 0;
     }
@@ -1244,8 +1244,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 << " tag=" <<
-                   entry->tag << " log=" << entry->log << " }");
+                   entry->result << ", user=" << entry->user.buf() << " tag=" <<
+                   entry->tag.buf() << " log=" << entry->log.buf() << " }");
 
         }
 
@@ -1278,7 +1278,7 @@ externalAclInit(void)
 
     for (p = Config.externalAclHelperList; p; p = p->next) {
         if (!p->cache)
-            p->cache = hash_create((HASHCMP *) std::strcmp, hashPrime(1024), hash4);
+            p->cache = hash_create((HASHCMP *) strcmp, hashPrime(1024), hash4);
 
         if (!p->theHelper)
             p->theHelper = helperCreate(p->name);
index 0c53c999edf087b0ccc5749f96ef152450b7ccd2..125327d2426d5aea295dfda708fc39738ca337ab 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: fqdncache.cc,v 1.172 2007/05/18 06:41:24 amosjeffries Exp $
+ * $Id: fqdncache.cc,v 1.173 2007/05/29 13:31:39 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 *) std::strcmp, n, hash4);
+    fqdn_table = hash_create((HASHCMP *) strcmp, n, hash4);
 
     memDataInit(MEM_FQDNCACHE_ENTRY, "fqdncache_entry",
                 sizeof(fqdncache_entry), 0);
index 9f3ca13f62aae0cfd8d0f28ccaf174c304d7e4ea..fdbda43fc5f7fd2e3e11db852697cafff7f620f9 100644 (file)
@@ -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;
index ba3cf361aab4fe09c16d80a7f5f15bb8b994f851..d52ef64b55d32eb6a784002fa3ecf7839dc21c52 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_coss.cc,v 1.74 2007/05/18 06:41:32 amosjeffries Exp $
+ * $Id: store_dir_coss.cc,v 1.75 2007/05/29 13:31:47 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<CossSwapDir *>(this)->stripe_path = xstrdup(result.c_str());
+        const_cast<CossSwapDir *>(this)->stripe_path = xstrdup(result.buf());
     }
 
     return stripe_path;
index d02f07a144345d5d9ca57fb875776f0f7b3ad271..80f1a4c76f304034486041f1b0b1d0715c61246c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_null.cc,v 1.13 2007/05/18 06:41:32 amosjeffries Exp $
+ * $Id: store_null.cc,v 1.14 2007/05/29 13:31:47 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");
index 1f289df0530df01effdb4d692173c00ba9785a98..ea0c90b0b185102ef0b7ed627cecbb5893fbef20 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_null.h,v 1.4 2007/05/18 06:41:33 amosjeffries Exp $
+ * $Id: store_null.h,v 1.5 2007/05/29 13:31:47 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
index 6403e51de4c31ac133ceae5fe42772692b317dea..f70ac817140bbf68ac2e6a71b251e171cfe599de 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_ufs.cc,v 1.83 2007/05/18 06:41:33 amosjeffries Exp $
+ * $Id: store_dir_ufs.cc,v 1.84 2007/05/29 13:31:47 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");
index 2cc2ff9a3d554f235d2a9666f9201afa8be9e3d9..6fb02639d83ea1a254b440b7a41710505579ce3f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ufscommon.h,v 1.10 2007/05/18 06:41:33 amosjeffries Exp $
+ * $Id: ufscommon.h,v 1.11 2007/05/29 13:31:47 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;
index 6fb39843d9fc08c4b3c5128a90d4e77dc0215d51..578d2d4d51f90d1e6df332ca68687a2b7fe3d06a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.423 2007/05/18 06:41:24 amosjeffries Exp $
+ * $Id: ftp.cc,v 1.424 2007/05/29 13:31:39 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.clear();
+    title_url.clean();
 
-    base_href.clear();
+    base_href.clean();
 
     safe_free(filepath);
 
@@ -507,7 +507,7 @@ FtpStateData::listingStart()
     wordlist *w;
     char *dirup;
     int i, j, k;
-    const char *title = title_url.c_str();
+    const char *title = title_url.buf();
     flags.listing_started = true;
     printfReplyBody("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
     printfReplyBody("<!-- HTML listing generated by Squid %s -->\n",
@@ -526,7 +526,7 @@ FtpStateData::listingStart()
 
     if (flags.need_base_href)
         printfReplyBody("<BASE HREF=\"%s\">\n",
-                        html_quote(base_href.c_str()));
+                        html_quote(base_href.buf()));
 
     printfReplyBody("</HEAD><BODY>\n");
 
@@ -955,7 +955,7 @@ FtpStateData::htmlifyListEntry(const char *line)
             if (flags.dir_slash) {
                 url = xstrdup("./");
             } else {
-                const char *title = title_url.c_str();
+                const char *title = title_url.buf();
                 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.compare("/%2f/")) {
+    } else if (!request->urlpath.cmp("/%2f/")) {
         /* UNIX root directory */
         flags.isdir = 1;
         flags.root_dir = 1;
-    } else if ((l >= 1) && (*(request->urlpath.c_str() + l - 1) == '/')) {
+    } else if ((l >= 1) && (*(request->urlpath.buf() + 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 << ", user=" << user << ", passwd=" <<
+           request->urlpath.buf() << ", 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.c_str();
+            filename = t ? t + 1 : ftpState->request->urlpath.buf();
             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.c_str());
+        p = path = xstrdup(ftpState->request->urlpath.buf());
 
         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);
+                   ftpState->title_url.buf());
 
             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.c_str());
+    path = xstrdup(ftpState->request->urlpath.buf());
 
     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 */
-            strncasecmp(ftpState->request->urlpath, "/%2f", 4) != 0) { /* No slash encoded */
+            ftpState->request->urlpath.caseCmp("/%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.c_str();
+    filename = (t = urlpath.rpos('/')) ? t + 1 : urlpath.buf();
 
     if (flags.isdir) {
         mime_type = "text/html";
@@ -3272,7 +3272,7 @@ ftpUrlWith2f(const HttpRequest * request)
              request->host,
              portbuf,
              "/%2f",
-             request->urlpath.c_str());
+             request->urlpath.buf());
 
     if ((t = strchr(buf, '?')))
         *t = '\0';
index 0caff50f9aa87d6e6f48246d48242c177ea2a6ec..e0c7a9555819cc5b9852b3e01fcbef57de4beda3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: gopher.cc,v 1.208 2007/05/23 21:10:06 hno Exp $
+ * $Id: gopher.cc,v 1.209 2007/05/29 13:31:40 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.c_str();
+    const char *path = req->urlpath.buf();
 
     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.c_str(), outbuf.size());
+        entry->append(outbuf.buf(), outbuf.size());
         /* now let start sending stuff to client */
         entry->flush();
     }
 
-    outbuf.clear();
+    outbuf.clean();
     return;
 }
 
index 4bc7eec5d37f954af9d07045997809f07b4fbf46..2dc02bcb0766041d24327560a0a34e7664a3440f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.522 2007/05/18 06:41:24 amosjeffries Exp $
+ * $Id: http.cc,v 1.523 2007/05/29 13:31:40 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.c_str();
+            url = orig_request->urlpath.buf();
         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.clear();
+        s.clean();
 
         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.clear();
+    vstr.clean();
     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.clear();
+            vstr.clean();
             break;
         }
 
         strListAdd(&vstr, name, ',');
         hdr = request->header.getByName(name);
         safe_free(name);
-        value = hdr.c_str();
+        value = hdr.buf();
 
         if (value) {
             value = rfc1738_escape_part(value);
@@ -618,10 +618,10 @@ httpMakeVaryMark(HttpRequest * request, HttpReply const * reply)
             vstr.append("\"", 1);
         }
 
-        hdr.clear();
+        hdr.clean();
     }
 
-    vary.clear();
+    vary.clean();
 #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.c_str();
+        value = hdr.buf();
 
         if (value) {
             value = rfc1738_escape_part(value);
@@ -643,14 +643,14 @@ httpMakeVaryMark(HttpRequest * request, HttpReply const * reply)
             vstr.append("\"", 1);
         }
 
-        hdr.clear();
+        hdr.clean();
     }
 
-    vary.clear();
+    vary.clean();
 #endif
 
-    debugs(11, 3, "httpMakeVaryMark: " << vstr);
-    return vstr.c_str();
+    debugs(11, 3, "httpMakeVaryMark: " << vstr.buf());
+    return vstr.buf();
 }
 
 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.c_str());
-        strVia.clear();
+        hdr_out->putStr(HDR_VIA, strVia.buf());
+        strVia.clean();
     }
 
 #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.c_str());
+        hdr_out->putStr(HDR_SURROGATE_CAPABILITY, strSurrogate.buf());
     }
 #endif
 
@@ -1419,9 +1419,9 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
     else
         strListAdd(&strFwd, "unknown", ',');
 
-    hdr_out->putStr(HDR_X_FORWARDED_FOR, strFwd.c_str());
+    hdr_out->putStr(HDR_X_FORWARDED_FOR, strFwd.buf());
 
-    strFwd.clear();
+    strFwd.clean();
 
     /* 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.c_str();
+                username = orig_request->extacl_user.buf();
 
             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.c_str(), orig_request->extacl_passwd.c_str());
+                snprintf(loginbuf, sizeof(loginbuf), "%s:%s", orig_request->extacl_user.buf(), orig_request->extacl_passwd.buf());
                 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.c_str(), orig_request->extacl_passwd.c_str());
+                snprintf(loginbuf, sizeof(loginbuf), "%s:%s", orig_request->extacl_user.buf(), orig_request->extacl_passwd.buf());
                 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.c_str();
+                username = orig_request->extacl_user.buf();
 
             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.c_str()));
+                assert(strstr(url, request->urlpath.buf()));
         }
 
         /* 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.clear();
+    strConnection.clean();
 }
 
 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 << ": " << e->value);
+    debugs(11, 5, "httpBuildRequestHeader: " << e->name.buf() << ": " << e->value.buf());
 
     if (!httpRequestHdrAllowed(e, &strConnection)) {
-        debugs(11, 2, "'" << e->name << "' header denied by anonymize_headers configuration");
+        debugs(11, 2, "'" << e->name.buf() << "' 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.c_str() : "/",
+               request->urlpath.size() ? request->urlpath.buf() : "/",
                httpver.major,httpver.minor);
     /* build and pack headers */
     {
index 0f9e3ef6b7b25e845305124cb90c07275802e1a0..7669782ed64f76105b0042bcf8ce9bb360744c3b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ident.cc,v 1.76 2007/05/18 06:41:24 amosjeffries Exp $
+ * $Id: ident.cc,v 1.77 2007/05/29 13:31:40 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 *) std::strcmp,
+    ident_hash = hash_create((HASHCMP *) strcmp,
                              hashPrime(Squid_MaxFD / 8),
                              hash4);
 }
index de729e90eac1c32589be70cfd3a5b787df74cae2..472270928f841fb26a8b2bae3a666fbcb966cf19 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: internal.cc,v 1.46 2007/05/18 06:41:24 amosjeffries Exp $
+ * $Id: internal.cc,v 1.47 2007/05/29 13:31:40 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.c_str();
+    const char *upath = request->urlpath.buf();
     debugs(76, 3, "internalStart: " << inet_ntoa(request->client_addr) << " requesting '" << upath << "'");
 
     if (0 == strcmp(upath, "/squid-internal-dynamic/netdb")) {
index c799bfab0f3ce0481fd49b177de54583dc7c7111..f3d5dfc8cc5b2060b0f23575d5ae97707ae2b5fe 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ipcache.cc,v 1.260 2007/05/18 06:41:24 amosjeffries Exp $
+ * $Id: ipcache.cc,v 1.261 2007/05/29 13:31:40 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 *) std::strcmp, n, hash4);
+    ip_table = hash_create((HASHCMP *) strcmp, n, hash4);
     memDataInit(MEM_IPCACHE_ENTRY, "ipcache_entry", sizeof(ipcache_entry), 0);
 }
 
index 0a5b26a1f43f9fdaf97404828d273a7e42a027bc..c332df926445d8109f83ab6c6b5f2e6b86f80c2a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: net_db.cc,v 1.195 2007/05/18 06:41:25 amosjeffries Exp $
+ * $Id: net_db.cc,v 1.196 2007/05/29 13:31:40 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 *) std::strcmp, n, hash_string);
+    addr_table = hash_create((HASHCMP *) strcmp, n, hash_string);
 
     n = hashPrime(3 * Config.Netdb.high / 4);
 
-    host_table = hash_create((HASHCMP *) std::strcmp, n, hash_string);
+    host_table = hash_create((HASHCMP *) strcmp, n, hash_string);
 
     eventAddIsh("netdbSaveState", netdbSaveState, NULL, 3600.0, 1);
 
index 5a1dbcad2a277da9ae71ae613783b3f25daaf8fc..d6d3f5f25f8286c6cbd0a5a259c50e692bc0adda 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: pconn.cc,v 1.52 2007/05/18 06:41:25 amosjeffries Exp $
+ * $Id: pconn.cc,v 1.53 2007/05/29 13:31:40 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 *) std::strcmp, 229, hash_string);
+    table = hash_create((HASHCMP *) strcmp, 229, hash_string);
 
     for (i = 0; i < PCONN_HIST_SZ; i++)
         hist[i] = 0;
index bc06bb54924c05a14f718bf7b9e02db8fe2016f5..6b4caadda34fc5e8cf86256f12fbf1a992df7b82 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: peer_digest.cc,v 1.124 2007/05/18 06:41:25 amosjeffries Exp $
+ * $Id: peer_digest.cc,v 1.125 2007/05/29 13:31:40 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.clear();
+    pd->host.clean();
 }
 
 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 << " in " << delay << " secs");
+    debugs(72, 3, "peerDigestSetCheck: will check peer " << pd->host.buf() << " in " << delay << " secs");
 }
 
 /*
@@ -241,10 +241,10 @@ void
 peerDigestNotePeerGone(PeerDigest * pd)
 {
     if (pd->flags.requested) {
-        debugs(72, 2, "peerDigest: peer " << pd->host << " gone, will destroy after fetch.");
+        debugs(72, 2, "peerDigest: peer " << pd->host.buf() << " gone, will destroy after fetch.");
         /* do nothing now, the fetching chain will notice and take action */
     } else {
-        debugs(72, 2, "peerDigest: peer " << pd->host << " is gone, destroying now.");
+        debugs(72, 2, "peerDigest: peer " << pd->host.buf() << " 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 <<
+        debugs(72, 2, "peerDigestCheck: " << pd->host.buf() <<
                ", 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 <<
+        debugs(72, 2, "peerDigestCheck: " << pd->host.buf() <<
                ", 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 << " status: " << status << 
+        debugs(72, 3, "peerDigestFetchReply: " << pd->host.buf() << " 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 <<
+            debugs(72, 1, "peerDigestSwapInHeaders: " << fetch->pd->host.buf() <<
                    " 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.c_str();
+            host = pd->host.buf();
     }
 
     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 << ", reason: " << reason);
+    debugs(72, 2, "peerDigestFetchStop: peer " << fetch->pd->host.buf() << ", 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 << ", reason: " << reason);
+    debugs(72, 2, "peerDigestFetchAbort: peer " << fetch->pd->host.buf() << ", 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.c_str();
+    const char *host = pd->host.buf();
 
     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.c_str();
+    const char *host = pd->host.buf();
 
     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 <<
+        debugs(72, 0, "Warning: " << pd->host.buf() <<
                " 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.c_str();
+    const char *host = pd->host.buf();
     storeAppendPrintf(e, "\npeer digest from %s\n", host);
 
     cacheDigestGuessStatsReport(&pd->stats.guess, e, host);
index a4daa15aeb65e1c91908192533c81ead53cfbf5e..791c594eadd5284b9f9f5d3d2c6ed09d87d5458f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.546 2007/05/23 21:10:07 hno Exp $
+ * $Id: protos.h,v 1.547 2007/05/29 13:31:40 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, unsigned int name_len, const HttpHeaderFieldInfo * attrs, int end);
+SQUIDCEXTERN http_hdr_type httpHeaderIdByName(const char *name, 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);
index d44611523decc0631cbac3fffeac96bcce5e97b6..258fb482b3a212c828980614766357e4412fb4b8 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: redirect.cc,v 1.119 2007/05/18 06:41:25 amosjeffries Exp $
+ * $Id: redirect.cc,v 1.120 2007/05/29 13:31:40 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.empty()) {
-        r->client_ident = http->request->extacl_user.c_str();
+    else if (http->request->extacl_user.buf() != NULL) {
+        r->client_ident = http->request->extacl_user.buf();
     }
 
     if (!r->client_ident && (conn != NULL && conn->rfc931[0]))
index 2d64dde2b2652305cfec0fa233fcd7e9df65748c..73317aa5455dc85fc95657735abdd467e9952c61 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: stat.cc,v 1.406 2007/05/18 06:41:25 amosjeffries Exp $
+ * $Id: stat.cc,v 1.407 2007/05/29 13:31:40 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.empty()) {
-            p = http->request->extacl_user.c_str();
+        else if (http->request->extacl_user.buf() != NULL) {
+            p = http->request->extacl_user.buf();
         }
 
         if (!p && (conn != NULL && conn->rfc931[0]))
index dd067d547d9c7bb8c4ea83dde11899731ad7f0ce..dad68fb3db7959dfd563dd348683d6fabf0d8cbd 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.614 2007/05/18 06:41:25 amosjeffries Exp $
+ * $Id: store.cc,v 1.615 2007/05/29 13:31:40 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.empty()) {
+            if (vary.size()) {
                 /* Again, we own this structure layout */
-                rep->header.putStr(HDR_VARY, vary.c_str());
-                vary.clear();
+                rep->header.putStr(HDR_VARY, vary.buf());
+                vary.clean();
             }
 
 #if X_ACCELERATOR_VARY
             vary = mem_obj->getReply()->header.getList(HDR_X_ACCELERATOR_VARY);
 
-            if (!vary.empty()) {
+            if (vary.buf()) {
                 /* Again, we own this structure layout */
-                rep->header.putStr(HDR_X_ACCELERATOR_VARY, vary.c_str());
-                vary.clear();
+                rep->header.putStr(HDR_X_ACCELERATOR_VARY, vary.buf());
+                vary.clean();
             }
 
 #endif
index f6635cccfedcdea41280438b3535ec6fd8a6cfdc..4ced1ed63c6fd743acf537db718b16cc82742251 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir.cc,v 1.160 2007/05/18 06:41:25 amosjeffries Exp $
+ * $Id: store_dir.cc,v 1.161 2007/05/29 13:31:41 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");
index 79480c5444b5ddd1d40f3af2df2492855d55e1ce..075820c3fdb4a4b456631ecf86e9d5176784ca7e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_log.cc,v 1.33 2007/05/18 06:41:25 amosjeffries Exp $
+ * $Id: store_log.cc,v 1.34 2007/05/29 13:31:41 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.empty() ? reply->content_type.c_str() : "unknown",
+                      reply->content_type.size() ? reply->content_type.buf() : "unknown",
                       reply->content_length,
                       e->contentLen(),
                       RequestMethodStr[mem->method],
index 2817123724c2c95b3597fc8d86d7581458875a5b..9413663f4c682c3c1d59d69f892562482d329c45 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.557 2007/05/26 06:38:05 wessels Exp $
+ * $Id: structs.h,v 1.558 2007/05/29 13:31:41 amosjeffries Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -843,8 +843,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 */
@@ -857,7 +857,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) */
@@ -893,7 +893,7 @@ public:
     HttpHeaderFieldInfo() : id (HDR_ACCEPT), type (ftInvalid){}
 
     http_hdr_type id;
-    string name;
+    String name;
     field_type type;
     HttpHeaderFieldStat stat;
 };
index 00ff198640deb7739bc542b1c37d9b212c3eb6bb..b992020482d27954c58e16f82aaeb458c1c966ac 100644 (file)
@@ -14,7 +14,7 @@ public:
 
     CapturingStoreEntry() : _buffer_calls(0), _flush_calls(0) {}
 
-    string _appended_text;
+    String _appended_text;
     int _buffer_calls;
     int _flush_calls;
 
index 872afba371595146b67349ded7cb24f04ff43979..c24fb83ad418f72c6c03b24da64f15f8fb44845d 100644 (file)
@@ -46,7 +46,7 @@ TestSwapDir::parse(int, char*)
 {}
 
 StoreSearch *
-TestSwapDir::search(string, HttpRequest *)
+TestSwapDir::search(String, HttpRequest *)
 {
     return NULL;
 }
index ff334a0dcb38ec4a9f08592c59b5028722be4db2..d93fcd6dbcaf529eb138bebdef4b5780ad2bb374 100644 (file)
@@ -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<TestSwapDir> TestSwapDirPointer;
index 6ab2b275a8aa449a238c49a1116fa7a051a9437d..02b165a61835a60810256c1f4341a6b98e932b9c 100644 (file)
@@ -45,8 +45,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);
index ad6881aeceaadb60b7d741687c9f01fee0e4b2b8..2902a1fa92c06d59ac4735a25e83c58329dd0494 100644 (file)
@@ -100,12 +100,13 @@ 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);
-    string expect =          "Last event to run: last event\n"
+    CPPUNIT_ASSERT_EQUAL(String(
+                             "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";
-    CPPUNIT_ASSERT_EQUAL( expect, anEntry->_appended_text);
+                             "test event2\t0.000000 seconds\t0\tN/A\n"
+                         ), anEntry->_appended_text);
     delete anEntry;
 }
 
index ecfcba8a376989ac524eca7cc148acf7c0376bad..d0840cca6afe809cef4a6da5eec7b684d06a9e7f 100644 (file)
@@ -37,10 +37,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");
@@ -48,10 +48,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);
@@ -63,10 +63,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);
 }
 
@@ -83,9 +83,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);
 }
index 38bbe75270e29a44e0a711dcc70485083944bd5c..7b479ebbe1c18d0d322440bcfb067a040f02d282 100644 (file)
@@ -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()));
 }
index fd7231bdbe81255fdaea594ef0b8e157f33320de..71d6781ccda053df1af5fd2846b6adfc2de15358 100644 (file)
@@ -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;
 }
index 84a1f4cac5bf363d1d7b148f4cf3f7d2dcb9dc94..b148f60b3ff87c982120b20c30386b46425389dc 100644 (file)
@@ -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<TestStore> TestStorePointer;
index e7ac34bff068e1ae178f0d1f8fc1c66581c6957a..76bd65ee3037641aa268f59f670df7357db25ab6 100644 (file)
@@ -78,9 +78,10 @@ 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();
@@ -108,7 +109,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.c_str());    /* do it after we clear KEY_PRIVATE */
+    e->hashInsert((const cache_key *)name.buf());      /* do it after we clear KEY_PRIVATE */
     return e;
 }
 
index 034e773d61b3197ca940dd72b43008ae1f37ac1f..3beb0805475efc9e4d1e7cf5143c142ef16e5736 100644 (file)
@@ -37,7 +37,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   !", (string)anEntry->_appended_text);
+        CPPUNIT_ASSERT_EQUAL(String("some text   !"), anEntry->_appended_text);
     }
 
     delete anEntry;
index 16c0e3370e62cfcaa5eb244aa704f60258e05087..766483eaa7dbdf06cdf09c221cb96b7a0ff73982 100644 (file)
@@ -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.c_str());    /* do it after we clear KEY_PRIVATE */
+    e->hashInsert((const cache_key *)name.buf());      /* do it after we clear KEY_PRIVATE */
     return e;
 }
 
index f2340881a117ebf71d8382858608cd64c335d637..48b701c8ef4e1a44974f25908bc3304c875e2d62 100644 (file)
@@ -19,217 +19,42 @@ testString::setUp()
     Mem::Init();
 }
 
-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( memcmp("hello world", cStr.c_str(), 11) == 0 );
-    CPPUNIT_ASSERT( memcmp("hello world\0", cStr.c_str(), 12) == 0 );
-    CPPUNIT_ASSERT( memcmp("hello world\0 untro", cStr.c_str(), 18) == 0 );
-    CPPUNIT_ASSERT( memcmp("hello world\0 untro\0", cStr.c_str(), 19) == 0 );
-}
-
-void
-testString::testAccess()
-{
-    string test;
-    test = "123456789a"; // to get a predictable length buffer.
-
-    CPPUNIT_ASSERT_EQUAL( test.size(), 10 );
-
-/* FIXME: flow checks do not seem to catch assert() sent from within code. */
-      /* underflow handling test: _should_ fail with core dump. */
-      /* this SHOULD be impossible due to unsigned type of parameter. */
-//    CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT( test[-1] ) );
-
-      /* overflow handling test: _should_ fail with core dump. */
-//    CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT( test[test.size()+10] ) );
-
-      /* [] access method (read and write) */
-    CPPUNIT_ASSERT( test[0]  == '1' );
-    CPPUNIT_ASSERT( test[9]  == 'a' );
-    CPPUNIT_ASSERT( test[10] == '\0' );
-
-    test.append('T');
-    CPPUNIT_ASSERT( test[10]  ==  'T' );
-    CPPUNIT_ASSERT( test[11]  == '\0' );
-    CPPUNIT_ASSERT_EQUAL((string)"123456789aT", test);
-
-      /* Random access inside buffer. */
-    test[5] = 't';
-    CPPUNIT_ASSERT( test[5]   ==  't' );
-    CPPUNIT_ASSERT( test[11]  == '\0' );
-    CPPUNIT_ASSERT_EQUAL((string)"12345t789aT", test);
-
-      /* border case at last position of string */
-    test[9] = 'E';
-    CPPUNIT_ASSERT( test[9]   ==  'E' );
-    CPPUNIT_ASSERT( test[11]  == '\0' );
-    CPPUNIT_ASSERT_EQUAL((string)"12345t789ET", test);
-
-      /* border case at EOS position */
-    test[11] = 'F';
-    CPPUNIT_ASSERT( test[11]  == 'F' );
-    CPPUNIT_ASSERT( test[12]  == '\0' );
-    CPPUNIT_ASSERT_EQUAL((string)"12345t789ETF", test);
-}
-
-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.compare(right));
-    CPPUNIT_ASSERT(!left.compare(NULL));
-    CPPUNIT_ASSERT(!left.compare(NULL, 1));
+    CPPUNIT_ASSERT(!left.cmp(right));
+    CPPUNIT_ASSERT(!left.cmp(NULL));
+    CPPUNIT_ASSERT(!left.cmp(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.compare(right));
-    CPPUNIT_ASSERT(!left.compare(NULL));
-    CPPUNIT_ASSERT(!left.compare(NULL, 1));
+    CPPUNIT_ASSERT(!left.cmp(right));
+    CPPUNIT_ASSERT(!left.cmp(NULL));
+    CPPUNIT_ASSERT(!left.cmp(NULL, 1));
     /* reverse the order to catch corners */
-    CPPUNIT_ASSERT(!right.compare(left));
-    CPPUNIT_ASSERT(!right.compare(""));
-    CPPUNIT_ASSERT(!right.compare("", 1));
+    CPPUNIT_ASSERT(!right.cmp(left));
+    CPPUNIT_ASSERT(!right.cmp(""));
+    CPPUNIT_ASSERT(!right.cmp("", 1));
 }
 
 void
 testString::testCmpNotEmptyDefault()
 {
-    string left("foo");
-    string right;
+    String left("foo");
+    String right;
     /* empty string sorts before everything */
-    CPPUNIT_ASSERT(left.compare(right) > 0);
-    CPPUNIT_ASSERT(left.compare(NULL) > 0);
-    CPPUNIT_ASSERT(left.compare(NULL, 1) > 0);
+    CPPUNIT_ASSERT(left.cmp(right) > 0);
+    CPPUNIT_ASSERT(left.cmp(NULL) > 0);
+    CPPUNIT_ASSERT(left.cmp(NULL, 1) > 0);
     /* reverse for symmetry tests */
-    CPPUNIT_ASSERT(right.compare(left) < 0);
-    CPPUNIT_ASSERT(right.compare("foo") < 0);
-    CPPUNIT_ASSERT(right.compare("foo", 1) < 0);
+    CPPUNIT_ASSERT(right.cmp(left) < 0);
+    CPPUNIT_ASSERT(right.cmp("foo") < 0);
+    CPPUNIT_ASSERT(right.cmp("foo", 1) < 0);
 }
index d4ff1d051fb6019ea341e5bb7b11b617bda7d603..7b3581d9e56f7446aa65861e228100577e1d0f42 100644 (file)
 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( testAccess );
-    CPPUNIT_TEST( testCstrMethods );
-    CPPUNIT_TEST( testSearch );
     CPPUNIT_TEST_SUITE_END();
 
 public:
     void setUp();
 
 protected:
-
-    /* std::string API */
-    void testDefaults();
     void testCmpDefault();
     void testCmpEmptyString();
     void testCmpNotEmptyDefault();
-    void testBooleans();
-    void testAppend();
-    void testAssignments();
-    void testAccess();
-    void testCstrMethods();
-    void testSearch();
 };
 
 #endif
+
index 892eb9bd0c6545038fc90cf49242ec7967f372ce..1ec0d0133f743c2b182740d52b46a37a6156791c 100644 (file)
@@ -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);
 }
index a00c30ccafb990eff7476cefb2e54a4c717d0ab1..2f52f12ae8b01bde4073fe1c6dccfb330a1fcedf 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: test_http_range.cc,v 1.2 2007/05/18 06:41:33 amosjeffries Exp $
+ * $Id: test_http_range.cc,v 1.3 2007/05/29 13:31:48 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 "";
+    return String();
 }
 
 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)
index 0aadf1650a887a40258257edaa19af5bc7f3f047..af21d6dd3d2cf10aff369118177e051cbb8223b1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: url.cc,v 1.161 2007/05/23 21:10:07 hno Exp $
+ * $Id: url.cc,v 1.162 2007/05/29 13:31:41 amosjeffries Exp $
  *
  * DEBUG: section 23    URL Parsing
  * AUTHOR: Duane Wessels
@@ -236,7 +236,7 @@ urlParse(method_t method, char *url, HttpRequest *request)
     for (t = host; *t; t++)
         *t = xtolower(*t);
 
-    if (strpbrk(host, w_space) != NULL) {
+    if (stringHasWhitespace(host)) {
         if (URI_WHITESPACE_STRIP == Config.uri_whitespace) {
             t = q = host;
 
@@ -284,7 +284,7 @@ urlParse(method_t method, char *url, HttpRequest *request)
     }
 
 #endif
-    if (strpbrk(urlpath, w_space) != NULL) {
+    if (stringHasWhitespace(urlpath)) {
         debugs(23, 2, "urlParse: URI has whitespace: {" << url << "}");
 
         switch (Config.uri_whitespace) {
@@ -349,7 +349,7 @@ urlCanonical(HttpRequest * request)
         return request->canonical;
 
     if (request->protocol == PROTO_URN) {
-        snprintf(urlbuf, MAX_URL, "urn:%s", request->urlpath.c_str());
+        snprintf(urlbuf, MAX_URL, "urn:%s", request->urlpath.buf());
     } else {
         switch (request->method) {
 
@@ -369,7 +369,7 @@ urlCanonical(HttpRequest * request)
                      *request->login ? "@" : null_string,
                      request->host,
                      portbuf,
-                     request->urlpath.c_str());
+                     request->urlpath.buf());
 
             break;
         }
@@ -378,22 +378,6 @@ 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)
 {
@@ -403,7 +387,7 @@ urlCanonicalClean(const HttpRequest * request)
     char *t;
 
     if (request->protocol == PROTO_URN) {
-        snprintf(buf, MAX_URL, "urn:%s", request->urlpath.c_str());
+        snprintf(buf, MAX_URL, "urn:%s", request->urlpath.buf());
     } else {
         switch (request->method) {
 
@@ -433,7 +417,7 @@ urlCanonicalClean(const HttpRequest * request)
                      loginbuf,
                      request->host,
                      portbuf,
-                     request->urlpath.c_str());
+                     request->urlpath.buf());
             /*
              * strip arguments AFTER a question-mark
              */
index 699f160b013e0250ab96ef8fd40c4eab739e56d3..d1d9c34923e43ccddc4e440d46725f862538028d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: urn.cc,v 1.106 2007/05/18 06:41:26 amosjeffries Exp $
+ * $Id: urn.cc,v 1.107 2007/05/29 13:31:41 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.c_str());
+        result = xstrdup(urlpath.buf());
         urlpath.set(t, ':');
     } else {
-        result = xstrdup(urlpath.c_str());
+        result = xstrdup(urlpath.buf());
     }
 
     return result;
@@ -193,7 +193,7 @@ UrnState::getHost (string &urlpath)
 bool
 UrnState::RequestNeedsMenu(HttpRequest *r)
 {
-    return strncasecmp(r->urlpath, "menu.", 5) == 0;
+    return strncasecmp(r->urlpath.buf(), "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.c_str());
+    snprintf(local_urlres, 4096, "http://%s/uri-res/N2L?urn:%s", host, uri.buf());
     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.c_str() + 5);
+        updateRequestURL(r, r->urlpath.buf() + 5);
         flags.force_menu = 1;
     }
 
index d8f948aaea4fd1a53ce5492dc5683f767c931bce..5af81a502d5b9f38731b75c8093e6d61464abe5c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: whois.cc,v 1.44 2007/05/18 06:41:26 amosjeffries Exp $
+ * $Id: whois.cc,v 1.45 2007/05/29 13:31:41 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.c_str() + 1);
+    snprintf(buf, l, "%s\r\n", p->request->urlpath.buf() + 1);
 
     comm_write(fd, buf, strlen(buf), whoisWriteComplete, p, NULL);
     comm_read(fd, p->buf, BUFSIZ, whoisReadReply, p);