]> granicus.if.org Git - pdns/commitdiff
remove xdb backend
authorKees Monshouwer <mind04@monshouwer.org>
Wed, 9 Oct 2013 22:25:07 +0000 (00:25 +0200)
committermind04 <mind04@monshouwer.org>
Wed, 9 Oct 2013 22:25:07 +0000 (00:25 +0200)
15 files changed:
build-scripts/tar-gz-build-instruction
configure.ac
modules/Makefile.am
modules/xdbbackend/.gitignore [deleted file]
modules/xdbbackend/Makefile.am [deleted file]
modules/xdbbackend/OBJECTFILES [deleted file]
modules/xdbbackend/OBJECTLIBS [deleted file]
modules/xdbbackend/README [deleted file]
modules/xdbbackend/xdb-fill.cc [deleted file]
modules/xdbbackend/xdb.hh [deleted file]
modules/xdbbackend/xdbbackend.cc [deleted file]
modules/xdbbackend/xgdbm.cc [deleted file]
modules/xdbbackend/xgdbm.hh [deleted file]
modules/xdbbackend/xtdb.cc [deleted file]
modules/xdbbackend/xtdb.hh [deleted file]

index caa421c2f72a543ea65d9a64ceebf7728087f66b..8cdbb49eee9fe6195c17ee06bbea8dfc516b1e58 100755 (executable)
@@ -2,6 +2,6 @@ rm -f $(find . -name "*~") &&
 ./bootstrap && 
 ./configure \
 --with-pgsql-lib=/opt/postgresql/lib --with-pgsql-includes=/opt/postgresql/include \
---with-modules="mydns gmysql mongodb lua gpgsql xdb pipe oracle pipe db2 ldap gsqlite3 geo goracle opendbx godbc" \
+--with-modules="mydns gmysql mongodb lua gpgsql pipe oracle pipe db2 ldap gsqlite3 geo goracle opendbx godbc" \
 --with-dynmodules="" &&
 make dist 
\ No newline at end of file
index 82d2d36779983311163d167c1f8d183d26bbb50e..b90c840e0409390763344bbd112db0d5e2067893 100644 (file)
@@ -771,7 +771,7 @@ pdns/backends/Makefile pdns/backends/bind/Makefile pdns/pdns pdns/precursor \
 modules/gmysqlbackend/Makefile modules/db2backend/Makefile \
 modules/geobackend/Makefile modules/opendbxbackend/Makefile \
 modules/pipebackend/Makefile modules/oraclebackend/Makefile \
-modules/xdbbackend/Makefile modules/godbcbackend/Makefile \
+modules/godbcbackend/Makefile \
 modules/gpgsqlbackend/Makefile modules/ldapbackend/Makefile \
 modules/gsqlite3backend/Makefile \
 modules/goraclebackend/Makefile modules/mydnsbackend/Makefile \
index f263da0995f8a014cd718338e2bdb51177ee9a24..8b7651cbecc697ebf9aa92155b46aee99f6dc9dd 100644 (file)
@@ -1,2 +1,2 @@
 SUBDIRS=@moduledirs@
-DIST_SUBDIRS=db2backend geobackend gmysqlbackend godbcbackend goraclebackend gpgsqlbackend gsqlite3backend ldapbackend luabackend mydnsbackend opendbxbackend oraclebackend pipebackend xdbbackend tinydnsbackend remotebackend randombackend
+DIST_SUBDIRS=db2backend geobackend gmysqlbackend godbcbackend goraclebackend gpgsqlbackend gsqlite3backend ldapbackend luabackend mydnsbackend opendbxbackend oraclebackend pipebackend tinydnsbackend remotebackend randombackend
diff --git a/modules/xdbbackend/.gitignore b/modules/xdbbackend/.gitignore
deleted file mode 100644 (file)
index 9ee6454..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/Makefile.in
-/Makefile
diff --git a/modules/xdbbackend/Makefile.am b/modules/xdbbackend/Makefile.am
deleted file mode 100644 (file)
index 606bd71..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-AM_CPPFLAGS=@THREADFLAGS@
-EXTRA_DIST=OBJECTFILES OBJECTLIBS 
-bin_PROGRAMS=xdb-fill
-
-lib_LTLIBRARIES = libxdbbackend.la
-
-libxdbbackend_la_SOURCES=xdbbackend.cc xtdb.cc xtdb.hh xdb.hh xgdbm.hh
-libxdbbackend_la_LDFLAGS=-module -avoid-version -ltdb
-libxdbbackend_la_CXXFLAGS = $(AM_CXXFLAGS)
-
-xdb_fill_SOURCES=xdb-fill.cc xtdb.cc xtdb.hh
-xdb_fill_LDFLAGS=-ltdb
diff --git a/modules/xdbbackend/OBJECTFILES b/modules/xdbbackend/OBJECTFILES
deleted file mode 100644 (file)
index 1a7dfcf..0000000
+++ /dev/null
@@ -1 +0,0 @@
-xdbbackend.lo xtdb.lo
diff --git a/modules/xdbbackend/OBJECTLIBS b/modules/xdbbackend/OBJECTLIBS
deleted file mode 100644 (file)
index ad81f2d..0000000
+++ /dev/null
@@ -1 +0,0 @@
--ltdb
diff --git a/modules/xdbbackend/README b/modules/xdbbackend/README
deleted file mode 100644 (file)
index aadc9c4..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-Currenly not documented and also not recently tested.
-
-GOOD LUCK!
-
-But let us know if you need this and have questions.
-pdns-dev@mailman.powerdns.com
diff --git a/modules/xdbbackend/xdb-fill.cc b/modules/xdbbackend/xdb-fill.cc
deleted file mode 100644 (file)
index f92c29e..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-#include "pdns/utility.hh"
-#include "xgdbm.hh"
-#include "xtdb.hh"
-#include "pdns/pdnsexception.hh"
-#include "pdns/logger.hh"
-#include <stdio.h>
-#include <sstream>
-#include <iostream>
-
-string stringerror()
-{
-  return strerror(errno);
-}
-
-
-string escape(const string &name) 
-{
-  string a;
-
-  for(string::const_iterator i=name.begin();i!=name.end();++i)
-    if(*i=='|' || *i=='\\'){
-      a+='\\';
-      a+=*i;
-    }
-    else
-      a+=*i;
-  return a;
-}
-
-XDBWrapper *db;
-
-map<string,string>arecords;
-
-void doAList(int domain_id, const string &qname, const string &qtype, const string &content, int ttl)
-{
-  if(qtype!="A")
-    return;
-  else arecords[qname]=content;
-  
-}
-
-void doInsert(int domain_id, const string &qname, const string &qtype, const string &content, int ttl)
-{
-  static string lastname;
-  static string writestr;
-
-
-  if(!lastname.empty() && lastname!=qname) {
-    db->append(lastname,writestr);
-    writestr="";
-  }
-  string rcontent(content);
-  if(qtype=="NS") {
-    rcontent+="@";
-    map<string,string>::const_iterator i=arecords.find(content);
-    if(i!=arecords.end())
-      rcontent+=i->second;
-  }
-
-  ostringstream ostr;
-  ostr<<escape(qname)<<"|"<<qtype<<"|"<<escape(rcontent)<<"|"<<3600<<"|"<<0<<"|"<<domain_id<<"|"<<0<<"|";
-  writestr+=ostr.str();
-    
-  lastname=qname;
-}
-
-typedef void insertFunc(int domain_id, const string &qname, const string &qtype, const string &content, int ttl);
-
-void walk(FILE *fp, insertFunc *ifp)
-{
-  char line[1024];
-  // 0        'ORG'    'SOA'   'A.GTLD-SERVERS.NET. NSTLD.VERISIGN-GRS.COM. 2002100700 1800 900 604800 86400'  0       3600
-  int count=0;
-  while(fgets(line,1023,fp)) {
-    if(!((count++)%10000))
-      cout<<count<<endl;
-
-    int domain_id=atoi(line);
-    //      cout<<"id="<<domain_id<<endl;
-    char *p=line;
-    while(*p++!='\'');
-    
-    char *q=p;
-    while(*++p!='\'');
-    
-    *p=0;
-    //      cout<<"qdomain='"<<q<<"'"<<endl;
-    string qname=q;
-    p=q;
-    
-    while(*p++!='\'');
-    q=p;
-    while(*++p!='\'');
-    *p=0;
-    //      cout<<"type='"<<q<<"'"<<endl;
-    string qtype=q;
-    p=q;
-    
-    while(*p++!='\'');
-    q=p;
-    while(*++p!='\'');
-    *p=0;
-    //      cout<<"content='"<<q<<"'"<<endl;
-    string content=q;
-    p=q;
-  
-    (*ifp)(domain_id,qname,qtype,content,3600);
-  
-  }
-  (*ifp)(0,"","","",0);
-}
-
-int main(int argc, char **argv)
-{
-  if(argc!=2) {
-    cerr<<"syntax: xdb-fill filename"<<endl;
-    exit(1);
-  }
-  FILE *fp=fopen(argv[1],"r");
-
-  try {
-    db=new XTDBWrapper("./powerdns.xdb"); //, XDBWrapper::ReadWrite);
-    
-    walk(fp,&doAList);
-    cerr<<"Number of glue records: "<<arecords.size()<<endl;
-    fseek(fp,0,SEEK_SET);
-    walk(fp,&doInsert);
-    delete db;
-  }
-  catch(XDBException &e) {
-    cerr<<"DB Error: "<<e.what<<endl;
-  }
-  
-  
-}
diff --git a/modules/xdbbackend/xdb.hh b/modules/xdbbackend/xdb.hh
deleted file mode 100644 (file)
index 1bc341c..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef XDB_HH
-#define XDB_HH
-#include <string>
-using std::string;
-
-class XDBException
-{
-public:
-  XDBException(const string &ex) : what(ex){}
-  string what;
-};
-
-class XDBWrapper
-{
-public:
-  virtual ~XDBWrapper(){}
-  virtual bool get(const string &key, string &value)=0;
-  virtual void del(const string &key)=0;
-  virtual void put(const string &key, const string &value)=0;
-  virtual void append(const string &key, const string &value)
-  {
-    string newKey;
-    get(key,newKey);
-    put(key,newKey+value);
-  }
-  typedef enum {ReadOnly, ReadWrite} Mode;
-};
-
-#endif 
diff --git a/modules/xdbbackend/xdbbackend.cc b/modules/xdbbackend/xdbbackend.cc
deleted file mode 100644 (file)
index 5a153e1..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-#include "pdns/utility.hh"
-#include "xtdb.hh"
-#include "pdns/dnsbackend.hh"
-#include "pdns/dns.hh"
-#include "pdns/dnsbackend.hh"
-#include "pdns/dnspacket.hh"
-#include "pdns/pdnsexception.hh"
-#include "pdns/logger.hh"
-#include "pdns/arguments.hh"
-
-/* FIRST PART */
-class XDBBackend : public DNSBackend
-{
-public:
-  XDBBackend(const string &suffix="") 
-  {
-    setArgPrefix("xdb"+suffix);
-    try {
-      d_db=new XTDBWrapper(getArg("filename"));
-    }
-    catch(XDBException &e) {
-      L<<Logger::Error<<"[XDBBackend] Error: "<<e.what<<endl;
-      throw PDNSException(e.what);
-    }
-    L<<Logger::Error<<"[XDBBackend] Open"<<endl;
-  }
-
-  ~XDBBackend()
-  {
-    delete d_db;
-  }
-
-  bool list(const string &target, int id) {
-    return false; // we don't support AXFR (go away)
-  }
-    
-  void lookup(const QType &type, const string &qdomain, DNSPacket *p, int zoneId)
-  {
-    d_answer="";
-    /*
-    if(arg().mustDo("query-logging"))
-      L<<Logger::Error<<"Query: '"<<qdomain+"|"+type.getName()<<"'"<<endl;
-    */
-
-    bool ret=d_db->get(qdomain, d_answer);   // think about lowercasing here
-
-    /*
-    if(arg().mustDo("query-logging")) {
-      if(ret)
-        L<<Logger::Error<<"Raw Answer: '"<<d_answer<<"'"<<endl;
-      else
-        L<<Logger::Error<<"No answer"<<endl;
-    }
-    */
-
-    d_qtype=type;
-  }
-
-  bool get(DNSResourceRecord &rr)
-  {
-    while(!d_answer.empty()) {
-      int len=rr.unSerialize(d_answer);
-      d_answer=d_answer.substr(len);
-      if(d_qtype.getCode()==QType::ANY || rr.qtype==d_qtype) {
-        /*
-        if(arg().mustDo("query-logging")) {
-          L<<Logger::Error<<"Real answer: "<<rr.qtype.getName()<<"/"<<rr.content<<endl;
-        */
-        return true;
-      }
-    }
-    return false;                                                   // no more data
-  }
-  
-private:
-  string d_answer;
-  QType d_qtype;
-  XDBWrapper *d_db;
-};
-
-/* SECOND PART */
-
-class XDBFactory : public BackendFactory
-{
-public:
-  XDBFactory() : BackendFactory("xdb") {}
-  void declareArguments(const string &suffix="")
-  {
-    declare(suffix,"filename","filename which is to be xdb","/tmp/powerdns.xdb");
-  }
-  DNSBackend *make(const string &suffix="")
-  {
-    return new XDBBackend(suffix);
-  }
-};
-
-/* THIRD PART */
-
-class XDBLoader
-{
-public:
-  XDBLoader()
-  {
-    BackendMakers().report(new XDBFactory);
-    
-    L<<Logger::Info<<" [XDBBackend] This is the xdbbackend ("__DATE__", "__TIME__") reporting"<<endl;
-  }  
-};
-
-static XDBLoader xdbLoader;
-
diff --git a/modules/xdbbackend/xgdbm.cc b/modules/xdbbackend/xgdbm.cc
deleted file mode 100644 (file)
index 14041f1..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-#include "xgdbm.hh"
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <iostream>
-
-#include "pdns/namespaces.hh"
-
-GDBM_FILE XGDBMWrapper::s_db;
-int XGDBMWrapper::s_usecount;
-
-XGDBMWrapper::XGDBMWrapper(const string &fname, Mode mode)
-{
-  if(!s_db) {
-    s_db = gdbm_open(const_cast<char *>(fname.c_str()), 2048,
-                 mode==ReadWrite ? GDBM_WRITER|GDBM_WRCREAT|GDBM_FAST : GDBM_READER,
-                 0666 , 0); 
-    if(!s_db) 
-      throw XDBException("Unable to open database: "+string(strerror(errno)));
-  }
-  s_usecount++;
-}
-
-XGDBMWrapper::~XGDBMWrapper()
-{
-  if(!--s_usecount) {
-    cerr<<"Closing down"<<endl;
-    gdbm_close(s_db);
-  }
-}
-
-bool XGDBMWrapper::get(const string &key, string &value)
-{
-  datum kdatum={const_cast<char *>(key.c_str()),key.size()+1};
-  
-  datum vdatum=gdbm_fetch(s_db,kdatum);
-  if(!vdatum.dptr)
-    return false;
-  value.assign(vdatum.dptr,vdatum.dsize);
-  free(vdatum.dptr);
-  return true;
-}
-
-void XGDBMWrapper::put(const string &key, const string &value)
-{
-  datum kdatum={const_cast<char *>(key.c_str()),key.size()+1};
-  datum vdatum={const_cast<char *>(value.c_str()),value.size()};
-  if(gdbm_store(s_db, kdatum, vdatum,GDBM_REPLACE)<0)
-    throw XDBException("Error storing key: "+string(strerror(errno)));
-
-}
-
-void XGDBMWrapper::del(const string &key)
-{
-}
-
-#ifdef TESTDRIVER
-main()
-{
-  try {
-    XDBWrapper *xdb=new XGDBMWrapper("wuh",XDBWrapper::ReadWrite);
-    xdb->put("ahu","toffe gast");
-    xdb->append("ahu",", echt waar!");
-    
-    string tst;
-    xdb->get("ahu",tst);
-    cout<<"Database zegt over ahu: '"<<tst<<"'"<<endl;
-    
-    xdb->append("ahu"," Toch niet!");
-    xdb->get("ahu",tst);
-    cout<<"Database zegt over ahu: '"<<tst<<"'"<<endl;
-    delete xdb;
-  }
-  catch(XDBException &e) {
-    cerr<<"Fatal error: "<<e.what<<endl;
-  }
-
-}
-
-#endif /* TESTDRIVER */
diff --git a/modules/xdbbackend/xgdbm.hh b/modules/xdbbackend/xgdbm.hh
deleted file mode 100644 (file)
index 980713c..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef XGDBM_HH
-#define XGDBM_HH
-
-#include "xdb.hh"
-#include <gdbm.h>
-
-class XGDBMWrapper : public XDBWrapper
-{
-public:
-  XGDBMWrapper(const string &filename, Mode mode=ReadOnly);
-  ~XGDBMWrapper();
-  bool get(const string &key, string &value);
-  void del(const string &key);
-  void put(const string &key, const string &value);
-private:
-  static GDBM_FILE s_db;
-  static int s_usecount;
-};
-#endif
diff --git a/modules/xdbbackend/xtdb.cc b/modules/xdbbackend/xtdb.cc
deleted file mode 100644 (file)
index 73d2a39..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-#include "xtdb.hh"
-#include "pdns/lock.hh"
-#include <tdb.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <iostream>
-
-
-#include "pdns/namespaces.hh"
-
-TDB_CONTEXT *XTDBWrapper::s_db;
-int XTDBWrapper::s_usecount;
-pthread_mutex_t XTDBWrapper::s_lock=PTHREAD_MUTEX_INITIALIZER;
-
-XTDBWrapper::XTDBWrapper(const string &fname)
-{
-  Lock l(&s_lock);
-  if(!s_db) {
-    s_db = tdb_open(const_cast<char *>(fname.c_str()), 5213331,
-                 TDB_NOLOCK,
-                 O_RDWR | O_CREAT , 0600); 
-    if(!s_db) 
-      throw XDBException("Unable to open database: "+string(strerror(errno)));
-  }
-  s_usecount++;
-
-}
-
-XTDBWrapper::~XTDBWrapper()
-{
-  if(!--s_usecount) {
-    tdb_close(s_db);
-    cerr<<"closed"<<endl;
-  }
-}
-
-bool XTDBWrapper::get(const string &key, string &value)
-{
-
-  TDB_DATA kdatum={const_cast<char *>(key.c_str()),key.size()+1};
-  TDB_DATA vdatum;
-
-  {
-    //Lock l(&s_lock);  
-    vdatum=tdb_fetch(s_db,kdatum);
-  }
-  if(!vdatum.dptr)
-    return false;
-  value.assign(vdatum.dptr,vdatum.dsize);
-  free(vdatum.dptr);
-  return true;
-}
-
-void XTDBWrapper::put(const string &key, const string &value)
-{
-  TDB_DATA kdatum={const_cast<char *>(key.c_str()),key.size()+1};
-  TDB_DATA vdatum={const_cast<char *>(value.c_str()),value.size()};
-  if(tdb_store(s_db, kdatum, vdatum,TDB_REPLACE)<0)
-    throw XDBException("Error storing key: "+string(strerror(errno)));
-
-}
-
-void XTDBWrapper::del(const string &key)
-{
-}
-
-#ifdef TESTDRIVER
-main()
-{
-  XDBWrapper *xdb=new XTDBWrapper("wuh");
-  xdb->put("ahu","toffe gast");
-  xdb->append("ahu",", echt waar!");
-  
-  string tst;
-  xdb->get("ahu",tst);
-  cout<<"Database zegt over ahu: '"<<tst<<"'"<<endl;
-
-  xdb->append("ahu"," Toch niet!");
-  xdb->get("ahu",tst);
-  cout<<"Database zegt over ahu: '"<<tst<<"'"<<endl;
-
-}
-#endif
diff --git a/modules/xdbbackend/xtdb.hh b/modules/xdbbackend/xtdb.hh
deleted file mode 100644 (file)
index 1a093bd..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#include "xdb.hh"
-#include <pthread.h>
-#include <tdb.h>
-
-class XTDBWrapper : public XDBWrapper
-{
-public:
-  XTDBWrapper(const string &filename);
-  ~XTDBWrapper();
-  bool get(const string &key, string &value);
-  void del(const string &key);
-  void put(const string &key, const string &value);
-private:
-  static TDB_CONTEXT *s_db;
-  static int s_usecount;
-  static pthread_mutex_t s_lock;
-};