]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/format/Config.h
f80a4bf92f55bbe05cbe0c8eb9b1a215fe60544a
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef SQUID_SRC_FORMAT_CONFIG_H
10 #define SQUID_SRC_FORMAT_CONFIG_H
12 #include "format/Format.h"
13 #include "SquidString.h"
22 class TokenTableEntry
;
24 /// A namespace or 'set' of tokens
25 /// components register their namespace prefix and an array of tokens
26 /// which can then be embedded in any format.
30 TokenNamespace(const SBuf
&nsName
, TokenTableEntry
const *tSet
) : prefix(nsName
), tokenSet(tSet
) {}
32 /// prefix namespace name (excluding '::')
35 /// array of tokens inside this namespace
36 /// The set of tokens may change, but the location of it pointed to from here must not.
37 TokenTableEntry
const *tokenSet
;
40 /// The set of custom formats defined in squid.conf
45 /// Parse a log format directive line (logfile_format)
48 /// Dump/display the formats currently known to the provided StoreEntry object
49 void dumpFormats(StoreEntry
*e
, const char *name
) {
50 formats
->dump(e
, name
);
53 /* Register a namespace set of tokens to be accepted by the format parser.
54 * Multiple arrays can be registered, they will be scanned for
55 * in order registered. So care needs to be taken that arrays registered
56 * first do not overlap or consume tokens registered later for a namespace.
58 void registerTokens(const SBuf
&nsName
, TokenTableEntry
const *tokenArray
);
60 /// Linked list of custom formats
63 /// list of token namespaces registered
64 std::list
<TokenNamespace
> tokens
;
75 extern FmtConfig TheConfig
;
79 // Legacy parsing wrappers
80 #define parse_format(X) (X)->parseFormats()
81 #define free_format(X) do{ delete (*(X)).formats; (*(X)).formats=NULL; }while(false)
82 #define dump_format(E,N,D) (D).dumpFormats((E),(N))