- Currently disabled attempts at logging commands
- Added a warning for excessive data rates on monitors - Added statistics to devser and thus to scriptcontext - Added byte concatenation to dynstring - Added aborting for reflection generation to fourmess.c - Added data checksum testing to hipadaba, use for update tests - Fixed interrupt discovery in network.c, caused invalid interrupt codes which in turn confused sicscron which had to be fixed too. - Renamed ubcalc into ubcalcint in order to reclaim the ubcalc for Jurg - Added an a3offset to tasub in order to fix what I perceive an IS problem - Added support for the newer version of the Siemens SPS, the S7 - Added a not yet fully working sinqhttpopt driver which talks to http HM without libghttp SKIPPED: psi/delcam.c psi/make_gen psi/psi.c psi/sinq.c psi/sinq.h psi/sinqhttpopt.c psi/slsvme.c psi/spss7.c
This commit is contained in:
74
commandlog.c
74
commandlog.c
@@ -16,6 +16,10 @@
|
||||
- timestamps look different and are omitted if no other text is written
|
||||
- socket number information is written on the timestamp line
|
||||
|
||||
Added command history logging. Due to problems this is currently disabled by
|
||||
writeHistory = 0 and code in SetWriteHistory
|
||||
|
||||
Mark Koennecke, July 2010
|
||||
--------------------------------------------------------------------------*/
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
@@ -28,7 +32,7 @@
|
||||
#include "scaldate.h"
|
||||
#include "network.h"
|
||||
#include "circular.h"
|
||||
|
||||
#include "stptok.h"
|
||||
|
||||
/* in conman.c */
|
||||
int TelnetWrite(mkChannel * pSock, char *pText);
|
||||
@@ -36,6 +40,9 @@ int TelnetWrite(mkChannel * pSock, char *pText);
|
||||
static FILE *fd = NULL;
|
||||
static FILE *fauto = NULL;
|
||||
static char pFile[256];
|
||||
/*------------------------- command history logging --------------------*/
|
||||
static char pHistoryFilter[1024] = "";
|
||||
static int writeHistory = 0;
|
||||
/*-------------------- the tail buffer ---------------------------------*/
|
||||
static pCircular pTail = NULL;
|
||||
#define MAXTAIL 1000
|
||||
@@ -484,6 +491,31 @@ int CommandLog(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
}
|
||||
SCPrintf(pCon, eValue, "%s.intervall [min] = %d", argv[0], iIntervall);
|
||||
return 1;
|
||||
} else if (strcmp(argv[1], "history") == 0) {
|
||||
if (argc > 2) {
|
||||
iRet = Tcl_GetInt(pSics->pTcl, argv[2], &iVal);
|
||||
if (iRet != TCL_OK) {
|
||||
SCWrite(pCon, "ERROR: failed to convert new history to number",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
writeHistory = iVal;
|
||||
}
|
||||
SCPrintf(pCon, eValue, "%s.writeHistory = %d", argv[0], writeHistory);
|
||||
return 1;
|
||||
} else if (strcmp(argv[1], "historyfilter") == 0) {
|
||||
if (argc > 2) {
|
||||
if(strlen(argv[2]) < 1024){
|
||||
strcpy(pHistoryFilter,argv[2]);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: history filter to long", eError);
|
||||
return 0;
|
||||
}
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
SCPrintf(pCon, eValue, "%s.historyFilter = %s", argv[0], pHistoryFilter);
|
||||
return 1;
|
||||
} else if (strcmp(argv[1], "compact") == 0) {
|
||||
if (argc > 2) {
|
||||
iCompact = atoi(argv[2]);
|
||||
@@ -554,13 +586,51 @@ static int openHistoryLog()
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------
|
||||
* This is to suppress certain stuff from the history log in order to stop it
|
||||
* from filling with garbage
|
||||
-----------------------------------------------------------------------------*/
|
||||
static int historyFilter(char *command)
|
||||
{
|
||||
static char *toRemove[] = {"sct", "hupdate","contextdo","transact", NULL};
|
||||
char token[50];
|
||||
char *pPtr = NULL;
|
||||
int i = 0;
|
||||
|
||||
while(toRemove[i] != NULL){
|
||||
if(strstr(command,toRemove[i]) != NULL){
|
||||
return 0;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
pPtr = pHistoryFilter;
|
||||
while((pPtr = stptok(pPtr,token,50,":")) != NULL){
|
||||
if(strstr(command,token) != NULL){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
void WriteCommandHistory(char *txt)
|
||||
{
|
||||
if(writeHistory == 0){
|
||||
return;
|
||||
}
|
||||
if(comHistory == NULL){
|
||||
openHistoryLog();
|
||||
}
|
||||
if(comHistory != NULL){
|
||||
fprintf(comHistory,"%s\n", txt);
|
||||
if(historyFilter(txt)){
|
||||
fprintf(comHistory,"%s\n", txt);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
void SetWriteHistory(int i)
|
||||
{
|
||||
/* writeHistory = i;*/
|
||||
writeHistory = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user