- Added code to read SANS TOF frames from a) files and b) from HM
- Fixed an bug causing core dumps on bad Tcl scripts - Started on a syntax checker for SICS
This commit is contained in:
32
commandlog.c
32
commandlog.c
@@ -37,10 +37,29 @@
|
||||
static pCircular pTail = NULL;
|
||||
#define MAXTAIL 1000
|
||||
/*----------------------------------------------------------------------*/
|
||||
void WriteToCommandLog(char *prompt,char *pText)
|
||||
void WriteToCommandLog(char *prompt,char *text)
|
||||
{
|
||||
int iNL = 0, iPos;
|
||||
char *pPtr = NULL;
|
||||
char *pPtr = NULL, *pCopy = NULL, *pText = NULL;
|
||||
char myBuffer[1024];
|
||||
|
||||
/*
|
||||
we change the text, so we need to make a local copy. A copy
|
||||
is dynamically allocated only if it does not fit into
|
||||
myBuffer.
|
||||
*/
|
||||
if(strlen(text) > 1023){
|
||||
pCopy = (char *)malloc((strlen(text)+2)*sizeof(char));
|
||||
if(pCopy == NULL){
|
||||
return;
|
||||
}
|
||||
memset(pCopy,0,(strlen(text)+2)*sizeof(char));
|
||||
strcpy(pCopy,text);
|
||||
pText = pCopy;
|
||||
} else {
|
||||
strcpy(myBuffer,text);
|
||||
pText = myBuffer;
|
||||
}
|
||||
|
||||
/* figure out if we have to do a newline with pText as well */
|
||||
pPtr = strrchr(pText,'\n');
|
||||
@@ -56,6 +75,9 @@
|
||||
/* supress status messages */
|
||||
if(strstr(pText,"status =") != NULL)
|
||||
{
|
||||
if(pCopy != NULL){
|
||||
free(pCopy);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -64,6 +86,9 @@
|
||||
*/
|
||||
if(strstr(pText,"TRANSACTIONFINISHED") != NULL)
|
||||
{
|
||||
if(pCopy != NULL){
|
||||
free(pCopy);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -108,6 +133,9 @@
|
||||
setCircular(pTail,strdup(pText));
|
||||
nextCircular(pTail);
|
||||
}
|
||||
if(pCopy != NULL){
|
||||
free(pCopy);
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
static void PrintTail(int iNum, SConnection *pCon)
|
||||
|
||||
Reference in New Issue
Block a user