]> granicus.if.org Git - pdns/commitdiff
I think this will finally give us working zone2sql merge
authorbert hubert <bert.hubert@netherlabs.nl>
Thu, 24 Apr 2014 07:34:53 +0000 (09:34 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Thu, 24 Apr 2014 07:34:53 +0000 (09:34 +0200)
pdns/Makefile.am
pdns/zone2sql.cc
pdns/zoneparser-tng.cc

index 5acc3b6f29c84a010990a33507829aefaae43128..0bf2fd040c1792430ce089fd857032b1d7cd1c92 100644 (file)
@@ -113,7 +113,7 @@ zone2sql_SOURCES=bindparser.yy bindlexer.l bind-dnssec.schema.sqlite3.sql.h \
        zoneparser-tng.cc dnsrecords.cc sillyrecords.cc \
        dnswriter.cc dnslabeltext.cc rcpgenerator.cc dnsparser.cc base64.cc \
        nsecrecords.cc dnssecinfra.cc base32.cc bindparserclasses.hh \
-       dns_random.cc
+       dns_random.cc json.cc json.hh
 
 zone2sql_LDFLAGS=@THREADFLAGS@
 zone2sql_LDADD= $(POLARSSL_LIBS)
index 3b50ecaec18631476d822ce550d59dacc7315a50..02cd8e07fa6d7c006abcf61bf7c50c7d17831024 100644 (file)
@@ -28,7 +28,7 @@
 #include <iostream>
 #include <stdio.h>
 #include "namespaces.hh"
-
+#include "json.hh"
 #include "dns.hh"
 #include "arguments.hh"
 #include "bindparserclasses.hh"
@@ -141,11 +141,7 @@ static void emitDomain(const string& domain, const vector<string> *masters = 0)
     }
   }
 }
-<<<<<<< HEAD
 
-static void emitRecord(const string& zoneName, const string &qname, const string &qtype, const string &ocontent, int ttl, int prio)
-{
-=======
 bool g_doJSONComments;
 static void emitRecord(const string& zoneName, const string &qname, const string &qtype, const string &ocontent, int ttl, int prio, const string& comment="")
 {
@@ -164,7 +160,7 @@ static void emitRecord(const string& zoneName, const string &qname, const string
       recordcomment=stringFromJson(document, "comment", "");
     }
   }
->>>>>>> jsonzone2sql
+
   g_numRecords++;
   string content(ocontent);
 
@@ -423,10 +419,6 @@ try
       DNSResourceRecord rr;
       startNewTransaction();
       emitDomain(zonename);
-<<<<<<< HEAD
-      while(zpt.get(rr)) 
-        emitRecord(zonename, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority);
-=======
       string comment;
       bool seenSOA=false;
       while(zpt.get(rr, &comment))  {
@@ -437,7 +429,6 @@ try
 
         emitRecord(zonename, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority, comment);
       }
->>>>>>> jsonzone2sql
       num_domainsdone=1;
     }
     cerr<<num_domainsdone<<" domains were fully parsed, containing "<<g_numRecords<<" records\n";
index c241e90f67386825e21cfa2d1617989c021c3786..0f58f82e4bf3f9bae6416b249613a2b843512813 100644 (file)
@@ -230,14 +230,17 @@ string ZoneParserTNG::getLineOfFile()
 }
 
 // ODD: this function never fills out the prio field! rest of pdns compensates though
-bool ZoneParserTNG::get(DNSResourceRecord& rr) 
+bool ZoneParserTNG::get(DNSResourceRecord& rr, std::string* comment
 {
  retry:;
   if(!getTemplateLine() && !getLine())
     return false;
 
   boost::trim_right_if(d_line, is_any_of(" \r\n\x1a"));
-
+  if(comment)
+    comment->clear();
+  if(comment && d_line.find(';') != string::npos)
+    *comment = d_line.substr(d_line.find(';'));
   parts_t parts;
   vstringtok(parts, d_line);
 
@@ -314,8 +317,9 @@ bool ZoneParserTNG::get(DNSResourceRecord& rr)
     if(nextpart.empty())
       break;
 
-    if(nextpart.find(';')!=string::npos)
+    if(nextpart.find(';')!=string::npos) {
       break;
+    }
 
     // cout<<"Next part: '"<<nextpart<<"'"<<endl;