-
Notifications
You must be signed in to change notification settings - Fork 638
Expand file tree
/
Copy pathToken.h
More file actions
82 lines (66 loc) · 2.02 KB
/
Token.h
File metadata and controls
82 lines (66 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Copyright (C) 1996-2026 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
* Please see the COPYING and CONTRIBUTORS files for details.
*/
#ifndef SQUID_SRC_FORMAT_TOKEN_H
#define SQUID_SRC_FORMAT_TOKEN_H
#include "format/ByteCode.h"
#include "proxyp/Elements.h"
/*
* Squid configuration allows users to define custom formats in
* several components.
* - logging
* - external ACL input
* - deny page URL
*
* These enumerations and classes define the API for parsing of
* format directives to define these patterns. Along with output
* functionality to produce formatted buffers.
*/
namespace Format
{
class TokenTableEntry;
#define LOG_BUF_SZ (MAX_URL<<2)
// XXX: inherit from linked list
class Token
{
public:
Token();
~Token();
/// Initialize the format token registrations
static void Init();
/** parses a single token. Returns the token length in characters,
* and fills in this item with the token information.
* def is for sure null-terminated.
*/
int parse(const char *def, enum Quoting *quote);
ByteCode_t type;
const char *label;
struct {
char *string;
// TODO: Add ID caching for protocols other than PROXY protocol.
/// the cached ID of the parsed header or zero
ProxyProtocol::Two::FieldType headerId;
struct {
char *header;
char *element;
char separator;
} header;
uint8_t byteValue; // %byte{} parameter or zero
} data;
int widthMin; ///< minimum field width
int widthMax; ///< maximum field width
enum Quoting quote;
bool left;
bool space;
bool zero;
int divisor; // class invariant: MUST NOT be zero.
Token *next; // TODO: move from linked list to array
private:
const char *scanForToken(TokenTableEntry const table[], const char *cur);
};
} // namespace Format
#endif /* SQUID_SRC_FORMAT_TOKEN_H */