- After a bug at TRICS I replaced all occurrences of strcpy, strcat, sprintf
by length limited versions wherever appropriate. SKIPPED: psi/el755driv.c psi/faverage.c psi/frame.c psi/lmd200.c psi/polterwrite.c psi/psi.c psi/sanswave.c psi/sinqhmdriv.c psi/termprot.c
This commit is contained in:
142
stdscan.c
142
stdscan.c
@ -94,25 +94,25 @@ void WriteTemplate(FILE * fd, FILE * temp, char *filename, pScanData pScan,
|
||||
/* find the variable */
|
||||
pCom = FindCommand(pSics, pName);
|
||||
if (!pCom) {
|
||||
sprintf(pError, "ERROR: variable %s NOT found", pName);
|
||||
snprintf(pError,sizeof(pError)-1, "ERROR: variable %s NOT found", pName);
|
||||
SCWrite(pCon, pError, eLogError);
|
||||
continue;
|
||||
}
|
||||
pVar = (pSicsVariable) pCom->pData;
|
||||
if (!pVar) {
|
||||
sprintf(pError, "ERROR: variable %s NOT found", pName);
|
||||
snprintf(pError,sizeof(pError)-1, "ERROR: variable %s NOT found", pName);
|
||||
SCWrite(pCon, pError, eLogError);
|
||||
continue;
|
||||
}
|
||||
switch (pVar->eType) {
|
||||
case veFloat:
|
||||
sprintf(pError, "%f", pVar->fVal);
|
||||
snprintf(pError,sizeof(pError)-1, "%f", pVar->fVal);
|
||||
break;
|
||||
case veInt:
|
||||
sprintf(pError, "%d", pVar->iVal);
|
||||
snprintf(pError,sizeof(pError)-1, "%d", pVar->iVal);
|
||||
break;
|
||||
case veText:
|
||||
sprintf(pError, "%s", pVar->text);
|
||||
snprintf(pError,sizeof(pError)-1, "%s", pVar->text);
|
||||
break;
|
||||
}
|
||||
/* finally write */
|
||||
@ -134,19 +134,19 @@ void WriteTemplate(FILE * fd, FILE * temp, char *filename, pScanData pScan,
|
||||
/* find the variable */
|
||||
pCom = FindCommand(pSics, pName);
|
||||
if (!pCom) {
|
||||
sprintf(pError, "ERROR: variable %s NOT found", pName);
|
||||
snprintf(pError,sizeof(pError)-1, "ERROR: variable %s NOT found", pName);
|
||||
SCWrite(pCon, pError, eLogError);
|
||||
continue;
|
||||
}
|
||||
pDum = (pDummy) pCom->pData;
|
||||
if (!pDum) {
|
||||
sprintf(pError, "ERROR: variable %s is NOT drivable", pName);
|
||||
snprintf(pError,sizeof(pError)-1, "ERROR: variable %s is NOT drivable", pName);
|
||||
SCWrite(pCon, pError, eLogError);
|
||||
continue;
|
||||
}
|
||||
pDriv = (pIDrivable) pDum->pDescriptor->GetInterface(pDum, DRIVEID);
|
||||
if (!pDriv) {
|
||||
sprintf(pError, "ERROR: variable %s is NOT drivable", pName);
|
||||
snprintf(pError,sizeof(pError)-1, "ERROR: variable %s is NOT drivable", pName);
|
||||
SCWrite(pCon, pError, eLogError);
|
||||
continue;
|
||||
}
|
||||
@ -169,7 +169,7 @@ void WriteTemplate(FILE * fd, FILE * temp, char *filename, pScanData pScan,
|
||||
/* find the motor */
|
||||
pMot = FindMotor(pSics, pName);
|
||||
if (!pMot) {
|
||||
sprintf(pError, "ERROR: motor %s NOT found", pName);
|
||||
snprintf(pError,sizeof(pError)-1, "ERROR: motor %s NOT found", pName);
|
||||
SCWrite(pCon, pError, eLogError);
|
||||
continue;
|
||||
}
|
||||
@ -321,25 +321,25 @@ int WriteHeaderOld(pScanData self)
|
||||
/* find the variable */
|
||||
pCom = FindCommand(self->pSics, pName);
|
||||
if (!pCom) {
|
||||
sprintf(pError, "ERROR: variable %s NOT found", pName);
|
||||
snprintf(pError,sizeof(pError)-1, "ERROR: variable %s NOT found", pName);
|
||||
SCWrite(self->pCon, pError, eError);
|
||||
continue;
|
||||
}
|
||||
pVar = (pSicsVariable) pCom->pData;
|
||||
if (!pVar) {
|
||||
sprintf(pError, "ERROR: variable %s NOT found", pName);
|
||||
snprintf(pError,sizeof(pError)-1, "ERROR: variable %s NOT found", pName);
|
||||
SCWrite(self->pCon, pError, eError);
|
||||
continue;
|
||||
}
|
||||
switch (pVar->eType) {
|
||||
case veFloat:
|
||||
sprintf(pError, "%f", pVar->fVal);
|
||||
snprintf(pError,sizeof(pError)-1, "%f", pVar->fVal);
|
||||
break;
|
||||
case veInt:
|
||||
sprintf(pError, "%d", pVar->iVal);
|
||||
snprintf(pError,sizeof(pError)-1, "%d", pVar->iVal);
|
||||
break;
|
||||
case veText:
|
||||
sprintf(pError, "%s", pVar->text);
|
||||
snprintf(pError,sizeof(pError)-1, "%s", pVar->text);
|
||||
break;
|
||||
}
|
||||
/* finally write */
|
||||
@ -361,19 +361,19 @@ int WriteHeaderOld(pScanData self)
|
||||
/* find the variable */
|
||||
pCom = FindCommand(self->pSics, pName);
|
||||
if (!pCom) {
|
||||
sprintf(pError, "ERROR: variable %s NOT found", pName);
|
||||
snprintf(pError,sizeof(pError)-1, "ERROR: variable %s NOT found", pName);
|
||||
SCWrite(self->pCon, pError, eError);
|
||||
continue;
|
||||
}
|
||||
pDum = (pDummy) pCom->pData;
|
||||
if (!pDum) {
|
||||
sprintf(pError, "ERROR: variable %s is NOT drivable", pName);
|
||||
snprintf(pError,sizeof(pError)-1, "ERROR: variable %s is NOT drivable", pName);
|
||||
SCWrite(self->pCon, pError, eError);
|
||||
continue;
|
||||
}
|
||||
pDriv = (pIDrivable) pDum->pDescriptor->GetInterface(pDum, DRIVEID);
|
||||
if (!pDriv) {
|
||||
sprintf(pError, "ERROR: variable %s is NOT drivable", pName);
|
||||
snprintf(pError,sizeof(pError)-1, "ERROR: variable %s is NOT drivable", pName);
|
||||
SCWrite(self->pCon, pError, eError);
|
||||
continue;
|
||||
}
|
||||
@ -396,7 +396,7 @@ int WriteHeaderOld(pScanData self)
|
||||
/* find the motor */
|
||||
pMot = FindMotor(self->pSics, pName);
|
||||
if (!pMot) {
|
||||
sprintf(pError, "ERROR: motor %s NOT found", pName);
|
||||
snprintf(pError,sizeof(pError)-1, "ERROR: motor %s NOT found", pName);
|
||||
SCWrite(self->pCon, pError, eError);
|
||||
continue;
|
||||
}
|
||||
@ -483,65 +483,65 @@ int WriteScanPoints(pScanData self, int iPoint)
|
||||
}
|
||||
|
||||
/* make the data header */
|
||||
sprintf(pLine, "%-4s ", "NP");
|
||||
snprintf(pLine,sizeof(pLine)-1, "%-4s ", "NP");
|
||||
strcpy(pInfo, "Scanning Variables: ");
|
||||
strcpy(pSteps, "Steps: ");
|
||||
for (i = 0; i < self->iScanVar; i++) {
|
||||
DynarGet(self->pScanVar, i, &pPtr);
|
||||
pVar = (pVarEntry) pPtr;
|
||||
if (pVar) {
|
||||
sprintf(pItem, "%-9.9s ", ScanVarName(pVar));
|
||||
strcat(pLine, pItem);
|
||||
sprintf(pItem, "%s, ", ScanVarName(pVar));
|
||||
strcat(pInfo, pItem);
|
||||
sprintf(pItem, "%f ", ScanVarStep(pVar));
|
||||
strcat(pSteps, pItem);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-9.9s ", ScanVarName(pVar));
|
||||
strncat(pLine, pItem,511);
|
||||
snprintf(pItem,30, "%s, ", ScanVarName(pVar));
|
||||
strncat(pInfo, pItem,1024);
|
||||
snprintf(pItem,30, "%f ", ScanVarStep(pVar));
|
||||
strncat(pSteps, pItem,255);
|
||||
}
|
||||
}
|
||||
strcat(pLine, " Counts ");
|
||||
strcat(pLine, "Monitor1 ");
|
||||
strcat(pLine, "Monitor2 ");
|
||||
strcat(pLine, "Monitor3 ");
|
||||
strcat(pLine, "Time ");
|
||||
strcat(pInfo, pSteps);
|
||||
sprintf(pItem, "\n%d Points,", self->iNP);
|
||||
strcat(pInfo, pItem);
|
||||
strncat(pLine, " Counts ",1024);
|
||||
strncat(pLine, "Monitor1 ",1024);
|
||||
strncat(pLine, "Monitor2 ",1024);
|
||||
strncat(pLine, "Monitor3 ",1024);
|
||||
strncat(pLine, "Time ",1024);
|
||||
strncat(pInfo, pSteps,1024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "\n%d Points,", self->iNP);
|
||||
strncat(pInfo, pItem,1024);
|
||||
if (self->iMode == eTimer) {
|
||||
strcat(pInfo, " Mode: Timer,");
|
||||
strncat(pInfo, " Mode: Timer,",1024);
|
||||
} else {
|
||||
strcat(pInfo, " Mode: Monitor,");
|
||||
strncat(pInfo, " Mode: Monitor,",1024);
|
||||
}
|
||||
sprintf(pItem, " Preset %f", self->fPreset);
|
||||
strcat(pInfo, pItem);
|
||||
snprintf(pItem,sizeof(pItem)-1, " Preset %f", self->fPreset);
|
||||
strncat(pInfo, pItem,1024);
|
||||
fprintf(self->fd, "%s\n", pInfo);
|
||||
fprintf(self->fd, "%s\n", pLine);
|
||||
|
||||
/* now the scan points */
|
||||
for (i = 0; i < self->iCounts; i++) {
|
||||
sprintf(pLine, "%-4d ", i);
|
||||
snprintf(pLine,sizeof(pLine)-1, "%-4d ", i);
|
||||
/* print vars */
|
||||
for (i2 = 0; i2 < self->iScanVar; i2++) {
|
||||
DynarGet(self->pScanVar, i2, &pPtr);
|
||||
pVar = (pVarEntry) pPtr;
|
||||
if (pVar) {
|
||||
sprintf(pItem, "%-9.3f ", GetScanVarPos(pVar, i));
|
||||
strcat(pLine, pItem);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-9.3f ", GetScanVarPos(pVar, i));
|
||||
strncat(pLine, pItem,1024);
|
||||
}
|
||||
}
|
||||
/* print Counts & Monitor */
|
||||
DynarGet(self->pCounts, i, &pPtr);
|
||||
pData = (pCountEntry) pPtr;
|
||||
if (pData) {
|
||||
sprintf(pItem, " %-11ld ", pData->lCount);
|
||||
strcat(pLine, pItem);
|
||||
sprintf(pItem, "%-11ld ", pData->Monitors[0]);
|
||||
strcat(pLine, pItem);
|
||||
sprintf(pItem, "%-11ld ", pData->Monitors[1]);
|
||||
strcat(pLine, pItem);
|
||||
sprintf(pItem, "%-11ld ", pData->Monitors[2]);
|
||||
strcat(pLine, pItem);
|
||||
sprintf(pItem, "%-5.1f ", pData->fTime);
|
||||
strcat(pLine, pItem);
|
||||
snprintf(pItem,sizeof(pItem)-1, " %-11ld ", pData->lCount);
|
||||
strncat(pLine, pItem,1024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-11ld ", pData->Monitors[0]);
|
||||
strncat(pLine, pItem,1024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-11ld ", pData->Monitors[1]);
|
||||
strncat(pLine, pItem,1024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-11ld ", pData->Monitors[2]);
|
||||
strncat(pLine, pItem,1024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-5.1f ", pData->fTime);
|
||||
strncat(pLine, pItem,1024);
|
||||
}
|
||||
fprintf(self->fd, "%s\n", pLine);
|
||||
}
|
||||
@ -715,8 +715,8 @@ static int CollectScanDataIntern(pScanData self, int iPoint,
|
||||
InitCountEntry(&sCount);
|
||||
|
||||
/* prepare output header */
|
||||
sprintf(pHead, "%-4.4s ", "NP");
|
||||
sprintf(pStatus, "%-4d ", iPoint);
|
||||
snprintf(pHead,sizeof(pHead)-1, "%-4.4s ", "NP");
|
||||
snprintf(pStatus,sizeof(pStatus)-1, "%-4d ", iPoint);
|
||||
|
||||
/* loop over all scan variables */
|
||||
status = 1;
|
||||
@ -726,10 +726,10 @@ static int CollectScanDataIntern(pScanData self, int iPoint,
|
||||
if (pVar) {
|
||||
fVal = pVar->pInter->GetValue(pVar->pObject, self->pCon);
|
||||
AppendScanVar(pVar, fVal);
|
||||
sprintf(pItem, "%-9.9s ", ScanVarName(pVar));
|
||||
strcat(pHead, pItem);
|
||||
sprintf(pItem, "%-9.3f ", fVal);
|
||||
strcat(pStatus, pItem);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-9.9s ", ScanVarName(pVar));
|
||||
strncat(pHead, pItem,2024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-9.3f ", fVal);
|
||||
strncat(pStatus, pItem,2024);
|
||||
}
|
||||
}
|
||||
|
||||
@ -739,23 +739,23 @@ static int CollectScanDataIntern(pScanData self, int iPoint,
|
||||
/*
|
||||
format header
|
||||
*/
|
||||
strcat(pHead, "Counts ");
|
||||
strncat(pHead, "Counts ",2024);
|
||||
|
||||
sprintf(pItem, "%-14ld ", sCount.lCount);
|
||||
strcat(pStatus, pItem);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-14ld ", sCount.lCount);
|
||||
strncat(pStatus, pItem,2024);
|
||||
|
||||
strcat(pHead, "Monitor1 ");
|
||||
sprintf(pItem, "%-11ld ", sCount.Monitors[0]);
|
||||
strcat(pStatus, pItem);
|
||||
strcat(pHead, "Monitor2 ");
|
||||
sprintf(pItem, "%-11ld ", sCount.Monitors[1]);
|
||||
strcat(pStatus, pItem);
|
||||
strcat(pHead, "Monitor3 ");
|
||||
sprintf(pItem, "%-11ld ", sCount.Monitors[2]);
|
||||
strcat(pStatus, pItem);
|
||||
strcat(pHead, "Time ");
|
||||
sprintf(pItem, "%-6.1f", sCount.fTime);
|
||||
strcat(pStatus, pItem);
|
||||
strncat(pHead, "Monitor1 ",2024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-11ld ", sCount.Monitors[0]);
|
||||
strncat(pStatus, pItem,2024);
|
||||
strncat(pHead, "Monitor2 ",2024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-11ld ", sCount.Monitors[1]);
|
||||
strncat(pStatus, pItem,2024);
|
||||
strncat(pHead, "Monitor3 ",2024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-11ld ", sCount.Monitors[2]);
|
||||
strncat(pStatus, pItem,2024);
|
||||
strncat(pHead, "Time ",2024);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-6.1f", sCount.fTime);
|
||||
strncat(pStatus, pItem,2024);
|
||||
|
||||
/* write progress */
|
||||
/*
|
||||
|
Reference in New Issue
Block a user