summaryrefslogtreecommitdiffstats
path: root/prog/6/conf.c
diff options
context:
space:
mode:
Diffstat (limited to 'prog/6/conf.c')
-rw-r--r--prog/6/conf.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/prog/6/conf.c b/prog/6/conf.c
new file mode 100644
index 0000000..6945876
--- /dev/null
+++ b/prog/6/conf.c
@@ -0,0 +1,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();
+}
+*/