]> granicus.if.org Git - pdns/commitdiff
API: remove rapidjson infrastructure
authorChristian Hofstaedtler <christian.hofstaedtler@deduktiva.com>
Mon, 28 Dec 2015 01:01:43 +0000 (02:01 +0100)
committerChristian Hofstaedtler <christian.hofstaedtler@deduktiva.com>
Tue, 29 Dec 2015 22:29:18 +0000 (23:29 +0100)
build-scripts/dist-recursor
pdns/Makefile-recursor
pdns/Makefile.am
pdns/json.cc
pdns/json.hh
pdns/webserver.cc
pdns/webserver.hh
pdns/ws-auth.cc
pdns/ws-recursor.cc

index 5da313f60dde41d6e2eff40156f2c8fda4886aae..137c8489f976491272b8243553809cdfb210bb57 100755 (executable)
@@ -70,9 +70,6 @@ cat >>$DIRNAME/config.h <<EOF
 #define HAVE_BOOST 1
 #define HAVE_MBEDTLS2 1
 EOF
-mkdir -p $DIRNAME/ext/rapidjson/include/rapidjson/internal
-cp -a ../ext/rapidjson/include/rapidjson/*.h $DIRNAME/ext/rapidjson/include/rapidjson/
-cp -a ../ext/rapidjson/include/rapidjson/internal/*.h $DIRNAME/ext/rapidjson/include/rapidjson/internal
 mkdir -p $DIRNAME/ext/mbedtls/include/mbedtls
 cp -a ../ext/mbedtls/include/mbedtls/{config.h,check_config.h,aes.h,ripemd160.h,sha1.h,md.h,md5.h,sha256.h,sha512.h,ecp.h,ecdsa.h,md_internal.h} ../ext/mbedtls/include/mbedtls/base64.h ../ext/mbedtls/include/mbedtls/platform.h ../ext/mbedtls/include/mbedtls/version.h $DIRNAME/ext/mbedtls/include/mbedtls
 cp -a ../ext/mbedtls/include/mbedtls/{entropy.h,ctr_drbg.h,hmac_drbg.h,rsa.h,ecp.h,bignum.h,oid.h,asn1.h,asn1write.h,pk.h,ecdsa.h,cipher.h,x509.h} $DIRNAME/ext/mbedtls/include/mbedtls
index 48ceb9238a77aea4aae28f894f06e8daea80e3ac..2cbb44fba91778521b1fa7827821f1d0058f7edd 100644 (file)
@@ -4,7 +4,7 @@ BINDIR=/usr/bin/
 SYSCONFDIR=/etc/powerdns/
 LOCALSTATEDIR=/var/run/
 OPTFLAGS?=-O3
-CXXFLAGS:= $(CXXFLAGS) -Iext/rapidjson/include -I$(CURDIR)/ext/mbedtls/include -I$(CURDIR)/ext/json11 -Wall @CF_PIE@ @CF_FORTIFY@ @CF_STACK@ $(OPTFLAGS) $(PROFILEFLAGS) $(ARCHFLAGS) -pthread -Iext/yahttp -DHAVE_CONFIG_H
+CXXFLAGS:= $(CXXFLAGS) -I$(CURDIR)/ext/mbedtls/include -I$(CURDIR)/ext/json11 -Wall @CF_PIE@ @CF_FORTIFY@ @CF_STACK@ $(OPTFLAGS) $(PROFILEFLAGS) $(ARCHFLAGS) -pthread -Iext/yahttp -DHAVE_CONFIG_H
 CFLAGS:=$(CFLAGS) -Wall $(OPTFLAGS) @CF_PIE@ @CF_FORTIFY@ @CF_STACK@ $(PROFILEFLAGS) $(ARCHFLAGS) -I$(CURDIR)/ext/mbedtls/include -pthread -DHAVE_CONFIG_H
 LDFLAGS:=$(LDFLAGS) $(ARCHFLAGS) -pthread @LD_RELRO@ @CF_STACK@ @LD_PIE@
 STRIP_BINARIES?=1
index a2af6b76942ea1c8011c5a00aefe07160cc3db7c..7708e9bef02621f547c4519af3b29bac3449897a 100644 (file)
@@ -2,7 +2,6 @@ JSON11_LIBS = -L$(top_srcdir)/ext/json11 -ljson11
 
 AM_CPPFLAGS += \
        -I$(top_srcdir)/ext/json11 \
-       -I$(top_srcdir)/ext/rapidjson/include \
        $(YAHTTP_CFLAGS) \
        $(MBEDTLS_CFLAGS)
 
index 1a94536caf9b56cfc86885e865e3f0d6b1cdfc77..c0fda4e7ae0249ded244d0111f052f06326d295b 100644 (file)
 #include "namespaces.hh"
 #include "misc.hh"
 
-#include "rapidjson/document.h"
-#include "rapidjson/stringbuffer.h"
-#include "rapidjson/writer.h"
-
-using namespace rapidjson;
 using json11::Json;
 
-int intFromJson(const Value& container, const char* key)
-{
-  if (!container.IsObject()) {
-    throw JsonException("Container was not an object.");
-  }
-  const Value& val = container[key];
-  if (val.IsInt()) {
-    return val.GetInt();
-  } else if (val.IsString()) {
-    return std::stoi(val.GetString());
-  } else {
-    throw JsonException("Key '" + string(key) + "' not an Integer or not present");
-  }
-}
-
-int intFromJson(const Value& container, const char* key, const int default_value)
-{
-  if (!container.IsObject()) {
-    throw JsonException("Container was not an object.");
-  }
-  const Value& val = container[key];
-  if (val.IsInt()) {
-    return val.GetInt();
-  } else if (val.IsString()) {
-    return std::stoi(val.GetString());
-  } else {
-    // TODO: check if value really isn't present
-    return default_value;
-  }
-}
-
 int intFromJson(const Json container, const std::string& key)
 {
   auto val = container[key];
@@ -89,19 +53,6 @@ int intFromJson(const Json container, const std::string& key, const int default_
   }
 }
 
-string stringFromJson(const Value& container, const char* key)
-{
-  if (!container.IsObject()) {
-    throw JsonException("Container was not an object.");
-  }
-  const Value& val = container[key];
-  if (val.IsString()) {
-    return val.GetString();
-  } else {
-    throw JsonException("Key '" + string(key) + "' not present or not a String");
-  }
-}
-
 string stringFromJson(const Json container, const std::string &key)
 {
   const Json val = container[key];
@@ -112,47 +63,7 @@ string stringFromJson(const Json container, const std::string &key)
   }
 }
 
-string stringFromJson(const Value& container, const char* key, const string& default_value)
-{
-  if (!container.IsObject()) {
-    throw JsonException("Container was not an object.");
-  }
-  const Value& val = container[key];
-  if (val.IsString()) {
-    return val.GetString();
-  } else {
-    // TODO: check if value really isn't present
-    return default_value;
-  }
-}
-
-bool boolFromJson(const rapidjson::Value& container, const char* key)
-{
-  if (!container.IsObject()) {
-    throw JsonException("Container was not an object.");
-  }
-  const Value& val = container[key];
-  if (val.IsBool()) {
-    return val.GetBool();
-  } else {
-    throw JsonException("Key '" + string(key) + "' not present or not a Bool");
-  }
-}
-
-bool boolFromJson(const rapidjson::Value& container, const char* key, const bool default_value)
-{
-  if (!container.IsObject()) {
-    throw JsonException("Container was not an object.");
-  }
-  const Value& val = container[key];
-  if (val.IsBool()) {
-    return val.GetBool();
-  } else {
-    return default_value;
-  }
-}
-
-bool boolFromJson(const json11::Json container, const std::string& key)
+bool boolFromJson(const Json container, const std::string& key)
 {
   auto val = container[key];
   if (val.is_bool()) {
@@ -162,7 +73,7 @@ bool boolFromJson(const json11::Json container, const std::string& key)
   }
 }
 
-bool boolFromJson(const json11::Json container, const std::string& key, const bool default_value)
+bool boolFromJson(const Json container, const std::string& key, const bool default_value)
 {
   auto val = container[key];
   if (val.is_bool()) {
@@ -171,11 +82,3 @@ bool boolFromJson(const json11::Json container, const std::string& key, const bo
     return default_value;
   }
 }
-
-string makeStringFromDocument(const Document& doc)
-{
-  StringBuffer output;
-  Writer<StringBuffer> w(output);
-  doc.Accept(w);
-  return string(output.GetString(), output.Size());
-}
index 6da395f1bfa3ff0e2fc7be155a058a9becff5e2b..ad214c5d611254d912a82e651f3fac5536570f56 100644 (file)
 #pragma once // it is 2012, deal with it
 
 #include <string>
-#include <map>
 #include <stdexcept>
-#include "rapidjson/document.h"
 #include "json11.hpp"
 
-std::string makeStringFromDocument(const rapidjson::Document& doc);
-int intFromJson(const rapidjson::Value& container, const char* key);
-int intFromJson(const rapidjson::Value& container, const char* key, const int default_value);
 int intFromJson(const json11::Json container, const std::string& key);
 int intFromJson(const json11::Json container, const std::string& key, const int default_value);
-std::string stringFromJson(const rapidjson::Value& container, const char* key);
-std::string stringFromJson(const rapidjson::Value& container, const char* key, const std::string& default_value);
 std::string stringFromJson(const json11::Json container, const std::string &key);
-bool boolFromJson(const rapidjson::Value& container, const char* key);
-bool boolFromJson(const rapidjson::Value& container, const char* key, const bool default_value);
 bool boolFromJson(const json11::Json container, const std::string& key);
 bool boolFromJson(const json11::Json container, const std::string& key, const bool default_value);
 
index 3d6cfdd732d13eac38c7861fd67b14774da3b6be..5ccff1f554c2c9cd022ab157a5071ea5d5b069c2 100644 (file)
@@ -39,18 +39,6 @@ struct connectionThreadData {
   Socket* client;
 };
 
-void HttpRequest::json(rapidjson::Document& document)
-{
-  if(this->body.empty()) {
-    L<<Logger::Debug<<"HTTP: JSON document expected in request body, but body was empty" << endl;
-    throw HttpBadRequestException();
-  }
-  if(document.Parse<0>(this->body.c_str()).HasParseError()) {
-    L<<Logger::Debug<<"HTTP: parsing of JSON document failed" << endl;
-    throw HttpBadRequestException();
-  }
-}
-
 json11::Json HttpRequest::json()
 {
   string err;
@@ -97,11 +85,6 @@ bool HttpRequest::compareHeader(const string &header_name, const string &expecte
 }
 
 
-void HttpResponse::setBody(rapidjson::Document& document)
-{
-  this->body = makeStringFromDocument(document);
-}
-
 void HttpResponse::setBody(const json11::Json& document)
 {
   document.dump(this->body);
index 7038b0d83dc04d106e9524bbfbf76ffa59096e1e..0e64344d890cc6b414050c345a4585fdf1f8d143 100644 (file)
@@ -26,9 +26,6 @@
 #include <list>
 #include <boost/utility.hpp>
 #include <yahttp/yahttp.hpp>
-#include "rapidjson/document.h"
-#include "rapidjson/stringbuffer.h"
-#include "rapidjson/writer.h"
 #include "json11.hpp"
 #include "namespaces.hh"
 #include "sstuff.hh"
@@ -42,7 +39,6 @@ public:
   bool accept_json;
   bool accept_html;
   bool complete;
-  void json(rapidjson::Document& document);
   json11::Json json();
 
   // checks password _only_.
@@ -55,7 +51,6 @@ public:
   HttpResponse() : YaHTTP::Response() { };
   HttpResponse(const YaHTTP::Response &resp) : YaHTTP::Response(resp) { };
 
-  void setBody(rapidjson::Document& document);
   void setBody(const json11::Json& document);
   void setErrorResult(const std::string& message, const int status);
   void setSuccessResult(const std::string& message, const int status = 200);
index ba3f2c880dd794affc0e10af8541b4bc40978236..f911898e63c8394db26863e9cf5ab5275abbb672 100644 (file)
@@ -37,9 +37,6 @@
 #include <boost/format.hpp>
 
 #include "namespaces.hh"
-#include "rapidjson/document.h"
-#include "rapidjson/stringbuffer.h"
-#include "rapidjson/writer.h"
 #include "ws-api.hh"
 #include "version.hh"
 #include "dnsseckeeper.hh"
@@ -48,7 +45,6 @@
 #include "common_startup.hh"
 
 
-using namespace rapidjson;
 using json11::Json;
 
 extern StatBag S;
index cc32213554cffc1d6f61595003925cf191c420b8..ce5d3bd196ea777238d0a10a83f0f74718fc0950 100644 (file)
@@ -34,9 +34,6 @@
 #include "misc.hh"
 #include "syncres.hh"
 #include "dnsparser.hh"
-#include "rapidjson/document.h"
-#include "rapidjson/stringbuffer.h"
-#include "rapidjson/writer.h"
 #include "json11.hpp"
 #include "webserver.hh"
 #include "ws-api.hh"
@@ -44,7 +41,6 @@
 
 extern __thread FDMultiplexer* t_fdm;
 
-using namespace rapidjson;
 using json11::Json;
 
 void productServerStatisticsFetch(map<string,string>& out)