]>
Commit | Line | Data |
---|---|---|
31971e6a AJ |
1 | #ifndef _SQUID_FORMAT_TOKEN_H |
2 | #define _SQUID_FORMAT_TOKEN_H | |
3 | ||
4 | //#include "format/TokenTableEntry.h" | |
5 | #include "format/ByteCode.h" | |
6 | ||
7 | /* | |
8 | * Squid configuration allows users to define custom formats in | |
9 | * several components. | |
10 | * - logging | |
11 | * - external ACL input | |
12 | * - deny page URL | |
13 | * | |
14 | * These enumerations and classes define the API for parsing of | |
15 | * format directives to define these patterns. Along with output | |
16 | * functionality to produce formatted buffers. | |
17 | */ | |
18 | ||
19 | namespace Format | |
20 | { | |
21 | ||
22 | class TokenTableEntry; | |
23 | ||
24 | #define LOG_BUF_SZ (MAX_URL<<2) | |
25 | ||
26 | // XXX: inherit from linked list | |
27 | class Token | |
28 | { | |
29 | public: | |
30 | Token() : type(LFT_NONE), | |
31 | label(NULL), | |
32 | widthMin(-1), | |
33 | widthMax(-1), | |
34 | quote(LOG_QUOTE_NONE), | |
1a6347cd FC |
35 | left(false), |
36 | space(false), | |
37 | zero(false), | |
31971e6a AJ |
38 | divisor(0), |
39 | next(NULL) | |
40 | { data.string = NULL; } | |
41 | ||
42 | ~Token(); | |
43 | ||
44 | /// Initialize the format token registrations | |
45 | static void Init(); | |
46 | ||
47 | /** parses a single token. Returns the token length in characters, | |
48 | * and fills in this item with the token information. | |
49 | * def is for sure null-terminated. | |
50 | */ | |
f4698e0b | 51 | int parse(const char *def, enum Quoting *quote); |
31971e6a AJ |
52 | |
53 | ByteCode_t type; | |
54 | const char *label; | |
55 | union { | |
56 | char *string; | |
57 | ||
58 | struct { | |
59 | char *header; | |
60 | char *element; | |
61 | char separator; | |
62 | } header; | |
63 | char *timespec; | |
64 | } data; | |
65 | int widthMin; ///< minimum field width | |
66 | int widthMax; ///< maximum field width | |
67 | enum Quoting quote; | |
1a6347cd FC |
68 | bool left; |
69 | bool space; | |
70 | bool zero; | |
31971e6a AJ |
71 | int divisor; |
72 | Token *next; /* todo: move from linked list to array */ | |
73 | ||
74 | private: | |
f4698e0b | 75 | const char *scanForToken(TokenTableEntry const table[], const char *cur); |
31971e6a AJ |
76 | }; |
77 | ||
31971e6a AJ |
78 | } // namespace Format |
79 | ||
80 | #endif /* _SQUID_FORMAT_TOKEN_H */ |