279 debugs(46, 8,
"compare tokens '" << lte->configTag <<
"' with '" <<
cur <<
"'");
280 if (strncmp(lte->configTag,
cur, strlen(lte->configTag)) == 0) {
281 type = lte->tokenType;
282 label = lte->configTag;
283 debugs(46, 7,
"Found token '" << label <<
"'");
284 return cur + strlen(lte->configTag);
292template <
typename Integer>
296 constexpr auto minValue = std::numeric_limits<Integer>::min();
297 constexpr auto maxValue = std::numeric_limits<Integer>::max();
304 ": Expected a decimal integer without leading zeros but got '",
305 rawInput,
"'"),
Here());
308 static_assert(minValue <= 0);
309 static_assert(0 <= maxValue);
315 using ParsedInteger = int64_t;
316 static_assert(minValue >= std::numeric_limits<ParsedInteger>::min());
317 static_assert(maxValue <= std::numeric_limits<ParsedInteger>::max());
319 ParsedInteger rawValue = 0;
320 if (!
tok.int64(rawValue, 10,
false)) {
324 ": Expected an unsigned decimal integer but got '",
325 rawInput,
"'"),
Here());
331 ": Trailing garbage after ", rawValue,
" in '",
332 rawInput,
"'"),
Here());
335 if (rawValue > maxValue) {
337 ": Expected an integer value not exceeding ", maxValue,
338 " but got ", rawValue),
Here());
341 if (rawValue < minValue) {
343 ": Expected an integer value not below ", minValue,
344 " but got ", rawValue),
Here());
347 return Integer(rawValue);
357 const char *
cur = def;
359 auto l = strcspn(
cur,
"%");
447 widthMin = strtol(
cur, &endp, 10);
452 widthMax = strtol(
cur, &endp, 10);
460 l = strcspn(
cur,
"}");
475 debugs(46, 7,
"check for possible " << itr.prefix <<
":: token");
476 const size_t len = itr.prefix.length();
477 if (itr.prefix.cmp(
cur, len) == 0 &&
cur[len] ==
':' &&
cur[len+1] ==
':') {
478 debugs(46, 5,
"check for " << itr.prefix <<
":: token in '" <<
cur <<
"'");
479 const char *old =
cur;
480 cur = scanForToken(itr.tokenSet,
cur+len+2);
492 if (strncmp(
cur,
"http::", 6) == 0 && *(
cur+6) !=
'%' )
499 debugs(46, 5,
"scan for possible Misc token");
503 debugs(46, 5,
"scan for possible 2C token");
508 debugs(46, 5,
"scan for possible 1C token");
518 if (*
cur ==
'{' && !data.string) {
521 l = strcspn(
cur,
"}");
541 throw TextException(
"logformat %byte requires a parameter (e.g., %byte{10})",
Here());
543 if (
const auto v = ParseUnsignedDecimalInteger<uint8_t>(
"logformat %byte{value}",
SBuf(data.string)))
546 throw TextException(
"logformat %byte{n} does not support zero n values yet",
Here());
570 char *header = data.string;
571 const auto initialType = type;
573 const auto pseudoHeader = header[0] ==
':';
574 char *cp = strchr(pseudoHeader ? header+1 : header,
':');
580 if (*cp ==
',' || *cp ==
';' || *cp ==
':') {
581 data.header.separator = *cp;
584 data.header.separator =
',';
587 data.header.element = cp;
623 throw TexcHere(
ToSBuf(
"Can't parse configuration token: '", def,
"': missing header name"));
627 else if (pseudoHeader)
628 throw TexcHere(
ToSBuf(
"Pseudo headers are not supported in this context; got: '", def,
"'"));
630 data.header.header = header;
684 for (
int i = widthMax; i > 0; --i)
714 debugs(46,
DBG_CRITICAL,
"WARNING: The \">eui\" formatting code requires EUI features which are disabled in this Squid.");
729 data.string =
xstrdup(
"urlgroup");
730 data.header.header = data.string;
751 data.string =
nullptr;
752 data.header.header =
nullptr;
753 data.header.element =
nullptr;
754 data.header.separator =
',';
#define Here()
source code location of the caller
#define TexcHere(msg)
legacy convenience macro; it is not difficult to type Here() now
static Integer ParseUnsignedDecimalInteger(const char *description, const SBuf &rawInput)
interprets input as an unsigned decimal integer that fits the specified Integer type
One entry in a table of format tokens.
struct SquidConfig::@90 onoff
bool logTlsServerHelloDetails
an std::runtime_error with thrower location info
#define DBG_PARSE_NOTE(x)
#define debugs(SECTION, LEVEL, CONTENT)
Two::FieldType FieldNameToFieldType(const SBuf &nameOrId)
SBuf ToSBuf(Args &&... args)
slowly stream-prints all arguments into a freshly allocated SBuf
char * xstrncpy(char *dst, const char *src, size_t n)