- First implementation of Hdbqueue
- First implementation of new object model for SICS
This commit is contained in:
73
exeman.c
73
exeman.c
@ -297,12 +297,12 @@ static int SCHdbWrite(SConnection *self, char *message, int outCode){
|
||||
}
|
||||
if(v.v.text != NULL){
|
||||
DynStringConcat(val,v.v.text);
|
||||
if(strrchr(v.v.text,(int)'\n') == NULL && strlen(v.v.text) > 2){
|
||||
if(strrchr(v.v.text,(int)'\n') == NULL && strlen(v.v.text) > 1){
|
||||
DynStringConcatChar(val,'\n');
|
||||
}
|
||||
}
|
||||
DynStringConcat(val,message);
|
||||
if(strrchr(message,(int)'\n') == NULL && strlen(message) > 2){
|
||||
if(strrchr(message,(int)'\n') == NULL && strlen(message) > 1){
|
||||
DynStringConcatChar(val,'\n');
|
||||
}
|
||||
if(v.v.text != NULL){
|
||||
@ -314,6 +314,66 @@ static int SCHdbWrite(SConnection *self, char *message, int outCode){
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
int exeHdbNode(pHdb exeNode, SConnection *pCon){
|
||||
char pBueffel[512], *name = NULL;
|
||||
pHdb node = NULL;
|
||||
pExeBuf buffer = NULL;
|
||||
hdbValue v;
|
||||
int status;
|
||||
commandContext cc;
|
||||
writeFunc oldWrite;
|
||||
|
||||
/*
|
||||
* clear log buffer
|
||||
*/
|
||||
node = GetHipadabaNode(exeNode,"log");
|
||||
if(node == NULL){
|
||||
SCWrite(pCon,"ERROR: Hdb node not found or in wrong format",eError);
|
||||
return 0;
|
||||
}
|
||||
v = MakeHdbText(strdup(""));
|
||||
UpdateHipadabaPar(node,v,pCon);
|
||||
/*
|
||||
* prepare context
|
||||
*/
|
||||
name = GetHipadabaPath(node);
|
||||
cc = SCGetContext(pCon);
|
||||
strncpy(cc.deviceID, name,255);
|
||||
strncpy(bufferNode,name,511);
|
||||
|
||||
/*
|
||||
* load commands into buffer
|
||||
*/
|
||||
node = GetHipadabaNode(exeNode,"commands");
|
||||
if(node == NULL){
|
||||
SCWrite(pCon,"ERROR: Hdb node not found or in wrong format",eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GetHipadabaPar(node,&v,pCon);
|
||||
if(v.dataType != HIPTEXT || v.v.text == NULL){
|
||||
SCWrite(pCon,"ERROR: Hdb node is of wrong type or contains no data",eError);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
buffer = exeBufCreate(name);
|
||||
if(!buffer){
|
||||
SCWrite(pCon,"ERROR: out of memory creating batch buffer",eError);
|
||||
return 0;
|
||||
}
|
||||
exeBufAppend(buffer,v.v.text);
|
||||
|
||||
strncpy(bufferNode,name,511);
|
||||
oldWrite = SCGetWriteFunc(pCon);
|
||||
SCSetWriteFunc(pCon,SCHdbWrite);
|
||||
SCPushContext2(pCon,cc);
|
||||
status = exeBufProcess(buffer,pServ->pSics,pCon,NULL,0);
|
||||
SCSetWriteFunc(pCon,oldWrite);
|
||||
SCPopContext(pCon);
|
||||
return status;
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
static int runHdbBuffer(pExeMan self, SConnection *pCon,
|
||||
SicsInterp *pSics, char *name){
|
||||
char pBueffel[512];
|
||||
@ -381,6 +441,15 @@ static int runHdbBuffer(pExeMan self, SConnection *pCon,
|
||||
SCPopContext(pCon);
|
||||
return status;
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
int exeHdbBuffer(SConnection *pCon,
|
||||
SicsInterp *pSics, char *name){
|
||||
pExeMan self = (pExeMan)FindCommandData(pSics,"exe","ExeManager");
|
||||
if(self != NULL){
|
||||
return runHdbBuffer(self,pCon,pSics,name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*-------------------------------------------------------------------*/
|
||||
int runExeBatchBuffer(void *pData, SConnection *pCon,
|
||||
SicsInterp *pSics, char *name){
|
||||
|
Reference in New Issue
Block a user