Gumput is used by GumTree to provide feedback from batchfiles.

This commit is contained in:
hauser_n
2007-01-18 23:33:59 +00:00
parent 60c2b58c95
commit 50e0d51445
3 changed files with 124 additions and 0 deletions

121
macro.c
View File

@ -770,6 +770,127 @@ static int ProtectedExec(ClientData clientData, Tcl_Interp *interp,
} }
return 1; return 1;
} }
/*-----------------------------------------------------------------------*/
int GumPut(SConnection *pCon, SicsInterp *pInter, void *pData,
int argc, char *argv[])
{
OutCode eOut = eWarning;
int i = 0, iCode, iLen;
int iMacro;
char *ppCode;
char *pMessage = NULL;
commandContext cc;
assert(pCon);
assert(pInter);
if(argc < 2)
{
SCWrite(pCon,"Insufficient arguments to ClientPut",eError);
return 0;
}
/* handle optional I/O codes */
if(argc > 2)
{
/* the last one must be the code */
iCode = argc - 1;
ppCode = strdup(argv[iCode]);
strtolower(ppCode);
while(pCode[i] != NULL)
{
if(strcmp(pCode[i],ppCode) == 0)
{
break;
}
i++;
}
if(ppCode)
{
free(ppCode);
}
}
else
{
i = 10;
iCode = argc;
}
switch(i)
{
case 0:
eOut = eInternal;
break;
case 1:
eOut = eCommand;
break;
case 2:
eOut = eHWError;
break;
case 3:
eOut = eInError;
break;
case 4:
eOut = eStatus;
break;
case 5:
eOut = eValue;
break;
case 6:
eOut = eWarning;
break;
case 7:
eOut = eFinish;
break;
case 8:
eOut = eEvent;
break;
case 9:
eOut = eWarning;
break;
case 10:
eOut = eError;
break;
default:
eOut = eWarning;
iCode = argc;
break;
}
/* recombine the message */
/* find length */
iLen = 0;
for(i = 1; i < iCode; i++)
{
iLen += strlen(argv[i]);
}
pMessage = (char *)malloc((iLen+100)*sizeof(char));
if(!pMessage)
{
SCWrite(pCon,"ERROR: out of memory in clientput",eError);
return 0;
}
memset(pMessage,0,(iLen+100)*sizeof(char));
Arg2Text(iCode-1,&argv[1],pMessage,(iLen+100)*sizeof(char));
/* now write, thereby tunneling macro flag in order to get proper
write to client and not into interpreter. We also make sure that the device
is gumput
*/
iMacro = SCinMacro(pCon);
SCsetMacro(pCon,0);
cc = SCGetContext(pCon);
strcpy(cc.deviceID,"gumput");
SCPushContext2(pCon,cc);
SCWrite(pCon,pMessage,eOut);
SCPopContext(pCon);
SCsetMacro(pCon,iMacro);
if(pMessage)
{
free(pMessage);
}
return 1;
}
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
int Broadcast(SConnection *pCon, SicsInterp *pInter, void *pData, int Broadcast(SConnection *pCon, SicsInterp *pInter, void *pData,
int argc, char *argv[]) int argc, char *argv[])

View File

@ -31,6 +31,8 @@
int argc, char *argv[]); int argc, char *argv[]);
int ClientPut(SConnection *pCon, SicsInterp *pInter, void *pData, int ClientPut(SConnection *pCon, SicsInterp *pInter, void *pData,
int argc, char *argv[]); int argc, char *argv[]);
int GumPut(SConnection *pCon, SicsInterp *pInter, void *pData,
int argc, char *argv[]);
int Broadcast(SConnection *pCon, SicsInterp *pInter, void *pData, int Broadcast(SConnection *pCon, SicsInterp *pInter, void *pData,
int argc, char *argv[]); int argc, char *argv[]);
int TransactAction(SConnection *pCon, SicsInterp *pSics, void *pData, int TransactAction(SConnection *pCon, SicsInterp *pSics, void *pData,

1
ofac.c
View File

@ -216,6 +216,7 @@
AddCommand(pInter,"FileWhere",MacroWhere,WhereKill,NULL); AddCommand(pInter,"FileWhere",MacroWhere,WhereKill,NULL);
*/ */
AddCommand(pInter,"ClientPut",ClientPut,NULL,NULL); AddCommand(pInter,"ClientPut",ClientPut,NULL,NULL);
AddCommand(pInter,"GumPut",GumPut,NULL,NULL);
AddCommand(pInter,"broadcast",Broadcast,NULL,NULL); AddCommand(pInter,"broadcast",Broadcast,NULL,NULL);
AddCommand(pInter,"transact",TransactAction,NULL,NULL); AddCommand(pInter,"transact",TransactAction,NULL,NULL);
AddCommand(pInter,"fulltransact",TransactAction,NULL,NULL); AddCommand(pInter,"fulltransact",TransactAction,NULL,NULL);