]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
make isblank not static
authorMiek Gieben <miekg@NLnetLabs.nl>
Tue, 13 Dec 2005 14:59:54 +0000 (14:59 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Tue, 13 Dec 2005 14:59:54 +0000 (14:59 +0000)
added -preproc to Makefile

and my grummy ldns-splitzone.c

examples/ldns-splitzone.c
ldns/util.h.in

index e700f095f0bec506c4c027418f056dbec7b2a241..814094d85dd7b6037f4442ea9dd6ba6a12cbae22 100644 (file)
@@ -72,16 +72,21 @@ main(int argc, char **argv)
        size_t split;
        size_t i;
        int splitting;
+       int compare;
        size_t file_counter;
        ldns_rdf *origin = NULL;
        ldns_rdf *current_rdf;
        ldns_rr *current_rr;
+       ldns_rr *lastrr;
+       ldns_rr_list *last_rrset;
 
        progname = strdup(argv[0]);
        split = 0;
        splitting = NO_SPLIT; 
        file_counter = 0;
        lastname = NULL;
+       lastrr = NULL;
+       last_rrset = ldns_rr_list_new();
 
        while ((c = getopt(argc, argv, "n:o:")) != -1) {
                switch(c) {
@@ -149,20 +154,29 @@ main(int argc, char **argv)
                current_rr = ldns_rr_list_rr(zrrs, i);
                current_rdf = ldns_rr_owner(current_rr);
 
+               compare = ldns_dname_compare(current_rdf, lastname);
+
+               if (compare == 0) {
+                       ldns_rr_list_push_rr(last_rrset, current_rr);
+               }
+
                if (i > 0 && (i % split) == 0) {
                        splitting = INTENT_TO_SPLIT;
                }
 
                if (splitting == INTENT_TO_SPLIT) { 
-                       if (ldns_dname_compare(current_rdf, lastname) != 0) {
+                       if (compare != 0) {
                                splitting = SPLIT_NOW;
                        } 
-                       /* else: do nothing */
                }
 
                if (splitting == SPLIT_NOW) {
+
                        fclose(fp);
 
+                       ldns_rr_list_push_rr(last_rrset, lastrr);
+                       ldns_rr_list_print(stderr, last_rrset);
+
                        /* SPLIT */
                        lastname = NULL;
                        splitting = NO_SPLIT;
@@ -171,12 +185,26 @@ main(int argc, char **argv)
                                exit(EXIT_FAILURE);
                        }
                        ldns_rr_print(fp, current_rr); 
+
+                       /* remove them */
+                       ldns_rr_list_free(last_rrset);
+                       last_rrset = ldns_rr_list_new();
+
+                       continue;
                }
 
                if (splitting == NO_SPLIT || splitting == INTENT_TO_SPLIT) {
-                       ldns_rr_print(fp, current_rr);
+                       ldns_rr_print(fp, current_rr); 
+               }
+
+               if (compare != 0) {
+                       /* remove them */
+                       ldns_rr_list_free(last_rrset);
+                       last_rrset = ldns_rr_list_new();
                }
+               /* remember the last seen rr */
                lastname = current_rdf;
+               lastrr = current_rr;
        }
        fclose(fp); 
 
index d0cc64dcc434b829914ae162cca19101df6d1d3d..50830306446ffed00fceb726c259002b26014339 100644 (file)
@@ -107,7 +107,7 @@ ldns_write_uint32(void *dst, uint32_t data)
 
 #ifndef HAVE_ISBLANK
 /* gnuism */
-static int 
+int 
 isblank(int c)
 {
  return (c==' ') || (c=='\t');