From 4c5c9cf3fcc03269b4f614a16535bc467b71784a Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Tue, 3 Jun 2014 12:04:28 -0300 Subject: [PATCH] safe fallback when boost-regex is not found --- src/bitcoinrpc.cpp | 3 +++ src/twister_rss.cpp | 10 +++++++++- src/twister_rss.h | 7 +++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index ef57a6e6..7be7e778 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -1057,6 +1057,9 @@ void ServiceConnection(AcceptedConnection *conn) case RSS_ERROR_NOT_A_NUMBER: conn->stream() << HTTPReply(HTTP_BAD_REQUEST, "Parameter 'max' must be a number", false) << std::flush; continue; + case RSS_ERROR_BOOST_REGEX: + conn->stream() << HTTPReply(HTTP_BAD_REQUEST, "boost-regex support missing", false) << std::flush; + continue; } } diff --git a/src/twister_rss.cpp b/src/twister_rss.cpp index 355b1824..6bc9f3dc 100644 --- a/src/twister_rss.cpp +++ b/src/twister_rss.cpp @@ -7,7 +7,9 @@ #include #include #include -#include +#ifdef HAVE_BOOST_REGEX + #include +#endif #include using namespace std; @@ -15,6 +17,9 @@ using namespace json_spirit; int generateRSS(string uri, string *output) { +#ifndef HAVE_BOOST_REGEX + return RSS_ERROR_BOOST_REGEX; +#else map parameterMap = parseQuery(uri); int max = 20; //default value string account = parameterMap["account"]; @@ -188,8 +193,10 @@ int generateRSS(string uri, string *output) *output = ret.str(); return RSS_OK; +#endif } +#ifdef HAVE_BOOST_REGEX map parseQuery(const string& query) { map data; @@ -206,6 +213,7 @@ map parseQuery(const string& query) return data; } +#endif bool sortByTime (Object i,Object j) { diff --git a/src/twister_rss.h b/src/twister_rss.h index f57a42d6..b050c9d2 100644 --- a/src/twister_rss.h +++ b/src/twister_rss.h @@ -10,11 +10,14 @@ enum RSSResultCode RSS_OK = 0, RSS_ERROR_NO_ACCOUNT = -1, RSS_ERROR_BAD_ACCOUNT = -2, - RSS_ERROR_NOT_A_NUMBER = -3 + RSS_ERROR_NOT_A_NUMBER = -3, + RSS_ERROR_BOOST_REGEX = -4 }; extern bool sortByTime (json_spirit::Object i,json_spirit::Object j); -extern std::map parseQuery(const std::string& query); +#ifdef HAVE_BOOST_REGEX + extern std::map parseQuery(const std::string& query); +#endif extern int generateRSS(std::string uri, std::string *output); #endif // TWISTER_RSS_H