NSECRecordContent::NSECRecordContent(const string& content, const string& zone)
{
- RecordTextReader rtr(content, zone);
+ RecordTextReader rtr(content, DNSName(zone));
rtr.xfrName(d_next);
while(!rtr.eof()) {
NSEC3RecordContent::NSEC3RecordContent(const string& content, const string& zone)
{
- RecordTextReader rtr(content, zone);
+ RecordTextReader rtr(content, DNSName(zone));
rtr.xfr8BitInt(d_algorithm);
rtr.xfr8BitInt(d_flags);
rtr.xfr16BitInt(d_iterations);
NSEC3PARAMRecordContent::NSEC3PARAMRecordContent(const string& content, const string& zone)
{
- RecordTextReader rtr(content, zone);
+ RecordTextReader rtr(content, DNSName(zone));
rtr.xfr8BitInt(d_algorithm);
rtr.xfr8BitInt(d_flags);
rtr.xfr16BitInt(d_iterations);
#include "base64.hh"
#include "namespaces.hh"
-RecordTextReader::RecordTextReader(const string& str, const string& zone) : d_string(str), d_zone(zone), d_pos(0)
+RecordTextReader::RecordTextReader(const string& str, const DNSName& zone) : d_string(str), d_zone(zone), d_pos(0)
{
/* remove whitespace */
boost::trim_if(d_string, boost::algorithm::is_space());
void RecordTextReader::xfrName(DNSName& val, bool, bool)
{
skipSpaces();
- string sval;
- sval.reserve(d_end - d_pos);
+ DNSName sval;
const char* strptr=d_string.c_str();
string::size_type begin_pos = d_pos;
d_pos++;
}
- sval.append(strptr+begin_pos, strptr+d_pos);
+ sval = DNSName(std::string(strptr+begin_pos, strptr+d_pos));
if(sval.empty())
sval=d_zone;
- else if(!d_zone.empty()) {
- char last=sval[sval.size()-1];
-
- if(last =='.')
- sval.resize(sval.size()-1);
- else if(last != '.' && !isdigit(last)) // don't add zone to IP address
- sval+="."+d_zone;
- }
- val = DNSName(sval);
+ else if(!d_zone.empty())
+ sval+=d_zone;
+ val = sval;
}
static bool isbase64(char c, bool acceptspace)
class RecordTextReader
{
public:
- RecordTextReader(const string& str, const string& zone="");
+ RecordTextReader(const string& str, const DNSName& zone=DNSName(""));
void xfr64BitInt(uint64_t& val);
void xfr48BitInt(uint64_t& val);
void xfr32BitInt(uint32_t& val);
bool eof();
private:
string d_string;
- string d_zone;
+ DNSName d_zone;
string::size_type d_pos;
string::size_type d_end;
void skipSpaces();