3030#include < asLib.h>
3131#include < logClient.h>
3232#include < epicsThread.h>
33+ #include < epicsMutex.h>
34+ #include < epicsGuard.h>
3335#include < epicsAtomic.h>
3436#include < dbAccessDefs.h>
3537#include < epicsMath.h>
4345#include " caPutLogTask.h"
4446#include " caPutJsonLogTask.h"
4547
48+ typedef epicsGuard<epicsMutex> guard_t ;
4649
4750#define isDbrNumeric (type ) ((type) > DBR_STRING && (type) <= DBR_ENUM)
4851
@@ -78,7 +81,7 @@ CaPutJsonLogTask::CaPutJsonLogTask()
7881CaPutJsonLogTask::~CaPutJsonLogTask ()
7982{
8083 clientItem *client, *nextclient;
81- epicsMutex:: guard_t G (clientsMutex);
84+ guard_t G (clientsMutex);
8285 nextclient = clients;
8386 clients = NULL ;
8487 while (nextclient) {
@@ -108,7 +111,7 @@ caPutJsonLogStatus CaPutJsonLogTask::report(int level)
108111
109112 if (clients != NULL ) {
110113 clientItem *client;
111- epicsMutex:: guard_t G (clientsMutex);
114+ guard_t G (clientsMutex);
112115 for (client = clients; client; client = client->next ) {
113116 logClientShow (client->caPutJsonLogClient , level);
114117 }
@@ -254,7 +257,7 @@ caPutJsonLogStatus CaPutJsonLogTask::configureServerLogging(const char* address)
254257 clientItem** pclient;
255258
256259 // Parse the address
257- epicsMutex:: guard_t G (clientsMutex);
260+ guard_t G (clientsMutex);
258261 for (pclient = &clients; *pclient; pclient = &(*pclient)->next ) {
259262 if (strcmp (address, (*pclient)->address ) == 0 ) {
260263 fprintf (stderr, " caPutJsonLog: address %s already configured\n " , address);
@@ -463,7 +466,11 @@ caPutJsonLogStatus CaPutJsonLogTask::buildJsonMsg(const VALUE *pold_value, const
463466 }
464467
465468 // Configure yajl generator
466- yajl_gen handle = yajl_gen_alloc (NULL );
469+ yajl_gen handle = yajl_gen_alloc (
470+ #ifndef EPICS_YAJL_VERSION
471+ NULL , // v1 yajl_gen_config struct*. v2 switched to yajl_gen_config() function
472+ #endif
473+ NULL );
467474 if (handle == NULL ) {
468475 errlogSevPrintf (errlogMinor, " caPutJsonLog: failed to allocate yajl handler\n " );
469476 return caPutJsonLogError;
@@ -674,7 +681,12 @@ caPutJsonLogStatus CaPutJsonLogTask::buildJsonMsg(const VALUE *pold_value, const
674681
675682 /* Get JSON as NULL terminated cstring */
676683 const unsigned char * buf;
677- size_t len = 0 ;
684+ #ifdef EPICS_YAJL_VERSION
685+ size_t
686+ #else
687+ unsigned int
688+ #endif
689+ len = 0 ;
678690 yajl_gen_get_buf (handle, &buf, &len);
679691
680692 /* Get a JSON as a string */
@@ -690,7 +702,7 @@ caPutJsonLogStatus CaPutJsonLogTask::buildJsonMsg(const VALUE *pold_value, const
690702void CaPutJsonLogTask::logToServer (std::string &msg)
691703{
692704 clientItem* client;
693- epicsMutex:: guard_t G (clientsMutex);
705+ guard_t G (clientsMutex);
694706 for (client = clients; client; client = client->next ) {
695707 logClientSend (client->caPutJsonLogClient , msg.c_str ());
696708 }
@@ -742,19 +754,22 @@ void CaPutJsonLogTask::calculateMin(VALUE *pres, const VALUE *pa, const VALUE *p
742754 case DBR_ULONG:
743755 pres->v_uint32 = std::min (pa->v_uint32 , pb->v_uint32 );
744756 return ;
757+ #ifdef DBR_INT64
745758 case DBR_INT64:
746759 pres->v_int64 = std::min (pa->v_int64 , pb->v_int64 );
747760 return ;
748761 case DBR_UINT64:
749762 pres->v_uint64 = std::min (pa->v_uint64 , pb->v_uint64 );
750763 return ;
764+ #endif
751765 case DBR_FLOAT:
752766 pres->v_float = std::min (pa->v_float , pb->v_float );
753767 return ;
754768 case DBR_DOUBLE:
755769 pres->v_double = std::min (pa->v_double , pb->v_double );
756770 return ;
757771 }
772+ memset (pres, 0 , sizeof (*pres));
758773}
759774
760775void CaPutJsonLogTask::calculateMax (VALUE *pres, const VALUE *pa, const VALUE *pb, short type)
@@ -779,19 +794,22 @@ void CaPutJsonLogTask::calculateMax(VALUE *pres, const VALUE *pa, const VALUE *p
779794 case DBR_ULONG:
780795 pres->v_uint32 = std::max (pa->v_uint32 , pb->v_uint32 );
781796 return ;
797+ #ifdef DBR_INT64
782798 case DBR_INT64:
783799 pres->v_int64 = std::max (pa->v_int64 , pb->v_int64 );
784800 return ;
785801 case DBR_UINT64:
786802 pres->v_uint64 = std::max (pa->v_uint64 , pb->v_uint64 );
787803 return ;
804+ #endif
788805 case DBR_FLOAT:
789806 pres->v_float = std::max (pa->v_float , pb->v_float );
790807 return ;
791808 case DBR_DOUBLE:
792809 pres->v_double = std::max (pa->v_double , pb->v_double );
793810 return ;
794811 }
812+ memset (pres, 0 , sizeof (*pres));
795813}
796814
797815#define SINGLE_TYPE_COMPARE (_t, _s ) \
@@ -860,10 +878,12 @@ int CaPutJsonLogTask::fieldVal2Str(char *pbuf, size_t buflen, const VALUE *pval,
860878 case DBR_DOUBLE:
861879 len = epicsSnprintf (pbuf, buflen, " %.17g" , ((epicsFloat64 *)pval)[index]);
862880 break ;
881+ #ifdef DBR_INT64
863882 case DBR_INT64:
864883 return epicsSnprintf (pbuf, buflen, " %lld" , ((epicsInt64 *)pval)[index]);
865884 case DBR_UINT64:
866885 return epicsSnprintf (pbuf, buflen, " %llu" , ((epicsUInt64 *)pval)[index]);
886+ #endif
867887 case DBR_STRING:
868888 return epicsSnprintf (pbuf, buflen, " %s" , ((char *)pval) + index * MAX_STRING_SIZE);
869889 default :
0 commit comments