]>
Commit | Line | Data |
---|---|---|
31971e6a AJ |
1 | #ifndef SQUID_SRC_FORMAT_CONFIG_H |
2 | #define SQUID_SRC_FORMAT_CONFIG_H | |
3 | ||
4 | #include "format/Format.h" | |
5 | //#include "format/TokenTableEntry.h" | |
6 | #include "SquidString.h" | |
7 | #include <list> | |
8 | ||
9 | class StoreEntry; | |
10 | ||
11 | namespace Format | |
12 | { | |
13 | ||
14 | class TokenTableEntry; | |
15 | ||
16 | /// A namespace or 'set' of tokens | |
17 | /// components register their namespace prefix and an array of tokens | |
18 | /// which can then be embeded in any format. | |
19 | class TokenNamespace | |
20 | { | |
21 | public: | |
22 | TokenNamespace(const String &nsName, TokenTableEntry const *tSet) : prefix(nsName), tokenSet(tSet) {} | |
23 | ||
24 | /// prefix namespace name (excluding '::') | |
25 | String prefix; | |
26 | ||
27 | /// array of tokens inside this namespace | |
28 | /// The set of tokens may change, but the location of it pointed to from here must not. | |
29 | TokenTableEntry const *tokenSet; | |
30 | }; | |
31 | ||
32 | /// The set of custom formats defined in squid.conf | |
33 | /// | |
34 | class FmtConfig | |
35 | { | |
36 | public: | |
37 | /// Parse a log format directive line (logfile_format) | |
38 | void parseFormats(); | |
39 | ||
40 | /// Dump/display the formats currently known to the provided StoreEntry object | |
41 | void dumpFormats(StoreEntry *e, const char *name) { | |
42 | formats->dump(e, name); | |
43 | } | |
44 | ||
45 | /* Register a namespace set of tokens to be accepted by the format parser. | |
46 | * Multiple arrays can be registered, they will be scanned for | |
47 | * in order registered. So care needs to be taken that arrays registered | |
48 | * first do not overlap or consume tokens registered later for a namespace. | |
49 | */ | |
50 | void registerTokens(const String &nsName, TokenTableEntry const *tokenArray); | |
51 | ||
52 | /// Linked list of custom formats | |
53 | Format *formats; | |
54 | ||
55 | /// list of token namespaces registered | |
56 | std::list<TokenNamespace> tokens; | |
57 | ||
58 | #if USE_ADAPTATION | |
59 | bool hasAdaptToken; | |
60 | #endif | |
61 | ||
62 | #if ICAP_CLIENT | |
63 | bool hasIcapToken; | |
64 | #endif | |
65 | }; | |
66 | ||
67 | extern FmtConfig TheConfig; | |
68 | ||
69 | } // namespace Format | |
70 | ||
71 | // Legacy parsing wrappers | |
72 | #define parse_format(X) (X)->parseFormats() | |
73 | #define free_format(X) do{ delete (*(X)).formats; (*(X)).formats=NULL; }while(false) | |
74 | #define dump_format(E,N,D) (D).dumpFormats((E),(N)) | |
75 | ||
76 | #endif |