]> git.ipfire.org Git - thirdparty/squid.git/blame - src/format/Config.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / format / Config.h
CommitLineData
bbc27441 1/*
bde978a6 2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
bbc27441
AJ
3 *
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.
7 */
8
31971e6a
AJ
9#ifndef SQUID_SRC_FORMAT_CONFIG_H
10#define SQUID_SRC_FORMAT_CONFIG_H
11
12#include "format/Format.h"
13//#include "format/TokenTableEntry.h"
14#include "SquidString.h"
15#include <list>
16
17class StoreEntry;
18
19namespace Format
20{
21
22class TokenTableEntry;
23
24/// A namespace or 'set' of tokens
25/// components register their namespace prefix and an array of tokens
26/// which can then be embeded in any format.
27class TokenNamespace
28{
29public:
30 TokenNamespace(const String &nsName, TokenTableEntry const *tSet) : prefix(nsName), tokenSet(tSet) {}
31
32 /// prefix namespace name (excluding '::')
33 String prefix;
34
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;
38};
39
40/// The set of custom formats defined in squid.conf
e83cdc25 41///
31971e6a
AJ
42class FmtConfig
43{
44public:
45 /// Parse a log format directive line (logfile_format)
46 void parseFormats();
47
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);
51 }
52
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.
57 */
58 void registerTokens(const String &nsName, TokenTableEntry const *tokenArray);
59
60 /// Linked list of custom formats
61 Format *formats;
62
63 /// list of token namespaces registered
64 std::list<TokenNamespace> tokens;
65
66#if USE_ADAPTATION
67 bool hasAdaptToken;
68#endif
69
70#if ICAP_CLIENT
71 bool hasIcapToken;
72#endif
73};
74
75extern FmtConfig TheConfig;
76
77} // namespace Format
78
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))
83
84#endif
f53969cc 85