- inserted command echo into exe manager
This commit is contained in:
4
exe.w
4
exe.w
@ -88,7 +88,7 @@ The interface to this buffer system comprises:
|
||||
* @@return 1 on success, 0 on error
|
||||
*/
|
||||
int exeBufProcess(pExeBuf self, SicsInterp *pSics,
|
||||
SConnection *pCon, pICallBack pCall);
|
||||
SConnection *pCon, pICallBack pCall, int echo);
|
||||
/**
|
||||
* retrieves the executing range
|
||||
* @@param self The exe buffer to query
|
||||
@ -145,6 +145,7 @@ typedef struct __EXEMAN{
|
||||
int exeStackPtr;
|
||||
int runList;
|
||||
pExeBuf uploadBuffer;
|
||||
int echo;
|
||||
}ExeMan, *pExeMan;
|
||||
@}
|
||||
The fields:
|
||||
@ -159,6 +160,7 @@ about the operation of this module.
|
||||
\item[uploadBuffer] A exe buffer to which data is uploaded. Also serves
|
||||
as a flag if uploading is possible. In this case uploadBuffer must be
|
||||
not NULL.
|
||||
\item[echo] Echo flag. When set, SICS commands are echoed.
|
||||
\end{itemize}
|
||||
|
||||
The public interface to the exe manager are the interpreter interface
|
||||
|
35
exebuf.c
35
exebuf.c
@ -147,11 +147,17 @@ static pDynString findBlockEnd(pExeBuf self){
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
int exeBufProcess(pExeBuf self, SicsInterp *pSics,
|
||||
SConnection *pCon, pICallBack pCall){
|
||||
SConnection *pCon, pICallBack pCall, int echo){
|
||||
pDynString command = NULL;
|
||||
Tcl_Interp *pTcl = NULL;
|
||||
int status;
|
||||
|
||||
static int weWantLogging = 1;
|
||||
char *cmd;
|
||||
char cmdName[128];
|
||||
char *ende;
|
||||
int l;
|
||||
|
||||
assert(self);
|
||||
assert(pSics);
|
||||
|
||||
@ -162,9 +168,34 @@ int exeBufProcess(pExeBuf self, SicsInterp *pSics,
|
||||
|
||||
InvokeCallBack(pCall,BATCHSTART,self->name);
|
||||
|
||||
if (echo) {
|
||||
SCsetMacro(pCon,0);
|
||||
}
|
||||
while((command = findBlockEnd(self)) != NULL){
|
||||
InvokeCallBack(pCall,BATCHAREA,NULL);
|
||||
status = Tcl_Eval(pTcl,GetCharArray(command));
|
||||
cmd = GetCharArray(command);
|
||||
|
||||
if (echo) {
|
||||
/* find first word */
|
||||
while (*cmd == ' ') {
|
||||
cmd++;
|
||||
}
|
||||
ende = cmd;
|
||||
while (*ende > ' ') {
|
||||
ende++;
|
||||
}
|
||||
l = ende - cmd;
|
||||
if (l < sizeof cmdName) {
|
||||
strncpy(cmdName, cmd, l);
|
||||
cmdName[l] = '\0';
|
||||
if (FindCommand(pSics, cmdName) != NULL) {
|
||||
/* print only SICS commands */
|
||||
SCPrintf(pCon, eValue, "%s:%d>> %s",self->name,self->lineno,cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
status = Tcl_Eval(pTcl,cmd);
|
||||
if(status != TCL_OK){
|
||||
if(pCon->sicsError == 0){
|
||||
/*
|
||||
|
6
exebuf.h
6
exebuf.h
@ -1,5 +1,5 @@
|
||||
|
||||
#line 205 "exe.w"
|
||||
#line 207 "exe.w"
|
||||
|
||||
/**
|
||||
* Buffer handling code for the Exe Buffer batch file processing
|
||||
@ -62,7 +62,7 @@
|
||||
* @return 1 on success, 0 on error
|
||||
*/
|
||||
int exeBufProcess(pExeBuf self, SicsInterp *pSics,
|
||||
SConnection *pCon, pICallBack pCall);
|
||||
SConnection *pCon, pICallBack pCall, int echo);
|
||||
/**
|
||||
* retrieves the executing range
|
||||
* @param self The exe buffer to query
|
||||
@ -89,7 +89,7 @@
|
||||
*/
|
||||
char *exeBufName(pExeBuf self);
|
||||
|
||||
#line 218 "exe.w"
|
||||
#line 220 "exe.w"
|
||||
|
||||
|
||||
#endif
|
||||
|
4
exebuf.i
4
exebuf.i
@ -1,5 +1,5 @@
|
||||
|
||||
#line 196 "exe.w"
|
||||
#line 198 "exe.w"
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
Internal header file for the exe buffer module. Do not edit. This is
|
||||
@ -16,6 +16,6 @@ typedef struct __EXEBUF{
|
||||
int lineno;
|
||||
} ExeBuf;
|
||||
|
||||
#line 201 "exe.w"
|
||||
#line 203 "exe.w"
|
||||
|
||||
|
||||
|
12
exeman.c
12
exeman.c
@ -208,7 +208,7 @@ static int runBatchBuffer(pExeMan self, SConnection *pCon,
|
||||
|
||||
self->exeStackPtr++;
|
||||
DynarPut(self->exeStack,self->exeStackPtr,buffer);
|
||||
status = exeBufProcess(buffer,pSics,pCon,self->pCall);
|
||||
status = exeBufProcess(buffer,pSics,pCon,self->pCall,self->echo);
|
||||
self->exeStackPtr--;
|
||||
return status;
|
||||
}
|
||||
@ -702,7 +702,7 @@ static int execQueue(pExeMan self, SConnection *pCon, SicsInterp *pSics){
|
||||
return 0;
|
||||
}
|
||||
DynarPut(self->exeStack,self->exeStackPtr,buf);
|
||||
status = exeBufProcess(buf,pSics,pCon,self->pCall);
|
||||
status = exeBufProcess(buf,pSics,pCon,self->pCall,self->echo);
|
||||
self->exeStackPtr--;
|
||||
if(SCGetInterrupt(pCon) >= eAbortBatch){
|
||||
SCWrite(pCon,"ERROR: queue processing interrupted",eError);
|
||||
@ -781,6 +781,14 @@ int ExeManagerWrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
SCSendOK(pCon);
|
||||
}
|
||||
return status;
|
||||
}else if(strcmp(argv[1],"echo") == 0){
|
||||
if (argc > 2) {
|
||||
self->echo = atoi(argv[2]) != 0;
|
||||
SCSendOK(pCon);
|
||||
} else {
|
||||
SCPrintf(pCon, eValue, "echo = %d", self->echo);
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
status = runBatchBuffer(self,pCon,pSics,pBufferName);
|
||||
if(self->exeStackPtr < 0){
|
||||
|
5
exeman.i
5
exeman.i
@ -1,5 +1,5 @@
|
||||
|
||||
#line 174 "exe.w"
|
||||
#line 176 "exe.w"
|
||||
|
||||
/*-------------------------------------------------------------------
|
||||
Internal header file for the exe manager module. Do not edit. This
|
||||
@ -17,7 +17,8 @@ typedef struct __EXEMAN{
|
||||
int exeStackPtr;
|
||||
int runList;
|
||||
pExeBuf uploadBuffer;
|
||||
int echo;
|
||||
}ExeMan, *pExeMan;
|
||||
|
||||
#line 179 "exe.w"
|
||||
#line 181 "exe.w"
|
||||
|
||||
|
Reference in New Issue
Block a user