- 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 <ENQ> which caused problems with
  GTSE to @ENQ@
This commit is contained in:
koennecke
2009-05-26 09:38:31 +00:00
parent caf59ef8eb
commit 5faf542574
3 changed files with 58 additions and 2 deletions

View File

@ -16,7 +16,7 @@ static int PfeifferHandler(Ascon *a)
switch(a->state){ switch(a->state){
case AsconWriteStart: case AsconWriteStart:
if(strstr(GetCharArray(a->wrBuffer),"<ENQ>") != NULL) { if(strstr(GetCharArray(a->wrBuffer),"@ENQ@") != NULL) {
AsconWriteChars(a->fd,&c,1); AsconWriteChars(a->fd,&c,1);
a->state = AsconWriteDone; a->state = AsconWriteDone;
return 1; return 1;

View File

@ -289,7 +289,7 @@ int MakeSANSWave(SConnection * pCon, SicsInterp * pSics, void *pData,
} }
pDum = (pDummy) pNew->pSelector; pDum = (pDummy) pNew->pSelector;
if (strcmp(pDum->pDescriptor->name, "VelocitySelector") != 0 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]); sprintf(pBueffel, "ERROR: velocity selector %s is invalid", argv[2]);
SCWrite(pCon, pBueffel, eError); SCWrite(pCon, pBueffel, eError);
KillSANSWave(pNew); KillSANSWave(pNew);

56
termprot.c Normal file
View File

@ -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 <errno.h>
#include <ascon.h>
#include <ascon.i>
#include <dynstring.h>
/*-----------------------------------------------------------------------------*/
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);
}