Added command stack wrappers and fixed up nread and removed dead code from nserver
Removed direct access from token.c
This commit is contained in:
39
conman.c
39
conman.c
@ -2437,4 +2437,43 @@ void SCSetProtocolID(SConnection *pCon, int id)
|
||||
}
|
||||
pCon->iProtocolID = id;
|
||||
}
|
||||
/*--------------------------------------------------------*/
|
||||
void SCCostaLock(SConnection *pCon)
|
||||
{
|
||||
if (!VerifyConnection(pCon)) {
|
||||
return;
|
||||
}
|
||||
CostaLock(pCon->pStack);
|
||||
}
|
||||
/*---------------------------------------------------------*/
|
||||
void SCCostaUnLock(SConnection *pCon){
|
||||
if (!VerifyConnection(pCon)) {
|
||||
return;
|
||||
}
|
||||
CostaUnlock(pCon->pStack);
|
||||
}
|
||||
/*---------------------------------------------------------*/
|
||||
int SCCostaLocked(SConnection *pCon)
|
||||
{
|
||||
if (!VerifyConnection(pCon)) {
|
||||
return 0;
|
||||
}
|
||||
return CostaLocked(pCon->pStack);
|
||||
}
|
||||
/*----------------------------------------------------------*/
|
||||
int SCCostaTop(SConnection *pCon, char *command)
|
||||
{
|
||||
if (!VerifyConnection(pCon)) {
|
||||
return 0;
|
||||
}
|
||||
return CostaTop(pCon->pStack, command);
|
||||
}
|
||||
/*----------------------------------------------------------*/
|
||||
void SCSetGrab(SConnection *pCon, int iGrab)
|
||||
{
|
||||
if (!VerifyConnection(pCon)) {
|
||||
return;
|
||||
}
|
||||
pCon->iGrab = iGrab;
|
||||
}
|
||||
|
||||
|
7
conman.h
7
conman.h
@ -153,6 +153,7 @@ void SCSetConStatus(SConnection *pCon, int conStatus);
|
||||
void SCSetEventType(SConnection *pCon, int eventType);
|
||||
void SCSetSicsError(SConnection *pCon, int sicsError);
|
||||
void SCSetProtocolID(SConnection *pCon, int proID);
|
||||
void SCSetGrab(SConnection *pCon, int iGrab);
|
||||
|
||||
/* **************************** Invocation ******************************** */
|
||||
int SCInvoke(SConnection * self, SicsInterp * pInter, char *pCommand);
|
||||
@ -195,4 +196,10 @@ int SCUnregisterID(SConnection * pCon, long ID);
|
||||
* returns -1 if no ID can be found.
|
||||
*/
|
||||
long SCgetCallbackID(SConnection * pCon, void *pData);
|
||||
/*************************** command stack handling **********************/
|
||||
void SCCostaLock(SConnection *pCon);
|
||||
void SCCostaUnLock(SConnection *pCon);
|
||||
int SCCostaLocked(SConnection *pCon);
|
||||
int SCCostaTop(SConnection *pCon, char *command);
|
||||
|
||||
#endif
|
||||
|
8
nread.c
8
nread.c
@ -1067,10 +1067,10 @@ static int CommandDataCB(int handle, void *userData)
|
||||
if (pPtr[i] == '\r' || pPtr[i] == '\n') {
|
||||
self->state = SKIPTERM;
|
||||
if (!testAndInvokeInterrupt(self, handle)) {
|
||||
if (self->pCon->iProtocolID == PROTSICS && CostaLocked(self->pCon->pStack))
|
||||
if (SCGetProtocolID(self->pCon) == PROTSICS && SCCostaLocked(self->pCon))
|
||||
status = 0;
|
||||
else
|
||||
status = CostaTop(self->pCon->pStack, GetCharArray(self->command));
|
||||
status = SCCostaTop(self->pCon, GetCharArray(self->command));
|
||||
if (!status) {
|
||||
SCWrite(self->pCon, "ERROR: Busy", eError);
|
||||
}
|
||||
@ -1171,10 +1171,10 @@ static int ANETTelnetProcess(int handle, void *usData)
|
||||
case '\r':
|
||||
case '\n':
|
||||
if (!testAndInvokeInterrupt(self, handle)) {
|
||||
if (self->pCon->iProtocolID == PROTSICS && CostaLocked(self->pCon->pStack))
|
||||
if (SCGetProtocolID(self->pCon) == PROTSICS && SCCostaLocked(self->pCon))
|
||||
status = 0;
|
||||
else
|
||||
status = CostaTop(self->pCon->pStack, GetCharArray(self->command));
|
||||
status = SCCostaTop(self->pCon, GetCharArray(self->command));
|
||||
if (!status) {
|
||||
SCWrite(self->pCon, "ERROR: Busy", eError);
|
||||
}
|
||||
|
11
nserver.c
11
nserver.c
@ -201,17 +201,6 @@ int InitServer(char *file, pServer * pServ)
|
||||
IFDeleteOptions(pSICSOptions);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
self->pServerPort = NETOpenPort(iPort);
|
||||
if(!self->pServerPort)
|
||||
{
|
||||
printf("Cannot open Server Socket\n");
|
||||
DeleteInterp(self->pSics);
|
||||
IFDeleteOptions(pSICSOptions);
|
||||
return 0;
|
||||
}
|
||||
NetReadRegister(pReader, self->pServerPort, naccept, NULL);
|
||||
*/
|
||||
NetReadInstallANETPort(pReader, naccept, iPort);
|
||||
|
||||
/* the device executor */
|
||||
|
4
token.c
4
token.c
@ -94,11 +94,11 @@ int TokenWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
/* we can do it */
|
||||
iToken = 1;
|
||||
TaskSignal(pServ->pTasker, TOKENGRAB, NULL);
|
||||
pCon->iGrab = 0; /* to enable us to do commands */
|
||||
SCSetGrab(pCon,0); /* to enable us to do commands */
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
} else if (strcmp(argv[1], "release") == 0) {
|
||||
if (pCon->iGrab != 0) {
|
||||
if (SCGetGrab(pCon) != 0) {
|
||||
SCWrite(pCon,
|
||||
"ERROR: you cannot release somebody elses control token!",
|
||||
eError);
|
||||
|
Reference in New Issue
Block a user