23 #include "epicsStdlib.h"
24 #include "epicsString.h"
26 #include "epicsMutex.h"
28 #include "dbStaticLib.h"
29 #include "dbFldTypes.h"
31 #include "dbAccessDefs.h"
32 #include <epicsTypes.h>
33 #include <epicsTime.h>
34 #include <epicsThread.h>
35 #include <epicsString.h>
36 #include <epicsTimer.h>
37 #include <epicsMutex.h>
46 #include <boost/scoped_array.hpp>
49 #include <registryFunction.h>
51 #include <epicsExport.h>
57 static int stringtestres(
const char* lhs,
int operation,
const char* rhs)
61 errlogPrintf(
"iocstringtest: ERROR: NULL lhs arg");
64 bool verbose = (operation & 0x1);
65 bool reverse = (operation & 0x8 ?
true :
false);
66 char* lhs_expand = macEnvExpand(lhs);
67 char* rhs_expand = (rhs != NULL ? macEnvExpand(rhs) : NULL);
68 if (lhs_expand == NULL)
70 errlogPrintf(
"iocstringtest: ERROR: NULL expanded lhs expression arg");
75 printf(
"iocstringtest: expanded expression=\"%s\"\n", lhs_expand);
80 if (strlen(lhs_expand) > 0)
85 else if (operation & 0x4)
87 if (rhs_expand != NULL)
89 result = (strcmp(lhs_expand, rhs_expand) == 0 ? 1 : 0);
93 errlogPrintf(
"iocstringtest: ERROR: NULL expanded rhs expression arg");
98 if (strlen(lhs_expand) > 0)
105 result = (result == 0 ? 1 : 0);
108 if (rhs_expand != NULL)
126 static void iocstringtest(
const char* resultvar,
const char* lhs,
int operation,
const char* rhs)
128 if (resultvar == NULL)
130 errlogPrintf(
"iocstringtest: ERROR: NULL args");
133 bool verbose = (operation & 0x1);
136 if ( sprintf(result_str,
"%s", (result != 0 ?
" " :
"#")) < 0 )
138 errlogPrintf(
"iocstringtest: ERROR: sprintf (hash mode)\n");
143 printf(
"iocstringtest: setting %s=\"%s\" (%ld)\n", resultvar, result_str, result);
145 epicsEnvSet(resultvar, result_str);
171 static void iocstringiftest(
const char* resultvar,
const char* lhs,
int operation,
const char* rhs)
173 if (resultvar == NULL)
175 errlogPrintf(
"iocstringtest: ERROR: NULL args");
178 bool verbose = (operation & 0x1);
180 char resultIfVar[128];
181 char resultNotIfVar[128];
182 sprintf(resultIfVar,
"IF%s", resultvar);
183 sprintf(resultNotIfVar,
"IFNOT%s", resultvar);
185 char resultNotIf[128];
188 sprintf(resultIf,
"%s",
" ");
189 sprintf(resultNotIf,
"%s",
"#");
193 sprintf(resultIf,
"%s",
"#");
194 sprintf(resultNotIf,
"%s",
" ");
198 printf(
"iocstringiftest: setting %s=\"%s\"\n", resultIfVar, resultIf);
199 printf(
"iocstringiftest: setting %s=\"%s\"\n", resultNotIfVar, resultNotIf);
201 epicsEnvSet(resultIfVar, resultIf);
202 epicsEnvSet(resultNotIfVar, resultNotIf);
225 iocstringtest(args[0].sval, args[1].sval, args[2].ival, args[3].sval);
244 iocstringiftest(args[0].sval, args[1].sval, args[2].ival, args[3].sval);
static const iocshArg stringtestInitArg2
The operation to perform on the string.
static const iocshArg stringiftestInitArg0
The name of the macro to put the result of the calculation into.
static const iocshArg stringtestInitArg0
The name of the macro to put the result of the calculation into.
static void stringiftestInitCallFunc(const iocshArgBuf *args)
static const iocshArg stringtestInitArg3
The right hand side argument.
static void iocstringtestRegister(void)
static void iocstringtest(const char *resultvar, const char *lhs, int operation, const char *rhs)
Compares the given strings based on the operation flag and returns ' ' on true and '#' on false into ...
static const iocshArg stringiftestInitArg1
The left hand side argument.
static void stringtestInitCallFunc(const iocshArgBuf *args)
static const iocshArg stringiftestInitArg2
The operation to perform on the string.
static const iocshArg stringiftestInitArg3
The right hand side argument.
epicsExportRegistrar(dbLoadRecordsFuncsRegister)
static int stringtestres(const char *lhs, int operation, const char *rhs)
Does the actual calculation comparing the given strings to each other.
static const iocshArg stringtestInitArg1
The left hand side argument.
static const iocshArg *const stringiftestInitArgs[]
static void iocstringiftest(const char *resultvar, const char *lhs, int operation, const char *rhs)
Compares the given strings based on the operation flag, putting the result in two different macros...
static const iocshFuncDef stringtestInitFuncDef
static const iocshFuncDef stringiftestInitFuncDef
static const iocshArg *const stringtestInitArgs[]