Gumput is used by GumTree to provide feedback from batchfiles.
This commit is contained in:
121
macro.c
121
macro.c
@ -770,6 +770,127 @@ static int ProtectedExec(ClientData clientData, Tcl_Interp *interp,
|
||||
}
|
||||
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 argc, char *argv[])
|
||||
|
2
macro.h
2
macro.h
@ -31,6 +31,8 @@
|
||||
int argc, char *argv[]);
|
||||
int ClientPut(SConnection *pCon, SicsInterp *pInter, void *pData,
|
||||
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 argc, char *argv[]);
|
||||
int TransactAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
|
1
ofac.c
1
ofac.c
@ -216,6 +216,7 @@
|
||||
AddCommand(pInter,"FileWhere",MacroWhere,WhereKill,NULL);
|
||||
*/
|
||||
AddCommand(pInter,"ClientPut",ClientPut,NULL,NULL);
|
||||
AddCommand(pInter,"GumPut",GumPut,NULL,NULL);
|
||||
AddCommand(pInter,"broadcast",Broadcast,NULL,NULL);
|
||||
AddCommand(pInter,"transact",TransactAction,NULL,NULL);
|
||||
AddCommand(pInter,"fulltransact",TransactAction,NULL,NULL);
|
||||
|
Reference in New Issue
Block a user