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
|
#include <stdio.h>
#include <search.h>
#include <string.h>
#include <arpa/inet.h>
int ipv6_compare (const struct in6_addr * a, const struct in6_addr * b) {
return memcmp(a->s6_addr, b->s6_addr, sizeof a->s6_addr);
}
struct zone {
struct in6_addr addr;
int mask;
char * email;
char ** ns;
int nslen;
struct zone * next;
};
struct ns {
struct in6_addr addr;
int mask;
char ** ns;
int nslen;
struct ns * next;
};
struct ptr {
struct in6_addr addr;
int mask;
char ptr;
time_t created;
};
struct config {
struct * zone; // linked list TODO use https://en.wikipedia.org/wiki/Trie instead
struct * ns; // linked list TODO use https://en.wikipedia.org/wiki/Trie instead
void * ptrrp; // ptr root pointer for tsearch(3)
};
struct config config (FILE * file) {
char line[1024];
while (!ferror(file) && !feof(file)) {
char * ret = fgets(line, sizeof line, file);
if (!ret)
break;
char * cp = strchr(line, '/');
int mask = -1;
if (cp) {
cp = '\0';
if (cp[1] <= '9' && cp[1] >= '0')
mask = strtol(cp+1, &cp, 10);
else
cp++;
} else {
cp = line;
for (; strchr("0123456789abcdefABCDEF:", *cp); cp++);
if (!*cp)
continue;
cp++;
}
struct in6_addr addr;
switch (inet_pton(AF_INET6, line, addr.s6_addr)) {
case 0:
continue;
case -1:
perror("inet_pton");
exit(EXIT_FAILURE);
}
line = cp;
char * saveptr = NULL;
cp = strtok_r(line, "\t\r\n ", &saveptr);
if (!cp)
continue;
if (mask == -1) { // ptr record
struct ;
continue;
}
}
}
/*
int main (int argc, char ** argv) {
if (argc != 2) {
fprintf(stderr, "6d configuration file checker\n"
" usage: %s configfile\n"
"an example configuration file can be found in the following locations:\n"
" /etc/6d\n"
" /usr/share/doc/6d/conf\n"
" http://ni.šijanec.eu/sijanec/r/tree/prog/6/6d.conf\n"
, argv[0]);
return 1;
}
config_file();
}
*/
|