diff --git a/protocol.c b/protocol.c index a099183b..1d96949d 100644 --- a/protocol.c +++ b/protocol.c @@ -450,6 +450,37 @@ int SCWriteSycamore(SConnection *pCon, char *pBuffer, int iOut) return 0; } + /* log it for any case */ + if(pCon->pSock) + { + iRet = pCon->pSock->sockid; + } + else + { + iRet = 0; + } + sprintf(pBueffel,"Next line intended for socket: %d",iRet); + SICSLogWrite(pBueffel,eInternal); + SICSLogWrite(pBuffer,iOut); + + /* write to commandlog if user or manager privilege */ + if(SCGetRights(pCon) <= usUser) + { + sprintf(pBueffel,"To sock %d :",iRet); + WriteToCommandLog(pBueffel,pBuffer); + } + + /* put it into the interpreter if present */ + if(SCinMacro(pCon)) + { + InterpWrite(pServ->pSics,pBuffer); + /* print it to client if error message */ + /* FIXME should report errors via sycamore + if((iOut== eError) || (iOut == eWarning) ) + iRet = SCDoSockWrite(pCon,GetCharArray(pMsgOut));*/ + } + else /* not in interpreter, normal logic */ + { comCon = SCGetContext(pCon); /* Return 0 without dying if no message data */ @@ -515,39 +546,14 @@ int SCWriteSycamore(SConnection *pCon, char *pBuffer, int iOut) free(savedTclResult); } - /* log it for any case */ - if(pCon->pSock) - { - iRet = pCon->pSock->sockid; - } - else - { - iRet = 0; - } - sprintf(pBueffel,"Next line intended for socket: %d",iRet); - SICSLogWrite(pBueffel,eInternal); - SICSLogWrite(GetCharArray(pMsgOut),iOut); - - /* write to commandlog if user or manager privilege */ - if(SCGetRights(pCon) <= usUser) - { - sprintf(pBueffel,"To sock %d :",iRet); - WriteToCommandLog(pBueffel,GetCharArray(pMsgOut)); - } - - /* put it into the interpreter if present */ - if(SCinMacro(pCon)) - { - InterpWrite(pSics,pBuffer); - iRet = SCDoSockWrite(pCon,GetCharArray(pMsgOut)); - } - else /* not in interpreter, normal logic */ - { /* is this really to be printed ? */ if(iOut < pCon->iOutput) { + if (parseCmd != NULL) DeleteDynString(parseCmd); + if (pMsg != NULL) DeleteDynString(pMsg); + if (pMsgOut != NULL) DeleteDynString(pMsgOut); return 0; } @@ -556,11 +562,13 @@ int SCWriteSycamore(SConnection *pCon, char *pBuffer, int iOut) iRet = SCDoSockWrite(pCon,GetCharArray(pMsgOut)); SCWriteToLogFiles(pCon,GetCharArray(pMsgOut)); } - if(pMsgOut != NULL){ - DeleteDynString(pMsgOut); + if (pMsgOut != NULL){ + DeleteDynString(pMsgOut); } - DeleteDynString(parseCmd); - DeleteDynString(pMsg); + if (parseCmd != NULL) + DeleteDynString(parseCmd); + if (pMsg != NULL) + DeleteDynString(pMsg); return 1; }