From e8ae6530950d50cb303df1e76374a170b574210c Mon Sep 17 00:00:00 2001 From: koennecke Date: Fri, 24 Feb 2017 11:11:42 +0100 Subject: [PATCH 1/2] Added nagging output about a user name when saving scan data files --- ofac.c | 1 + sicsutil.c | 29 ++++++++++++++++++++++++++++- sicsutil.h | 1 + stdscan.c | 1 + 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/ofac.c b/ofac.c index 0576da22..2f6d6ee9 100644 --- a/ofac.c +++ b/ofac.c @@ -127,6 +127,7 @@ static void InitIniCommands(SicsInterp * pInter) PCMD("wait", UserWait); PCMD("yield", UserYield); PCMD("checksum", CheckSum); + PCMD("loguserinfo", LogUserInfoWrapper); /* startup commands in alphabetic order */ SCMD("allowexec", AllowExec); diff --git a/sicsutil.c b/sicsutil.c index c18f6686..dea1e3a7 100644 --- a/sicsutil.c +++ b/sicsutil.c @@ -1,4 +1,4 @@ -/** + /** * Some general functions for SICS. Most part is moved from ofac.c * * copyright: see file COPYRIGHT @@ -15,6 +15,7 @@ #include "sicsdata.h" #include "SCinter.h" #include "sicshipadaba.h" +#include "sicsget.h" static char *aCode[] = { "internal", @@ -140,4 +141,30 @@ int CheckSum(SConnection * pCon, SicsInterp * pSics, void *pData, SCWrite(pCon,"ERROR: object type not recognized", eError); return 0; } +/*-----------------------------------------------------------------------------*/ +void LogUserInfo(void *data) +{ + hdbValue user, proposal; + SConnection *pCon = (SConnection *)data; + + if(data == NULL){ + return; + } + user = MakeHdbText(strdup("Martina Notconfigured")); + proposal = MakeHdbText(strdup("Unproposed")); + + sget("user",&user); + sget("proposalid",&proposal); + SCPrintf(pCon,eLog,"WARNING: Saving data for %s, proposal %s", user.v.text, proposal.v.text); + ReleaseHdbValue(&user); + ReleaseHdbValue(&proposal); + +} +/*--------------------------------------------------------------------------*/ +int LogUserInfoWrapper(SConnection * pCon, SicsInterp * pSics, void *pData, + int argc, char *argv[]) +{ + LogUserInfo(pCon); + return 1; +} diff --git a/sicsutil.h b/sicsutil.h index bbc50b27..26fe8ca3 100644 --- a/sicsutil.h +++ b/sicsutil.h @@ -24,3 +24,4 @@ unsigned short fletcher16( char *data, size_t len); +void LogUserInfo(void *pCon); diff --git a/stdscan.c b/stdscan.c index 5689b077..f4e98423 100644 --- a/stdscan.c +++ b/stdscan.c @@ -579,6 +579,7 @@ int prepareDataFile(pScanData self) } snprintf(pBueffel, 511, "Writing data file: %s ...", pPtr); SCWrite(self->pCon, pBueffel, eLog); + LogUserInfo(self->pCon); strcpy(self->pFile, pPtr); free(pPtr); return 1; From e94e80264df74f3abe49dccb8ebe1e224754fbfc Mon Sep 17 00:00:00 2001 From: koennecke Date: Wed, 15 Mar 2017 16:45:52 +0100 Subject: [PATCH 2/2] Some fix to sicshipadaba to prevent problems when trying to format a NULL node Protected the nagging messages from scans/etc from missing data --- sicshipadaba.c | 4 ++-- sicsutil.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sicshipadaba.c b/sicshipadaba.c index 3e7df068..fa3e1f8c 100644 --- a/sicshipadaba.c +++ b/sicshipadaba.c @@ -2065,7 +2065,7 @@ pDynString formatValue(hdbValue v, pHdb node) DynStringCopy(result, number); break; 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); } else { snprintf(number, 30, "%.6g", v.v.doubleValue); @@ -2084,7 +2084,7 @@ pDynString formatValue(hdbValue v, pHdb node) break; case HIPFLOATAR: case HIPFLOATVARAR: - if (GetHdbProperty(node, "fmt", format + 1, sizeof format - 2)) { + if (node != NULL && GetHdbProperty(node, "fmt", format + 1, sizeof format - 2)) { format[0] = ' '; } else { strcpy(format, " %.6g"); diff --git a/sicsutil.c b/sicsutil.c index dea1e3a7..783c77ef 100644 --- a/sicsutil.c +++ b/sicsutil.c @@ -142,12 +142,13 @@ int CheckSum(SConnection * pCon, SicsInterp * pSics, void *pData, return 0; } /*-----------------------------------------------------------------------------*/ -void LogUserInfo(void *data) +void LogUserInfo(void *pData) { hdbValue user, proposal; - SConnection *pCon = (SConnection *)data; + SConnection *pCon = (SConnection *)pData; + pDynString data; - if(data == NULL){ + if(pData == NULL){ return; } user = MakeHdbText(strdup("Martina Notconfigured")); @@ -155,7 +156,10 @@ void LogUserInfo(void *data) sget("user",&user); sget("proposalid",&proposal); - SCPrintf(pCon,eLog,"WARNING: Saving data for %s, proposal %s", user.v.text, proposal.v.text); + 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);