]> git.ipfire.org Git - thirdparty/squid.git/blame - src/format/Format.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / format / Format.h
CommitLineData
bbc27441 1/*
ef57eb7b 2 * Copyright (C) 1996-2016 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
38e16f92
AJ
9#ifndef _SQUID_FORMAT_FORMAT_H
10#define _SQUID_FORMAT_FORMAT_H
11
8bf217bd 12#include "base/RefCount.h"
2eceb328 13#include "ConfigParser.h"
bbc27441 14
38e16f92
AJ
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
27class AccessLogEntry;
41ebd397 28typedef RefCount<AccessLogEntry> AccessLogEntryPointer;
38e16f92
AJ
29class MemBuf;
30class StoreEntry;
31
32namespace Format
33{
34
35class Token;
36
37// XXX: inherit from linked list
38class Format
39{
40public:
41 Format(const char *name);
2eceb328 42 virtual ~Format();
38e16f92
AJ
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. */
f4698e0b 48 bool parse(const char *def);
38e16f92
AJ
49
50 /// assemble the state information into a formatted line.
41ebd397 51 void assemble(MemBuf &mb, const AccessLogEntryPointer &al, int logSequenceNumber) const;
38e16f92
AJ
52
53 /// dump this whole list of formats into the provided StoreEntry
4e56d7f6 54 void dump(StoreEntry * entry, const char *directiveName, bool eol = true) const;
38e16f92
AJ
55
56 char *name;
57 Token *format;
58 Format *next;
59};
60
61} // namespace Format
62
63#endif /* _SQUID_FORMAT_FORMAT_H */
f53969cc 64