-
Notifications
You must be signed in to change notification settings - Fork 1
/
extractor.h
69 lines (51 loc) · 1.48 KB
/
extractor.h
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
#ifndef MAFIA_EXTRACTOR_H
#define MAFIA_EXTRACTOR_H
#define MAX_INTERESTED_PAIRS 8
#define MAX_ENRICHEE 32
#define MAX_ORIG_VAL_LEN 1024
#define MAX_ENRICHED_VALUE_LEN 4096
#define MAX_PAYLOAD_SIZE 8192
#if __GNUC__ >= 3
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else
#define likely(x) (x)
#define unlikely(x) (x)
#endif
#define ENR_IGNORE 1
#define ENR_DELETE 2
#define ENR_UPDATE 3
#define ENR_ADD 4
#define ENR_GET 5
#include <stdio.h>
#include <string.h>
#include <stdint.h>
struct enrichee {
int orig_name_len;
const char *orig_name;
int orig_value_len;
const char *orig_value; // 如果是string的话包括双引号
int enriched_value_len;
char *enriched_value;
int use;
int mode;
};
typedef int (*enricher)(struct enrichee *enrichee__);
struct interested_pair {
int mode;
int name_len;
char *name;
enricher enricher__;
};
extern struct enrichee enrichees[MAX_ENRICHEE];
int extract(const char *buf, const char *buf_end);
int register_enricher(const char *interested_name, int mode, enricher enricher__);
int init();
int ip_enricher(struct enrichee *enrichee__);
int ua_enricher(struct enrichee *enrichee__);
int time_enricher(struct enrichee *enrichee__);
int kafka_enricher(struct enrichee *enrichee__);
int type_enricher(struct enrichee *enrichee__);
int guid_enricher(struct enrichee *enrichee__);
int combine_enrichee(const char *buf, char *result);
#endif // MAFIA_EXTRACTOR_H