Commit 75119520 authored by Pavel Vainerman's avatar Pavel Vainerman

fixed build with --disable-api

parent 11024403
......@@ -46,7 +46,9 @@ jobs:
- name: install packages
run: |
sudo apt-get install libcomedi-dev libpoco-dev libmysqlclient-dev libomniorb4-dev libev-dev omniidl xsltproc libpqxx3-dev librrd-dev libsigc++-2.0-dev libsqlite3-dev python-dev libmosquittopp-dev
sudo apt-get install libcomedi-dev libpoco-dev libmysqlclient-dev libomniorb4-dev \
libev-dev omniidl xsltproc libpqxx3-dev librrd-dev libsigc++-2.0-dev \
libsqlite3-dev python-dev libmosquittopp-dev libpoco-dev
wget https://github.com/catchorg/Catch2/releases/download/v1.11.0/catch.hpp -O include/catch.hpp
- name: build
......@@ -55,7 +57,7 @@ jobs:
# due broken comedi
export CXXFLAGS="$CXXFLAGS -Wl,--unresolved-symbols=ignore-in-shared-libs"
autoreconf -fiv
./configure --enable-mysql --enable-sqlite --enable-rrd --enable-io --disable-python --disable-mqtt --disable-pgsql --disable-api --disable-netdata --disable-logdb
./configure --disable-python --disable-netdata
make
- name: Perform CodeQL Analysis
......
......@@ -74,6 +74,7 @@ else
fi
AM_CONDITIONAL(DISABLE_REST_API, test ${buildapi} = false)
AM_CONDITIONAL(ENABLE_REST_API, test ${buildapi} = true)
AC_SUBST(DISABLE_REST_API)
AC_SUBST(REST_API_CFLAGS)
AC_SUBST(REST_API_CLIBS)
......
if ENABLE_REST_API
bin_PROGRAMS = @PACKAGE@-httpresolver
@PACKAGE@_httpresolver_LDADD = $(top_builddir)/lib/libUniSet2.la
@PACKAGE@_httpresolver_SOURCES = HttpResolver.cc main.cc
include $(top_builddir)/include.mk
endif
\ No newline at end of file
......@@ -99,18 +99,12 @@ LogDB::LogDB( const string& name, int argc, const char* const* argv, const strin
qbufSize = uniset::getArgPInt("--" + prefix + "db-buffer-size", argc, argv, it.getProp("dbBufferSize"), qbufSize);
maxdbRecords = uniset::getArgPInt("--" + prefix + "db-max-records", argc, argv, it.getProp("dbMaxRecords"), qbufSize);
maxwsocks = uniset::getArgPInt("--" + prefix + "ws-max", argc, argv, it.getProp("wsMax"), maxwsocks);
string tformat = uniset::getArg2Param("--" + prefix + "db-timestamp-format", argc, argv, it.getProp("dbTeimastampFormat"), "localtime");
if( tformat == "localtime" || tformat == "utc" )
tmsFormat = tformat;
bgColor = uniset::getArg2Param("--" + prefix + "bg-color", argc, argv, it.getProp("bgColor"), bgColor);
fgColor = uniset::getArg2Param("--" + prefix + "fg-color", argc, argv, it.getProp("fgColor"), fgColor);
fgColorTitle = uniset::getArg2Param("--" + prefix + "fg-color-title", argc, argv, it.getProp("fgColorTitle"), fgColorTitle);
bgColorTitle = uniset::getArg2Param("--" + prefix + "bg-color-title", argc, argv, it.getProp("bgColorTitle"), bgColorTitle);
double checkConnection_sec = atof( uniset::getArg2Param("--" + prefix + "ls-check-connection-sec", argc, argv, it.getProp("lsCheckConnectionSec"), "5").c_str());
int bufSize = uniset::getArgPInt("--" + prefix + "ls-read-buffer-size", argc, argv, it.getProp("lsReadBufferSize"), 10001);
......@@ -255,6 +249,13 @@ LogDB::LogDB( const string& name, int argc, const char* const* argv, const strin
dblog1 << myname << "(init): http server parameters " << httpHost << ":" << httpPort << endl;
Poco::Net::SocketAddress sa(httpHost, httpPort);
maxwsocks = uniset::getArgPInt("--" + prefix + "ws-max", argc, argv, it.getProp("wsMax"), maxwsocks);
bgColor = uniset::getArg2Param("--" + prefix + "bg-color", argc, argv, it.getProp("bgColor"), bgColor);
fgColor = uniset::getArg2Param("--" + prefix + "fg-color", argc, argv, it.getProp("fgColor"), fgColor);
fgColorTitle = uniset::getArg2Param("--" + prefix + "fg-color-title", argc, argv, it.getProp("fgColorTitle"), fgColorTitle);
bgColorTitle = uniset::getArg2Param("--" + prefix + "bg-color-title", argc, argv, it.getProp("bgColorTitle"), bgColorTitle);
try
{
Poco::Net::HTTPServerParams* httpParams = new Poco::Net::HTTPServerParams;
......@@ -281,9 +282,13 @@ LogDB::~LogDB()
if( evIsActive() )
evstop();
#ifndef DISABLE_REST_API
if( httpserv )
httpserv->stop();
#endif
if( db )
db->close();
}
......@@ -311,6 +316,8 @@ void LogDB::onTerminate( ev::sig& evsig, int revents )
evsig.stop();
//evsig.loop.break_loop();
#ifndef DISABLE_REST_API
try
{
httpserv->stop();
......@@ -320,6 +327,8 @@ void LogDB::onTerminate( ev::sig& evsig, int revents )
dbinfo << myname << "(onTerminate): " << ex.what() << endl;
}
#endif
try
{
evstop();
......@@ -499,9 +508,13 @@ void LogDB::help_print()
// -----------------------------------------------------------------------------
void LogDB::run( bool async )
{
#ifndef DISABLE_REST_API
if( httpserv )
httpserv->start();
#endif
if( async )
async_evrun();
else
......@@ -556,6 +569,7 @@ void LogDB::onActivate( ev::async& watcher, int revents )
return;
}
#ifndef DISABLE_REST_API
uniset_rwmutex_rlock lk(wsocksMutex);
for( const auto& s : wsocks )
......@@ -563,6 +577,8 @@ void LogDB::onActivate( ev::async& watcher, int revents )
if( !s->isActive() )
s->set(loop);
}
#endif
}
// -----------------------------------------------------------------------------
bool LogDB::Log::isConnected() const
......@@ -787,6 +803,21 @@ void LogDB::Log::close()
//tcp = nullptr;
}
// -----------------------------------------------------------------------------
std::string LogDB::qEscapeString( const string& txt )
{
ostringstream ret;
for( const auto& c : txt )
{
ret << c;
if( c == '\'' || c == '"' )
ret << c;
}
return ret.str();
}
// -----------------------------------------------------------------------------
#ifndef DISABLE_REST_API
// -----------------------------------------------------------------------------
class LogDBRequestHandler:
......@@ -1173,21 +1204,6 @@ string LogDB::qDate( const string& p, const char sep )
return p.substr(0, 4) + "-" + p.substr(4, 2) + "-" + p.substr(6, 2);
}
// -----------------------------------------------------------------------------
std::string LogDB::qEscapeString( const string& txt )
{
ostringstream ret;
for( const auto& c : txt )
{
ret << c;
if( c == '\'' || c == '"' )
ret << c;
}
return ret.str();
}
// -----------------------------------------------------------------------------
void LogDB::onWebSocketSession(Poco::Net::HTTPServerRequest& req, Poco::Net::HTTPServerResponse& resp)
{
using Poco::Net::WebSocket;
......
......@@ -216,6 +216,9 @@ namespace uniset
size_t getCountOfRecords( const std::string& logname = "" );
size_t getFirstOfOldRecord( size_t maxnum );
// экранирование кавычек (удваивание для sqlite)
static std::string qEscapeString( const std::string& s );
#ifndef DISABLE_REST_API
Poco::JSON::Object::Ptr respError( Poco::Net::HTTPServerResponse& resp, Poco::Net::HTTPResponse::HTTPStatus s, const std::string& message );
Poco::JSON::Object::Ptr httpGetRequest( const std::string& cmd, const Poco::URI::QueryParameters& p );
......@@ -232,9 +235,6 @@ namespace uniset
// преобразование в дату 'YYYY-MM-DD' из строки 'YYYYMMDD' или 'YYYY/MM/DD'
static std::string qDate(const std::string& p, const char sep = '-');
// экранирование кавычек (удваивание для sqlite)
static std::string qEscapeString( const std::string& s );
std::shared_ptr<LogWebSocket> newWebSocket(Poco::Net::HTTPServerRequest* req, Poco::Net::HTTPServerResponse* resp, const std::string& logname );
void delWebSocket( std::shared_ptr<LogWebSocket>& ws );
#endif
......
if ENABLE_REST_API
noinst_PROGRAMS = uhttp-test
uhttp_test_LDADD = $(top_builddir)/lib/libUniSet2.la $(SIGC_LIBS) $(POCO_LIBS)
uhttp_test_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions/include $(SIGC_CFLAGS) $(POCO_CFLAGS)
uhttp_test_SOURCES = uhttp-test.cc
endif
\ No newline at end of file
......@@ -14,6 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// --------------------------------------------------------------------------
#include <cmath>
#include <sstream>
#include <mutex>
#include <string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment