- 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:
koennecke
2009-12-04 12:58:31 +00:00
parent 297f9f2e02
commit 8cc5474334
80 changed files with 899 additions and 881 deletions

42
hkl.c
View File

@ -427,7 +427,7 @@ int CalculateSettings(pHKL self, float fHKL[3], float fPsi, int iHamil,
}
if (!status) {
sprintf(pBueffel,
snprintf(pBueffel,sizeof(pBueffel)-1,
"ERROR: cannot calculate %4.1f %4.1f %4.1f, psi = %4.1f",
fHKL[0], fHKL[1], fHKL[2], dHkl[3]);
SCWrite(pCon, pBueffel, eError);
@ -687,7 +687,7 @@ static int GetCommandData(int argc, char *argv[], float fHKL[3],
/* get the reflection */
for (i = 0; i < 3; i++) {
if (!isNumeric(argv[i])) {
sprintf(pBueffel, "ERROR: %s is NOT recognized as a number",
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: %s is NOT recognized as a number",
argv[i]);
SCWrite(pCon, pBueffel, eError);
return 0;
@ -701,7 +701,7 @@ static int GetCommandData(int argc, char *argv[], float fHKL[3],
/* has psi been specicifed ? */
if (argc > 3) {
if (!isNumeric(argv[3])) {
sprintf(pBueffel, "ERROR: %s is NOT recognized as a number",
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: %s is NOT recognized as a number",
argv[3]);
SCWrite(pCon, pBueffel, eError);
}
@ -711,7 +711,7 @@ static int GetCommandData(int argc, char *argv[], float fHKL[3],
/* has iHamil been specified ? */
if (argc > 4) {
if (!isNumeric(argv[4])) {
sprintf(pBueffel, "ERROR: %s is NOT recognized as a number",
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: %s is NOT recognized as a number",
argv[4]);
SCWrite(pCon, pBueffel, eError);
}
@ -829,19 +829,19 @@ int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
/*-------- handle list */
strtolower(argv[1]);
if (strcmp(argv[1], "list") == 0) {
sprintf(pBueffel,
snprintf(pBueffel,sizeof(pBueffel)-1,
"lambda = %f Normal Beam = %d Quadrant = %d HM = %d",
SXGetLambda(), self->iNOR, self->iQuad, self->iHM);
SCWrite(pCon, pBueffel, eValue);
dUB = SXGetUB();
sprintf(pBueffel, "UB = { %f %f %f", dUB[0], dUB[1], dUB[2]);
snprintf(pBueffel,sizeof(pBueffel)-1, "UB = { %f %f %f", dUB[0], dUB[1], dUB[2]);
SCWrite(pCon, pBueffel, eValue);
sprintf(pBueffel, " %f %f %f", dUB[3], dUB[4], dUB[5]);
snprintf(pBueffel,sizeof(pBueffel)-1, " %f %f %f", dUB[3], dUB[4], dUB[5]);
SCWrite(pCon, pBueffel, eValue);
sprintf(pBueffel, " %f %f %f }", dUB[6], dUB[7], dUB[8]);
snprintf(pBueffel,sizeof(pBueffel)-1, " %f %f %f }", dUB[6], dUB[7], dUB[8]);
SCWrite(pCon, pBueffel, eValue);
return 1;
sprintf(pBueffel, "Last HKL: %f %f %f ",
snprintf(pBueffel,sizeof(pBueffel)-1, "Last HKL: %f %f %f ",
self->fLastHKL[0], self->fLastHKL[1], self->fLastHKL[2]);
SCWrite(pCon, pBueffel, eValue);
snprintf(pBueffel, 510, "%s.scantolerance = %f", argv[0],
@ -852,7 +852,7 @@ int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
/*----------- current */
else if (strcmp(argv[1], "current") == 0) {
GetHKLFromAngles(self, pCon, fHKL);
sprintf(pBueffel, "Current HKL: %8.4f %8.4f %8.4f ",
snprintf(pBueffel,sizeof(pBueffel)-1, "Current HKL: %8.4f %8.4f %8.4f ",
fHKL[0], fHKL[1], fHKL[2]);
SCWrite(pCon, pBueffel, eValue);
return 1;
@ -877,7 +877,7 @@ int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
for (i = 0; i < 3; i++) {
fHKL[i] = dHKL[i];
}
sprintf(pBueffel, "HKL from angles: %8.4f %8.4f %8.4f ",
snprintf(pBueffel,sizeof(pBueffel)-1, "HKL from angles: %8.4f %8.4f %8.4f ",
fHKL[0], fHKL[1], fHKL[2]);
SCWrite(pCon, pBueffel, eValue);
return 1;
@ -909,7 +909,7 @@ int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
}
for (i = 2; i < 11; i++) {
if (!isNumeric(argv[i])) {
sprintf(pBueffel, "ERROR: %s was not recognized as a number",
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: %s was not recognized as a number",
argv[i]);
SCWrite(pCon, pBueffel, eError);
return 0;
@ -927,7 +927,7 @@ int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
/*------------- HM mode */
else if (strcmp(argv[1], "hm") == 0) {
if (argc < 3) {
sprintf(pBueffel, "%s.hm = %d", argv[0], self->iHM);
snprintf(pBueffel,sizeof(pBueffel)-1, "%s.hm = %d", argv[0], self->iHM);
SCWrite(pCon, pBueffel, eValue);
return 1;
}
@ -935,7 +935,7 @@ int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
return 0;
}
if (!isNumeric(argv[2])) {
sprintf(pBueffel, "ERROR: %s was not recognized as a number",
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: %s was not recognized as a number",
argv[2]);
SCWrite(pCon, pBueffel, eError);
return 0;
@ -955,7 +955,7 @@ int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
return 0;
}
if (!isNumeric(argv[2])) {
sprintf(pBueffel, "ERROR: %s was not recognized as a number",
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: %s was not recognized as a number",
argv[2]);
SCWrite(pCon, pBueffel, eError);
return 0;
@ -982,14 +982,14 @@ int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
return 0;
}
if (!isNumeric(argv[2])) {
sprintf(pBueffel, "ERROR: %s was not recognized as a number",
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: %s was not recognized as a number",
argv[2]);
SCWrite(pCon, pBueffel, eError);
return 0;
}
iRet = atoi(argv[2]);
if (!((iRet == 1) || (iRet == 0))) {
sprintf(pBueffel,
snprintf(pBueffel,sizeof(pBueffel)-1,
"ERROR: Invalid parameter %d for quadrant, posiible: 0,1",
iRet);
SCWrite(pCon, pBueffel, eError);
@ -1011,7 +1011,7 @@ int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
return 0;
}
if (!isNumeric(argv[2])) {
sprintf(pBueffel, "ERROR: %s was not recognized as a number",
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: %s was not recognized as a number",
argv[2]);
SCWrite(pCon, pBueffel, eError);
return 0;
@ -1028,11 +1028,11 @@ int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
}
iRet = CalculateSettings(self, fHKL, fPsi, iHamil, fSet, pCon);
if (SXGetMode() == NB) {
sprintf(pBueffel, " gamma = %f, omega = %f, nu = %f",
snprintf(pBueffel,sizeof(pBueffel)-1, " gamma = %f, omega = %f, nu = %f",
fSet[0], fSet[1], fSet[2]);
SCWrite(pCon, pBueffel, eValue);
} else {
sprintf(pBueffel, " 2-theta = %f, omega = %f, chi = %f, phi = %f",
snprintf(pBueffel,sizeof(pBueffel)-1, " 2-theta = %f, omega = %f, chi = %f, phi = %f",
fSet[0], fSet[1], fSet[2], fSet[3]);
SCWrite(pCon, pBueffel, eValue);
}
@ -1091,7 +1091,7 @@ int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
else if (strcmp(argv[1], "bitonb") == 0) {
return HandleBiToNB(pCon, argc, argv);
} else {
sprintf(pBueffel, "ERROR: subcommand --> %s <-- not recognized",
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: subcommand --> %s <-- not recognized",
argv[1]);
SCWrite(pCon, pBueffel, eError);
return 0;