]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Shuffle packerPrintf() to be Packer::Printf method
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 3 Mar 2015 07:46:18 +0000 (23:46 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 3 Mar 2015 07:46:18 +0000 (23:46 -0800)
src/HttpHdrCc.cc
src/HttpHdrContRange.cc
src/HttpHdrRange.cc
src/HttpHdrSc.cc
src/HttpRequest.cc
src/Packer.cc
src/Packer.h
src/http/StatusLine.cc

index 5bef6009215b351468d14d24add95afa8fad181b..c079b7447e598cb53ba72473d4fc4bc09bafe938 100644 (file)
@@ -265,24 +265,24 @@ HttpHdrCc::packInto(Packer * p) const
         if (isSet(flag) && flag != CC_OTHER) {
 
             /* print option name for all options */
-            packerPrintf(p, (pcount ? ", %s": "%s") , CcAttrs[flag].name);
+            p->Printf((pcount ? ", %s": "%s") , CcAttrs[flag].name);
 
             /* for all options having values, "=value" after the name */
             switch (flag) {
             case CC_MAX_AGE:
-                packerPrintf(p, "=%d", (int) maxAge());
+                p->Printf("=%d", (int) maxAge());
                 break;
             case CC_S_MAXAGE:
-                packerPrintf(p, "=%d", (int) sMaxAge());
+                p->Printf("=%d", (int) sMaxAge());
                 break;
             case CC_MAX_STALE:
                 /* max-stale's value is optional.
                   If we didn't receive it, don't send it */
                 if (maxStale()!=MAX_STALE_ANY)
-                    packerPrintf(p, "=%d", (int) maxStale());
+                    p->Printf("=%d", (int) maxStale());
                 break;
             case CC_MIN_FRESH:
-                packerPrintf(p, "=%d", (int) minFresh());
+                p->Printf("=%d", (int) minFresh());
                 break;
             default:
                 /* do nothing, directive was already printed */
@@ -294,7 +294,7 @@ HttpHdrCc::packInto(Packer * p) const
     }
 
     if (other.size() != 0)
-        packerPrintf(p, (pcount ? ", " SQUIDSTRINGPH : SQUIDSTRINGPH),
+        p->Printf((pcount ? ", " SQUIDSTRINGPH : SQUIDSTRINGPH),
                      SQUIDSTRINGPRINT(other));
 }
 
index 98eebf1bb69927358645a35f6c4a5c130c207731..0c33b75311f61da213e3c37216b3be0d4ba2f2c2 100644 (file)
@@ -104,9 +104,9 @@ httpHdrRangeRespSpecPackInto(const HttpHdrRangeSpec * spec, Packer * p)
     assert (spec->length >= 0);
 
     if (!known_spec(spec->offset) || !known_spec(spec->length))
-        packerPrintf(p, "*");
+        p->Printf("*");
     else
-        packerPrintf(p, "bytes %" PRId64 "-%" PRId64,
+        p->Printf("bytes %" PRId64 "-%" PRId64,
                      spec->offset, spec->offset + spec->length - 1);
 }
 
@@ -208,9 +208,9 @@ httpHdrContRangePackInto(const HttpHdrContRange * range, Packer * p)
     assert (range->elength >= 0);
 
     if (!known_spec(range->elength))
-        packerPrintf(p, "/*");
+        p->Printf("/*");
     else
-        packerPrintf(p, "/%" PRId64, range->elength);
+        p->Printf("/%" PRId64, range->elength);
 }
 
 void
index 80d7e19905d37b1333b75efd611fb5c7217a2cdf..e297de7258e4d2dd728c90083bbb9ab0f41b40a4 100644 (file)
@@ -108,12 +108,11 @@ void
 HttpHdrRangeSpec::packInto(Packer * packer) const
 {
     if (!known_spec(offset))    /* suffix */
-        packerPrintf(packer, "-%" PRId64,  length);
+        packer->Printf("-%" PRId64,  length);
     else if (!known_spec(length))       /* trailer */
-        packerPrintf(packer, "%" PRId64 "-", offset);
+        packer->Printf("%" PRId64 "-", offset);
     else            /* range */
-        packerPrintf(packer, "%" PRId64 "-%" PRId64,
-                     offset, offset + length - 1);
+        packer->Printf("%" PRId64 "-%" PRId64, offset, offset + length - 1);
 }
 
 void
index 83906481cc1c42db734e6c6af72fc4c508998121..537b880ad75907ee7de2680e01c2986b90b6dec3 100644 (file)
@@ -245,23 +245,23 @@ HttpHdrScTarget::packInto(Packer * p) const
         if (isSet(flag) && flag != SC_OTHER) {
 
             /* print option name */
-            packerPrintf(p, (pcount ? ", " SQUIDSTRINGPH : SQUIDSTRINGPH),
+            p->Printf((pcount ? ", " SQUIDSTRINGPH : SQUIDSTRINGPH),
                          SQUIDSTRINGPRINT(ScFieldsInfo[flag].name));
 
             /* handle options with values */
 
             if (flag == SC_MAX_AGE)
-                packerPrintf(p, "=%d", (int) max_age);
+                p->Printf("=%d", (int) max_age);
 
             if (flag == SC_CONTENT)
-                packerPrintf(p, "=\"" SQUIDSTRINGPH "\"", SQUIDSTRINGPRINT(content_));
+                p->Printf("=\"" SQUIDSTRINGPH "\"", SQUIDSTRINGPRINT(content_));
 
             ++pcount;
         }
     }
 
     if (hasTarget())
-        packerPrintf (p, ";" SQUIDSTRINGPH, SQUIDSTRINGPRINT(target));
+        p->Printf(";" SQUIDSTRINGPH, SQUIDSTRINGPRINT(target));
 }
 
 void
index 942a2e84709363bf0be378c7762b185214515bba..9206a3e64dc3dcca617f01722ba4cc6d99d3341f 100644 (file)
@@ -377,9 +377,9 @@ HttpRequest::pack(Packer * p)
 {
     assert(p);
     /* pack request-line */
-    packerPrintf(p, SQUIDSBUFPH " " SQUIDSTRINGPH " HTTP/%d.%d\r\n",
-                 SQUIDSBUFPRINT(method.image()), SQUIDSTRINGPRINT(urlpath),
-                 http_ver.major, http_ver.minor);
+    p->Printf(SQUIDSBUFPH " " SQUIDSTRINGPH " HTTP/%d.%d\r\n",
+              SQUIDSBUFPRINT(method.image()), SQUIDSTRINGPRINT(urlpath),
+              http_ver.major, http_ver.minor);
     /* headers */
     header.packInto(p);
     /* trailer */
@@ -510,10 +510,10 @@ const char *HttpRequest::packableURI(bool full_uri) const
 void HttpRequest::packFirstLineInto(Packer * p, bool full_uri) const
 {
     // form HTTP request-line
-    packerPrintf(p, SQUIDSBUFPH " %s HTTP/%d.%d\r\n",
-                 SQUIDSBUFPRINT(method.image()),
-                 packableURI(full_uri),
-                 http_ver.major, http_ver.minor);
+    p->Printf(SQUIDSBUFPH " %s HTTP/%d.%d\r\n",
+              SQUIDSBUFPRINT(method.image()),
+              packableURI(full_uri),
+              http_ver.major, http_ver.minor);
 }
 
 /*
index b9f7675459baf1d96fac8326c7389e659ff1b364..fcc674cc751545ee6a6c09d6d2c0a6c95207cc1c 100644 (file)
@@ -123,14 +123,13 @@ Packer::append(const char *buf, int sz)
 }
 
 void
-packerPrintf(Packer * p, const char *fmt,...)
+Packer::Printf(const char *fmt,...)
 {
     va_list args;
     va_start(args, fmt);
 
-    assert(p);
-    assert(p->real_handler && p->packer_vprintf);
-    p->packer_vprintf(p->real_handler, fmt, args);
+    assert(real_handler && packer_vprintf);
+    packer_vprintf(real_handler, fmt, args);
     va_end(args);
 }
 
index 964913aad2c47eb5adf4b0520d5ffea855a774fb..86a37bd6d56d087ddfb757ca2660763eeaa79ec9 100644 (file)
@@ -24,15 +24,20 @@ class Packer
 
 public:
     virtual ~Packer();
+
     virtual void append(const char *buf, int size);
 
+    /*
+     * \note  we use Printf instead of printf so the compiler won't
+     *        think we're calling the libc printf()
+     */
+    virtual void Printf(const char *fmt,...) PRINTF_FORMAT_ARG2;
+
     /* protected, use interface functions instead */
     append_f append_;
     vprintf_f packer_vprintf;
     void *real_handler;     /* first parameter to real append and vprintf */
 };
 
-void packerPrintf(Packer * p, const char *fmt,...) PRINTF_FORMAT_ARG2;
-
 #endif /* SQUID_PACKER_H */
 
index b06161ea88750f43ae3a3b99b639fd400dc34626..57008291c6236d7ab591c3120df011c45facca72 100644 (file)
@@ -57,14 +57,14 @@ Http::StatusLine::packInto(Packer * p) const
         debugs(57, 9, "packing sline " << this << " using " << p << ":");
         debugs(57, 9, "FORMAT=" << IcyStatusLineFormat );
         debugs(57, 9, "ICY " << status() << " " << reason());
-        packerPrintf(p, IcyStatusLineFormat, status(), reason());
+        p->Printf(IcyStatusLineFormat, status(), reason());
         return;
     }
 
     debugs(57, 9, "packing sline " << this << " using " << p << ":");
     debugs(57, 9, "FORMAT=" << Http1StatusLineFormat );
     debugs(57, 9, "HTTP/" << version.major << "." << version.minor << " " << status() << " " << reason());
-    packerPrintf(p, Http1StatusLineFormat, version.major, version.minor, status(), reason());
+    p->Printf(Http1StatusLineFormat, version.major, version.minor, status(), reason());
 }
 
 /*