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 */
}
if (other.size() != 0)
- packerPrintf(p, (pcount ? ", " SQUIDSTRINGPH : SQUIDSTRINGPH),
+ p->Printf((pcount ? ", " SQUIDSTRINGPH : SQUIDSTRINGPH),
SQUIDSTRINGPRINT(other));
}
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);
}
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
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
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
{
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 */
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);
}
/*
}
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);
}
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 */
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());
}
/*