From db3fdf54e9535ee56c270c210509452068d3d8f5 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 3 Oct 2018 14:45:43 -0700 Subject: [PATCH] allow setting p2pReadOnly from config file --- loopback.conf | 1 + p2pApp/gwmain.cpp | 13 +++++++++++++ p2pApp/pva2pva.h | 8 ++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/loopback.conf b/loopback.conf index 82443a3..b43d68b 100644 --- a/loopback.conf +++ b/loopback.conf @@ -14,6 +14,7 @@ */ { "version":1, + /* "readOnly":true, */ "clients":[ { "name":"theclient", diff --git a/p2pApp/gwmain.cpp b/p2pApp/gwmain.cpp index f8b0707..cb3b88b 100644 --- a/p2pApp/gwmain.cpp +++ b/p2pApp/gwmain.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -25,14 +26,18 @@ #include #include "server.h" +#include "pva2pva.h" namespace pvd = epics::pvData; namespace pva = epics::pvAccess; +extern int p2pReadOnly; + namespace { pvd::StructureConstPtr schema(pvd::getFieldCreate()->createFieldBuilder() ->add("version", pvd::pvUInt) + ->add("readOnly", pvd::pvBoolean) ->addNestedStructureArray("clients") ->add("name", pvd::pvString) ->add("provider", pvd::pvString) @@ -95,6 +100,12 @@ void getargs(ServerConfig& arg, int argc, char *argv[]) std::ifstream strm(argv[optind]); pvd::parseJSON(strm, arg.conf); + { + pvd::PVScalarPtr V(arg.conf->getSubField("readOnly")); + if(V) + p2pReadOnly = V->getAs(); + } + unsigned version = arg.conf->getSubFieldT("version")->get(); if(version==0) { std::cerr<<"Warning: config file missing \"version\" key. Assuming 1\n"; @@ -222,6 +233,8 @@ int main(int argc, char *argv[]) epics::iocshRegister("gwsr", "level", "channel"); epics::iocshRegister("gwcr", "level", "client", "channel"); + libComRegister(); + registerReadOnly(); epics::registerRefCounter("ChannelCacheEntry", &ChannelCacheEntry::num_instances); epics::registerRefCounter("ChannelCacheEntry::CRequester", &ChannelCacheEntry::CRequester::num_instances); epics::registerRefCounter("GWChannel", &GWChannel::num_instances); diff --git a/p2pApp/pva2pva.h b/p2pApp/pva2pva.h index cecf095..2329b6d 100644 --- a/p2pApp/pva2pva.h +++ b/p2pApp/pva2pva.h @@ -10,9 +10,9 @@ typedef epicsGuard Guard; typedef epicsGuardRelease UnGuard; -epicsShareExtern void registerGWClientIocsh(); -epicsShareExtern void gwServerShutdown(); -epicsShareExtern void gwClientShutdown(); -epicsShareExtern void registerReadOnly(); +void registerGWClientIocsh(); +void gwServerShutdown(); +void gwClientShutdown(); +void registerReadOnly(); #endif // PVA2PVA_H