/*
PowerDNS Versatile Database Driven Nameserver
- Copyright (C) 2002 - 2014 PowerDNS.COM BV
+ Copyright (C) 2002 - 2011 PowerDNS.COM BV
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
#include <unistd.h>
#include <string>
#include <map>
-#include "json.hh"
+
#include <iostream>
#include <stdio.h>
#include "namespaces.hh"
}
}
-static void emitRecord(const string& zoneName, const string &qname, const string &qtype, const string &ocontent, int ttl, int prio, const string& comment="")
+static void emitRecord(const string& zoneName, const string &qname, const string &qtype, const string &ocontent, int ttl, int prio)
{
- int disabled=0;
- string recordcomment;
-
- if(!comment.empty()) {
- string::size_type pos = comment.find("json={");
- if(pos!=string::npos) {
- string json = comment.substr(pos+5);
- rapidjson::Document document;
- if(document.Parse<0>(json.c_str()).HasParseError())
- throw runtime_error("Could not parse JSON '"+json+"'");
-
- disabled=boolFromJson(document, "disabled", false);
- recordcomment=stringFromJson(document, "comment", "");
- }
- }
g_numRecords++;
string content(ocontent);
cout<<"insert into records (domain_id, name, type,content,ttl,prio,disabled) select id ,"<<
sqlstr(toLower(stripDot(qname)))<<", "<<
sqlstr(qtype)<<", "<<
- sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", "<<disabled<<
+ sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", 0"<<
" from domains where name="<<toLower(sqlstr(zoneName))<<";\n";
-
- if(!recordcomment.empty()) {
- cout<<"insert into comments (domain_id,name,type,modified_at, comment) select id, "<<toLower(sqlstr(zoneName))<<", "<<sqlstr(qtype)<<", "<<time(0)<<", "<<sqlstr(recordcomment)<<" from domains where name="<<toLower(sqlstr(zoneName))<<";\n";
-
- }
-
-
} else
{
cout<<"insert into records (domain_id, name, ordername, auth, type,content,ttl,prio,disabled) select id ,"<<
sqlstr(toLower(stripDot(qname)))<<", "<<
sqlstr(toLower(labelReverse(makeRelative(stripDot(qname), zoneName))))<<", "<<auth<<", "<<
sqlstr(qtype)<<", "<<
- sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", "<<disabled<<
+ sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", 0"<<
" from domains where name="<<toLower(sqlstr(zoneName))<<";\n";
}
}
cout<<"insert into records (domain_id, name,type,content,ttl,prio,disabled) select id ,"<<
sqlstr(toLower(stripDot(qname)))<<", "<<
sqlstr(qtype)<<", "<<
- sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", "<< (disabled ? 't': 'f')<<
+ sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", 'f'"<<
" from domains where name="<<toLower(sqlstr(zoneName))<<";\n";
} else
{
sqlstr(toLower(stripDot(qname)))<<", "<<
sqlstr(toLower(labelReverse(makeRelative(stripDot(qname), zoneName))))<<", '"<< (auth ? 't' : 'f') <<"', "<<
sqlstr(qtype)<<", "<<
- sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", "<<(disabled ? 't': 'f') <<
+ sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", 'f'"<<
" from domains where name="<<toLower(sqlstr(zoneName))<<";\n";
}
}
cout<<"insert into Records (id, domain_id, name, type, content, ttl, prio, disabled) select RECORDS_ID_SEQUENCE.nextval,id ,"<<
sqlstr(toLower(stripDot(qname)))<<", "<<
sqlstr(qtype)<<", "<<
- sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", "<<disabled<<
+ sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", 0"
" from Domains where name="<<toLower(sqlstr(zoneName))<<";\n";
}
else if(g_mode==ORACLE) {
DNSResourceRecord rr;
startNewTransaction();
emitDomain(zonename);
- string comment;
-
- while(zpt.get(rr, &comment)) {
-
- emitRecord(zonename, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority, comment);
- }
+ while(zpt.get(rr))
+ emitRecord(zonename, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority);
num_domainsdone=1;
}
cerr<<num_domainsdone<<" domains were fully parsed, containing "<<g_numRecords<<" records\n";
ZoneParserTNG::ZoneParserTNG(const string& fname, const string& zname, const string& reldir) : d_reldir(reldir),
d_zonename(zname), d_defaultttl(3600),
- d_havedollarttl(false), d_doPassComments(0)
+ d_havedollarttl(false)
{
d_zonename = toCanonic("", d_zonename);
stackFile(fname);
}
// ODD: this function never fills out the prio field! rest of pdns compensates though
-bool ZoneParserTNG::get(DNSResourceRecord& rr, std::string* comment)
+bool ZoneParserTNG::get(DNSResourceRecord& rr)
{
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;