]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
framework laid for reading zonefiles. Addition to the db.miek.nl zonefile
authorMiek Gieben <miekg@NLnetLabs.nl>
Tue, 26 Jul 2005 11:48:44 +0000 (11:48 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Tue, 26 Jul 2005 11:48:44 +0000 (11:48 +0000)
TODO
ldns/parse.h
ldns/zone.h
parse.c
tests/db.miek.nl
zone.c

diff --git a/TODO b/TODO
index aca18aa3c5103405d7243c9530787aadfe5d7dd9..6173283e5079c614a94c2383a91fbc65e0361f7a 100644 (file)
--- a/TODO
+++ b/TODO
@@ -35,3 +35,4 @@ o private key type? This works, but not (yet) for tsig stuff
        work in progress - works for RSA/DSA. I want to 
        fold in the tsig stuff as well
 o install mx, keygen, chaos somewhere, along with manpages??
+o All lookup table stuff in _table types?
index 66aba83e66bfdcb28342ba618abe5344648f64e0..9a5a5aa118640199b46197a0737704955599fcce 100644 (file)
 #include <ldns/common.h>
 #include <ldns/buffer.h>
 
-
 #define LDNS_PARSE_SKIP_SPACE          "\f\n\r\v"
 #define LDNS_PARSE_NORMAL              " \f\n\r\t\v"
 #define LDNS_PARSE_NO_NL               " \t"
 #define LDNS_MAX_LINELEN               512
 #define LDNS_MAX_KEYWORDLEN            32
 
+/**
+ * different type of directives in zone files
+ * We now deal with $TTL, $ORIGIN and $INCLUDE.
+ * The latter is not implemented in ldns (yet)
+ */
+enum ldns_enum_directive
+{
+       LDNS_DIR_TTL,
+       LDNS_DIR_ORIGIN,
+       LDNS_DIR_INCLUDE
+};
+typedef enum ldns_enum_directive ldns_directive;
+
 /** 
  * returns a token/char from the stream F.
  * This function deals with ( and ) in the stream,
index e25b1d4550bdc984419126744f2152193030bd38..a0189f244029832b447fcccd40d61c9ad2fd7b0d 100644 (file)
@@ -88,4 +88,8 @@ bool ldns_zone_push_rr(ldns_zone *z, ldns_rr *rr);
  */
 bool ldns_zone_rr_is_glue(ldns_zone *z, ldns_rr *rr);
 
+
+ldns_zone *
+ldns_zone_new_frm_fp(FILE *fp, ldns_rdf **origin, uint16_t *ttl, ldns_rr_class *c);
+
 #endif /* LDNS_ZONE_H */
diff --git a/parse.c b/parse.c
index bb639ff769519a0f413c1c41a5fa78207ec8978a..2e9e8c53418a90cacc9d4b879c72e7a41dadf0a0 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -8,13 +8,18 @@
  * See the file LICENSE for the license
  */
 #include <ldns/config.h>
-
 #include <ldns/dns.h>
 
-
 #include <limits.h>
 #include <strings.h>
 
+ldns_lookup_table ldns_directive_types[] = {
+        { LDNS_DIR_TTL, "$TTL" },  
+        { LDNS_DIR_ORIGIN, "$ORIGIN" }, 
+        { LDNS_DIR_INCLUDE, "$INCLUDE" },  
+        { 0, NULL }
+};
+
 ssize_t
 ldns_fget_keyword_data(FILE *f, const char *keyword, const char *k_del, char *data, 
                const char *d_del, size_t data_limit)
@@ -300,35 +305,6 @@ tokenread:
        return (ssize_t)i;
 }
 
-#if 0
-# not needed anymore
-
-char *
-ldns_str_remove_comment(char *str)
-{
-       char *s;
-       int comment;
-       char *str2;
-
-       comment = 0;
-       str2 = strdup(str);
-
-       for(s = str2; *s; s++) {
-               if (*s == ';')  {
-                       comment = 1;
-               }
-               if (*s == '\n') {
-                       *s = ' ';
-                       comment = 0;
-               }
-               if (comment == 1) {
-                       *s = ' ';
-               }
-       }
-       return str2;
-}
-#endif
-
 void
 ldns_bskipc(ldns_buffer *buffer, char c)
 {
@@ -394,3 +370,12 @@ ldns_fskipcs(FILE *fp, const char *s)
                }
        }
 }
+
+ldns_directive
+ldns_directive_new_frm_str(const char *str, void **arg)
+{
+       str = str;
+       arg = arg;
+       /* directive<SPACE>arguments */
+       return LDNS_DIR_TTL;
+}
index f760227309172aabea8b388d27fac60cceb0991b..9f0bc3ff2049fc4ae3e2d584839df3eeeca280b1 100644 (file)
@@ -1,7 +1,7 @@
 ;
 ; BIND data file for miek.nl for internal use
 ;
-$TTL    1H
+$TTL    2H
 @       IN      SOA     elektron.atoom.net. miekg.atoom.net. (
                      2005060700         ; Serial
                              6H         ; Refresh
@@ -13,5 +13,10 @@ $TTL    1H
 @      IN      MX      10 elektron.atoom.net.
 @      IN      A       192.168.1.2
 
-a      IN      A       192.168.1.2
-www     IN      CNAME   a
+god    IN      A       192.168.1.2
+
+
+sub.domain.miek.nl     IN      NS elektron.atoom.net.
+                       IN      MX 10 elektron.atoom.net.
+
+www     IN      CNAME   god
diff --git a/zone.c b/zone.c
index 47e86f518329e501b0ca6d160797dba7f57ca760..4dc4756135581d62c397444df4a935a5f34c2f02 100644 (file)
--- a/zone.c
+++ b/zone.c
@@ -60,6 +60,30 @@ ldns_zone_rr_is_glue(ldns_zone *z, ldns_rr *rr)
        return false;
 }
 
+/* we don't want state, so we have to give it as arguments */
+/* we regocnize:
+ * $TTL, $ORIGIN
+ */
+ldns_zone *
+ldns_zone_new_frm_fp(FILE *fp, ldns_rdf **origin, uint16_t *ttl, ldns_rr_class *c)
+{
+#if 0
+       ldns_zone *newzone;
+       ldns_rr *rr;
+#endif
+
+       /* read until we got a soa, all crap above is discarded 
+        * except $directives
+        */
+
+       fp = fp;
+       origin = origin;
+       ttl = ttl;
+       c = c;
+
+       /* re-order stuff with rrsets */
+       return NULL;
+}
 
 #if 0
 /**