Update from PSI
r1039 | ffr | 2006-08-03 09:59:29 +1000 (Thu, 03 Aug 2006) | 2 lines
This commit is contained in:
committed by
Douglas Clowes
parent
4aa50787c2
commit
074f1cb3cd
68
macro.c
68
macro.c
@@ -61,16 +61,15 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <tcl.h>
|
||||
#include "SCinter.h"
|
||||
#include "conman.h"
|
||||
#include "macro.h"
|
||||
#include <sics.h>
|
||||
#include "status.h"
|
||||
#include "obdes.h"
|
||||
#include "macro.h"
|
||||
#include "splitter.h"
|
||||
#include "ifile.h"
|
||||
#include "Dbg.h"
|
||||
#include "servlog.h"
|
||||
#include "stringdict.h"
|
||||
#include "exeman.h"
|
||||
|
||||
#define SICSERROR "005567SICS"
|
||||
/*----------------------------------------------------------------------------
|
||||
@@ -131,7 +130,8 @@
|
||||
char *lastCommand = NULL, comBuffer[132];
|
||||
int iRet = 0,i;
|
||||
int iMacro;
|
||||
|
||||
Statistics *old;
|
||||
|
||||
/* get the datastructures */
|
||||
pSics = (struct __SicsUnknown *)pData;
|
||||
assert(pSics);
|
||||
@@ -180,7 +180,9 @@
|
||||
/* invoke */
|
||||
iMacro = SCinMacro(pCon);
|
||||
SCsetMacro(pCon,1);
|
||||
old=StatisticsBegin(pCommand->stat);
|
||||
iRet = pCommand->OFunc(pCon,pSinter,pCommand->pData,margc, myarg);
|
||||
StatisticsEnd(old);
|
||||
SCsetMacro(pCon,iMacro);
|
||||
/*
|
||||
lastUnkown gets deeply stacked with each SICS command exec'd.
|
||||
@@ -431,6 +433,21 @@ static int ProtectedExec(ClientData clientData, Tcl_Interp *interp,
|
||||
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int MacroFileEvalNew(SConnection *pCon, SicsInterp *pInter, void *pData,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
void *pCom = NULL;
|
||||
pCom = FindCommandData(pInter,"exe","ExeManager");
|
||||
assert(pCom != NULL);
|
||||
|
||||
if(argc < 2){
|
||||
SCWrite(pCon,"ERROR: no batch buffer to execute specified",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
return runExeBatchBuffer(pCom,pCon,pInter,argv[1]);
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
int MacroFileEval(SConnection *pCon, SicsInterp *pInter, void *pData,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
@@ -459,8 +476,8 @@ static int ProtectedExec(ClientData clientData, Tcl_Interp *interp,
|
||||
/* open filename */
|
||||
if( argc < 2)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: No filename specified ",eError);
|
||||
return 0;
|
||||
SCWrite(pCon,"ERROR: No filename specified ",eError);
|
||||
return 0;
|
||||
}
|
||||
fp = fopen(argv[1],"r");
|
||||
if(!fp)
|
||||
@@ -490,7 +507,7 @@ static int ProtectedExec(ClientData clientData, Tcl_Interp *interp,
|
||||
{
|
||||
iChar = fgetc(fp);
|
||||
if(iChar == EOF)
|
||||
{
|
||||
{
|
||||
iChar = (int)'\n';
|
||||
iRun = 0;
|
||||
}
|
||||
@@ -505,11 +522,11 @@ static int ProtectedExec(ClientData clientData, Tcl_Interp *interp,
|
||||
SetStatus(eEager);
|
||||
FirstWord(pCom,pBueffel);
|
||||
if(FindCommand(pInter,pBueffel) != NULL)
|
||||
{
|
||||
{
|
||||
sprintf(pBueffel,"%s:%d>> %s",pFile,iLine,pCom);
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
if(pWhere != NULL)
|
||||
{
|
||||
{
|
||||
free(pWhere);
|
||||
}
|
||||
pWhere = strdup(pBueffel);
|
||||
@@ -524,16 +541,16 @@ static int ProtectedExec(ClientData clientData, Tcl_Interp *interp,
|
||||
{ /* Tcl error */
|
||||
if(strlen(pTcl->result) > 2)
|
||||
{
|
||||
/*
|
||||
local copy in order to resolve a valgrind error
|
||||
*/
|
||||
strncpy(pBueffel,pTcl->result,511);
|
||||
/*
|
||||
local copy in order to resolve a valgrind error
|
||||
*/
|
||||
strncpy(pBueffel,pTcl->result,511);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
}
|
||||
pCom = Tcl_DStringValue(&command);
|
||||
SCWrite(pCon,"ERROR: in Tcl block:",eError);
|
||||
SCWrite(pCon,"ERROR: in Tcl block:",eError);
|
||||
SCWrite(pCon,pCom,eError);
|
||||
SCWrite(pCon,"ERROR: end of Tcl error block",eError);
|
||||
SCWrite(pCon,"ERROR: end of Tcl error block",eError);
|
||||
}
|
||||
else /* SICS error */
|
||||
{
|
||||
@@ -546,7 +563,7 @@ static int ProtectedExec(ClientData clientData, Tcl_Interp *interp,
|
||||
fclose(fp);
|
||||
Tcl_DStringFree(&command);
|
||||
SCWrite(pCon,"ERROR: batch processing interrupted",eError);
|
||||
SetStatus(eEager);
|
||||
SetStatus(eEager);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
@@ -865,7 +882,7 @@ static int ProtectedExec(ClientData clientData, Tcl_Interp *interp,
|
||||
}
|
||||
|
||||
/* make a string */
|
||||
pCommand = Arg2Tcl(argc,argv,pBueffel,sizeof(pBueffel));
|
||||
pCommand = Arg2Tcl0(argc-1,argv+1,pBueffel,sizeof(pBueffel),self->command);
|
||||
if (!pCommand) {
|
||||
SCWrite(pCon, "ERROR: no more memory", eError);
|
||||
return 0;
|
||||
@@ -895,8 +912,6 @@ static int ProtectedExec(ClientData clientData, Tcl_Interp *interp,
|
||||
}
|
||||
return 1; /* not reached */
|
||||
}
|
||||
|
||||
#include "access.c"
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int TclPublish(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
@@ -924,17 +939,8 @@ static int ProtectedExec(ClientData clientData, Tcl_Interp *interp,
|
||||
}
|
||||
|
||||
/* try convert last parameter to user code */
|
||||
iUser = 0;
|
||||
strtolower(argv[2]);
|
||||
while(aCode[iUser] != NULL)
|
||||
{
|
||||
if(strcmp(aCode[iUser],argv[2]) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
iUser++;
|
||||
}
|
||||
if(iUser > iCodes)
|
||||
iUser = decodeSICSPriv(argv[2]);
|
||||
if(iUser < 0)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: cannot identify %s as a valid user code",
|
||||
argv[2]);
|
||||
|
||||
Reference in New Issue
Block a user