]> granicus.if.org Git - pdns/commitdiff
Use extractComment for comments
authorAki Tuomi <cmouse@desteem.org>
Wed, 5 Aug 2015 15:56:04 +0000 (18:56 +0300)
committerAki Tuomi <cmouse@desteem.org>
Wed, 5 Aug 2015 15:56:04 +0000 (18:56 +0300)
pdns/backends/gsql/gsqlbackend.cc
pdns/backends/gsql/gsqlbackend.hh

index 44768ffa7cc5a7f7edefdf621dc307cefd5095b5..df6e9beb22994ab6a768093dc8a87b27aa8481d3 100644 (file)
@@ -1408,13 +1408,7 @@ bool GSQLBackend::getComment(Comment& comment)
     throw PDNSException("GSQLBackend comment get: "+e.txtReason());
   }
   // domain_id,name,type,modified_at,account,comment
-  comment.domain_id = atol(row[0].c_str());
-  comment.qname = row[1];
-  comment.qtype = row[2];
-  comment.modified_at = atol(row[3].c_str());
-  comment.account = row[4];
-  comment.content = row[5];
-
+  extractComment(row, comment);
   return true;
 }
 
@@ -1539,12 +1533,7 @@ bool GSQLBackend::searchComments(const string &pattern, int maxResults, vector<C
       SSqlStatement::row_t row;
       d_SearchCommentsQuery_stmt->nextRow(row);
       Comment comment;
-      comment.domain_id = atol(row[0].c_str());
-      comment.qname = row[1];
-      comment.qtype = row[2];
-      comment.modified_at = atol(row[3].c_str());
-      comment.account = row[4];
-      comment.content = row[5];
+      extractComment(row, comment);
       result.push_back(comment);
     }
 
@@ -1588,6 +1577,16 @@ void GSQLBackend::extractRecord(const SSqlStatement::row_t& row, DNSResourceReco
   r.domain_id=atoi(row[4].c_str());
 }
 
+void GSQLBackend::extractComment(const SSqlStatement::row_t& row, Comment& comment)
+{
+ comment.domain_id = atol(row[0].c_str());
+ comment.qname = row[1];
+ comment.qtype = row[2];
+ comment.modified_at = atol(row[3].c_str());
+ comment.account = row[4];
+ comment.content = row[5];
+}
+
 SSqlStatement::~SSqlStatement() { 
 // make sure vtable won't break 
 }
index 4cc93472c061473b2596fc26c2f2abf7a4903ea4..cb006744069e30bdc43be6fdd055300ce864a7c2 100644 (file)
@@ -227,6 +227,7 @@ public:
 protected:
   string pattern2SQLPattern(const string& pattern);
   void extractRecord(const SSqlStatement::row_t& row, DNSResourceRecord& rr);
+  void extractComment(const SSqlStatement::row_t& row, Comment& c);
 
 private:
   DNSName d_qname;