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)
#include <iostream>
#include <stdio.h>
#include "namespaces.hh"
-
+#include "json.hh"
#include "dns.hh"
#include "arguments.hh"
#include "bindparserclasses.hh"
}
}
}
-<<<<<<< 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="")
{
recordcomment=stringFromJson(document, "comment", "");
}
}
->>>>>>> jsonzone2sql
+
g_numRecords++;
string content(ocontent);
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)) {
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";
}
// 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);
if(nextpart.empty())
break;
- if(nextpart.find(';')!=string::npos)
+ if(nextpart.find(';')!=string::npos) {
break;
+ }
// cout<<"Next part: '"<<nextpart<<"'"<<endl;