Merge branch 'develop' into rhel7

This commit is contained in:
2017-04-03 11:41:29 +02:00
5 changed files with 37 additions and 3 deletions

1
ofac.c
View File

@ -127,6 +127,7 @@ static void InitIniCommands(SicsInterp * pInter)
PCMD("wait", UserWait); PCMD("wait", UserWait);
PCMD("yield", UserYield); PCMD("yield", UserYield);
PCMD("checksum", CheckSum); PCMD("checksum", CheckSum);
PCMD("loguserinfo", LogUserInfoWrapper);
/* startup commands in alphabetic order */ /* startup commands in alphabetic order */
SCMD("allowexec", AllowExec); SCMD("allowexec", AllowExec);

View File

@ -2065,7 +2065,7 @@ pDynString formatValue(hdbValue v, pHdb node)
DynStringCopy(result, number); DynStringCopy(result, number);
break; break;
case HIPFLOAT: case HIPFLOAT:
if (GetHdbProperty(node, "fmt", format, sizeof format - 1)) { if (node != NULL && GetHdbProperty(node, "fmt", format, sizeof format - 1)) {
snprintf(number, 30, format, v.v.doubleValue); snprintf(number, 30, format, v.v.doubleValue);
} else { } else {
snprintf(number, 30, "%.6g", v.v.doubleValue); snprintf(number, 30, "%.6g", v.v.doubleValue);
@ -2084,7 +2084,7 @@ pDynString formatValue(hdbValue v, pHdb node)
break; break;
case HIPFLOATAR: case HIPFLOATAR:
case HIPFLOATVARAR: case HIPFLOATVARAR:
if (GetHdbProperty(node, "fmt", format + 1, sizeof format - 2)) { if (node != NULL && GetHdbProperty(node, "fmt", format + 1, sizeof format - 2)) {
format[0] = ' '; format[0] = ' ';
} else { } else {
strcpy(format, " %.6g"); strcpy(format, " %.6g");

View File

@ -1,4 +1,4 @@
/** /**
* Some general functions for SICS. Most part is moved from ofac.c * Some general functions for SICS. Most part is moved from ofac.c
* *
* copyright: see file COPYRIGHT * copyright: see file COPYRIGHT
@ -15,6 +15,7 @@
#include "sicsdata.h" #include "sicsdata.h"
#include "SCinter.h" #include "SCinter.h"
#include "sicshipadaba.h" #include "sicshipadaba.h"
#include "sicsget.h"
static char *aCode[] = { static char *aCode[] = {
"internal", "internal",
@ -140,4 +141,34 @@ int CheckSum(SConnection * pCon, SicsInterp * pSics, void *pData,
SCWrite(pCon,"ERROR: object type not recognized", eError); SCWrite(pCon,"ERROR: object type not recognized", eError);
return 0; return 0;
} }
/*-----------------------------------------------------------------------------*/
void LogUserInfo(void *pData)
{
hdbValue user, proposal;
SConnection *pCon = (SConnection *)pData;
pDynString data;
if(pData == NULL){
return;
}
user = MakeHdbText(strdup("Martina Notconfigured"));
proposal = MakeHdbText(strdup("Unproposed"));
sget("user",&user);
sget("proposalid",&proposal);
data = formatValue(proposal,NULL);
SCPrintf(pCon,eLog,"WARNING: Saving data for %s, proposal %s", user.v.text,
GetCharArray(data));
DeleteDynString(data);
ReleaseHdbValue(&user);
ReleaseHdbValue(&proposal);
}
/*--------------------------------------------------------------------------*/
int LogUserInfoWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
int argc, char *argv[])
{
LogUserInfo(pCon);
return 1;
}

View File

@ -24,3 +24,4 @@ unsigned short fletcher16( char *data, size_t len);
void LogUserInfo(void *pCon);

View File

@ -579,6 +579,7 @@ int prepareDataFile(pScanData self)
} }
snprintf(pBueffel, 511, "Writing data file: %s ...", pPtr); snprintf(pBueffel, 511, "Writing data file: %s ...", pPtr);
SCWrite(self->pCon, pBueffel, eLog); SCWrite(self->pCon, pBueffel, eLog);
LogUserInfo(self->pCon);
strcpy(self->pFile, pPtr); strcpy(self->pFile, pPtr);
free(pPtr); free(pPtr);
return 1; return 1;