]> git.ipfire.org Git - thirdparty/squid.git/blob - src/format/Format.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / format / Format.h
1 /*
2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
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
9 #ifndef _SQUID_FORMAT_FORMAT_H
10 #define _SQUID_FORMAT_FORMAT_H
11
12 #include "base/RefCount.h"
13 #include "ConfigParser.h"
14
15 /*
16 * Squid configuration allows users to define custom formats in
17 * several components.
18 * - logging
19 * - external ACL input
20 * - deny page URL
21 *
22 * These enumerations and classes define the API for parsing of
23 * format directives to define these patterns. Along with output
24 * functionality to produce formatted buffers.
25 */
26
27 class AccessLogEntry;
28 typedef RefCount<AccessLogEntry> AccessLogEntryPointer;
29 class MemBuf;
30 class StoreEntry;
31
32 namespace Format
33 {
34
35 class Token;
36
37 // XXX: inherit from linked list
38 class Format
39 {
40 public:
41 Format(const char *name);
42 virtual ~Format();
43
44 /* very inefficent parser, but who cares, this needs to be simple */
45 /* First off, let's tokenize, we'll optimize in a second pass.
46 * A token can either be a %-prefixed sequence (usually a dynamic
47 * token but it can be an escaped sequence), or a string. */
48 bool parse(const char *def);
49
50 /// assemble the state information into a formatted line.
51 void assemble(MemBuf &mb, const AccessLogEntryPointer &al, int logSequenceNumber) const;
52
53 /// dump this whole list of formats into the provided StoreEntry
54 void dump(StoreEntry * entry, const char *directiveName, bool eol = true) const;
55
56 char *name;
57 Token *format;
58 Format *next;
59 };
60
61 } // namespace Format
62
63 #endif /* _SQUID_FORMAT_FORMAT_H */
64