]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
defined printf-helping macros,
authorFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 11 Feb 2009 17:08:24 +0000 (18:08 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 11 Feb 2009 17:08:24 +0000 (18:08 +0100)
reverted some unnecessary renamings
further unsafeBuf conversions.

15 files changed:
src/CommonPool.h
src/DelayTagged.cc
src/DiskIO/AIO/AIODiskFile.cc
src/ESI.cc
src/ESIAssign.cc
src/ICAP/ICAPModXact.cc
src/ICAP/ICAPXaction.cc
src/SquidString.h
src/client_side.cc
src/client_side_reply.cc
src/client_side_request.cc
src/eCAP/MessageRep.cc
src/errorpage.cc
src/gopher.cc
src/peer_digest.cc

index 281025e21828e6c1fbe503e1ce5c9ef6f7c36bd5..fb24c43bde8df6a3e68bc9d3ea674d459bbcea1c 100644 (file)
@@ -59,7 +59,7 @@ public:
     void *operator new(size_t);
     void operator delete (void *);
     static CommonPool *Factory (unsigned char _class, CompositePoolNode::Pointer&);
-    char const* theClassTypeLabel() const {return typeLabel.unsafeBuf();}
+    char const* theClassTypeLabel() const {return typeLabel.termedBuf();}
 
 protected:
     CommonPool();
index a5c08e6041947d3627e8629d97fb64171c1bd7da..377c2f6584dbaf947144bad1e31b94228d76bd0b 100644 (file)
@@ -77,7 +77,7 @@ int
 DelayTaggedCmp(DelayTaggedBucket::Pointer const &left, DelayTaggedBucket::Pointer const &right)
 {
     /* for rate limiting, case insensitive */
-    return left->tag.caseCmp(right->tag.unsafeBuf());
+    return left->tag.caseCmp(right->tag);
 }
 
 void
@@ -195,7 +195,7 @@ DelayTaggedBucket::~DelayTaggedBucket()
 void
 DelayTaggedBucket::stats (StoreEntry *entry) const
 {
-    storeAppendPrintf(entry, " %s:", tag.unsafeBuf());
+    storeAppendPrintf(entry, " " SQUIDSTRINGPH , SQUIDSTRINGPRINT(tag));
     theBucket.stats (entry);
 }
 
index 1a2c801366fb00070bb144a8eb644f9de2b30d29..3ed4d48eb027e3758f59c4cff5a6e506120658a9 100644 (file)
@@ -129,7 +129,7 @@ AIODiskFile::read(ReadRequest *request)
         fatal("Aiee! out of aiocb slots! - FIXME and wrap file_read\n");
         debugs(79, 1, "WARNING: out of aiocb slots!");
         /* fall back to blocking method */
-        //        file_read(fd, request->unsafeBuf, request->len, request->offset, callback, data);
+        //        file_read(fd, request->buf, request->len, request->offset, callback, data);
         return;
     }
 
@@ -166,7 +166,7 @@ AIODiskFile::read(ReadRequest *request)
         fatalf("Aiee! aio_read() returned error (%d)  FIXME and wrap file_read !\n", errno);
         debugs(79, 1, "WARNING: aio_read() returned error: " << xstrerror());
         /* fall back to blocking method */
-        //        file_read(fd, request->unsafeBuf, request->len, request->offset, callback, data);
+        //        file_read(fd, request->buf, request->len, request->offset, callback, data);
     }
 
 }
@@ -187,7 +187,7 @@ AIODiskFile::write(WriteRequest *request)
         fatal("Aiee! out of aiocb slots FIXME and wrap file_write !\n");
         debugs(79, 1, "WARNING: out of aiocb slots!");
         /* fall back to blocking method */
-        //        file_write(fd, offset, unsafeBuf, len, callback, data, freefunc);
+        //        file_write(fd, offset, buf, len, callback, data, freefunc);
         return;
     }
 
@@ -224,7 +224,7 @@ AIODiskFile::write(WriteRequest *request)
         fatalf("Aiee! aio_write() returned error (%d) FIXME and wrap file_write !\n", errno);
         debugs(79, 1, "WARNING: aio_write() returned error: " << xstrerror());
         /* fall back to blocking method */
-        //       file_write(fd, offset, unsafeBuf, len, callback, data, freefunc);
+        //       file_write(fd, offset, buf, len, callback, data, freefunc);
     }
 }
 
index dda16d50566bd7d456c57881eba833934c0dc24c..875e8b25df9e4e62184d7b084eaecb8b68284744 100644 (file)
@@ -2430,7 +2430,7 @@ esiEnableProcessing (HttpReply *rep)
              */
             return 0;
 
-        if (strstr (sctusable->content.unsafeBuf(), "ESI/1.0"))
+        if (sctusable->content.pos("ESI/1.0") != NULL)
             rv = 1;
 
         httpHdrScTargetDestroy (sctusable);
index 496bdfa8a4030535c5f98697359e3210f10dcace..3efc390638ed0c31a95efd7c27c5f65fe6b27a40 100644 (file)
@@ -89,7 +89,7 @@ ESIAssign::evaluateVariable()
     variable = NULL;
 
     if (unevaluatedVariable.size()) {
-        varState->feedData(unevaluatedVariable.unsafeBuf(), unevaluatedVariable.size());
+        varState->feedData(unevaluatedVariable.rawBuf(), unevaluatedVariable.size());
         char const *result = varState->extractChar ();
 
         /* Consider activating this, when we want to evaluate variables to a
@@ -123,7 +123,7 @@ ESIAssign::process (int dovars)
     if (!value)
         return ESI_PROCESS_COMPLETE;
 
-    varState->addVariable (name.unsafeBuf(), name.size(), value);
+    varState->addVariable (name.rawBuf(), name.size(), value);
 
     value = NULL;
 
@@ -194,7 +194,7 @@ void
 ESIVariableExpression::eval (ESIVarState &state, char const *subref, char const *defaultOnEmpty) const
 {
     /* XXX: Implement evaluation of the expression */
-    ESISegment::ListAppend (state.getOutput(), expression.unsafeBuf(), expression.size());
+    ESISegment::ListAppend (state.getOutput(), expression.rawBuf(), expression.size());
 }
 
 #endif /* USE_SQUID_ESI == 1 */
index bbb0d85d3ca195856edc743f3752c82d02a2ba15..0a919f5c7dfab413015cd0f6225004a504e904f0 100644 (file)
@@ -1111,7 +1111,7 @@ void ICAPModXact::makeRequestHeaders(MemBuf &buf)
     if (TheICAPConfig.send_client_username && request)
         makeUsernameHeader(request, buf);
 
-    // fprintf(stderr, "%s\n", unsafeBuf.content());
+    // fprintf(stderr, "%s\n", buf.content());
 
     buf.append(ICAP::crlf, 2); // terminate ICAP header
 
@@ -1272,7 +1272,7 @@ void ICAPModXact::finishNullOrEmptyBodyPreview(MemBuf &buf)
     Must(!preview.ad());
 
     // do not add last-chunk because our Encapsulated header says null-body
-    // addLastRequestChunk(unsafeBuf);
+    // addLastRequestChunk(buf);
     preview.wrote(0, true);
 
     Must(preview.done());
index 9bf529eddd236983ebfafef1d6730c2717bcc62a..dcf864c208309fc266e7287294bb8f48b5cbed4c 100644 (file)
@@ -295,7 +295,7 @@ void ICAPXaction::scheduleRead()
 
     /*
      * See comments in ICAPXaction.h about why we use commBuf
-     * here instead of reading directly into readBuf.unsafeBuf.
+     * here instead of reading directly into readBuf.buf.
      */
     typedef CommCbMemFunT<ICAPXaction, CommIoCbParams> Dialer;
     reader = asyncCall(93,3, "ICAPXaction::noteCommRead",
@@ -320,7 +320,7 @@ void ICAPXaction::noteCommRead(const CommIoCbParams &io)
 
     /*
      * See comments in ICAPXaction.h about why we use commBuf
-     * here instead of reading directly into readBuf.unsafeBuf.
+     * here instead of reading directly into readBuf.buf.
      */
 
     if (io.size > 0) {
index 7fe23b112e2f4d6e76bfd5679c9385763fb95294..0aac98957b229c372187d7754a6e22f19364c59e 100644 (file)
 /** todo checks to wrap this include properly */
 #include <ostream>
 
+/* squid string placeholder (for printf) */
+#ifndef SQUIDSTRINGPH
+#define SQUIDSTRINGPH "%.*s"
+#define SQUIDSTRINGPRINT(s) s.psize(),s.rawBuf()
+#endif /* SQUIDSTRINGPH */
+
 
 #define DEBUGSTRINGS 0
 #if DEBUGSTRINGS
index 98d2924712ff08365c2bc0f3b1104ac512604f14..6a2af2bf735bbdbeea6ed94ab1e059c5969cce5d 100644 (file)
@@ -489,7 +489,7 @@ ClientHttpRequest::logRequest()
             al.http.content_type = al.reply->content_type.termedBuf();
         } 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.unsafeBuf();
+            al.http.content_type = loggingEntry()->mem_obj->getReply()->content_type.termedBuf();
         }
 
         debugs(33, 9, "clientLogRequest: http.code='" << al.http.code << "'");
@@ -890,7 +890,7 @@ clientPackRangeHdr(const HttpReply * rep, const HttpHdrRangeSpec * spec, String
 }
 
 /**
- * extracts a "range" from *unsafeBuf and appends them to mb, updating
+ * extracts a "range" from *buf and appends them to mb, updating
  * all offsets and such.
  */
 void
@@ -1924,7 +1924,7 @@ parseHttpRequest(ConnStateData *conn, HttpParser *hp, HttpRequestMethod * method
         req_sz = HttpParserReqSz(hp);
     }
 
-    /* We know the whole request is in hp->unsafeBuf now */
+    /* We know the whole request is in hp->buf now */
 
     assert(req_sz <= (size_t) hp->bufsiz);
 
@@ -2623,7 +2623,7 @@ ConnStateData::handleReadData(char *buf, size_t size)
 }
 
 /**
- * called when new request body data has been buffered in in.unsafeBuf
+ * called when new request body data has been buffered in in.buf
  * may close the connection if we were closing and piped everything out
  */
 void
index 0b2b0858ff837417b84263b20cf6a9d1b6a13bba..cb359f406ddad259f8a0c154bdf00367b64d1ed6 100644 (file)
@@ -1671,7 +1671,7 @@ clientReplyDetach(clientStreamNode * node, ClientHttpRequest * http)
 }
 
 /*
- * accepts chunk of a http message in unsafeBuf, parses prefix, filters headers and
+ * accepts chunk of a http message in buf, parses prefix, filters headers and
  * such, writes processed message to the message recipient
  */
 void
index e49ed3ddba3fbaad4dcf1f7dc271a95169fde83a..781e7dcab3be139f386813fbe8c4603948edd5fa 100644 (file)
@@ -426,7 +426,7 @@ clientFollowXForwardedForCheck(int answer, void *data)
         const char *asciiaddr;
         int l;
         struct in_addr addr;
-        p = request->x_forwarded_for_iterator.unsafeBuf();
+        p = request->x_forwarded_for_iterator.termedBuf();
         l = request->x_forwarded_for_iterator.size();
 
         /*
@@ -897,7 +897,7 @@ clientInterpretRequestHeaders(ClientHttpRequest * http)
         }
 
 #if FORW_VIA_DB
-        fvdbCountVia(s.unsafeBuf());
+        fvdbCountVia(s.termedBuf());
 
 #endif
 
@@ -923,7 +923,7 @@ clientInterpretRequestHeaders(ClientHttpRequest * http)
 
     if (req_hdr->has(HDR_X_FORWARDED_FOR)) {
         String s = req_hdr->getList(HDR_X_FORWARDED_FOR);
-        fvdbCountForw(s.unsafeBuf());
+        fvdbCountForw(s.termedBuf());
         s.clean();
     }
 
index b8069bb44c87192cd4e1bdf0ed1743a1872821df..f3b8b298ecf04ac514be16dc4e7696348cad1b72 100644 (file)
@@ -192,7 +192,7 @@ Ecap::RequestLineRep::uri(const Area &aUri)
 Ecap::RequestLineRep::Area
 Ecap::RequestLineRep::uri() const
 {
-    return Area::FromTempBuffer(theMessage.urlpath.unsafeBuf(),
+    return Area::FromTempBuffer(theMessage.urlpath.rawBuf(),
                                 theMessage.urlpath.size());
 }
 
index f5657778da2438d542ad29db89a5e7d43b37d3e0..20e2c48c3961fb93a3086a6cd01ee3800dc8bfc7 100644 (file)
@@ -556,9 +556,16 @@ ErrorState::Dump(MemBuf * mb)
 
     if (NULL != request) {
         Packer p;
-        str.Printf("%s %s HTTP/%d.%d\n",
+        String urlpath_or_slash;
+
+        if (request->urlpath.size() != 0)
+            urlpath_or_slash = request->urlpath;
+        else
+            urlpath_or_slash = "/";
+
+        str.Printf("%s " SQUIDSTRINGPH " HTTP/%d.%d\n",
                    RequestMethodStr(request->method),
-                   request->urlpath.size() ? request->urlpath.unsafeBuf() : "/",
+                   SQUIDSTRINGPRINT(urlpath_or_slash),
                    request->http_ver.major, request->http_ver.minor);
         packerToMemInit(&p, &str);
         request->header.packInto(&p);
@@ -734,9 +741,16 @@ ErrorState::Convert(char token)
 
         if (NULL != request) {
             Packer p;
-            mb.Printf("%s %s HTTP/%d.%d\n",
+            String urlpath_or_slash;
+
+            if (request->urlpath.size() != 0)
+                urlpath_or_slash = request->urlpath;
+            else
+                urlpath_or_slash = "/";
+
+            mb.Printf("%s " SQUIDSTRINGPH " HTTP/%d.%d\n",
                       RequestMethodStr(request->method),
-                      request->urlpath.size() ? request->urlpath.unsafeBuf() : "/",
+                      SQUIDSTRINGPRINT(urlpath_or_slash),
                       request->http_ver.major, request->http_ver.minor);
             packerToMemInit(&p, &mb);
             request->header.packInto(&p);
@@ -928,7 +942,7 @@ ErrorState::BuildContent()
      */
     if (!Config.errorDirectory && request && request->header.getList(HDR_ACCEPT_LANGUAGE, &hdr) ) {
 
-        const char *unsafeBuf = hdr.unsafeBuf(); // raw header string for parsing
+        const char *raw_hdr = hdr.termedBuf(); // raw header string for parsing
         size_t pos = 0; // current parsing position in header string
         char *reset = NULL; // where to reset the p pointer for each new tag file
         char *dt = NULL;
@@ -950,12 +964,12 @@ ErrorState::BuildContent()
              *  - IFF a tag contains only two characters we can wildcard ANY translations matching: <it> '-'? .*
              *    with preference given to an exact match.
              */
-            while (pos < hdr.size() && unsafeBuf[pos] != ';' && unsafeBuf[pos] != ',' && !xisspace(unsafeBuf[pos]) && dt < (dir+256) ) {
-                *dt++ = xtolower(unsafeBuf[pos++]);
+            while (pos < hdr.size() && raw_hdr[pos] != ';' && raw_hdr[pos] != ',' && !xisspace(raw_hdr[pos]) && dt < (dir+256) ) {
+                *dt++ = xtolower(raw_hdr[pos++]);
             }
             *dt++ = '\0'; // nul-terminated the filename content string before system use.
 
-            debugs(4, 9, HERE << "STATE: dt='" << dt << "', reset='" << reset << "', reset[1]='" << reset[1] << "', pos=" << pos << ", buf='" << &unsafeBuf[pos] << "'");
+            debugs(4, 9, HERE << "STATE: dt='" << dt << "', reset='" << reset << "', reset[1]='" << reset[1] << "', pos=" << pos << ", buf='" << &raw_hdr[pos] << "'");
 
             /* if we found anything we might use, try it. */
             if (*reset != '\0') {
@@ -983,8 +997,8 @@ ErrorState::BuildContent()
             dt = reset; // reset for next tag testing. we replace the failed name instead of cloning.
 
             // IFF we terminated the tag on ';' we need to skip the 'q=' bit to the next ',' or end.
-            while (pos < hdr.size() && unsafeBuf[pos] != ',') pos++;
-            if (unsafeBuf[pos] == ',') pos++;
+            while (pos < hdr.size() && raw_hdr[pos] != ',') pos++;
+            if (raw_hdr[pos] == ',') pos++;
         }
     }
 #endif /* USE_ERR_LOCALES */
index 6d86a34d8c8d1632ac1c0a07438bec36451c5c13..015f34a6d571b4ebeb8d295f99e54996b547d929 100644 (file)
@@ -853,7 +853,7 @@ gopherReadReply(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void
         do_next_read = 0;
     } else if (len == 0) {
         /* Connection closed; retrieval done. */
-        /* flush the rest of data in temp unsafeBuf if there is one. */
+        /* flush the rest of data in temp buf if there is one. */
 
         if (gopherState->conversion != gopher_ds::NORMAL)
             gopherEndHTML(gopherState);
index 450a0bff914203eaf7449e508d0c43481743d270..d8b510bb7d45bece2c329ce0116086c20737b647 100644 (file)
@@ -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.unsafeBuf() << " in " << delay << " secs");
+    debugs(72, 3, "peerDigestSetCheck: will check peer " << pd->host << " in " << delay << " secs");
 }
 
 /*
@@ -241,10 +241,10 @@ void
 peerDigestNotePeerGone(PeerDigest * pd)
 {
     if (pd->flags.requested) {
-        debugs(72, 2, "peerDigest: peer " << pd->host.unsafeBuf() << " gone, will destroy after fetch.");
+        debugs(72, 2, "peerDigest: peer " << pd->host << " gone, will destroy after fetch.");
         /* do nothing now, the fetching chain will notice and take action */
     } else {
-        debugs(72, 2, "peerDigest: peer " << pd->host.unsafeBuf() << " is gone, destroying now.");
+        debugs(72, 2, "peerDigest: peer " << pd->host << " is gone, destroying now.");
         peerDigestDestroy(pd);
     }
 }