forked from yaosj2k/dnsforwarder
-
Notifications
You must be signed in to change notification settings - Fork 9
/
stringchunk.h
executable file
·109 lines (87 loc) · 4.25 KB
/
stringchunk.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef STRINGCHUNK_H_INCLUDED
#define STRINGCHUNK_H_INCLUDED
#include "simpleht.h"
#include "stringlist.h"
#include "array.h"
#include "stablebuffer.h"
typedef struct _StringChunk{
StringList *List;
/* Positions of every domain in `List' */
SimpleHT List_Pos;
/* Positions of every domain in `List_W' */
Array List_W_Pos;
/* Chunk of all additional datas */
StableBuffer AdditionalDataChunk;
} StringChunk;
typedef BOOL (*DataCompare)(const void **Data, const void *Expected);
int StringChunk_Init(StringChunk *dl, StringList *List);
int StringChunk_Add(StringChunk *dl,
const char *Str,
const void *AdditionalData,
int LengthOfAdditionalData
);
int StringChunk_Add_Domain(StringChunk *dl,
const char *Domain,
const void *AdditionalData,
int LengthOfAdditionalData /* The length will not be stored. */
);
/* NOTICE : Data address returned, not offset. */
BOOL StringChunk_Match_NoWildCard(StringChunk *dl,
const char *Str,
const uint32_t *HashValue,
void **Data,
DataCompare cb,
void *Expected
);
BOOL StringChunk_Match_OnlyWildCard(StringChunk *dl,
const char *Str,
void **Data,
DataCompare cb,
void *Expected
);
BOOL StringChunk_Match_OnlyWildCard_GetOne(StringChunk *dl,
const char *Str,
void **Data,
DataCompare cb,
void *Expected
);
BOOL StringChunk_Match(StringChunk *dl,
const char *Str,
const uint32_t *HashValue,
void **Data,
DataCompare cb,
void *Expected
);
BOOL StringChunk_Match_Exactly(StringChunk *dl,
const char *Str,
const uint32_t *HashValue,
void **Data,
DataCompare cb,
void *Expected
);
BOOL StringChunk_Domain_Match_NoWildCard(StringChunk *dl,
const char *Domain,
const uint32_t *HashValue,
void **Data,
DataCompare cb,
void *Expected
);
/* Closest */
BOOL StringChunk_Domain_Match(StringChunk *dl,
const char *Domain,
const uint32_t *HashValue,
void **Data,
DataCompare cb,
void *Expected
);
BOOL StringChunk_Domain_Match_WildCardRandom(StringChunk *dl,
const char *Domain,
const uint32_t *HashValue,
void **Data,
DataCompare cb,
void *Expected
);
const char *StringChunk_Enum_NoWildCard(StringChunk *dl, int32_t *Start, void **Data);
void StringChunk_Free(StringChunk *dl, BOOL FreeStringList);
int InitChunk(StringChunk **dl);
#endif /* STRINGCHUNK_H_INCLUDED */