- Changed strncpy to strlcpy, strncat to strlcat
- Added strlcpy and strlcat to SICS - Added a driver for the POLDI power supplies SKIPPED: psi/A1931.c psi/autowin.c psi/bruker.c psi/docho.c psi/dornier2.c psi/dspcode.c psi/ease.c psi/ecb.c psi/ecbcounter.c psi/ecbdriv.c psi/el734dc.c psi/el734driv.c psi/el734hp.c psi/el737driv.c psi/el737hpdriv.c psi/el737hpdrivsps.c psi/el737hpv2driv.c psi/el755driv.c psi/eurodriv.c psi/haakedriv.c psi/itc4driv.c psi/julcho.c psi/linadriv.c psi/lmd200.c psi/lscsupport.c psi/ltc11.c psi/make_gen psi/oicom.c psi/oxinst.c psi/pimotor.c psi/pipiezo.c psi/polterwrite.c psi/psi.c psi/sanscook.c psi/sanslirebin.c psi/sanswave.c psi/sinqhmdriv.c psi/sinqhttp.c psi/slsecho.c psi/slsmagnet.c psi/slsvme.c psi/sps.c psi/swmotor.c psi/swmotor2.c psi/tabledrive.c psi/tasscan.c psi/tdchm.c psi/velodorn.c psi/velodornier.c
This commit is contained in:
4
Dbg.c
4
Dbg.c
@ -410,7 +410,7 @@ char *argv[];
|
||||
if (compress) {
|
||||
/* this copies from our static buf to printify's static buf */
|
||||
/* and back to our static buf */
|
||||
strncpy(buf, printify(buf), buf_width);
|
||||
strlcpy(buf, printify(buf), buf_width);
|
||||
}
|
||||
|
||||
/* usually but not always right, but assume truncation if buffer is */
|
||||
@ -684,7 +684,7 @@ char **argv;
|
||||
|
||||
if (argc == 1)
|
||||
argv[1] = "1";
|
||||
strncpy(viewFrameName, argv[1], FRAMENAMELEN);
|
||||
strlcpy(viewFrameName, argv[1], FRAMENAMELEN);
|
||||
|
||||
return TCL_RETURN;
|
||||
}
|
||||
|
68
SCinter.c
68
SCinter.c
@ -128,7 +128,7 @@ int AddCommandWithFlag(SicsInterp * pInterp, char *pName, ObjectFunc pFunc,
|
||||
assert(pFunc);
|
||||
assert(pInterp);
|
||||
|
||||
strncpy(pBueffel, pName,511);
|
||||
strlcpy(pBueffel, pName,511);
|
||||
strtolower(pBueffel);
|
||||
RemoveAlias(&pInterp->AList, pBueffel); /* M.Z. */
|
||||
if (FindCommand(pInterp, pBueffel) != NULL) {
|
||||
@ -206,7 +206,7 @@ int RemoveCommand(SicsInterp * pInterp, char *pName)
|
||||
assert(pInterp);
|
||||
assert(pName);
|
||||
|
||||
strncpy(pBueffel, pName,255);
|
||||
strlcpy(pBueffel, pName,255);
|
||||
strtolower(pBueffel);
|
||||
|
||||
if (pInterp->iDeleting) {
|
||||
@ -390,7 +390,7 @@ CommandList *FindCommand(SicsInterp * self, char *pName)
|
||||
}
|
||||
|
||||
memset(pBueffel,0,1024);
|
||||
strncpy(pBueffel, pName,1023);
|
||||
strlcpy(pBueffel, pName,1023);
|
||||
strtolower(pBueffel);
|
||||
|
||||
pCmd = TranslateAlias(&self->AList, pBueffel); /* M.Z. */
|
||||
@ -559,15 +559,15 @@ static void printAll(SicsInterp * pSics, SConnection * pCon)
|
||||
pCurrent = pSics->pCList;
|
||||
while (pCurrent) {
|
||||
if (iNum == 0) {
|
||||
strncpy(pBueffel, pCurrent->pName,255);
|
||||
strlcpy(pBueffel, pCurrent->pName,255);
|
||||
iNum++;
|
||||
} else if (iNum < 4) {
|
||||
strncat(pBueffel, " ",255);
|
||||
strncat(pBueffel, pCurrent->pName,255);
|
||||
strlcat(pBueffel, " ",255);
|
||||
strlcat(pBueffel, pCurrent->pName,255);
|
||||
iNum++;
|
||||
} else {
|
||||
strncat(pBueffel, " ",255);
|
||||
strncat(pBueffel, pCurrent->pName,255);
|
||||
strlcat(pBueffel, " ",255);
|
||||
strlcat(pBueffel, pCurrent->pName,255);
|
||||
strcat(pBueffel, "\r\n");
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
iNum = 0;
|
||||
@ -578,7 +578,7 @@ static void printAll(SicsInterp * pSics, SConnection * pCon)
|
||||
|
||||
/* write final entries */
|
||||
if (strlen(pBueffel) > 2) {
|
||||
strncat(pBueffel, "\r\n",255);
|
||||
strlcat(pBueffel, "\r\n",255);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
}
|
||||
}
|
||||
@ -625,7 +625,7 @@ static void printAllTypes(SicsInterp * pSics, SConnection * pCon,
|
||||
pTest = (pDummy) pCurrent->pData;
|
||||
if (NULL != pTest->pDescriptor) {
|
||||
pType = pTest->pDescriptor->name;
|
||||
strncpy(pType_lc, pType,255);
|
||||
strlcpy(pType_lc, pType,255);
|
||||
strtolower(pType_lc);
|
||||
|
||||
LLDnodePtr2First(typeListID);
|
||||
@ -640,7 +640,7 @@ static void printAllTypes(SicsInterp * pSics, SConnection * pCon,
|
||||
/* NB: First checked node is current node, then search to end of list */
|
||||
|
||||
if (0 != LLDnodeFind(typeListID, compareStringNode, (void *) pType)) { /* empty list or 'typename' not found */
|
||||
strncpy(pName_lc, pCurrent->pName,255);
|
||||
strlcpy(pName_lc, pCurrent->pName,255);
|
||||
strtolower(pName_lc);
|
||||
if ((0 == iFiltered) || ((1 == iFiltered) && (0 != strcmp(pType_lc, pName_lc)))) { /*ie Add if unfiltered or pass filter(name!=typename) */
|
||||
LLDstringAdd(typeListID, pType);
|
||||
@ -675,16 +675,16 @@ static void printInterface(SicsInterp * pSics, SConnection * pCon, int id)
|
||||
if (pObj != NULL) {
|
||||
if (pObj->GetInterface(pObj, id) != NULL) {
|
||||
if (iNum == 0) {
|
||||
strncpy(pBueffel, pCurrent->pName,255);
|
||||
strlcpy(pBueffel, pCurrent->pName,255);
|
||||
iNum++;
|
||||
} else if (iNum < 4) {
|
||||
strncat(pBueffel, " ",255);
|
||||
strncat(pBueffel, pCurrent->pName,255);
|
||||
strlcat(pBueffel, " ",255);
|
||||
strlcat(pBueffel, pCurrent->pName,255);
|
||||
iNum++;
|
||||
} else {
|
||||
strncat(pBueffel, " ",255);
|
||||
strncat(pBueffel, pCurrent->pName,255);
|
||||
strncat(pBueffel, "\r\n",255);
|
||||
strlcat(pBueffel, " ",255);
|
||||
strlcat(pBueffel, pCurrent->pName,255);
|
||||
strlcat(pBueffel, "\r\n",255);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
iNum = 0;
|
||||
pBueffel[0] = '\0';
|
||||
@ -721,16 +721,16 @@ static void printMatch(SicsInterp * pSics, SConnection * pCon, char *mask)
|
||||
if (pObj != NULL) {
|
||||
if (!match(mask, pObj->name)) {
|
||||
if (iNum == 0) {
|
||||
strncpy(pBueffel, pCurrent->pName,255);
|
||||
strlcpy(pBueffel, pCurrent->pName,255);
|
||||
iNum++;
|
||||
} else if (iNum < 4) {
|
||||
strncat(pBueffel, " ",255);
|
||||
strncat(pBueffel, pCurrent->pName,255);
|
||||
strlcat(pBueffel, " ",255);
|
||||
strlcat(pBueffel, pCurrent->pName,255);
|
||||
iNum++;
|
||||
} else {
|
||||
strncat(pBueffel, " ",255);
|
||||
strncat(pBueffel, pCurrent->pName,255);
|
||||
strncat(pBueffel, "\r\n",255);
|
||||
strlcat(pBueffel, " ",255);
|
||||
strlcat(pBueffel, pCurrent->pName,255);
|
||||
strlcat(pBueffel, "\r\n",255);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
pBueffel[0] = '\0';
|
||||
iNum = 0;
|
||||
@ -741,7 +741,7 @@ static void printMatch(SicsInterp * pSics, SConnection * pCon, char *mask)
|
||||
}
|
||||
|
||||
/* write final entries */
|
||||
strncat(pBueffel, "\r\n",255);
|
||||
strlcat(pBueffel, "\r\n",255);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
}
|
||||
|
||||
@ -766,16 +766,16 @@ static void printType(SicsInterp * pSics, SConnection * pCon,
|
||||
if (pCurrent->pData != NULL) {
|
||||
if (iHasType(pCurrent->pData, typeName)) {
|
||||
if (iNum == 0) {
|
||||
strncpy(pBueffel, pCurrent->pName,255);
|
||||
strlcpy(pBueffel, pCurrent->pName,255);
|
||||
iNum++;
|
||||
} else if (iNum < 4) {
|
||||
strncat(pBueffel, " ",255);
|
||||
strncat(pBueffel, pCurrent->pName,255);
|
||||
strlcat(pBueffel, " ",255);
|
||||
strlcat(pBueffel, pCurrent->pName,255);
|
||||
iNum++;
|
||||
} else {
|
||||
strncat(pBueffel, " ",255);
|
||||
strncat(pBueffel, pCurrent->pName,255);
|
||||
strncat(pBueffel, "\r\n",255);
|
||||
strlcat(pBueffel, " ",255);
|
||||
strlcat(pBueffel, pCurrent->pName,255);
|
||||
strlcat(pBueffel, "\r\n",255);
|
||||
Tcl_DStringAppend(&txt, pBueffel, -1);
|
||||
pBueffel[0] = '\0';
|
||||
iNum = 0;
|
||||
@ -786,7 +786,7 @@ static void printType(SicsInterp * pSics, SConnection * pCon,
|
||||
}
|
||||
|
||||
/* write final entries */
|
||||
strncat(pBueffel, "\r\n",255);
|
||||
strlcat(pBueffel, "\r\n",255);
|
||||
SCWrite(pCon, Tcl_DStringValue(&txt), eValue);
|
||||
Tcl_DStringFree(&txt);
|
||||
}
|
||||
@ -869,12 +869,12 @@ int ListObjects(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
printAllTypes(pSics, pCon, 0);
|
||||
return 1;
|
||||
}
|
||||
strncpy(pType, argv[2],255);
|
||||
strlcpy(pType, argv[2],255);
|
||||
/* Cater for multi-word types eg 'Environment Monitor' */
|
||||
if (argc > 3) {
|
||||
for (i = 3; i < argc; i++) {
|
||||
strncat(pType, " ",255);
|
||||
strncat(pType, argv[i],255);
|
||||
strlcat(pType, " ",255);
|
||||
strlcat(pType, argv[i],255);
|
||||
}
|
||||
}
|
||||
printType(pSics, pCon, pType);
|
||||
|
@ -394,7 +394,7 @@ int AntiColliderAction(SConnection * pCon, SicsInterp * pSics,
|
||||
return 0;
|
||||
}
|
||||
seq.level = atoi(argv[2]);
|
||||
strncpy(seq.pMotor, argv[3], 79);
|
||||
strlcpy(seq.pMotor, argv[3], 79);
|
||||
seq.target = atof(argv[4]);
|
||||
LLDnodeAppendFrom(self->sequenceList, &seq);
|
||||
SCSendOK(pCon);
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <strlutil.h>
|
||||
#include "asynnet.h"
|
||||
#include "rwpuffer.h"
|
||||
|
||||
@ -484,7 +485,7 @@ int ANETinfo(int handle, char *hostname, int hostnameLen)
|
||||
return ANETSOCKERROR;
|
||||
}
|
||||
memset(hostname, 0, hostnameLen);
|
||||
strncpy(hostname, host->h_name, hostnameLen);
|
||||
strlcpy(hostname, host->h_name, hostnameLen);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -58,11 +58,11 @@ static int CHLimits(void *pData, float fVal, char *error, int iErrlen)
|
||||
assert(self);
|
||||
|
||||
if (fVal < self->fLower) {
|
||||
strncpy(error, "Lower limit violated", iErrlen);
|
||||
strlcpy(error, "Lower limit violated", iErrlen);
|
||||
return 0;
|
||||
}
|
||||
if (fVal > self->fUpper) {
|
||||
strncpy(error, "Upper limit violated", iErrlen);
|
||||
strlcpy(error, "Upper limit violated", iErrlen);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@ -356,7 +356,7 @@ static int AVEVGetError(pEVDriver self, int *iCode, char *pReply, int iLen)
|
||||
assert(myData);
|
||||
|
||||
if (myData->iLastError == NOTIMPLEMENTED) {
|
||||
strncpy(pReply, "ERROR: Not Implemented here!", iLen);
|
||||
strlcpy(pReply, "ERROR: Not Implemented here!", iLen);
|
||||
*iCode = NOTIMPLEMENTED;
|
||||
myData->iLastError = 0;
|
||||
return 1;
|
||||
|
@ -87,7 +87,7 @@ void WriteToCommandLogId(char *prompt, int id, char *text)
|
||||
pCopy = malloc(l + 1);
|
||||
if (pCopy == NULL)
|
||||
return;
|
||||
strncpy(pCopy, text, l);
|
||||
strlcpy(pCopy, text, l);
|
||||
pCopy[l] = '\0';
|
||||
if (prompt == cmdPrompt && iCompact) {
|
||||
pPtr = strstr(pCopy, "fulltransact ");
|
||||
@ -460,7 +460,7 @@ int CommandLog(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
strncpy(pFile, argv[2],255);
|
||||
strlcpy(pFile, argv[2],255);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
} else if (strcmp(argv[1], "auto") == 0) {
|
||||
|
2
cone.c
2
cone.c
@ -292,7 +292,7 @@ int MakeCone(SConnection * pCon, SicsInterp * pSics, void *pData, int argc,
|
||||
pHdb cmd;
|
||||
|
||||
if (argc > 1) {
|
||||
strncpy(pName, argv[1],80);
|
||||
strlcpy(pName, argv[1],80);
|
||||
} else {
|
||||
strcpy(pName, "cone");
|
||||
}
|
||||
|
@ -219,13 +219,13 @@ static int ConfCheckLimits(void *pData, float fVal, char *error,
|
||||
if (self->targetValue != fVal) {
|
||||
commandList = invokeMotorScript(self, fVal);
|
||||
if (commandList == NULL) {
|
||||
strncpy(error, self->scriptError, errLen);
|
||||
strlcpy(error, self->scriptError, errLen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
status = parseCommandList(self, commandList);
|
||||
if (status != 1) {
|
||||
strncpy(error, self->scriptError, errLen);
|
||||
strlcpy(error, self->scriptError, errLen);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
14
conman.c
14
conman.c
@ -590,10 +590,10 @@ int SCWriteInContext(SConnection * pCon, char *pBuffer, int out,
|
||||
transID = pCon->transID;
|
||||
strcpy(oldDevice, pCon->deviceID);
|
||||
pCon->transID = cc.transID;
|
||||
strncpy(pCon->deviceID, cc.deviceID, SCDEVIDLEN);
|
||||
strlcpy(pCon->deviceID, cc.deviceID, SCDEVIDLEN);
|
||||
status = SCWrite(pCon, pBuffer, out);
|
||||
pCon->transID = transID;
|
||||
strncpy(pCon->deviceID, oldDevice, SCDEVIDLEN);
|
||||
strlcpy(pCon->deviceID, oldDevice, SCDEVIDLEN);
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -1281,7 +1281,7 @@ int SCPrompt(SConnection * pCon, char *pPrompt, char *pResult, int iLen)
|
||||
if (iRet == 1) {
|
||||
SetStatus(eOld);
|
||||
CostaLock(pCon->pStack);
|
||||
strncpy(pResult, pPtr, iLen);
|
||||
strlcpy(pResult, pPtr, iLen);
|
||||
WriteToCommandLogId(" prompted>", pCon->sockHandle, pPtr);
|
||||
return 1;
|
||||
}
|
||||
@ -1409,7 +1409,7 @@ int SCInvoke(SConnection * self, SicsInterp * pInter, char *pCommand)
|
||||
SCWrite(self, "ERROR: out of memory in SCInvoke", eError);
|
||||
return 0;
|
||||
}
|
||||
strncpy(pCopy->deviceID, pBueffel, SCDEVIDLEN);
|
||||
strlcpy(pCopy->deviceID, pBueffel, SCDEVIDLEN);
|
||||
/* SCAdvanceContext(self,pBueffel); */
|
||||
iRet = InterpExecute(pInter, pCopy, pCommand);
|
||||
/* SCPopContext(self); */
|
||||
@ -2051,7 +2051,7 @@ long SCTagContext(SConnection * self, char *tagName)
|
||||
return -1;
|
||||
|
||||
a = SCGetContext(self);
|
||||
strncpy(a.deviceID, tagName, SCDEVIDLEN);
|
||||
strlcpy(a.deviceID, tagName, SCDEVIDLEN);
|
||||
/*
|
||||
SCGetContext will already have advanced the stack pointer to the
|
||||
last position
|
||||
@ -2094,7 +2094,7 @@ int SCPushContext(SConnection * self, int ID, char *deviceID)
|
||||
}
|
||||
|
||||
neu.transID = ID;
|
||||
strncpy(neu.deviceID, deviceID, SCDEVIDLEN);
|
||||
strlcpy(neu.deviceID, deviceID, SCDEVIDLEN);
|
||||
LLDnodeAppendFrom(self->contextStack, &neu);
|
||||
return 1;
|
||||
}
|
||||
@ -2116,7 +2116,7 @@ commandContext SCGetContext(SConnection * pCon)
|
||||
return neu;
|
||||
}
|
||||
neu.transID = pCon->transID;
|
||||
strncpy(neu.deviceID, pCon->deviceID, SCDEVIDLEN);
|
||||
strlcpy(neu.deviceID, pCon->deviceID, SCDEVIDLEN);
|
||||
return neu;
|
||||
}
|
||||
|
||||
|
15
counter.c
15
counter.c
@ -578,6 +578,16 @@ float GetCounterPreset(pCounter self)
|
||||
return self->getPreset(self);
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
float GetControlValue(pCounter self)
|
||||
{
|
||||
return self->getControlValue(self);
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
static float GetControlValueImpl(pCounter self)
|
||||
{
|
||||
return self->pDriv->fLastCurrent;
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
static float GetCounterPresetImpl(pCounter self)
|
||||
{
|
||||
int i;
|
||||
@ -739,6 +749,7 @@ pCounter CreateCounter(char *name, pCounterDriver pDriv)
|
||||
pRes->getNMonitor = GetNMonitorImpl;
|
||||
pRes->setPreset = SetCounterPresetImpl;
|
||||
pRes->getPreset = GetCounterPresetImpl;
|
||||
pRes->getControlValue = GetControlValueImpl;
|
||||
pRes->getCounts = GetCountsImpl;
|
||||
pRes->getMonitor = GetMonitorImpl;
|
||||
pRes->setMonitor = SetMonitorValueImpl;
|
||||
@ -920,8 +931,8 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
if (GetCounterMode(self) == ePreset) {
|
||||
sprintf(pBueffel, "%s.CountStatus = %d %d Beam: %ld E6",
|
||||
argv[0],
|
||||
(int) nintf(self->pDriv->fPreset),
|
||||
(int) nintf(self->pDriv->fLastCurrent),
|
||||
(int) nintf(GetCounterPreset(self)),
|
||||
(int) nintf(GetControlValue(self)),
|
||||
GetMonitor(self, 4, pCon) / 100000);
|
||||
} else {
|
||||
sprintf(pBueffel, "%s.CountStatus = %8.2f %8.2f Beam %ld E6",
|
||||
|
@ -35,6 +35,7 @@ typedef struct __Counter{
|
||||
int (*getNMonitor)(struct __Counter *self);
|
||||
int (*setPreset)(struct __Counter *self, float val);
|
||||
float (*getPreset)(struct __Counter *self);
|
||||
float (*getControlValue)(struct __Counter *self);
|
||||
long (*getCounts)(struct __Counter *self, SConnection *pCon);
|
||||
long (*getMonitor)(struct __Counter *self, int iNum, SConnection *pCon);
|
||||
void (*setMonitor)(struct __Counter *self, int iNum, long val);
|
||||
@ -57,6 +58,7 @@ CounterMode GetCounterMode(pCounter self);
|
||||
|
||||
int SetCounterPreset(pCounter self, float fVal);
|
||||
float GetCounterPreset(pCounter self);
|
||||
float GetControlValue(pCounter self);
|
||||
|
||||
long GetCounts(pCounter self, SConnection * pCon);
|
||||
long GetMonitor(pCounter self, int iNum, SConnection * pCon);
|
||||
|
12
countersec.c
12
countersec.c
@ -287,6 +287,17 @@ static float SecCtrGetPreset(pCounter self)
|
||||
GetHipadabaPar(node,&v,NULL);
|
||||
return (float)v.v.doubleValue;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static float SecCtrGetControlValue(pCounter self)
|
||||
{
|
||||
hdbValue v;
|
||||
pHdb node = NULL;
|
||||
|
||||
node = GetHipadabaNode(self->pDes->parNode,"control");
|
||||
assert(node != NULL);
|
||||
GetHipadabaPar(node,&v,NULL);
|
||||
return (float)v.v.doubleValue;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int SecCtrGetNMonitor(pCounter self)
|
||||
{
|
||||
@ -438,6 +449,7 @@ pCounter CreateSecCounter(SConnection *pCon, char *type, char *name, int length)
|
||||
pRes->getNMonitor = SecCtrGetNMonitor;
|
||||
pRes->setPreset = SecCtrSetPreset;
|
||||
pRes->getPreset = SecCtrGetPreset;
|
||||
pRes->getControlValue = SecCtrGetControlValue;
|
||||
pRes->getCounts = SecCtrGetCounts;
|
||||
pRes->getMonitor = SecCtrGetMonitor;
|
||||
pRes->setMonitor = SecCtrSetMonitor;
|
||||
|
@ -84,7 +84,7 @@ int openDevexecLog()
|
||||
if (devLog == NULL) {
|
||||
fileName = IFindOption(pSICSOptions, "devexeclog");
|
||||
if (fileName != NULL) {
|
||||
strncpy(fileBuffer, fileName,1024);
|
||||
strlcpy(fileBuffer, fileName,1024);
|
||||
} else {
|
||||
iDate = time(NULL);
|
||||
psTime = localtime(&iDate);
|
||||
|
18
ecbcounter.c
18
ecbcounter.c
@ -418,30 +418,30 @@ static int ECBGetError(struct __COUNTER *self, int *iCode,
|
||||
*iCode = self->iErrorCode;
|
||||
switch (self->iErrorCode) {
|
||||
case COMMERROR:
|
||||
strncpy(errorText, "Communication error with ECB", errlen);
|
||||
strlcpy(errorText, "Communication error with ECB", errlen);
|
||||
break;
|
||||
case TOMANYCOUNTS:
|
||||
strncpy(errorText, "Preset is to high!", errlen);
|
||||
strlcpy(errorText, "Preset is to high!", errlen);
|
||||
break;
|
||||
case NOSEND:
|
||||
strncpy(errorText, "Cannot send naked data to ECB", errlen);
|
||||
strlcpy(errorText, "Cannot send naked data to ECB", errlen);
|
||||
break;
|
||||
case UNKNOWNPAR:
|
||||
strncpy(errorText, "parameter unknown", errlen);
|
||||
strlcpy(errorText, "parameter unknown", errlen);
|
||||
break;
|
||||
case INVALIDCOUNTER:
|
||||
strncpy(errorText, "Invalid counter number requested, 0-7 allowed",
|
||||
strlcpy(errorText, "Invalid counter number requested, 0-7 allowed",
|
||||
errlen);
|
||||
break;
|
||||
case INVALIDPRESCALER:
|
||||
strncpy(errorText, "Invalid prescaler value, allowed 1 or 10", errlen);
|
||||
strlcpy(errorText, "Invalid prescaler value, allowed 1 or 10", errlen);
|
||||
break;
|
||||
case BADFREQ:
|
||||
strncpy(errorText, "Bad timer frequency: 10 or 1000 allowed", errlen);
|
||||
strlcpy(errorText, "Bad timer frequency: 10 or 1000 allowed", errlen);
|
||||
break;
|
||||
default:
|
||||
sprintf(pBueffel, "Unknown error code %d", self->iErrorCode);
|
||||
strncpy(errorText, pBueffel, errlen);
|
||||
strlcpy(errorText, pBueffel, errlen);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
@ -563,7 +563,7 @@ static int ECBGet(struct __COUNTER *self, char *name,
|
||||
static int ECBSend(struct __COUNTER *self, char *text,
|
||||
char *reply, int replylen)
|
||||
{
|
||||
strncpy(reply, "ECB does not feast on ASCII strings, refused!",
|
||||
strlcpy(reply, "ECB does not feast on ASCII strings, refused!",
|
||||
replylen);
|
||||
return OKOK;
|
||||
}
|
||||
|
@ -323,14 +323,14 @@ static int EVILimits(void *pData, float fVal, char *pError, int iErrLen)
|
||||
/* lower limit */
|
||||
if (fVal < ObVal(self->pParam, LOWLIMIT)) {
|
||||
sprintf(pBueffel, "ERROR: %g violates lower limit of device", fVal);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
strlcpy(pError, pBueffel, iErrLen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* upper limit */
|
||||
if (fVal > ObVal(self->pParam, UPLIMIT)) {
|
||||
sprintf(pBueffel, "ERROR: %g violates upper limit of device", fVal);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
strlcpy(pError, pBueffel, iErrLen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
2
exebuf.c
2
exebuf.c
@ -210,7 +210,7 @@ int exeBufProcess(pExeBuf self, SicsInterp * pSics,
|
||||
}
|
||||
l = ende - cmd;
|
||||
if (l < sizeof cmdName) {
|
||||
strncpy(cmdName, cmd, l);
|
||||
strlcpy(cmdName, cmd, l);
|
||||
cmdName[l] = '\0';
|
||||
if (FindCommand(pSics, cmdName) != NULL) {
|
||||
/* print only SICS commands */
|
||||
|
32
exeman.c
32
exeman.c
@ -201,15 +201,15 @@ static int makeExePath(pExeMan self, SConnection * pCon, int argc,
|
||||
* do nothing to absolute path
|
||||
*/
|
||||
if (argv[2][0] == '/') {
|
||||
strncat(buffer, argv[2], 511 - strlen(buffer));
|
||||
strlcat(buffer, argv[2], 511 - strlen(buffer));
|
||||
SCWrite(pCon, buffer, eValue);
|
||||
return 1;
|
||||
}
|
||||
pPtr = self->batchPath;
|
||||
pPtr = stptok(pPtr, pPath, 131, ":");
|
||||
strncat(buffer, pPath, 511 - strlen(buffer));
|
||||
strncat(buffer, "/", 511 - strlen(buffer));
|
||||
strncat(buffer, argv[2], 511 - strlen(buffer));
|
||||
strlcat(buffer, pPath, 511 - strlen(buffer));
|
||||
strlcat(buffer, "/", 511 - strlen(buffer));
|
||||
strlcat(buffer, argv[2], 511 - strlen(buffer));
|
||||
SCWrite(pCon, buffer, eValue);
|
||||
|
||||
return 1;
|
||||
@ -363,8 +363,8 @@ int exeHdbNode(pHdb exeNode, SConnection * pCon)
|
||||
SCWrite(pCon, "ERROR: out of memory in exehdbNode", eError);
|
||||
return 0;
|
||||
}
|
||||
strncpy(conCon->deviceID, name, 255);
|
||||
strncpy(bufferNode, name, 511);
|
||||
strlcpy(conCon->deviceID, name, 255);
|
||||
strlcpy(bufferNode, name, 511);
|
||||
|
||||
/*
|
||||
* load commands into buffer
|
||||
@ -390,7 +390,7 @@ int exeHdbNode(pHdb exeNode, SConnection * pCon)
|
||||
}
|
||||
exeBufAppend(buffer, v.v.text);
|
||||
|
||||
strncpy(bufferNode, name, 511);
|
||||
strlcpy(bufferNode, name, 511);
|
||||
SCSetWriteFunc(conCon, SCHdbWrite);
|
||||
status = exeBufProcess(buffer, pServ->pSics, conCon, NULL, 0);
|
||||
SCDeleteConnection(conCon);
|
||||
@ -438,7 +438,7 @@ static int runHdbBuffer(pExeMan self, SConnection * pCon,
|
||||
* prepare context
|
||||
*/
|
||||
conCon = SCCopyConnection(pCon);
|
||||
strncpy(conCon->deviceID, pBueffel,255);
|
||||
strlcpy(conCon->deviceID, pBueffel,255);
|
||||
|
||||
/*
|
||||
* load commands into buffer
|
||||
@ -465,7 +465,7 @@ static int runHdbBuffer(pExeMan self, SConnection * pCon,
|
||||
}
|
||||
exeBufAppend(buffer, v.v.text);
|
||||
|
||||
strncpy(bufferNode, name, 511);
|
||||
strlcpy(bufferNode, name, 511);
|
||||
SCSetWriteFunc(conCon, SCHdbWrite);
|
||||
self->exeStackPtr++;
|
||||
self->runCon = conCon;
|
||||
@ -749,13 +749,13 @@ static int uploadForceSave(pExeMan self, SConnection * pCon,
|
||||
pPtr = self->batchPath;
|
||||
pPtr = stptok(pPtr, pPath, 131, ":");
|
||||
if (strlen(pPath) + 1 + strlen(argv[2]) <= 256) {
|
||||
strncat(pPath, "/",255);
|
||||
strncat(pPath, argv[2],255);
|
||||
strlcat(pPath, "/",255);
|
||||
strlcat(pPath, argv[2],255);
|
||||
} else {
|
||||
strncpy(pPath, argv[2], 255);
|
||||
strlcpy(pPath, argv[2], 255);
|
||||
}
|
||||
} else {
|
||||
strncpy(pPath, argv[2], 131);
|
||||
strlcpy(pPath, argv[2], 131);
|
||||
}
|
||||
|
||||
status = exeBufSave(self->uploadBuffer, pPath);
|
||||
@ -794,10 +794,10 @@ static int uploadSave(pExeMan self, SConnection * pCon,
|
||||
strcat(pPath, "/");
|
||||
strcat(pPath, argv[2]);
|
||||
} else {
|
||||
strncpy(pPath, argv[2], 255);
|
||||
strlcpy(pPath, argv[2], 255);
|
||||
}
|
||||
} else {
|
||||
strncpy(pPath, argv[2], 131);
|
||||
strlcpy(pPath, argv[2], 131);
|
||||
}
|
||||
if (fileExists(pPath)) {
|
||||
SCWrite(pCon, "ERROR: file exists", eError);
|
||||
@ -1299,7 +1299,7 @@ int ExeManagerWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
|
||||
|
||||
if (argc > 1) {
|
||||
strncpy(pBufferName, argv[1], 255);
|
||||
strlcpy(pBufferName, argv[1], 255);
|
||||
strtolower(argv[1]);
|
||||
status = handleBatchPath(self, pCon, argc, argv);
|
||||
if (status >= 0) {
|
||||
|
@ -162,7 +162,7 @@ static int FourMessStart(pSICSOBJ self, SConnection * pCon,
|
||||
}
|
||||
priv->currentFileRoot = strdup(pFile);
|
||||
free(pFile);
|
||||
strncpy(pRoot, priv->currentFileRoot, 511);
|
||||
strlcpy(pRoot, priv->currentFileRoot, 511);
|
||||
|
||||
|
||||
/* open the reflection file */
|
||||
|
@ -112,7 +112,7 @@ static int SIMclear(int devID)
|
||||
/*---------------------------------------------------------------------*/
|
||||
static void SIMerror(int code, char *buffer, int maxBuf)
|
||||
{
|
||||
strncpy(buffer, "Unknown simulated error", maxBuf);
|
||||
strlcpy(buffer, "Unknown simulated error", maxBuf);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
@ -267,7 +267,7 @@ int GPIBAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
strncpy(pBuffer, argv[3], 1024);
|
||||
strlcpy(pBuffer, argv[3], 1024);
|
||||
pBuffer[strlen(pBuffer)] = (char) terminator;
|
||||
status = GPIBsend(self, devID, pBuffer, (int) strlen(pBuffer));
|
||||
if (status > 0) {
|
||||
|
8
help.c
8
help.c
@ -45,7 +45,7 @@ static FILE *findHelpFile(char *name)
|
||||
while ((pPtr = stptok(pPtr, dir, 131, PATHSEP)) != NULL) {
|
||||
strcpy(pBueffel, dir);
|
||||
strcat(pBueffel, DIRSEP);
|
||||
strncat(pBueffel, name, (254 - strlen(pBueffel)));
|
||||
strlcat(pBueffel, name, (254 - strlen(pBueffel)));
|
||||
fd = fopen(pBueffel, "r");
|
||||
if (fd != NULL) {
|
||||
return fd;
|
||||
@ -117,7 +117,7 @@ int SicsHelp(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
char helpFile[256];
|
||||
FILE *fd = NULL;
|
||||
|
||||
strncpy(helpFile, defaultFile, 255);
|
||||
strlcpy(helpFile, defaultFile, 255);
|
||||
|
||||
if (argc > 1) {
|
||||
strtolower(argv[1]);
|
||||
@ -140,8 +140,8 @@ int SicsHelp(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
/*
|
||||
the parameter is a help file name
|
||||
*/
|
||||
strncpy(helpFile, argv[1], 255);
|
||||
strncat(helpFile, ".txt", 255);
|
||||
strlcpy(helpFile, argv[1], 255);
|
||||
strlcat(helpFile, ".txt", 255);
|
||||
}
|
||||
|
||||
/*
|
||||
|
8
hmdata.c
8
hmdata.c
@ -582,7 +582,7 @@ static pNXDS subSampleCommand(pNXDS source, char *command,
|
||||
}
|
||||
|
||||
if (dim < source->rank - 1) {
|
||||
strncpy(error,
|
||||
strlcpy(error,
|
||||
"ERROR: Not enough border values specified for subsampling",
|
||||
errLen);
|
||||
return NULL;
|
||||
@ -654,7 +654,7 @@ HistInt *subSample(pHMdata self, char *command, char *error, int errLen)
|
||||
|
||||
start = hmDataToNXDataset(self);
|
||||
if (start == NULL) {
|
||||
strncpy(error, "Out-Of-Memory or no data while subsampling ", errLen);
|
||||
strlcpy(error, "Out-Of-Memory or no data while subsampling ", errLen);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -666,7 +666,7 @@ HistInt *subSample(pHMdata self, char *command, char *error, int errLen)
|
||||
} else if (strstr(subCommand, "sum") != NULL) {
|
||||
result = sumCommand(source, subCommand, error, errLen);
|
||||
} else {
|
||||
strncpy(error, "ERROR: invalid subcommand to process requested",
|
||||
strlcpy(error, "ERROR: invalid subcommand to process requested",
|
||||
errLen);
|
||||
return NULL;
|
||||
}
|
||||
@ -681,7 +681,7 @@ HistInt *subSample(pHMdata self, char *command, char *error, int errLen)
|
||||
length = getNXDatasetLength(result);
|
||||
data = malloc((length + 1) * sizeof(int));
|
||||
if (data == NULL) {
|
||||
strncpy(error, "Out-Of-Mmeory in Subsample", errLen);
|
||||
strlcpy(error, "Out-Of-Mmeory in Subsample", errLen);
|
||||
dropNXDataset(result);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ static int HMSlaveGetError(pHistDriver self, int *code,
|
||||
HMSlave pPriv = NULL;
|
||||
|
||||
pPriv = (HMSlave) self->pPriv;
|
||||
strncpy(error, "Weird status: slaves do not err..", errLen);
|
||||
strlcpy(error, "Weird status: slaves do not err..", errLen);
|
||||
*code = -77;
|
||||
return 1;
|
||||
}
|
||||
|
4
ifile.c
4
ifile.c
@ -118,9 +118,9 @@ IPair *IFReadConfigFile(FILE * fd)
|
||||
continue;
|
||||
|
||||
iLen = pPos - pBueffel;
|
||||
strncpy(pName, pBueffel, iLen);
|
||||
strlcpy(pName, pBueffel, iLen);
|
||||
pName[iLen] = '\0';
|
||||
strncpy(pValue, (pPos + 1),131);
|
||||
strlcpy(pValue, (pPos + 1),131);
|
||||
RemoveWhiteSpace(pName);
|
||||
RemoveWhiteSpace(pValue);
|
||||
pList = CreateNewEntry(pName, pValue, pList);
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <strlutil.h>
|
||||
|
||||
#include "fortify.h"
|
||||
#include "conman.h"
|
||||
#include "SCinter.h"
|
||||
@ -96,7 +98,7 @@ int Interrupt2Text(int iInterrupt, char *text, int iTextLen)
|
||||
if ((iInterrupt < 0) || (iInterrupt > MAXINTERRUPT)) {
|
||||
return 0;
|
||||
}
|
||||
strncpy(text, pIntText[iInterrupt], iTextLen - 1);
|
||||
strlcpy(text, pIntText[iInterrupt], iTextLen - 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -502,7 +502,7 @@ static int LogReader(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
if (!inRange) {
|
||||
if (t < startim) {
|
||||
lastval[0] = '\0';
|
||||
strncat(lastval, val, sizeof lastval - 1);
|
||||
strlcat(lastval, val, sizeof lastval - 1);
|
||||
lastt = t;
|
||||
} else {
|
||||
inRange = 1;
|
||||
|
2
macro.c
2
macro.c
@ -525,7 +525,7 @@ int MacroFileEval(SConnection * pCon, SicsInterp * pInter, void *pData,
|
||||
/*
|
||||
local copy in order to resolve a valgrind error
|
||||
*/
|
||||
strncpy(pBueffel, pTcl->result, 511);
|
||||
strlcpy(pBueffel, pTcl->result, 511);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
}
|
||||
pCom = Tcl_DStringValue(&command);
|
||||
|
2
make_gen
2
make_gen
@ -41,7 +41,7 @@ SOBJ = network.o ifile.o conman.o SCinter.o splitter.o passwd.o \
|
||||
sgclib.o sgfind.o sgio.o sgsi.o sghkl.o singlediff.o singlebi.o \
|
||||
singlenb.o simindex.o simidx.o uselect.o singletas.o motorsec.o \
|
||||
rwpuffer.o asynnet.o background.o countersec.o hdbtable.o velosec.o \
|
||||
histmemsec.o sansbc.o sicsutil.o
|
||||
histmemsec.o sansbc.o sicsutil.o strlutil.o
|
||||
|
||||
MOTOROBJ = motor.o simdriv.o
|
||||
COUNTEROBJ = countdriv.o simcter.o counter.o
|
||||
|
18
mccontrol.c
18
mccontrol.c
@ -153,7 +153,7 @@ static int invokeScript(pMcStasController self, char *name,
|
||||
int status;
|
||||
|
||||
if (!StringDictGet(self->scripts, name, pScript, 131)) {
|
||||
strncpy(result, "ERROR: script not found", resultLen);
|
||||
strlcpy(result, "ERROR: script not found", resultLen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ static int invokeScript(pMcStasController self, char *name,
|
||||
|
||||
pTcl = InterpGetTcl(pSics);
|
||||
status = Tcl_Eval(pTcl, pCommand);
|
||||
strncpy(result, pTcl->result, resultLen);
|
||||
strlcpy(result, pTcl->result, resultLen);
|
||||
if (status == TCL_OK) {
|
||||
return 1;
|
||||
} else {
|
||||
@ -280,12 +280,12 @@ int McStasStart(pMcStasController self, CounterMode mode, float fPreset)
|
||||
* make sure that the monitor file has only a 0 in it...
|
||||
*/
|
||||
if (!StringDictGet(self->scripts, "mcmonfile", pResult, 255)) {
|
||||
strncpy(self->errorText, "Misconfiguration: no monfile", 255);
|
||||
strlcpy(self->errorText, "Misconfiguration: no monfile", 255);
|
||||
return HWFault;
|
||||
}
|
||||
fd = fopen(pResult, "w");
|
||||
if (fd == NULL) {
|
||||
strncpy(self->errorText, "Failed to access monitor file", 255);
|
||||
strlcpy(self->errorText, "Failed to access monitor file", 255);
|
||||
return HWFault;
|
||||
}
|
||||
fprintf(fd, "0\n");
|
||||
@ -296,7 +296,7 @@ int McStasStart(pMcStasController self, CounterMode mode, float fPreset)
|
||||
*/
|
||||
status = invokeScript(self, "mcstart", pServ->pSics, pResult, 255);
|
||||
if (status == 0) {
|
||||
strncpy(self->errorText, pResult, 255);
|
||||
strlcpy(self->errorText, pResult, 255);
|
||||
return HWFault;
|
||||
}
|
||||
|
||||
@ -344,7 +344,7 @@ int McStasStatus(pMcStasController self, float *fControl)
|
||||
SicsWait(1);
|
||||
status = invokeScript(self, "mcisrunning", pServ->pSics, pResult, 255);
|
||||
if (status == 0) {
|
||||
strncpy(self->errorText, pResult, 255);
|
||||
strlcpy(self->errorText, pResult, 255);
|
||||
return HWFault;
|
||||
}
|
||||
status = atoi(pResult);
|
||||
@ -428,7 +428,7 @@ int McStasTransferData(pMcStasController self)
|
||||
if (self->pid >= 0) {
|
||||
status = invokeScript(self, "mcdump", pServ->pSics, pResult, 255);
|
||||
if (status == 0) {
|
||||
strncpy(self->errorText, pResult, 255);
|
||||
strlcpy(self->errorText, pResult, 255);
|
||||
self->lastUpdate = time(NULL) - self->updateIntervall;
|
||||
return HWFault;
|
||||
}
|
||||
@ -436,7 +436,7 @@ int McStasTransferData(pMcStasController self)
|
||||
|
||||
status = invokeScript(self, "mccopydata", pServ->pSics, pResult, 255);
|
||||
if (status == 0) {
|
||||
strncpy(self->errorText, pResult, 255);
|
||||
strlcpy(self->errorText, pResult, 255);
|
||||
self->lastUpdate = time(NULL) - self->updateIntervall;
|
||||
return HWFault;
|
||||
}
|
||||
@ -446,7 +446,7 @@ int McStasTransferData(pMcStasController self)
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int McStasGetError(pMcStasController self, char *error, int errLen)
|
||||
{
|
||||
strncpy(error, self->errorText, errLen);
|
||||
strlcpy(error, self->errorText, errLen);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ static void MCReportError(void *pData, char *txt)
|
||||
|
||||
self = (pMcStasReader) pData;
|
||||
if (self != NULL) {
|
||||
strncpy(self->nexusError, txt, 1024);
|
||||
strlcpy(self->nexusError, txt, 1024);
|
||||
} else {
|
||||
printf
|
||||
("ERROR: NeXus error in McStasReader without McStasReader data structure: %s\n",
|
||||
|
@ -104,10 +104,10 @@ static int McGetError(struct __COUNTER *self, int *iCode, char *error,
|
||||
McStasGetError(pMcStas, error, iErrLen);
|
||||
break;
|
||||
case NOTIMPLEMENTED:
|
||||
strncpy(error, "Feauture not implemented", iErrLen);
|
||||
strlcpy(error, "Feauture not implemented", iErrLen);
|
||||
break;
|
||||
default:
|
||||
strncpy(error, "Unknown error code in McStas Driver", iErrLen);
|
||||
strlcpy(error, "Unknown error code in McStas Driver", iErrLen);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
@ -143,7 +143,7 @@ static int McGet(struct __COUNTER *self, char *name, int iCter,
|
||||
static int McSend(struct __COUNTER *self, char *pText,
|
||||
char *pReply, int iReplyLen)
|
||||
{
|
||||
strncpy(pReply, "WARNING: McStas simulation cannot be sent anything",
|
||||
strlcpy(pReply, "WARNING: McStas simulation cannot be sent anything",
|
||||
iReplyLen);
|
||||
return 1;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ static int McHMGetError(pHistDriver self, int *iCode, char *error,
|
||||
return pCount->pDriv->GetError(pCount->pDriv, iCode, error, errLen);
|
||||
} else {
|
||||
*iCode = -1000;
|
||||
strncpy(error, "Feature not implemented in McStasHM", errLen);
|
||||
strlcpy(error, "Feature not implemented in McStasHM", errLen);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
10
moregress.c
10
moregress.c
@ -123,19 +123,19 @@ static void RGGetError(void *data, int *iCode, char *buffer, int iBufLen)
|
||||
*iCode = self->errorType;
|
||||
switch (self->errorType) {
|
||||
case NONE:
|
||||
strncpy(buffer, "No error found", iBufLen);
|
||||
strlcpy(buffer, "No error found", iBufLen);
|
||||
break;
|
||||
case BADPOS:
|
||||
strncpy(buffer, "Position not reached", iBufLen);
|
||||
strlcpy(buffer, "Position not reached", iBufLen);
|
||||
break;
|
||||
case FAIL:
|
||||
strncpy(buffer, "Hardware is mad", iBufLen);
|
||||
strlcpy(buffer, "Hardware is mad", iBufLen);
|
||||
break;
|
||||
case STARTFAIL:
|
||||
strncpy(buffer, "Failed to start motor", iBufLen);
|
||||
strlcpy(buffer, "Failed to start motor", iBufLen);
|
||||
break;
|
||||
case READFAIL:
|
||||
strncpy(buffer, "Failed to read motor", iBufLen);
|
||||
strlcpy(buffer, "Failed to read motor", iBufLen);
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ int addMotorToList(int listHandle, char *name, float targetValue)
|
||||
return 0;
|
||||
}
|
||||
tuktuk.data = pMot;
|
||||
strncpy(tuktuk.name, name, 79);
|
||||
strlcpy(tuktuk.name, name, 79);
|
||||
tuktuk.pDriv = pMot->pDrivInt;
|
||||
tuktuk.target = targetValue;
|
||||
tuktuk.running = 0;
|
||||
|
10
motorsec.c
10
motorsec.c
@ -135,7 +135,7 @@ static int SecMotorCheckBoundary(pMotor self, float fVal, float *fTarget,
|
||||
/* check for fixed */
|
||||
if (fixed >= 0) {
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "Motor %s is Fixed", self->name);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
strlcpy(pError, pBueffel, iErrLen);
|
||||
return 0; /* is this an error? */
|
||||
}
|
||||
|
||||
@ -143,13 +143,13 @@ static int SecMotorCheckBoundary(pMotor self, float fVal, float *fTarget,
|
||||
if (fVal > upperlim) {
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%f violates upper software limit %f on %s",
|
||||
fVal, upperlim, self->name);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
strlcpy(pError, pBueffel, iErrLen);
|
||||
return 0;
|
||||
}
|
||||
if (fVal < lowerlim) {
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%f violates lower software limit %f on %s",
|
||||
fVal, lowerlim, self->name);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
strlcpy(pError, pBueffel, iErrLen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -167,13 +167,13 @@ static int SecMotorCheckBoundary(pMotor self, float fVal, float *fTarget,
|
||||
if (fHard > hupper) {
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%f violates upper hardware limit %f on %s",
|
||||
fVal, hupper, self->name);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
strlcpy(pError, pBueffel, iErrLen);
|
||||
return 0;
|
||||
}
|
||||
if (fHard < hlower) {
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%f violates lower hardware limit %f on %s",
|
||||
fVal, hlower, self->name);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
strlcpy(pError, pBueffel, iErrLen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ static int MMCCStatus(void *pData, SConnection * pCon)
|
||||
|
||||
status = self->slaves[0]->CheckCountStatus(self->slaveData[0], pCon);
|
||||
pMaster = (pCounter)self->slaveData[0];
|
||||
pCount->pDriv->fLastCurrent = pMaster->pDriv->fLastCurrent;
|
||||
pCount->pDriv->fLastCurrent = GetControlValue(pMaster);
|
||||
if (status == HWIdle || status == HWFault) {
|
||||
/*
|
||||
stop counting on slaves when finished or when an error
|
||||
@ -368,9 +368,9 @@ static int MultiCounterError(struct __COUNTER *pDriv, int *iCode,
|
||||
|
||||
|
||||
if (pDriv->iErrorCode == NOCOUNTERS) {
|
||||
strncpy(error, "NO counters configured!", errlen);
|
||||
strlcpy(error, "NO counters configured!", errlen);
|
||||
} else {
|
||||
strncpy(error, "Not Implemented", errlen);
|
||||
strlcpy(error, "Not Implemented", errlen);
|
||||
}
|
||||
return COTERM;
|
||||
}
|
||||
|
20
mumo.c
20
mumo.c
@ -353,7 +353,7 @@ static int ParseAlias(psParser pParse, SConnection * pCon, pMulMot self)
|
||||
iRet = StringDictGet(self->pAlias, pParse->Token, pBueffel, 131);
|
||||
/* that it is alias has been tested earlier */
|
||||
assert(iRet == 1);
|
||||
strncat(pCommand, pBueffel,1024);
|
||||
strlcat(pCommand, pBueffel,1024);
|
||||
|
||||
/* now find the value to handle */
|
||||
iToken = GetNextToken(pParse, self);
|
||||
@ -384,12 +384,12 @@ static int ParseAlias(psParser pParse, SConnection * pCon, pMulMot self)
|
||||
MotorGetSoftPosition(pMot, pCon, &fVal);
|
||||
fVal += iSign * fIn;
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, " %f ", fVal);
|
||||
strncat(pCommand, pBueffel,1024);
|
||||
strlcat(pCommand, pBueffel,1024);
|
||||
InterpExecute(GetInterpreter(), pCon, pCommand);
|
||||
return 1;
|
||||
} else {
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, " %f ", iSign * fIn);
|
||||
strncat(pCommand, pBueffel,1024);
|
||||
strlcat(pCommand, pBueffel,1024);
|
||||
InterpExecute(GetInterpreter(), pCon, pCommand);
|
||||
return 1;
|
||||
}
|
||||
@ -426,7 +426,7 @@ static int MakeCurrentNamPos(char *name, SConnection * pCon, pMulMot self)
|
||||
pCommand[0] = '\0';
|
||||
pAlias = StringDictGetNext(self->pAlias, pMotort, 131);
|
||||
while (pAlias != NULL) {
|
||||
strncat(pCommand, pMotort,1024);
|
||||
strlcat(pCommand, pMotort,1024);
|
||||
pMot = FindMotor(GetInterpreter(), pMotort);
|
||||
assert(pMot); /* validity of alias has already been checked */
|
||||
iRet = MotorGetSoftPosition(pMot, pCon, &fVal);
|
||||
@ -437,7 +437,7 @@ static int MakeCurrentNamPos(char *name, SConnection * pCon, pMulMot self)
|
||||
return 0;
|
||||
}
|
||||
snprintf(pMotort,sizeof(pMotort)-1, " %f ", fVal);
|
||||
strncat(pCommand, pMotort,1024);
|
||||
strlcat(pCommand, pMotort,1024);
|
||||
pAlias = StringDictGetNext(self->pAlias, pMotort, 131);
|
||||
}
|
||||
if (StringDictExists(self->pNamPos, name)) {
|
||||
@ -633,7 +633,7 @@ static int ParseDefPos(SicsInterp * pSics, psParser pPP,
|
||||
return 0;
|
||||
}
|
||||
|
||||
strncpy(namPos, pPP->Token, 79);
|
||||
strlcpy(namPos, pPP->Token, 79);
|
||||
iToken = GetNextToken(pPP, self);
|
||||
command[0] = '\0';
|
||||
while (iToken != END) {
|
||||
@ -643,16 +643,16 @@ static int ParseDefPos(SicsInterp * pSics, psParser pPP,
|
||||
return 0;
|
||||
}
|
||||
StringDictGet(self->pAlias, pPP->Token, motorName, 79);
|
||||
strncat(command, motorName,1024);
|
||||
strncat(command, " ",1024);
|
||||
strlcat(command, motorName,1024);
|
||||
strlcat(command, " ",1024);
|
||||
iToken = GetNextToken(pPP, self);
|
||||
if (iToken != NUMBER) {
|
||||
snprintf(command,sizeof(command)-1, "ERROR: expected number, got: %s", pPP->Token);
|
||||
SCWrite(pCon, command, eError);
|
||||
return 0;
|
||||
}
|
||||
strncat(command, pPP->Token,1024);
|
||||
strncat(command, " ",1024);
|
||||
strlcat(command, pPP->Token,1024);
|
||||
strlcat(command, " ",1024);
|
||||
iToken = GetNextToken(pPP, self);
|
||||
}
|
||||
|
||||
|
@ -399,7 +399,7 @@ int NETInfo(mkChannel * self, char *pCompost, int iBufLen)
|
||||
sizeof sin.sin_addr, AF_INET)) == NULL) {
|
||||
return 0;
|
||||
} else {
|
||||
strncpy(pCompost, host->h_name, iBufLen);
|
||||
strlcpy(pCompost, host->h_name, iBufLen);
|
||||
pCompost[iBufLen - 1] = '\0';
|
||||
}
|
||||
}
|
||||
@ -619,12 +619,14 @@ int NETReadTillTerm(mkChannel * self, long timeout,
|
||||
return status;
|
||||
}
|
||||
if ('&' != pTerm[0]) {
|
||||
/* This accepts any terminator */
|
||||
for (i = 0; i < length; i++) {
|
||||
if (c == pTerm[i]) {
|
||||
return bufPtr + 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* this is for accepting a terminator consisting of multiple characters, pTerm[0] is & */
|
||||
if (matchIndex == 1 && c == pTerm[1]) {
|
||||
matchIndex++;
|
||||
} else {
|
||||
|
10
nigpib.c
10
nigpib.c
@ -88,22 +88,22 @@ static void NIerror(int code, char *buffer, int maxBuffer)
|
||||
case EDVR:
|
||||
case ENEB:
|
||||
case ECIC:
|
||||
strncpy(buffer, "NI-GPIB not correctly installed or bad address",
|
||||
strlcpy(buffer, "NI-GPIB not correctly installed or bad address",
|
||||
maxBuffer);
|
||||
return;
|
||||
case EABO:
|
||||
strncpy(buffer, "Timeout on data transfer", maxBuffer);
|
||||
strlcpy(buffer, "Timeout on data transfer", maxBuffer);
|
||||
return;
|
||||
case EBUS:
|
||||
strncpy(buffer, "No device connected to GPIB or address errror",
|
||||
strlcpy(buffer, "No device connected to GPIB or address errror",
|
||||
maxBuffer);
|
||||
return;
|
||||
case ENOL:
|
||||
strncpy(buffer, "No listeners on bus. Perhaps address error?",
|
||||
strlcpy(buffer, "No listeners on bus. Perhaps address error?",
|
||||
maxBuffer);
|
||||
return;
|
||||
default:
|
||||
strncpy(buffer, "Unrecognised error code, fix nigpib.c", maxBuffer);
|
||||
strlcpy(buffer, "Unrecognised error code, fix nigpib.c", maxBuffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
6
nread.c
6
nread.c
@ -21,6 +21,8 @@
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
#include <sys/time.h>
|
||||
#include <strlutil.h>
|
||||
|
||||
#include "fortify.h"
|
||||
#include "lld.h"
|
||||
#include "network.h"
|
||||
@ -289,7 +291,7 @@ static int NetReadRead(pNetRead self, pNetItem pItem)
|
||||
*pEnd = '\0';
|
||||
/* do we have something in hold ? */
|
||||
if (strlen(pItem->pHold) > 0) {
|
||||
strncat(pItem->pHold, pPtr,511);
|
||||
strlcat(pItem->pHold, pPtr,511);
|
||||
iStat = CostaTop(pItem->pCon->pStack, pItem->pHold);
|
||||
if (!iStat) {
|
||||
SCWrite(pItem->pCon, "ERROR: Busy", eError);
|
||||
@ -320,7 +322,7 @@ static int NetReadRead(pNetRead self, pNetItem pItem)
|
||||
}
|
||||
/* when we are here we may still have an incomplete command pending */
|
||||
if (pEnd != pPtr && strlen(pPtr) > 0) {
|
||||
strncpy(pItem->pHold, pPtr, 511);
|
||||
strlcpy(pItem->pHold, pPtr, 511);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ void StopServer(pServer self)
|
||||
strcpy(pBueffel, "Backup ");
|
||||
pText = IFindOption(pSICSOptions, "statusfile");
|
||||
if (pText) {
|
||||
strncat(pBueffel, pText,511);
|
||||
strlcat(pBueffel, pText,511);
|
||||
} else {
|
||||
strcat(pBueffel, DEFAULTSTATUSFILE);
|
||||
}
|
||||
|
22
nxscript.c
22
nxscript.c
@ -279,8 +279,8 @@ static void putMotor(SConnection * pCon, SicsInterp * pSics,
|
||||
/*
|
||||
if alias_null is available: write zero point
|
||||
*/
|
||||
strncpy(buffer, argv[2],131);
|
||||
strncat(buffer, "_null",131);
|
||||
strlcpy(buffer, argv[2],131);
|
||||
strlcat(buffer, "_null",131);
|
||||
if (NXDdefget(self->dictHandle, buffer, dummy, 255)) {
|
||||
MotorGetPar(brumm, "softzero", &fVal);
|
||||
status =
|
||||
@ -326,8 +326,8 @@ static void putCounter(SConnection * pCon, SicsInterp * pSics,
|
||||
do preset
|
||||
*/
|
||||
fVal = GetCounterPreset(cter);
|
||||
strncpy(newAlias, argv[2],255);
|
||||
strncat(newAlias, "_preset",255);
|
||||
strlcpy(newAlias, argv[2],255);
|
||||
strlcat(newAlias, "_preset",255);
|
||||
status =
|
||||
NXDputalias(self->fileHandle, self->dictHandle, newAlias, &fVal);
|
||||
if (status != NX_OK) {
|
||||
@ -357,8 +357,8 @@ static void putCounter(SConnection * pCon, SicsInterp * pSics,
|
||||
do time
|
||||
*/
|
||||
fVal = GetCountTime(cter, pCon);
|
||||
strncpy(newAlias, argv[2],255);
|
||||
strncat(newAlias, "_time",255);
|
||||
strlcpy(newAlias, argv[2],255);
|
||||
strlcat(newAlias, "_time",255);
|
||||
if (NXDdefget(self->dictHandle, newAlias, dummy, 79)) {
|
||||
status =
|
||||
NXDputalias(self->fileHandle, self->dictHandle, newAlias, &fVal);
|
||||
@ -474,7 +474,7 @@ static void putHdb(SConnection * pCon, SicsInterp * pSics, pNXScript self,
|
||||
argv[2]);
|
||||
return;
|
||||
} else {
|
||||
strncpy(alias, argv[3], 512);
|
||||
strlcpy(alias, argv[3], 512);
|
||||
}
|
||||
}
|
||||
GetHipadabaPar(node, &v, pCon);
|
||||
@ -540,7 +540,7 @@ static void putHdbOff(SConnection * pCon, SicsInterp * pSics, pNXScript self,
|
||||
argv[2]);
|
||||
return;
|
||||
} else {
|
||||
strncpy(alias, argv[4], 512);
|
||||
strlcpy(alias, argv[4], 512);
|
||||
}
|
||||
}
|
||||
offset = atoi(argv[3]);
|
||||
@ -1319,10 +1319,10 @@ static int handlePut(SConnection * pCon, SicsInterp * pSics,
|
||||
return 1;
|
||||
}
|
||||
if (strlen(defString) < 900) {
|
||||
strncat(defString, " -dim {",1024);
|
||||
strlcat(defString, " -dim {",1024);
|
||||
snprintf(numBuf,sizeof(numBuf)-1, "%d", (int) strlen(buffer) + 1);
|
||||
strncat(defString, numBuf,1024);
|
||||
strncat(defString, " }",1024);
|
||||
strlcat(defString, numBuf,1024);
|
||||
strlcat(defString, " }",1024);
|
||||
} else {
|
||||
SCWrite(pCon, "ERROR: out of definition string space in puttext",
|
||||
eLogError);
|
||||
|
8
nxutil.c
8
nxutil.c
@ -27,7 +27,7 @@ int SNXSPutMotor(SicsInterp * pSics, SConnection * pCon,
|
||||
int iRet;
|
||||
|
||||
/* Find the motor */
|
||||
strncpy(pBueffel, pName, 511);
|
||||
strlcpy(pBueffel, pName, 511);
|
||||
strtolower(pBueffel);
|
||||
pMot = FindMotor(pSics, pBueffel);
|
||||
if (!pMot) {
|
||||
@ -57,7 +57,7 @@ int SNXSPutMotorNull(SicsInterp * pSics, SConnection * pCon,
|
||||
int iRet;
|
||||
|
||||
/* Find the motor */
|
||||
strncpy(pBueffel, pName, 511);
|
||||
strlcpy(pBueffel, pName, 511);
|
||||
strtolower(pBueffel);
|
||||
pMot = FindMotor(pSics, pBueffel);
|
||||
if (!pMot) {
|
||||
@ -92,7 +92,7 @@ int SNXSPutVariable(SicsInterp * pSics, SConnection * pCon,
|
||||
char *pText = NULL;
|
||||
|
||||
/* find it */
|
||||
strncpy(pBueffel, pName, 511);
|
||||
strlcpy(pBueffel, pName, 511);
|
||||
strtolower(pBueffel);
|
||||
pVar = FindVariable(pSics, pBueffel);
|
||||
if (!pVar) {
|
||||
@ -108,7 +108,7 @@ int SNXSPutVariable(SicsInterp * pSics, SConnection * pCon,
|
||||
VarGetText(pVar, &pText);
|
||||
if (pText != NULL) {
|
||||
memset(pBueffel, 0, 511);
|
||||
strncpy(pBueffel, pText, 511);
|
||||
strlcpy(pBueffel, pText, 511);
|
||||
iRet = NXDputalias(hFil, pDict, pAlias, pBueffel);
|
||||
free(pText);
|
||||
return iRet;
|
||||
|
@ -87,7 +87,7 @@ static int InitDefaultProtocol(SConnection * pCon, Protocol * pPro);
|
||||
/* Signatures for protocol writers implemented in this file */
|
||||
int SCWriteSycamore(SConnection * pCon, char *pBuffer, int iOut);
|
||||
int SCWriteJSON_String(SConnection * pCon, char *pBuffer, int iOut);
|
||||
/* Signatures for ptotocols from conman.c*/
|
||||
/* Signatures for protocols from conman.c*/
|
||||
extern int SCAllWrite(SConnection * self, char *buffer, int iOut);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@ -182,7 +182,7 @@ static int ContextDo(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
SCWrite(pCon, buffer, eError);
|
||||
return 0;
|
||||
}
|
||||
strncpy(comCon->deviceID, argv[2], SCDEVIDLEN);
|
||||
strlcpy(comCon->deviceID, argv[2], SCDEVIDLEN);
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
command = Arg2Tcl(argc - 2, &argv[2], buffer, sizeof buffer);
|
||||
if (!command) {
|
||||
@ -330,7 +330,7 @@ int ProtocolGet(SConnection * pCon, void *pData, char *pProName, int len)
|
||||
pPro->isDefaultSet = 1;
|
||||
pCon->iProtocolID = 0;
|
||||
}
|
||||
strncpy(pProName, pPro->pProList[pCon->iProtocolID], len);
|
||||
strlcpy(pProName, pPro->pProList[pCon->iProtocolID], len);
|
||||
return 1;
|
||||
#if 0
|
||||
Index = pCon->iProtocolID;
|
||||
|
2
proxy.c
2
proxy.c
@ -79,7 +79,7 @@ static int ProxyLimits(void *data, float fval, char *error, int iErrLen)
|
||||
return proxy->pSlaveDriv->CheckLimits(proxy->slaveData, fval,
|
||||
error, iErrLen);
|
||||
} else {
|
||||
strncpy(error, "ERROR: device not configured", iErrLen);
|
||||
strlcpy(error, "ERROR: device not configured", iErrLen);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ static int ShowCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode,
|
||||
}
|
||||
|
||||
child = row->child;
|
||||
strncpy(data,par[0]->value.v.text,1023);
|
||||
strlcpy(data,par[0]->value.v.text,1023);
|
||||
strcat(data," 1");
|
||||
while(child != NULL){
|
||||
snprintf(num,20," %f",child->value.v.doubleValue);
|
||||
|
@ -165,7 +165,7 @@ static int RegressReadValues(struct __COUNTER *self)
|
||||
static int RegressGetError(struct __COUNTER *self, int *iCode, char *error,
|
||||
int iErrLen)
|
||||
{
|
||||
strncpy(error, "Regression counter error", iErrLen);
|
||||
strlcpy(error, "Regression counter error", iErrLen);
|
||||
*iCode = 1;
|
||||
return 1;
|
||||
}
|
||||
@ -237,7 +237,7 @@ static int RegressGet(struct __COUNTER *self, char *name,
|
||||
static int RegressSend(struct __COUNTER *self, char *pText,
|
||||
char *pReply, int iReplyLen)
|
||||
{
|
||||
strncpy(pReply, "Simulated response", iReplyLen);
|
||||
strlcpy(pReply, "Simulated response", iReplyLen);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -360,30 +360,30 @@ void getRS232Error(int iCode, char *errorBuffer, int errorBufferLen)
|
||||
*/
|
||||
switch (iCode) {
|
||||
case BADMEMORY:
|
||||
strncpy(errorBuffer,
|
||||
strlcpy(errorBuffer,
|
||||
"Out of memory for appending terminators", errorBufferLen);
|
||||
break;
|
||||
case NOTCONNECTED:
|
||||
strncpy(errorBuffer, "Not connected!", errorBufferLen);
|
||||
strlcpy(errorBuffer, "Not connected!", errorBufferLen);
|
||||
break;
|
||||
case TIMEOUT:
|
||||
strncpy(errorBuffer,
|
||||
strlcpy(errorBuffer,
|
||||
"Timeout or network error when reading data", errorBufferLen);
|
||||
break;
|
||||
case FAILEDCONNECT:
|
||||
strncpy(errorBuffer,
|
||||
strlcpy(errorBuffer,
|
||||
"Failed to connect to terminal server", errorBufferLen);
|
||||
break;
|
||||
case INCOMPLETE:
|
||||
strncpy(errorBuffer, "Did not find terminator in read buffer",
|
||||
strlcpy(errorBuffer, "Did not find terminator in read buffer",
|
||||
errorBufferLen);
|
||||
break;
|
||||
case BADSEND:
|
||||
strncpy(errorBuffer, "Network problem: failed to send",
|
||||
strlcpy(errorBuffer, "Network problem: failed to send",
|
||||
errorBufferLen);
|
||||
break;
|
||||
default:
|
||||
strncpy(errorBuffer, strerror(errno), errorBufferLen);
|
||||
strlcpy(errorBuffer, strerror(errno), errorBufferLen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
18
scan.c
18
scan.c
@ -151,14 +151,14 @@ pScanData CreateScanObject(char *pRecover, char *pHeader, pCounter pCount,
|
||||
|
||||
/* assign various things */
|
||||
if (pRecover) {
|
||||
strncpy(pNew->pRecover, pRecover,1024);
|
||||
strlcpy(pNew->pRecover, pRecover,1024);
|
||||
}
|
||||
if (pHeader) {
|
||||
strncpy(pNew->pHeaderFile, pHeader,1024);
|
||||
strlcpy(pNew->pHeaderFile, pHeader,1024);
|
||||
}
|
||||
pNew->iMode = eTimer;
|
||||
pNew->fPreset = 10.;
|
||||
strncpy(pNew->pCounterName, pCount->name,511);
|
||||
strlcpy(pNew->pCounterName, pCount->name,511);
|
||||
pNew->pCounterData = pCount;
|
||||
pNew->PrepareScan = PrepareScan;
|
||||
pNew->WriteHeader = WriteHeader;
|
||||
@ -167,7 +167,7 @@ pScanData CreateScanObject(char *pRecover, char *pHeader, pCounter pCount,
|
||||
pNew->ScanCount = ScanCount;
|
||||
pNew->CollectScanData = CollectScanData;
|
||||
pNew->iWindow = 6;
|
||||
strncpy(pNew->objectName, objName, 131);
|
||||
strlcpy(pNew->objectName, objName, 131);
|
||||
ConfigureScanDict(pNew->scanFunctions);
|
||||
|
||||
return pNew;
|
||||
@ -800,7 +800,7 @@ int ContinueScan(pScanData self, SicsInterp * pSics, SConnection * pCon,
|
||||
}
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "Writing data file: %s ...", pPtr);
|
||||
SCWrite(self->pCon, pBueffel, eWarning);
|
||||
strncpy(self->pFile, pPtr,1023);
|
||||
strlcpy(self->pFile, pPtr,1023);
|
||||
free(pPtr);
|
||||
iRet = self->WriteHeader(self);
|
||||
if (!iRet) {
|
||||
@ -986,7 +986,7 @@ int GetScanVarName(pScanData self, int iWhich, char *pName, int iLength)
|
||||
DynarGet(self->pScanVar, iWhich, &pPtr);
|
||||
pVar = (pVarEntry) pPtr;
|
||||
if (pVar) {
|
||||
strncpy(pName, ScanVarName(pVar), iLength);
|
||||
strlcpy(pName, ScanVarName(pVar), iLength);
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
@ -1401,7 +1401,7 @@ static void PrintScanVars(pScanData self, char *scanname,
|
||||
DynarGet(self->pScanVar, i, &pPtr);
|
||||
pVar = (pVarEntry) pPtr;
|
||||
if (pVar != NULL) {
|
||||
strncat(pBueffel, ScanVarName(pVar), 1023 - strlen(pBueffel));
|
||||
strlcat(pBueffel, ScanVarName(pVar), 1023 - strlen(pBueffel));
|
||||
strcat(pBueffel, " ");
|
||||
}
|
||||
}
|
||||
@ -1594,7 +1594,7 @@ static int DumpScan(pScanData self, SConnection * pCon)
|
||||
*/
|
||||
oldCon = self->pCon;
|
||||
pFile[0] = '\0';
|
||||
strncpy(pFile, self->pFile, 1023);
|
||||
strlcpy(pFile, self->pFile, 1023);
|
||||
prepareDataFile(self);
|
||||
self->pCon = pCon;
|
||||
self->WriteHeader(self);
|
||||
@ -1603,7 +1603,7 @@ static int DumpScan(pScanData self, SConnection * pCon)
|
||||
}
|
||||
SCWrite(pCon, "Scan dumped", eValue);
|
||||
self->pCon = oldCon;
|
||||
strncpy(self->pFile, pFile, 1023);
|
||||
strlcpy(self->pFile, pFile, 1023);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ pVarEntry MakeScanVar(SicsInterp * pSics, SConnection * pCon, char
|
||||
}
|
||||
|
||||
/* got everything, fill in the VarEntry structure */
|
||||
strncpy(pVar->Name, name,131);
|
||||
strlcpy(pVar->Name, name,131);
|
||||
pVar->pInter = pDriv;
|
||||
pVar->pObject = pData;
|
||||
pVar->fStart = start;
|
||||
@ -113,7 +113,7 @@ pVarEntry MakeLogVar(SicsInterp * pSics, SConnection * pCon, char *name)
|
||||
}
|
||||
|
||||
/* got everything, fill in the VarEntry structure */
|
||||
strncpy(pVar->Name, name,131);
|
||||
strlcpy(pVar->Name, name,131);
|
||||
pVar->pInter = pDriv;
|
||||
pVar->pObject = pData;
|
||||
pVar->logVar = 1;
|
||||
|
@ -89,7 +89,7 @@ static int SCTDRIVCheckLimits(void *data, float val,
|
||||
"script %s called with result %s\n ", script, result);
|
||||
}
|
||||
if (status == 0) {
|
||||
strncpy(error, result, errlen);
|
||||
strlcpy(error, result, errlen);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ static int SCTDRIVCheckLimits(void *data, float val,
|
||||
"script %s called with result %s\n ", script, result);
|
||||
}
|
||||
if (status == 0) {
|
||||
strncpy(error, result, errlen);
|
||||
strlcpy(error, result, errlen);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ int MonoLimits(pSicsSelector self, float fWaveLength,
|
||||
if (sNeu.fTheta > 900.) { /* invalid wavelength or energy */
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: Invalid wavelength or energy to high: %f",
|
||||
fWaveLength);
|
||||
strncpy(error, pBueffel, iErrLen - 1);
|
||||
strlcpy(error, pBueffel, iErrLen - 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
2
selvar.c
2
selvar.c
@ -121,7 +121,7 @@ static int CheckELimits(void *pSelf, float fNew, char *error, int iErrLen)
|
||||
fWave = fNew / 2.07;
|
||||
if (fWave < .0) {
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: Invalid energy %f specified", fNew);
|
||||
strncpy(error, pBueffel, iErrLen);
|
||||
strlcpy(error, pBueffel, iErrLen);
|
||||
return 0;
|
||||
}
|
||||
fWave = sqrt(fWave);
|
||||
|
@ -203,7 +203,7 @@ int SerialSicsExecute(void **pData, char *pCommand,
|
||||
if (control.iEnd == 1) {
|
||||
iResult = 1;
|
||||
pPtr = GetCharArray(control.data);
|
||||
strncpy(pReply, pPtr, iBufLen);
|
||||
strlcpy(pReply, pPtr, iBufLen);
|
||||
} else if (control.iEnd == 2) { /* interrupted */
|
||||
iResult = INTERRUPTED;
|
||||
} else {
|
||||
|
@ -53,6 +53,8 @@
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <strlutil.h>
|
||||
|
||||
#include "ifile.h"
|
||||
#include "conman.h"
|
||||
#include "servlog.h"
|
||||
@ -220,7 +222,7 @@ int OpenVerifyLogFile()
|
||||
if (!pChar) { /* Try to write to file "server" in */
|
||||
strcpy(pFile, "server");
|
||||
} else {
|
||||
strncpy(pFile, pChar, 255);
|
||||
strlcpy(pFile, pChar, 255);
|
||||
}
|
||||
snprintf(filnam, 511, "%s%2.2d.log", pFile, iFile);
|
||||
fLogFile = fopen(filnam, "w");
|
||||
|
4
sics.h
4
sics.h
@ -23,6 +23,9 @@ typedef enum {
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <strlutil.h>
|
||||
|
||||
#include "Scommon.h"
|
||||
#include "event.h"
|
||||
#include "obdes.h"
|
||||
@ -36,6 +39,7 @@ typedef enum {
|
||||
#include "servlog.h"
|
||||
#include "sicsutil.h"
|
||||
|
||||
|
||||
extern pServer pServ;
|
||||
|
||||
|
||||
|
@ -300,7 +300,7 @@ static pHdb CreateMotorAdapter(char *name, pMotor pMot)
|
||||
* We want to be notified when this motor drives around. Or
|
||||
* its parameters change.
|
||||
*/
|
||||
strncpy(comCom.deviceID, name, 255);
|
||||
strlcpy(comCom.deviceID, name, 255);
|
||||
comCom.transID = -77;
|
||||
RegisterCallback(pMot->pCall, MOTDRIVE, MoveCallback, result, NULL);
|
||||
RegisterCallback(pMot->pCall, HDBVAL, MotorValueCallback, result, NULL);
|
||||
|
@ -1064,7 +1064,7 @@ static hdbCallbackReturn MemGenSetCallback(pHdb node, void *userData,
|
||||
memcpy(userData, &mm->v->v.doubleValue, sizeof(double));
|
||||
break;
|
||||
case HIPTEXT:
|
||||
strncpy((char *) userData, (const char *) mm->v->v.text,
|
||||
strlcpy((char *) userData, (const char *) mm->v->v.text,
|
||||
node->value.arrayLength);
|
||||
break;
|
||||
case HIPINTAR:
|
||||
@ -1555,7 +1555,11 @@ pHdb FindHdbNode(char *rootpath, char *relpath, SConnection * pCon)
|
||||
return FindHdbParent(rootpath, relpath, NULL, pCon);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------------------
|
||||
* This does not use strlcpy, strlcat on purpose: it caused a bug
|
||||
* There are so many length checks in the code anyway so that is
|
||||
* not necessary either.
|
||||
--------------------------------------------------------------------------*/
|
||||
int GetHdbPath(pHdb nodeArg, char *path, size_t pathlen)
|
||||
{
|
||||
pHdb node, parent;
|
||||
@ -1882,9 +1886,9 @@ void PrintSICSParList(pHdb node, SConnection * pCon, char *prefix)
|
||||
}
|
||||
}
|
||||
if (child->child != NULL) {
|
||||
strncpy(childPrefix, prefix, 1024);
|
||||
strncat(childPrefix, child->name, 1024);
|
||||
strncat(childPrefix, "/", 1024);
|
||||
strlcpy(childPrefix, prefix, 1024);
|
||||
strlcat(childPrefix, child->name, 1024);
|
||||
strlcat(childPrefix, "/", 1024);
|
||||
PrintSICSParList(child, pCon, prefix);
|
||||
}
|
||||
child = child->next;
|
||||
@ -2432,7 +2436,7 @@ static int ZipGetHdbNode(SConnection * pCon, SicsInterp * pSics,
|
||||
return 0;
|
||||
}
|
||||
|
||||
strncpy(oriPath, argv[1], 511);
|
||||
strlcpy(oriPath, argv[1], 511);
|
||||
targetNode = FindHdbNode(NULL, argv[1], pCon);
|
||||
if (targetNode == NULL) {
|
||||
return 0;
|
||||
@ -2467,7 +2471,7 @@ static int GetHdbNode(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
return 0;
|
||||
}
|
||||
|
||||
strncpy(oriPath, argv[1], 511);
|
||||
strlcpy(oriPath, argv[1], 511);
|
||||
targetNode = FindHdbNode(NULL, argv[1], pCon);
|
||||
if (targetNode == NULL) {
|
||||
return 0;
|
||||
@ -2519,7 +2523,7 @@ static int GetHdbVal(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
return 0;
|
||||
}
|
||||
|
||||
strncpy(oriPath, argv[1], 511);
|
||||
strlcpy(oriPath, argv[1], 511);
|
||||
targetNode = FindHdbNode(NULL, argv[1], pCon);
|
||||
if (targetNode == NULL) {
|
||||
return 0;
|
||||
@ -2570,7 +2574,7 @@ static int HdbNodeInfo(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
return 0;
|
||||
}
|
||||
|
||||
strncpy(oriPath, argv[1], 511);
|
||||
strlcpy(oriPath, argv[1], 511);
|
||||
targetNode = FindHdbNode(NULL, argv[1], pCon);
|
||||
if (targetNode == NULL) {
|
||||
return 0;
|
||||
|
@ -350,7 +350,7 @@ static int MakeScriptFunc(pSICSOBJ self, SConnection * pCon,
|
||||
}
|
||||
|
||||
|
||||
strncpy(path, argv[2], 511);
|
||||
strlcpy(path, argv[2], 511);
|
||||
pPtr = strrchr(path, '/');
|
||||
if (pPtr == NULL) {
|
||||
/* no hierarchy */
|
||||
@ -405,7 +405,7 @@ static void objFormatNode(pHdb node, char separator,
|
||||
if(GetDynStringLength(dyn) < 256){
|
||||
DynStringConcat(data, GetCharArray(dyn));
|
||||
} else {
|
||||
strncpy(buffer,GetCharArray(dyn),255);
|
||||
strlcpy(buffer,GetCharArray(dyn),255);
|
||||
DynStringConcat(data, buffer);
|
||||
DynStringConcat(data,"......");
|
||||
}
|
||||
|
14
simchop.c
14
simchop.c
@ -154,7 +154,7 @@ static int SDGetPar(pCodri self, char *parname, char *pBuffer, int iBufLen)
|
||||
pPriv->iError = UNKNOWNPAR;
|
||||
return 0;
|
||||
}
|
||||
strncpy(pBuffer, pBueffel, iBufLen);
|
||||
strlcpy(pBuffer, pBueffel, iBufLen);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ static int SDGetPar(pCodri self, char *parname, char *pBuffer, int iBufLen)
|
||||
pPriv->iError = UNKNOWNPAR;
|
||||
return 0;
|
||||
}
|
||||
strncpy(pBuffer, pBueffel, iBufLen);
|
||||
strlcpy(pBuffer, pBueffel, iBufLen);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -223,19 +223,19 @@ static int SDGetError(pCodri self, int *iCode, char *pError, int iErrLen)
|
||||
|
||||
switch (pPriv->iError) {
|
||||
case UNKNOWNPAR:
|
||||
strncpy(pError, "Parameter Unknown", iErrLen);
|
||||
strlcpy(pError, "Parameter Unknown", iErrLen);
|
||||
break;
|
||||
case RANDOMWARNING:
|
||||
strncpy(pError, "Random non deadly error", iErrLen);
|
||||
strlcpy(pError, "Random non deadly error", iErrLen);
|
||||
break;
|
||||
case RANDOMERROR:
|
||||
strncpy(pError, "Random DEADLY Error", iErrLen);
|
||||
strlcpy(pError, "Random DEADLY Error", iErrLen);
|
||||
break;
|
||||
case STOPPED:
|
||||
strncpy(pError, "User initiated STOP", iErrLen);
|
||||
strlcpy(pError, "User initiated STOP", iErrLen);
|
||||
break;
|
||||
default:
|
||||
strncpy(pError, "Unknown error code", iErrLen);
|
||||
strlcpy(pError, "Unknown error code", iErrLen);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
|
@ -259,7 +259,7 @@ static int SIMReadValues(struct __COUNTER *self)
|
||||
static int SIMGetError(struct __COUNTER *self, int *iCode, char *error,
|
||||
int iErrLen)
|
||||
{
|
||||
strncpy(error, "Randomly simulated counter error", iErrLen);
|
||||
strlcpy(error, "Randomly simulated counter error", iErrLen);
|
||||
*iCode = 1;
|
||||
return 1;
|
||||
}
|
||||
@ -292,7 +292,7 @@ static int SIMGet(struct __COUNTER *self, char *name, int iCter,
|
||||
static int SIMSend(struct __COUNTER *self, char *pText,
|
||||
char *pReply, int iReplyLen)
|
||||
{
|
||||
strncpy(pReply, "Simulated response", iReplyLen);
|
||||
strlcpy(pReply, "Simulated response", iReplyLen);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,8 @@
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <strlutil.h>
|
||||
|
||||
#include "fortify.h"
|
||||
#include "conman.h"
|
||||
#include "modriv.h"
|
||||
@ -149,10 +151,10 @@ static void SimError(void *self, int *iCode, char *error, int iErrLen)
|
||||
|
||||
if (RunComplete((SIMDriv *) self)) {
|
||||
*iCode = 56;
|
||||
strncpy(error, "ERROR: HW: HahahahahahahHahahHahaha-Mmmpfff", iErrLen);
|
||||
strlcpy(error, "ERROR: HW: HahahahahahahHahahHahaha-Mmmpfff", iErrLen);
|
||||
} else {
|
||||
*iCode = 12;
|
||||
strncpy(error, "Motor still creeping along", iErrLen - 1);
|
||||
strlcpy(error, "Motor still creeping along", iErrLen - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
8
simev.c
8
simev.c
@ -42,6 +42,8 @@
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include <strlutil.h>
|
||||
|
||||
#include "fortify.h"
|
||||
#include "conman.h"
|
||||
#include "servlog.h"
|
||||
@ -149,11 +151,11 @@ static int SimError(pEVDriver self, int *iCode, char *error, int iErrLen)
|
||||
|
||||
if (RunComplete(self)) {
|
||||
*iCode = 56;
|
||||
strncpy(error, "ERROR: (-: Simulated environment device error :-) ",
|
||||
strlcpy(error, "ERROR: (-: Simulated environment device error :-) ",
|
||||
iErrLen);
|
||||
} else {
|
||||
*iCode = 12;
|
||||
strncpy(error, "Environment still creeping along", iErrLen - 1);
|
||||
strlcpy(error, "Environment still creeping along", iErrLen - 1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -173,7 +175,7 @@ static int SimSend(pEVDriver self, char *pCommand, char *pReply, int iLen)
|
||||
return 0;
|
||||
}
|
||||
|
||||
strncpy(pReply, "Device gracefully accepted command", iLen);
|
||||
strlcpy(pReply, "Device gracefully accepted command", iLen);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
2
sinfox.c
2
sinfox.c
@ -378,7 +378,7 @@ static int SinfoxReadKey(pSinfox pSin, SicsInterp * pSics,
|
||||
continue;
|
||||
|
||||
iLen = pPos - pBuf;
|
||||
strncpy(pName, pBuf, iLen);
|
||||
strlcpy(pName, pBuf, iLen);
|
||||
pName[iLen] = '\0';
|
||||
strcpy(pValue, (pPos + 1));
|
||||
RemoveWhiteSpace(pName);
|
||||
|
2
status.c
2
status.c
@ -148,7 +148,7 @@ Status GetStatus(void)
|
||||
/*-------------------------------------------------------------------------*/
|
||||
void GetStatusText(char *buf, int iBufLen)
|
||||
{
|
||||
strncpy(buf, pText[(int) eCode], iBufLen - 1);
|
||||
strlcpy(buf, pText[(int) eCode], iBufLen - 1);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
64
stdscan.c
64
stdscan.c
@ -197,7 +197,7 @@ void WriteTemplate(FILE * fd, FILE * temp, char *filename, pScanData pScan,
|
||||
fprintf(fd, "%s\n", Tcl_GetStringResult(InterpGetTcl(pSics)));
|
||||
} else {
|
||||
SCWrite(pCon, "ERROR: failed to execute Tcl command", eError);
|
||||
strncpy(pBuffer, Tcl_GetStringResult(InterpGetTcl(pSics)), 511);
|
||||
strlcpy(pBuffer, Tcl_GetStringResult(InterpGetTcl(pSics)), 511);
|
||||
SCWrite(pCon, pBuffer, eLogError);
|
||||
continue;
|
||||
}
|
||||
@ -491,28 +491,28 @@ int WriteScanPoints(pScanData self, int iPoint)
|
||||
pVar = (pVarEntry) pPtr;
|
||||
if (pVar) {
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-9.9s ", ScanVarName(pVar));
|
||||
strncat(pLine, pItem,511);
|
||||
strlcat(pLine, pItem,511);
|
||||
snprintf(pItem,30, "%s, ", ScanVarName(pVar));
|
||||
strncat(pInfo, pItem,1024);
|
||||
strlcat(pInfo, pItem,1024);
|
||||
snprintf(pItem,30, "%f ", ScanVarStep(pVar));
|
||||
strncat(pSteps, pItem,255);
|
||||
strlcat(pSteps, pItem,255);
|
||||
}
|
||||
}
|
||||
strncat(pLine, " Counts ",1024);
|
||||
strncat(pLine, "Monitor1 ",1024);
|
||||
strncat(pLine, "Monitor2 ",1024);
|
||||
strncat(pLine, "Monitor3 ",1024);
|
||||
strncat(pLine, "Time ",1024);
|
||||
strncat(pInfo, pSteps,1024);
|
||||
strlcat(pLine, " Counts ",1024);
|
||||
strlcat(pLine, "Monitor1 ",1024);
|
||||
strlcat(pLine, "Monitor2 ",1024);
|
||||
strlcat(pLine, "Monitor3 ",1024);
|
||||
strlcat(pLine, "Time ",1024);
|
||||
strlcat(pInfo, pSteps,1024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "\n%d Points,", self->iNP);
|
||||
strncat(pInfo, pItem,1024);
|
||||
strlcat(pInfo, pItem,1024);
|
||||
if (self->iMode == eTimer) {
|
||||
strncat(pInfo, " Mode: Timer,",1024);
|
||||
strlcat(pInfo, " Mode: Timer,",1024);
|
||||
} else {
|
||||
strncat(pInfo, " Mode: Monitor,",1024);
|
||||
strlcat(pInfo, " Mode: Monitor,",1024);
|
||||
}
|
||||
snprintf(pItem,sizeof(pItem)-1, " Preset %f", self->fPreset);
|
||||
strncat(pInfo, pItem,1024);
|
||||
strlcat(pInfo, pItem,1024);
|
||||
fprintf(self->fd, "%s\n", pInfo);
|
||||
fprintf(self->fd, "%s\n", pLine);
|
||||
|
||||
@ -525,7 +525,7 @@ int WriteScanPoints(pScanData self, int iPoint)
|
||||
pVar = (pVarEntry) pPtr;
|
||||
if (pVar) {
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-9.3f ", GetScanVarPos(pVar, i));
|
||||
strncat(pLine, pItem,1024);
|
||||
strlcat(pLine, pItem,1024);
|
||||
}
|
||||
}
|
||||
/* print Counts & Monitor */
|
||||
@ -533,15 +533,15 @@ int WriteScanPoints(pScanData self, int iPoint)
|
||||
pData = (pCountEntry) pPtr;
|
||||
if (pData) {
|
||||
snprintf(pItem,sizeof(pItem)-1, " %-11ld ", pData->lCount);
|
||||
strncat(pLine, pItem,1024);
|
||||
strlcat(pLine, pItem,1024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-11ld ", pData->Monitors[0]);
|
||||
strncat(pLine, pItem,1024);
|
||||
strlcat(pLine, pItem,1024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-11ld ", pData->Monitors[1]);
|
||||
strncat(pLine, pItem,1024);
|
||||
strlcat(pLine, pItem,1024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-11ld ", pData->Monitors[2]);
|
||||
strncat(pLine, pItem,1024);
|
||||
strlcat(pLine, pItem,1024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-5.1f ", pData->fTime);
|
||||
strncat(pLine, pItem,1024);
|
||||
strlcat(pLine, pItem,1024);
|
||||
}
|
||||
fprintf(self->fd, "%s\n", pLine);
|
||||
}
|
||||
@ -727,9 +727,9 @@ static int CollectScanDataIntern(pScanData self, int iPoint,
|
||||
fVal = pVar->pInter->GetValue(pVar->pObject, self->pCon);
|
||||
AppendScanVar(pVar, fVal);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-9.9s ", ScanVarName(pVar));
|
||||
strncat(pHead, pItem,2024);
|
||||
strlcat(pHead, pItem,2024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-9.3f ", fVal);
|
||||
strncat(pStatus, pItem,2024);
|
||||
strlcat(pStatus, pItem,2024);
|
||||
}
|
||||
}
|
||||
|
||||
@ -739,23 +739,23 @@ static int CollectScanDataIntern(pScanData self, int iPoint,
|
||||
/*
|
||||
format header
|
||||
*/
|
||||
strncat(pHead, "Counts ",2024);
|
||||
strlcat(pHead, "Counts ",2024);
|
||||
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-14ld ", sCount.lCount);
|
||||
strncat(pStatus, pItem,2024);
|
||||
strlcat(pStatus, pItem,2024);
|
||||
|
||||
strncat(pHead, "Monitor1 ",2024);
|
||||
strlcat(pHead, "Monitor1 ",2024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-11ld ", sCount.Monitors[0]);
|
||||
strncat(pStatus, pItem,2024);
|
||||
strncat(pHead, "Monitor2 ",2024);
|
||||
strlcat(pStatus, pItem,2024);
|
||||
strlcat(pHead, "Monitor2 ",2024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-11ld ", sCount.Monitors[1]);
|
||||
strncat(pStatus, pItem,2024);
|
||||
strncat(pHead, "Monitor3 ",2024);
|
||||
strlcat(pStatus, pItem,2024);
|
||||
strlcat(pHead, "Monitor3 ",2024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-11ld ", sCount.Monitors[2]);
|
||||
strncat(pStatus, pItem,2024);
|
||||
strncat(pHead, "Time ",2024);
|
||||
strlcat(pStatus, pItem,2024);
|
||||
strlcat(pHead, "Time ",2024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-6.1f", sCount.fTime);
|
||||
strncat(pStatus, pItem,2024);
|
||||
strlcat(pStatus, pItem,2024);
|
||||
|
||||
/* write progress */
|
||||
/*
|
||||
|
@ -41,6 +41,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <strlutil.h>
|
||||
|
||||
#include "fortify.h"
|
||||
#include "lld.h"
|
||||
#include "stringdict.h"
|
||||
@ -167,7 +169,7 @@ int StringDictGet(pStringDict self, char *name, char *pResult, int iLen)
|
||||
if (pResult == NULL) {
|
||||
return strlen(sVal.value) + 1; /* for \0 */
|
||||
} else {
|
||||
strncpy(pResult, sVal.value, iLen);
|
||||
strlcpy(pResult, sVal.value, iLen);
|
||||
/* strncpy is not guaranteed to be '\0' terminated */
|
||||
if (iLen > 0 && pResult[iLen - 1] != '\0') {
|
||||
/* overflow */
|
||||
@ -258,7 +260,7 @@ const char *StringDictGetNext(pStringDict self, char *pValue, int iValLen)
|
||||
return NULL;
|
||||
} else {
|
||||
LLDnodeDataTo(self->iList, &sVal);
|
||||
strncpy(pValue, sVal.value, iValLen);
|
||||
strlcpy(pValue, sVal.value, iValLen);
|
||||
/* strncpy is not guaranteed to be '\0' terminated */
|
||||
if (iValLen > 0 && pValue[iValLen-1] != '\0') {
|
||||
/* overflow */
|
||||
@ -275,7 +277,7 @@ const char *StringDictGetNext(pStringDict self, char *pValue, int iValLen)
|
||||
} else {
|
||||
self->iTraverse = 1;
|
||||
LLDnodeDataTo(self->iList, &sVal);
|
||||
strncpy(pValue, sVal.value, iValLen);
|
||||
strlcpy(pValue, sVal.value, iValLen);
|
||||
/* strncpy is not guaranteed to be '\0' terminated */
|
||||
if (iValLen > 0 && pValue[iValLen-1] != '\0') {
|
||||
/* overflow */
|
||||
|
@ -215,7 +215,7 @@ tryagain:
|
||||
return 0;
|
||||
} else {
|
||||
if (test > 0) {
|
||||
strncat(pBueffel, pRead, 2047 - strlen(pBueffel));
|
||||
strlcat(pBueffel, pRead, 2047 - strlen(pBueffel));
|
||||
}
|
||||
}
|
||||
if (strstr(pBueffel, "TRANSACTIONFINISHED") != NULL) {
|
||||
|
26
tasscanub.c
26
tasscanub.c
@ -58,7 +58,7 @@ static void strcenter(char *str, char *target, int iLength)
|
||||
catch the error if target is to long
|
||||
*/
|
||||
if (strlen(str) >= iLength) {
|
||||
strncpy(target, str, iLength);
|
||||
strlcpy(target, str, iLength);
|
||||
}
|
||||
|
||||
iPtr = (iLength - strlen(str)) / 2;
|
||||
@ -275,7 +275,7 @@ static int TASUBHeader(pScanData self)
|
||||
DynarGet(self->pScanVar, i, &pPtr);
|
||||
pVar = (pVarEntry) pPtr;
|
||||
if (pVar) {
|
||||
strncpy(pWork2, ScanVarName(pVar), 59);
|
||||
strlcpy(pWork2, ScanVarName(pVar), 59);
|
||||
strtoupper(pWork2);
|
||||
snprintf(pWork,sizeof(pWork)-1, "D%s=%8.4f, ", pWork2, ScanVarStep(pVar));
|
||||
strcat(pBueffel, pWork);
|
||||
@ -399,7 +399,7 @@ static int TASUBHeader(pScanData self)
|
||||
iCount = 0;
|
||||
fprintf(self->fd, "\nVARIA: ");
|
||||
}
|
||||
strncpy(pWork2, pCom->pName,60);
|
||||
strlcpy(pWork2, pCom->pName,60);
|
||||
strtoupper(pWork2);
|
||||
fprintf(self->fd, "%-8s=%8.4f, ", pWork2, fVal);
|
||||
iCount++;
|
||||
@ -430,7 +430,7 @@ static int TASUBHeader(pScanData self)
|
||||
iCount = 0;
|
||||
fprintf(self->fd, "\nZEROS: ");
|
||||
}
|
||||
strncpy(pWork2, pCom->pName,60);
|
||||
strlcpy(pWork2, pCom->pName,60);
|
||||
strtoupper(pWork2);
|
||||
fprintf(self->fd, "%-8s=%8.4f, ", pWork2, fVal);
|
||||
iCount++;
|
||||
@ -485,11 +485,11 @@ static int TASUBHeader(pScanData self)
|
||||
DynarGet(self->pScanVar, i, &pPtr);
|
||||
pVar = (pVarEntry) pPtr;
|
||||
if (pVar) {
|
||||
strncat(pBueffel, "F9.4,1X,",1024);
|
||||
strncpy(pWork2, pVar->Name, 59);
|
||||
strlcat(pBueffel, "F9.4,1X,",1024);
|
||||
strlcpy(pWork2, pVar->Name, 59);
|
||||
strtoupper(pWork2);
|
||||
strcenter(pWork2, pTen, 11);
|
||||
strncat(pHeader, pTen,1024);
|
||||
strlcat(pHeader, pTen,1024);
|
||||
}
|
||||
}
|
||||
/*
|
||||
@ -502,16 +502,16 @@ static int TASUBHeader(pScanData self)
|
||||
*/
|
||||
for (i = 0; i < pTAS->addCount; i++) {
|
||||
if (i == pTAS->addCount - 1) {
|
||||
strncat(pBueffel, "F9.4",1024);
|
||||
strlcat(pBueffel, "F9.4",1024);
|
||||
} else {
|
||||
strncat(pBueffel, "F9.4,1X,",1024);
|
||||
strlcat(pBueffel, "F9.4,1X,",1024);
|
||||
}
|
||||
strncpy(pWork2, pTAS->out[i],60);
|
||||
strlcpy(pWork2, pTAS->out[i],60);
|
||||
strtoupper(pWork2);
|
||||
strcenter(pWork2, pTen, 11);
|
||||
strncat(pHeader, pTen,1024);
|
||||
strlcat(pHeader, pTen,1024);
|
||||
}
|
||||
strncat(pBueffel, ")",1024);
|
||||
strlcat(pBueffel, ")",1024);
|
||||
|
||||
/*
|
||||
write the final bit
|
||||
@ -867,7 +867,7 @@ static void ParseOutput(pTASdata pTAS, SConnection * pCon)
|
||||
continue;
|
||||
|
||||
if (FindCommand(pServ->pSics, trim(pToken))) {
|
||||
strncpy(pTAS->out[pTAS->addCount], trim(pToken), 10);
|
||||
strlcpy(pTAS->out[pTAS->addCount], trim(pToken), 10);
|
||||
pTAS->addCount++;
|
||||
} else {
|
||||
strtolower(pToken);
|
||||
|
145
tcl/nhq202m.tcl
Normal file
145
tcl/nhq202m.tcl
Normal file
@ -0,0 +1,145 @@
|
||||
#----------------------------------------------------------
|
||||
# This is a scriptcontext driver for a NHQ 202M high
|
||||
# voltage power supply as used at the POLDI for the
|
||||
# detector. This has a peculiar protocol and requires the
|
||||
# charbychar protocol driver.
|
||||
#
|
||||
# If this responds only with ?WCN, then it is on the wrong
|
||||
# channel.
|
||||
#
|
||||
# Mark Koennecke, April 2010
|
||||
#--------------------------------------------------------
|
||||
|
||||
namespace eval nhq202m {}
|
||||
|
||||
#-------------------------------------------------------
|
||||
# Sometimes numbers come in the form: polarity/mantissse/exponent
|
||||
# This checks for this and converts it into a proper number
|
||||
#-------------------------------------------------------
|
||||
proc nhq202m::fixnumber {num} {
|
||||
set c [string index $num 0]
|
||||
if {[string compare $c -] == 0} {
|
||||
set num [string range $num 1 end]
|
||||
}
|
||||
clientput $num
|
||||
if {[string first - $num] > 0} {
|
||||
set l [split $num -]
|
||||
set man [string trimleft [lindex $l 0] 0]
|
||||
set exp [string trimleft [lindex $l 1] 0]
|
||||
clientput "$num, $man, $exp"
|
||||
return [expr $man * pow(10,-$exp)]
|
||||
} elseif { [string first + $num] > 0} {
|
||||
set l [split $num +]
|
||||
set man [string trimleft [lindex $l 0] 0]
|
||||
set exp [string trimleft [lindex $l 1] 0]
|
||||
return [expr $man * pow(10,$exp)]
|
||||
} else {
|
||||
return $num
|
||||
}
|
||||
}
|
||||
#-------------------------------------------------------
|
||||
proc nhq202m::sendreadcommand {command} {
|
||||
sct send $command
|
||||
return readreply
|
||||
}
|
||||
#--------------------------------------------------------
|
||||
proc nhq202m::readreply {} {
|
||||
set val [sct result]
|
||||
if {[string first ? $val] >= 0} {
|
||||
clientput "Read Command not understood, result = $val"
|
||||
} else {
|
||||
sct update [nhq202m::fixnumber $val]
|
||||
}
|
||||
return idle
|
||||
}
|
||||
#--------------------------------------------------------
|
||||
proc nhq202m::sendwrite {command} {
|
||||
set val [sct target]
|
||||
sct send [format "%s=%d" $command $val]
|
||||
return writereply
|
||||
}
|
||||
#------------------------------------------------------
|
||||
proc nhq202m::writereply {} {
|
||||
set val [sct result]
|
||||
if {[string first ? $val] >= 0} {
|
||||
clientput "Write command not understood, result = $val"
|
||||
}
|
||||
[sct controller] queue [sct] progress read
|
||||
return idle
|
||||
}
|
||||
#----------------------------------------------------
|
||||
proc nhq202m::startwrite {} {
|
||||
hupdate [sct]/stop 0
|
||||
set num [sct numpower]
|
||||
set com [format "D%1.1d" $num]
|
||||
nhq202m::sendwrite $com
|
||||
return setreply
|
||||
}
|
||||
#----------------------------------------------------
|
||||
proc nhq202m::setreply {} {
|
||||
set val [sct result]
|
||||
if {[string first ? $val] >= 0} {
|
||||
clientput "Write command not understood, result = $val"
|
||||
}
|
||||
set num [sct numpower]
|
||||
sct send [format "G%1.1d" $num]
|
||||
return goreply
|
||||
}
|
||||
#----------------------------------------------------
|
||||
proc nhq202m::goreply {} {
|
||||
set badcodes [list MAN ERR OFF]
|
||||
set val [sct result]
|
||||
if {[string first ? $val] >= 0} {
|
||||
clientput "Write command not understood, result = $val"
|
||||
}
|
||||
set l [split $val =]
|
||||
set code [string trim [lindex $l 1]]
|
||||
if {[lsearch $badcodes $code] >= 0} {
|
||||
hupdate [sct]/stop 1
|
||||
error "Bad code in $val, probably front panel switches fucked up"
|
||||
}
|
||||
return idle
|
||||
}
|
||||
#----------------------------------------------------
|
||||
proc nhq202m::makehv {name sct num} {
|
||||
makesctdriveobj $name float mugger NHQ202M $sct
|
||||
hfactory /sics/${name}/tolerance plain mugger int
|
||||
hset /sics/${name}/tolerance 2
|
||||
hfactory /sics/${name}/upperlimit plain mugger int
|
||||
hset /sics/${name}/upperlimit 4000
|
||||
hfactory /sics/${name}/lowerlimit plain mugger int
|
||||
hset /sics/${name}/lowerlimit 0
|
||||
hfactory /sics/${name}/stop plain mugger int
|
||||
hset /sics/${name}/stop 0
|
||||
|
||||
hsetprop /sics/${name} checklimits stddrive::stdcheck $name
|
||||
hsetprop /sics/${name} checkstatus stddrive::stdstatus $name
|
||||
hsetprop /sics/${name} halt stddrive::stop $name
|
||||
|
||||
hsetprop /sics/${name} read nhq202m::sendreadcommand [format "U%1.1d" $num]
|
||||
hsetprop /sics/${name} readreply nhq202m::readreply
|
||||
hsetprop /sics/${name} numpower $num
|
||||
hsetprop /sics/${name} write nhq202m::startwrite
|
||||
hsetprop /sics/${name} setreply nhq202m::setreply
|
||||
hsetprop /sics/${name} goreply nhq202m::goreply
|
||||
$sct write /sics/${name}
|
||||
$sct poll /sics/${name} 180
|
||||
$sct queue /sics/${name} progress read
|
||||
|
||||
hfactory /sics/${name}/ramp plain mugger int
|
||||
hsetprop /sics/${name}/ramp read nhq202m::sendreadcommand [format "V%1.1d" $num]
|
||||
hsetprop /sics/${name}/ramp readreply nhq202m::readreply
|
||||
hsetprop /sics/${name}/ramp write nhq202m::sendwrite [format "V%1.1d" $num]
|
||||
hsetprop /sics/${name}/ramp writereply nhq202m::writereply
|
||||
$sct poll /sics/${name}/ramp 180
|
||||
$sct write /sics/${name}/ramp
|
||||
$sct queue /sics/${name}/ramp progress read
|
||||
|
||||
|
||||
hfactory /sics/${name}/current plain mugger int
|
||||
hsetprop /sics/${name}/current read nhq202m::sendreadcommand [format "N%1.1d" $num]
|
||||
hsetprop /sics/${name}/current readreply nhq202m::readreply
|
||||
$sct poll /sics/${name}/current 180
|
||||
$sct queue /sics/${name}/current progress read
|
||||
|
||||
}
|
@ -24,6 +24,7 @@ proc slsecho::readreply {} {
|
||||
#--------------------------------------------------------------
|
||||
proc slsecho::sendwrite {num} {
|
||||
set val [sct target]
|
||||
hupdate [sct]/stop 0
|
||||
sct send "$num:w:0x90:$val:write"
|
||||
return readreply
|
||||
}
|
||||
@ -87,7 +88,7 @@ proc slsecho::errorreply {} {
|
||||
set reply [sct result]
|
||||
set l [split $reply :]
|
||||
set val [lindex $l 1]
|
||||
set key [format "0x%x" $val]
|
||||
set key [format "0x%x" [expr int($val)]]
|
||||
clientput "$key"
|
||||
clientput "$slsecho::error($key)"
|
||||
sct update $slsecho::error($key)
|
||||
@ -102,7 +103,7 @@ proc slsecho::makeslsecho {name num sct} {
|
||||
hset /sics/${name}/upperlimit 10
|
||||
hfactory /sics/${name}/lowerlimit plain internal float
|
||||
hset /sics/${name}/lowerlimit -10
|
||||
hfactory /sics/${name}/stop plain internal int
|
||||
hfactory /sics/${name}/stop plain user int
|
||||
hset /sics/${name}/stop 0
|
||||
|
||||
hsetprop /sics/${name} checklimits stddrive::stdcheck $name
|
||||
|
@ -50,7 +50,7 @@ proc stddrive::stdstatus {name} {
|
||||
#-------------------------------------------------------
|
||||
proc stddrive::stop {name} {
|
||||
hset /sics/${name}/stop 1
|
||||
return OK
|
||||
return idle
|
||||
}
|
||||
#-------------------------------------------------------
|
||||
proc stddrive::deread {} {
|
||||
@ -87,7 +87,7 @@ proc stddrive::makestddrive {name sicsclass sct} {
|
||||
hset /sics/${name}/upperlimit 300
|
||||
hfactory /sics/${name}/lowerlimit plain user float
|
||||
hset /sics/${name}/lowerlimit 10
|
||||
hfactory /sics/${name}/stop plain internal int
|
||||
hfactory /sics/${name}/stop plain user int
|
||||
hset /sics/${name}/stop 0
|
||||
|
||||
hsetprop /sics/${name} checklimits stddrive::stdcheck $name
|
||||
|
@ -294,7 +294,7 @@ static int TclDrivableCheckLimits(void *data, float fVal,
|
||||
if (command) {
|
||||
status = Tcl_Eval(pTcl, command);
|
||||
if (status != TCL_OK) {
|
||||
strncpy(error, pTcl->result, errlen);
|
||||
strlcpy(error, pTcl->result, errlen);
|
||||
status = 0;
|
||||
} else {
|
||||
status = 1;
|
||||
|
18
tclev.c
18
tclev.c
@ -38,7 +38,7 @@ static int TclSetValue(pEVDriver self, float fNew)
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%s %s %f", pPriv->pSetValue, pPriv->pArray, fNew);
|
||||
iRet = Tcl_Eval(pPriv->pTcl, pBueffel);
|
||||
if (iRet != TCL_OK) {
|
||||
strncpy(pBueffel, pPriv->pTcl->result, 1023);
|
||||
strlcpy(pBueffel, pPriv->pTcl->result, 1023);
|
||||
iRet = Tcl_GetInt(pPriv->pTcl, pBueffel, &iErrCode);
|
||||
if (iRet != TCL_OK) {
|
||||
pPriv->iLastError = STUPIDTCL;
|
||||
@ -65,7 +65,7 @@ static int TclGetValue(pEVDriver self, float *fVal)
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%s %s", pPriv->pGetValue, pPriv->pArray);
|
||||
iRet = Tcl_Eval(pPriv->pTcl, pBueffel);
|
||||
if (iRet != TCL_OK) {
|
||||
strncpy(pBueffel, pPriv->pTcl->result, 1023);
|
||||
strlcpy(pBueffel, pPriv->pTcl->result, 1023);
|
||||
iRet = Tcl_GetInt(pPriv->pTcl, pBueffel, &iErrCode);
|
||||
if (iRet != TCL_OK) {
|
||||
pPriv->iLastError = STUPIDTCL;
|
||||
@ -106,7 +106,7 @@ static int TclSend(pEVDriver self, char *pCommand,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%s %s %s", pPriv->pSend, pPriv->pArray, pCommand);
|
||||
iRet = Tcl_Eval(pPriv->pTcl, pBueffel);
|
||||
if (iRet != TCL_OK) {
|
||||
strncpy(pBueffel, pPriv->pTcl->result, 1023);
|
||||
strlcpy(pBueffel, pPriv->pTcl->result, 1023);
|
||||
iRet = Tcl_GetInt(pPriv->pTcl, pBueffel, &iErrCode);
|
||||
if (iRet != TCL_OK) {
|
||||
pPriv->iLastError = STUPIDTCL;
|
||||
@ -115,7 +115,7 @@ static int TclSend(pEVDriver self, char *pCommand,
|
||||
pPriv->iLastError = iErrCode;
|
||||
return 0;
|
||||
} else {
|
||||
strncpy(pReply, pPriv->pTcl->result, iReplyLen);
|
||||
strlcpy(pReply, pPriv->pTcl->result, iReplyLen);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -140,7 +140,7 @@ static int TclGetError(pEVDriver self, int *iCode,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1,
|
||||
"Your Tcl-script returned a stupid answer:\n --> %s <--",
|
||||
pPriv->pTcl->result);
|
||||
strncpy(pReply, pBueffel, iReplyLen);
|
||||
strlcpy(pReply, pBueffel, iReplyLen);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ static int TclGetError(pEVDriver self, int *iCode,
|
||||
pPriv->iLastError);
|
||||
iRet = Tcl_Eval(pPriv->pTcl, pBueffel);
|
||||
if (iRet != TCL_OK) {
|
||||
strncpy(pBueffel, pPriv->pTcl->result, 1023);
|
||||
strlcpy(pBueffel, pPriv->pTcl->result, 1023);
|
||||
iRet = Tcl_GetInt(pPriv->pTcl, pPriv->pTcl->result, &iErrCode);
|
||||
if (iRet != TCL_OK) {
|
||||
pPriv->iLastError = STUPIDTCL;
|
||||
@ -158,7 +158,7 @@ static int TclGetError(pEVDriver self, int *iCode,
|
||||
pPriv->iLastError = iErrCode;
|
||||
return 0;
|
||||
} else {
|
||||
strncpy(pReply, pPriv->pTcl->result, iReplyLen);
|
||||
strlcpy(pReply, pPriv->pTcl->result, iReplyLen);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -214,7 +214,7 @@ static int TclInit(pEVDriver self)
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%s %s", pPriv->pInit, pPriv->pArray);
|
||||
iRet = Tcl_Eval(pPriv->pTcl, pBueffel);
|
||||
if (iRet != TCL_OK) {
|
||||
strncpy(pBueffel, pPriv->pTcl->result, 1023);
|
||||
strlcpy(pBueffel, pPriv->pTcl->result, 1023);
|
||||
iRet = Tcl_GetInt(pPriv->pTcl, pBueffel, &iErrCode);
|
||||
if (iRet != TCL_OK) {
|
||||
pPriv->iLastError = STUPIDTCL;
|
||||
@ -240,7 +240,7 @@ static int TclClose(pEVDriver self)
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%s %s", pPriv->pClose, pPriv->pArray);
|
||||
iRet = Tcl_Eval(pPriv->pTcl, pBueffel);
|
||||
if (iRet != TCL_OK) {
|
||||
strncpy(pBueffel, pPriv->pTcl->result, 1023);
|
||||
strlcpy(pBueffel, pPriv->pTcl->result, 1023);
|
||||
iRet = Tcl_GetInt(pPriv->pTcl, pBueffel, &iErrCode);
|
||||
if (iRet != TCL_OK) {
|
||||
pPriv->iLastError = STUPIDTCL;
|
||||
|
26
tclmotdriv.c
26
tclmotdriv.c
@ -74,7 +74,7 @@ static int GetTclPos(void *self, float *fPos)
|
||||
}
|
||||
if (status != TCL_OK) {
|
||||
pDriv->errorCode = TCLERROR;
|
||||
strncpy(pDriv->tclError, result, 1023);
|
||||
strlcpy(pDriv->tclError, result, 1023);
|
||||
return HWFault;
|
||||
}
|
||||
sscanf(result, "%f", fPos);
|
||||
@ -99,7 +99,7 @@ static int TclRun(void *self, float fVal)
|
||||
return HWFault;
|
||||
}
|
||||
snprintf(num, 79, "%f", fVal);
|
||||
strncat(tclCommand, num, 1023 - strlen(tclCommand));
|
||||
strlcat(tclCommand, num, 1023 - strlen(tclCommand));
|
||||
|
||||
status = Tcl_Eval(pServ->pSics->pTcl, tclCommand);
|
||||
result = Tcl_GetStringResult(pServ->pSics->pTcl);
|
||||
@ -109,7 +109,7 @@ static int TclRun(void *self, float fVal)
|
||||
}
|
||||
if (status != TCL_OK) {
|
||||
pDriv->errorCode = TCLERROR;
|
||||
strncpy(pDriv->tclError, result, 1023);
|
||||
strlcpy(pDriv->tclError, result, 1023);
|
||||
return HWFault;
|
||||
}
|
||||
sscanf(result, "%d", &status);
|
||||
@ -122,18 +122,18 @@ static int evaluateInternalErrors(TCLDriv * pDriv, int *iCode,
|
||||
{
|
||||
switch (pDriv->errorCode) {
|
||||
case FUNCNOTFOUND:
|
||||
strncpy(error, "Config Error: Tcl function for driver not found",
|
||||
strlcpy(error, "Config Error: Tcl function for driver not found",
|
||||
iErrLen);
|
||||
*iCode = pDriv->errorCode;
|
||||
return 1;
|
||||
break;
|
||||
case TCLERROR:
|
||||
strncpy(error, pDriv->tclError, iErrLen);
|
||||
strlcpy(error, pDriv->tclError, iErrLen);
|
||||
*iCode = pDriv->errorCode;
|
||||
return 1;
|
||||
break;
|
||||
case NOTCLRESULT:
|
||||
strncpy(error, "Tcl function did not return result", iErrLen);
|
||||
strlcpy(error, "Tcl function did not return result", iErrLen);
|
||||
*iCode = pDriv->errorCode;
|
||||
return 1;
|
||||
break;
|
||||
@ -172,14 +172,14 @@ static void TclError(void *self, int *iCode, char *error, int iErrLen)
|
||||
}
|
||||
if (status != TCL_OK && result != NULL) {
|
||||
pDriv->errorCode = TCLERROR;
|
||||
strncpy(pDriv->tclError, result, 1023);
|
||||
strlcpy(pDriv->tclError, result, 1023);
|
||||
}
|
||||
}
|
||||
|
||||
if (evaluateInternalErrors(pDriv, iCode, error, iErrLen) == 1) {
|
||||
return;
|
||||
}
|
||||
strncpy(error, result, iErrLen);
|
||||
strlcpy(error, result, iErrLen);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -199,7 +199,7 @@ static int TclFix(void *self, int iError, float fNew)
|
||||
return HWFault;
|
||||
}
|
||||
snprintf(num, 79, "%d %f", pDriv->errorCode, fNew);
|
||||
strncat(tclCommand, num, 1023 - strlen(tclCommand));
|
||||
strlcat(tclCommand, num, 1023 - strlen(tclCommand));
|
||||
|
||||
status = Tcl_Eval(pServ->pSics->pTcl, tclCommand);
|
||||
result = Tcl_GetStringResult(pServ->pSics->pTcl);
|
||||
@ -209,7 +209,7 @@ static int TclFix(void *self, int iError, float fNew)
|
||||
}
|
||||
if (status != TCL_OK) {
|
||||
pDriv->errorCode = TCLERROR;
|
||||
strncpy(pDriv->tclError, result, 1023);
|
||||
strlcpy(pDriv->tclError, result, 1023);
|
||||
return HWFault;
|
||||
}
|
||||
sscanf(result, "%d", &status);
|
||||
@ -241,7 +241,7 @@ static int TclHalt(void *self)
|
||||
}
|
||||
if (status != TCL_OK) {
|
||||
pDriv->errorCode = TCLERROR;
|
||||
strncpy(pDriv->tclError, result, 1023);
|
||||
strlcpy(pDriv->tclError, result, 1023);
|
||||
return HWFault;
|
||||
}
|
||||
return OKOK;
|
||||
@ -272,7 +272,7 @@ static int TclStat(void *self)
|
||||
}
|
||||
if (status != TCL_OK) {
|
||||
pDriv->errorCode = TCLERROR;
|
||||
strncpy(pDriv->tclError, result, 1023);
|
||||
strlcpy(pDriv->tclError, result, 1023);
|
||||
return HWFault;
|
||||
}
|
||||
sscanf(result, "%d", &status);
|
||||
@ -393,7 +393,7 @@ MotorDriver *CreateTclMotDriv(SConnection * pCon, int argc, char *argv[])
|
||||
}
|
||||
|
||||
pDriv->name = strdup("Tcl-Driver");
|
||||
strncpy(pDriv->motName, argv[1], 131);
|
||||
strlcpy(pDriv->motName, argv[1], 131);
|
||||
pDriv->GetPosition = GetTclPos;
|
||||
pDriv->RunTo = TclRun;
|
||||
pDriv->GetStatus = TclStat;
|
||||
|
2
telnet.c
2
telnet.c
@ -46,7 +46,7 @@ pTelTask CreateTelnet(SConnection * pCon)
|
||||
pRes->pCon = pCon;
|
||||
pRes->iLogin = 0;
|
||||
pRes->tStart = time(&shit);
|
||||
strncpy(pRes->pLoginWord, pPtr,131);
|
||||
strlcpy(pRes->pLoginWord, pPtr,131);
|
||||
return pRes;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
271
|
||||
294
|
||||
NEVER, EVER modify or delete this file
|
||||
You'll risk eternal damnation and a reincarnation as a cockroach!|n
|
||||
You'll risk eternal damnation and a reincarnation as a cockroach!
|
||||
|
@ -52,11 +52,14 @@ test motorpar-1.8 {Test ignorefault} -body {
|
||||
test motorpar-1.9 {Test movecount} -body {
|
||||
testPar "brumm movecount" 12 Mugger } -result OK
|
||||
|
||||
test motorpar-1.10 {Test hardupper} -body {
|
||||
testROPar "brumm hardupperlim" 180 } -result OK
|
||||
#-------- This test always fails because the regression motor driver
|
||||
# handles hard limits
|
||||
#---------------------------------------------------------------
|
||||
# test motorpar-1.10 {Test hardupper} -body {
|
||||
# testPar "brumm hardupperlim" 180 Mugger} -result OK
|
||||
|
||||
test motorpar-1.11 {Test hardlower} -body {
|
||||
testROPar "brumm hardlowerlim" -180 } -result OK
|
||||
# test motorpar-1.11 {Test hardlower} -body {
|
||||
# testPar "brumm hardlowerlim" -180 Mugger} -result OK
|
||||
|
||||
brumm recover 0
|
||||
brumm errortype 0
|
||||
|
@ -177,6 +177,9 @@ phi movecount 10.000000
|
||||
# Counter scancter
|
||||
scancter SetPreset 0.000000
|
||||
scancter SetMode Timer
|
||||
# Counter counter
|
||||
counter SetPreset 0.000000
|
||||
counter SetMode Timer
|
||||
hm CountMode timer
|
||||
hm preset 10.000000
|
||||
tof CountMode timer
|
||||
|
@ -4,6 +4,8 @@
|
||||
# Started: Dr. Mark Koennecke, July 2006
|
||||
#---------------------------------------------------------------------------
|
||||
set home $env(HOME)/src/workspace/sics/test
|
||||
|
||||
protocol set all
|
||||
#----------------------------------------------------------------------------
|
||||
# O P T I O N S
|
||||
# --------------- ----------------------------------------------------------
|
||||
@ -100,6 +102,7 @@ Motor chi SIM 0 360 -.1 10
|
||||
Motor phi SIM 0 360 -.1 10
|
||||
|
||||
MakeMultiCounter scanCter aba
|
||||
SicsAlias scanCter counter
|
||||
|
||||
proc scantransfer {} {
|
||||
set FWHM 1.5
|
||||
@ -191,6 +194,11 @@ sa endconfig
|
||||
#-----------------------------------------------------------------------
|
||||
# Hipadaba
|
||||
#----------------------------------------------------------------------
|
||||
proc SplitReply { text } {
|
||||
set l [split $text =]
|
||||
return [string trim [lindex $l 1]]
|
||||
}
|
||||
#---------------------------------------------------------------------
|
||||
source ../tcl/hdbutil.tcl
|
||||
hmake /instrument spy none
|
||||
hmake /instrument/sample spy none
|
||||
@ -703,10 +711,40 @@ proc testerr {input} {
|
||||
}
|
||||
|
||||
|
||||
set slsecho 1
|
||||
|
||||
if {$slsecho == 1} {
|
||||
makesctcontroller echo testprot testprot.dat
|
||||
|
||||
source ../tcl/stddrive.tcl
|
||||
source ../tcl/slsecho.tcl
|
||||
makesctcontroller slssct slsecho 129.129.195.50:5001
|
||||
makesctcontroller slssct slsecho taspmagnet:5001
|
||||
#makesctcontroller slssct slsecho localhost:8080
|
||||
slsecho::makeslsecho ma1 0 slssct
|
||||
}
|
||||
|
||||
|
||||
set nhq202m 0
|
||||
|
||||
if {$nhq202m == 1} {
|
||||
source ../tcl/stddrive.tcl
|
||||
source ../tcl/nhq202m.tcl
|
||||
#makesctcontroller nhq202 charbychar localhost:8005 "\r\n"
|
||||
#makesctcontroller nhq202 charbychar localhost:8080 "\r\n"
|
||||
makesctcontroller nhq202 charbychar psts225:3002 "\r\n"
|
||||
#------- Put him into lovely mode, it needs a few commands before it gets there
|
||||
nhq202 transact \#
|
||||
nhq202 transact \#
|
||||
nhq202 transact \#
|
||||
nhq202 debug 0
|
||||
nhq202m::makehv hv1 nhq202 1
|
||||
}
|
||||
|
||||
set poldizug 0
|
||||
|
||||
if {$poldizug == 1} {
|
||||
makesctcontroller zugsct std pc6651:4167 "\r\n" 3.0 "\r\n"
|
||||
zugsct debug 0
|
||||
source ../tcl/stddrive.tcl
|
||||
source ../sim/poldi_sics/zug.tcl
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ int SendQuieck(int iType, char *pText)
|
||||
switch (iType) {
|
||||
case QUIECK:
|
||||
strcpy(pMessage, "QUIECK/");
|
||||
strncat(pMessage, pText,512);
|
||||
strlcat(pMessage, pText,512);
|
||||
break;
|
||||
default:
|
||||
strcpy(pMessage, "Error");
|
||||
|
10
velo.c
10
velo.c
@ -95,7 +95,7 @@ static int VSLimits(void *pData, float fVal, char *pError, int iErrLen)
|
||||
if ((fVal < Alcatraz.fMin) || (fVal > Alcatraz.fMax)) {
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, " %f out of range: %f --- %f",
|
||||
fVal, Alcatraz.fMin, Alcatraz.fMax);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
strlcpy(pError, pBueffel, iErrLen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ static int VSLimits(void *pData, float fVal, char *pError, int iErrLen)
|
||||
if ((fVal > Alcatraz.fMin) && (fVal < Alcatraz.fMax)) {
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, " %f violates forbidden region %f --- %f",
|
||||
fVal, Alcatraz.fMin, Alcatraz.fMax);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
strlcpy(pError, pBueffel, iErrLen);
|
||||
return 0;
|
||||
}
|
||||
iRet = LLDnodePtr2Next(self->iForbidden);
|
||||
@ -679,7 +679,7 @@ static int DummyVelError(pEVDriver self, int *iCode, char *pError,
|
||||
assert(ich);
|
||||
|
||||
if (ich->iLastError == VELONOTPERMITTED) {
|
||||
strncpy(pError,
|
||||
strlcpy(pError,
|
||||
"ERROR: this operation is NOT Permitted, use velocity selector object instead",
|
||||
iErrLen);
|
||||
*iCode = VELONOTPERMITTED;
|
||||
@ -847,8 +847,8 @@ int VelSelFactory(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
return 0;
|
||||
}
|
||||
pBueffel[0] = '\0';
|
||||
strncpy(pBueffel, argv[1],255);
|
||||
strncat(pBueffel, "watch",255);
|
||||
strlcpy(pBueffel, argv[1],255);
|
||||
strlcat(pBueffel, "watch",255);
|
||||
pNew->pMonitor = CreateEVController(pMonDriv, pBueffel, &iRet);
|
||||
if (!pNew->pMonitor) {
|
||||
DeleteEVDriver(pMonDriv); /* was missing M.Z. Jul 04 */
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <strlutil.h>
|
||||
#include "fortify.h"
|
||||
#include "conman.h"
|
||||
#include "servlog.h"
|
||||
@ -164,12 +165,12 @@ static int SimError(pVelSelDriv self, int *iCode, char *error, int iErrLen)
|
||||
|
||||
if (RunComplete(self)) {
|
||||
*iCode = 56;
|
||||
strncpy(error,
|
||||
strlcpy(error,
|
||||
"ERROR: HW: Simulated selector error on simulated selector",
|
||||
iErrLen);
|
||||
} else {
|
||||
*iCode = 12;
|
||||
strncpy(error, "Selector still creeping along", iErrLen - 1);
|
||||
strlcpy(error, "Selector still creeping along", iErrLen - 1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -237,7 +238,7 @@ static int SimStat(pVelSelDriv self, int *iCode, float *fVal)
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int SimText(pVelSelDriv self, char *pText, int iTextLen)
|
||||
{
|
||||
strncpy(pText, "Simulated Info on a simulated velocity selector",
|
||||
strlcpy(pText, "Simulated Info on a simulated velocity selector",
|
||||
iTextLen);
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user