- Major changes folling the rework of the connection object

- Added support for galil controllers
This commit is contained in:
koennecke
2009-02-03 08:07:30 +00:00
parent 9374bea841
commit 6c7bb14fad
29 changed files with 364 additions and 139 deletions

View File

@ -129,7 +129,7 @@ int ParPrintf(void *object, int iOut, const char *fmt, ...) {
if (ctx && pobj == ctx->obj && ctx->con) {
con = ctx->con;
} else {
con = SCLoad(pobj->conn);
con = pobj->conn;
}
} else if (ctx) {
con = ctx->con;
@ -138,7 +138,7 @@ int ParPrintf(void *object, int iOut, const char *fmt, ...) {
if (iOut < 0) {
if (!con) return 0; /* no connection, no verbose output */
if (-iOut > pobj->verbose) return 0; /* check verbosity level */
iOut = eStatus;
iOut = eValue;
}
va_start(ap, fmt);
@ -317,15 +317,17 @@ void ParLogForced(void *object) {
ParEnd();
}
/*-------------------------------------------------------------------------*/
static int ParCallBack(int event, void *eventData, void *userData,
commandContext cc) {
static int ParCallBack(int event, void *eventData, void *userData) {
char *pBuf = (char *)eventData;
SConnection *con = (SConnection *)userData;
/* check kill condition */
if(con == NULL || !SCisConnected(con)){
return -1;
}
if (event == VALUECHANGE) {
SCPushContext2(con,cc);
SCWrite(con,pBuf,eValue);
SCPopContext(con);
return 1;
}
return 1;
@ -386,7 +388,7 @@ static void ParListSugar(SConnection *con, ParData *o) {
}
p = p->next;
}
SCWrite(con, buf, eStatus);
SCWrite(con, buf, eValue);
}
/*----------------------------------------------------------------------------*/
void ParSaveConn(void *object, SConnection *con) {
@ -394,8 +396,11 @@ void ParSaveConn(void *object, SConnection *con) {
int rights;
rights = SCGetRights(con);
if (rights >= usMugger && rights <= usUser && con->pSock != NULL) {
o->conn = SCSave(con, o->conn);
if (rights >= usMugger && rights <= usUser && con->sockHandle >= 0) {
if(o->conn != NULL){
SCDeleteConnection(o->conn);
}
o->conn = SCCopyConnection(con);
}
}
/*----------------------------------------------------------------------------*/
@ -449,14 +454,14 @@ static int ParExecute(SConnection *con, SicsInterp *sics, void *object, int argc
o->pCall = CreateCallBackInterface();
}
assert(o->pCall);
id = RegisterCallback(o->pCall, SCGetContext(con),VALUECHANGE, ParCallBack, con, NULL);
SCRegister(con, pServ->pSics, o->pCall, id);
id = RegisterCallback(o->pCall,VALUECHANGE, ParCallBack,
SCCopyConnection(con), SCDeleteConnection);
SCSendOK(con);
ParEnd();
return 1;
} else if (strcmp(argv[1],"uninterest") == 0) {
if (o->pCall) {
RemoveCallback2(o->pCall, con);
RemoveCallbackCon(o->pCall, con);
}
SCSendOK(con);
ParEnd();
@ -1251,7 +1256,7 @@ void ParKill(void *object) {
if (o->creationCmd) free(o->creationCmd);
if (o->pCall) DeleteCallBackInterface(o->pCall);
if (o->desc) DeleteDescriptor(o->desc);
if (o->conn) SCStoreFree(o->conn);
if (o->conn) SCDeleteConnection(o->conn);
p = o->infoList;
while (p) {
q = p->next;