]> git.ipfire.org Git - thirdparty/squid.git/blob - src/format/Token.h
Docs: Copyright updates for 2018 (#114)
[thirdparty/squid.git] / src / format / Token.h
1 /*
2 * Copyright (C) 1996-2018 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_TOKEN_H
10 #define _SQUID_FORMAT_TOKEN_H
11
12 #include "format/ByteCode.h"
13
14 /*
15 * Squid configuration allows users to define custom formats in
16 * several components.
17 * - logging
18 * - external ACL input
19 * - deny page URL
20 *
21 * These enumerations and classes define the API for parsing of
22 * format directives to define these patterns. Along with output
23 * functionality to produce formatted buffers.
24 */
25
26 namespace Format
27 {
28
29 class TokenTableEntry;
30
31 #define LOG_BUF_SZ (MAX_URL<<2)
32
33 // XXX: inherit from linked list
34 class Token
35 {
36 public:
37 Token();
38 ~Token();
39
40 /// Initialize the format token registrations
41 static void Init();
42
43 /** parses a single token. Returns the token length in characters,
44 * and fills in this item with the token information.
45 * def is for sure null-terminated.
46 */
47 int parse(const char *def, enum Quoting *quote);
48
49 ByteCode_t type;
50 const char *label;
51 struct {
52 char *string;
53
54 struct {
55 char *header;
56 char *element;
57 char separator;
58 } header;
59 } data;
60 int widthMin; ///< minimum field width
61 int widthMax; ///< maximum field width
62 enum Quoting quote;
63 bool left;
64 bool space;
65 bool zero;
66 int divisor; // class invariant: MUST NOT be zero.
67 Token *next; /* todo: move from linked list to array */
68
69 private:
70 const char *scanForToken(TokenTableEntry const table[], const char *cur);
71 };
72
73 } // namespace Format
74
75 #endif /* _SQUID_FORMAT_TOKEN_H */
76