From 5faf5425748f9e867700c85fff32e694c9e15f4c Mon Sep 17 00:00:00 2001 From: koennecke Date: Tue, 26 May 2009 09:38:31 +0000 Subject: [PATCH] - Added a variable terminator protocol driver for scriptcontext and velocity selectors. - Fixed sanswave to work with the new velocity selector driver - Changed pfeifferprot to replace which caused problems with GTSE to @ENQ@ --- pfeifferprot.c | 2 +- sanswave.c | 2 +- termprot.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 termprot.c diff --git a/pfeifferprot.c b/pfeifferprot.c index 4368fcd..5ee0e69 100644 --- a/pfeifferprot.c +++ b/pfeifferprot.c @@ -16,7 +16,7 @@ static int PfeifferHandler(Ascon *a) switch(a->state){ case AsconWriteStart: - if(strstr(GetCharArray(a->wrBuffer),"") != NULL) { + if(strstr(GetCharArray(a->wrBuffer),"@ENQ@") != NULL) { AsconWriteChars(a->fd,&c,1); a->state = AsconWriteDone; return 1; diff --git a/sanswave.c b/sanswave.c index f2ba265..e3e382d 100644 --- a/sanswave.c +++ b/sanswave.c @@ -289,7 +289,7 @@ int MakeSANSWave(SConnection * pCon, SicsInterp * pSics, void *pData, } pDum = (pDummy) pNew->pSelector; if (strcmp(pDum->pDescriptor->name, "VelocitySelector") != 0 - && strcmp(pDum->pDescriptor->name,"NVS") == 0) { + && strcmp(pDum->pDescriptor->name,"NVS") != 0) { sprintf(pBueffel, "ERROR: velocity selector %s is invalid", argv[2]); SCWrite(pCon, pBueffel, eError); KillSANSWave(pNew); diff --git a/termprot.c b/termprot.c new file mode 100644 index 0000000..7d4821f --- /dev/null +++ b/termprot.c @@ -0,0 +1,56 @@ +/* + * This is yet another protocol for scriptcontext. This is for variable + * terminated protocols. The Astriums have deliverd the SANS-2 NVS with + * a protocol which uses a \n as a terminator most of teh time but sometimes + * a \. This protocl handler expects messages in the form: terminator:payload + * The caller is responsible for providing the proper send termiantor. + * + * copyright: see file COPYRIGHT + * + * Mark Koennecke, April 2009 + */ +#include +#include +#include +#include + +/*-----------------------------------------------------------------------------*/ +int TermProtHandler(Ascon *a) +{ + char *data, *copy, *colon; + + switch (a->state) { + case AsconWriteStart: + data = GetCharArray(a->wrBuffer); + copy = strdup(data); + if(copy){ + colon = strstr(copy,":"); + if(colon){ + *colon = '\0'; + if(a->replyTerminator != NULL){ + free(a->replyTerminator); + } + a->replyTerminator = strdup(copy); + colon++; + DynStringClear(a->wrBuffer); + DynStringConcat(a->wrBuffer,colon); + } + free(copy); + } + a->state = AsconWriting; + a->wrPos = 0; + break; + } + return AsconStdHandler(a); +} +/*-------------------------------------------------------------------------*/ +void AddTermProtocoll() +{ + AsconProtocol *prot = NULL; + + prot = calloc(sizeof(AsconProtocol), 1); + prot->name = strdup("varterm"); + prot->init = AsconStdInit; + prot->handler = TermProtHandler; + AsconInsertProtocol(prot); +}