diff --git a/CMakeLists.txt b/CMakeLists.txt index 795800d..ecb6398 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 3.2) -Project(emgauwa-core) +Project(core) link_directories(/usr/local/lib) link_libraries(drogon trantor pthread dl) @@ -104,4 +104,4 @@ foreach(cspFile ${SCP_LIST}) endforeach() include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -add_executable(emgauwa-core ${SRC_DIR} ${CTL_SRC} ${FILTER_SRC} ${VIEWSRC} ${PLUGIN_SRC} ${MODEL_SRC} ${HELPER_SRC}) +add_executable(core ${SRC_DIR} ${CTL_SRC} ${FILTER_SRC} ${VIEWSRC} ${PLUGIN_SRC} ${MODEL_SRC} ${HELPER_SRC}) diff --git a/controllers/api_v1_controllers_discover.cc b/controllers/api_v1_controllers_discover.cc index 6f19c91..18306fa 100644 --- a/controllers/api_v1_controllers_discover.cc +++ b/controllers/api_v1_controllers_discover.cc @@ -4,6 +4,7 @@ #include <helpers.h> #include <cmath> #include <models/controller_dbo.h> +#include <fstream> #include "api_v1_controllers.h" using namespace api::v1; @@ -93,11 +94,19 @@ void controllers::post_discover(const HttpRequestPtr &req, std::function<void(co } answer_payload[payload_length] = '\0'; + std::ifstream answer_payload_stream(answer_payload); - Json::Reader json_reader; + Json::CharReaderBuilder json_reader; + std::string errs; Json::Value client_info; - json_reader.parse(answer_payload, &answer_payload[payload_length], client_info, false); + if (!Json::parseFromStream(json_reader, answer_payload_stream, &client_info, &errs)) + { + // report to the user the failure and their locations in the document. + std::cout << "Failed to parse configuration\n" + << errs; + return; + } free(answer_payload);