forked from yaosj2k/dnsforwarder
-
Notifications
You must be signed in to change notification settings - Fork 9
/
hostscontainer.h
executable file
·51 lines (38 loc) · 1.56 KB
/
hostscontainer.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
#ifndef HOSTSCONTAINER_H_INCLUDED
#define HOSTSCONTAINER_H_INCLUDED
#define DOMAIN_NAME_LENGTH_MAX 128
#include "stringchunk.h"
#include "oo.h"
typedef enum _HostsRecordType{
HOSTS_TYPE_TOO_LONG = -1,
HOSTS_TYPE_UNKNOWN = 0,
HOSTS_TYPE_A = 1 << 1,
HOSTS_TYPE_AAAA = 1 << 2,
HOSTS_TYPE_CNAME = 1 << 3,
HOSTS_TYPE_EXCLUEDE = 1 << 4,
HOSTS_TYPE_GOOD_IP_LIST = 1 << 5,
} HostsRecordType;
typedef struct _HostsContainer HostsContainer;
/* Return 0 : continue; Otherwise : break; */
typedef int (*HostsFindFunc)(int Number, /* Start with 1 */
HostsRecordType Type,
const void *Data,
void *Arg
);
struct _HostsContainer{
PRIMEMB StringChunk Mappings;
PRIMEMB StableBuffer Table;
PRIMEMB StableBuffer TableIPAddr;
PUBMEMB HostsRecordType (*Load)(HostsContainer *Container,
const char *MetaLine
);
PUBMEMB const void *(*Find)(HostsContainer *Container,
const char *Name,
HostsRecordType Type,
HostsFindFunc Func,
void *Arg
);
PUBMEMB void (*Free)(HostsContainer *Container);
};
int HostsContainer_Init(HostsContainer *Container);
#endif /* HOSTSCONTAINER_H_INCLUDED */