From: Bert Hubert Date: Mon, 3 Dec 2012 15:52:42 +0000 (+0000) Subject: migrate to rapidjson, away from difficult to source libjsoncpp X-Git-Tag: auth-3.2-rc2~49 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ca9fc6a14bb092650b0df7ae42d9316d09744117;p=pdns migrate to rapidjson, away from difficult to source libjsoncpp git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2952 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/configure.ac b/configure.ac index 66be75a1a..6e51bd509 100644 --- a/configure.ac +++ b/configure.ac @@ -498,10 +498,6 @@ then AC_DEFINE(HAVE_SQLITE3,1,[If we have sqlite3]) fi -PKG_CHECK_MODULES(JSONCPP, jsoncpp, HAVE_JSONCPP=yes, AC_MSG_ERROR([Could not find jsoncpp]) -AC_SUBST(JSONCPP_LIBS) -AC_SUBST(JSONCPP_CFLAGS)) - if test "$needcdb" then PKG_CHECK_MODULES(CDB, libcdb, HAVE_CDB=yes, AC_MSG_ERROR([+Could not find libcdb/tinycdb])) diff --git a/pdns/Makefile.am b/pdns/Makefile.am index 144736027..0e8194155 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -1,9 +1,10 @@ if HAVE_LIBPOLARSSL -AM_CXXFLAGS=-DSYSCONFDIR=\"@sysconfdir@\" -DLIBDIR=\"@libdir@\" -DLOCALSTATEDIR=\"@socketdir@\" -Ibackends/bind @THREADFLAGS@ $(LUA_CFLAGS) $(SQLITE3_CFLAGS) +AM_CXXFLAGS=-DSYSCONFDIR=\"@sysconfdir@\" -DLIBDIR=\"@libdir@\" -DLOCALSTATEDIR=\"@socketdir@\" -Ibackends/bind @THREADFLAGS@ $(LUA_CFLAGS) $(SQLITE3_CFLAGS) -I ext/rapidjson/include else -AM_CXXFLAGS=-DSYSCONFDIR=\"@sysconfdir@\" -DLIBDIR=\"@libdir@\" -DLOCALSTATEDIR=\"@socketdir@\" -Ibackends/bind @THREADFLAGS@ $(LUA_CFLAGS) $(SQLITE3_CFLAGS) -Iext/polarssl-1.1.2/include +AM_CXXFLAGS=-DSYSCONFDIR=\"@sysconfdir@\" -DLIBDIR=\"@libdir@\" -DLOCALSTATEDIR=\"@socketdir@\" -Ibackends/bind @THREADFLAGS@ $(LUA_CFLAGS) $(SQLITE3_CFLAGS) -Iext/polarssl-1.1.2/include -Iext/rapidjson/include + endif -AM_CPPFLAGS=-Ibackends/bind $(BOOST_CPPFLAGS) @THREADFLAGS@ $(JSONCPP_CPPFLAGS) +AM_CPPFLAGS=-Ibackends/bind $(BOOST_CPPFLAGS) @THREADFLAGS@ if BOTAN110 AM_CPPFLAGS += $(BOTAN110_CFLAGS) @@ -64,10 +65,10 @@ aes/aestab.c aes/aestab.h aes/brg_endian.h aes/brg_types.h aes/dns_random.cc \ randomhelper.cc namespaces.hh nsecrecords.cc base32.cc dbdnsseckeeper.cc dnssecinfra.cc \ dnsseckeeper.hh dnssecinfra.hh base32.hh dns.cc dnssecsigner.cc polarrsakeyinfra.cc md5.cc \ md5.hh signingpipe.cc signingpipe.hh dnslabeltext.cc lua-pdns.cc lua-auth.cc lua-auth.hh serialtweaker.cc \ -ednssubnet.cc ednssubnet.hh cachecleaner.hh json.cc json.hh +ednssubnet.cc ednssubnet.hh cachecleaner.hh json.cc json.hh # -pdns_server_LDFLAGS=@moduleobjects@ @modulelibs@ @DYNLINKFLAGS@ @LIBDL@ @THREADFLAGS@ $(BOOST_SERIALIZATION_LDFLAGS) $(JSONCPP_LIBS) -rdynamic +pdns_server_LDFLAGS=@moduleobjects@ @modulelibs@ @DYNLINKFLAGS@ @LIBDL@ @THREADFLAGS@ $(BOOST_SERIALIZATION_LDFLAGS) -rdynamic pdns_server_LDADD= ext/polarssl-1.1.2/library/libpolarssl.a $(BOOST_SERIALIZATION_LIBS) $(LUA_LIBS) $(SQLITE3_LIBS) if BOTAN110 diff --git a/pdns/ws.cc b/pdns/ws.cc index 7ca54b28d..181d95c90 100644 --- a/pdns/ws.cc +++ b/pdns/ws.cc @@ -28,7 +28,7 @@ #include #include #include "namespaces.hh" -#include +#include "rapidjson/document.h" extern StatBag S; @@ -400,25 +400,24 @@ string StatWebServer::jsonstat(const string& method, const string& post, const m } else if(method=="POST") { - Json::Value root; // will contains the root value after parsing. - Json::Reader reader; - if(!reader.parse(post, root )) { + rapidjson::Document document; + if(document.Parse<0>(post.c_str()).HasParseError()) { return ret+"{\"error\": \"Unable to parse JSON\""; } - const Json::Value records=root["records"]; - + DNSResourceRecord rr; vector rrset; - for(unsigned int i = 0 ; i < records.size(); ++i) { - const Json::Value& record = records[i]; - rr.qname=record["name"].asString(); - rr.content=record["content"].asString(); - rr.qtype=record["type"].asString(); + const rapidjson::Value &records= document["records"]; + for(rapidjson::SizeType i = 0; i < records.Size(); ++i) { + const rapidjson::Value& record = records[i]; + rr.qname=record["name"].GetString(); + rr.content=record["content"].GetString(); + rr.qtype=record["type"].GetString(); rr.domain_id = sd.domain_id; rr.auth=0; - rr.ttl=atoi(record["ttl"].asString().c_str()); - rr.priority=atoi(record["priority"].asString().c_str()); + rr.ttl=atoi(record["ttl"].GetString()); + rr.priority=atoi(record["priority"].GetString()); rrset.push_back(rr);