1 #ifndef HOSTSCONTAINER_H_INCLUDED 2 #define HOSTSCONTAINER_H_INCLUDED 3 4 #define DOMAIN_NAME_LENGTH_MAX 128 5 6 #include "stringchunk.h" 7 #include "oo.h" 8 9 typedef enum _HostsRecordType{ 10 HOSTS_TYPE_TOO_LONG = -1, 11 HOSTS_TYPE_UNKNOWN = 0, 12 HOSTS_TYPE_A = 1 << 1, 13 HOSTS_TYPE_AAAA = 1 << 2, 14 HOSTS_TYPE_CNAME = 1 << 3, 15 HOSTS_TYPE_EXCLUEDE = 1 << 4, 16 HOSTS_TYPE_GOOD_IP_LIST = 1 << 5, 17 18 } HostsRecordType; 19 20 typedef struct _HostsContainer HostsContainer; 21 22 /* Return 0 : continue; Otherwise : break; */ 23 typedef int (*HostsFindFunc)(int Number, /* Start with 1 */ 24 HostsRecordType Type, 25 const void *Data, 26 void *Arg 27 ); 28 29 struct _HostsContainer{ 30 PRIMEMB StringChunk Mappings; 31 PRIMEMB StableBuffer Table; 32 33 PUBMEMB HostsRecordType (*Load)(HostsContainer *Container, 34 const char *MetaLine 35 ); 36 37 PUBMEMB const void *(*Find)(HostsContainer *Container, 38 const char *Name, 39 HostsRecordType Type, 40 HostsFindFunc Func, 41 void *Arg 42 ); 43 44 PUBMEMB void (*Free)(HostsContainer *Container); 45 46 }; 47 48 int HostsContainer_Init(HostsContainer *Container); 49 50 #endif // HOSTSCONTAINER_H_INCLUDED 51