- Switched motor to hdb
- Changes to Hipadaba - Added project to histogram memory code - Started regression testing code - Added hill climbing as optimization method to optimise
This commit is contained in:
53
conman.c
53
conman.c
@ -39,6 +39,8 @@
|
||||
fields.
|
||||
Mark Koennecke, December 2004
|
||||
|
||||
Aded buffering support, Mark Koennecke, July 2006
|
||||
|
||||
Copyright: see copyright.h
|
||||
-----------------------------------------------------------------------------*/
|
||||
#include "fortify.h"
|
||||
@ -457,6 +459,11 @@ extern pServer pServ;
|
||||
DeleteCommandStack(pVictim->pStack);
|
||||
}
|
||||
|
||||
/* remove possible buffers */
|
||||
if(pVictim->data != NULL)
|
||||
{
|
||||
DeleteDynString(pVictim->data);
|
||||
}
|
||||
|
||||
pVictim->lMagic=0; /* make a write to a freed connection harmless */
|
||||
/* finally free pVictim*/
|
||||
@ -809,6 +816,52 @@ static void writeToLogFiles(SConnection *self, char *buffer)
|
||||
free(bufPtr);
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int SCBufferWrite(SConnection *self, char *buffer, int iOut)
|
||||
{
|
||||
if(!VerifyConnection(self))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
assert(self->data != NULL);
|
||||
DynStringConcat(self->data,buffer);
|
||||
if(strchr(buffer,'\n') == NULL){
|
||||
DynStringConcat(self->data,"\n");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int SCStartBuffering(SConnection *pCon)
|
||||
{
|
||||
if(!VerifyConnection(pCon))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if(pCon->data != NULL)
|
||||
{
|
||||
DeleteDynString(pCon->data);
|
||||
}
|
||||
pCon->data = CreateDynString(128,128);
|
||||
if(pCon->data == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
pCon->oldWriteFunc = pCon->write;
|
||||
pCon->write = SCBufferWrite;
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
pDynString SCEndBuffering(SConnection *pCon)
|
||||
{
|
||||
if(!VerifyConnection(pCon))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
assert(pCon->oldWriteFunc != NULL);
|
||||
pCon->write = pCon->oldWriteFunc;
|
||||
pCon->oldWriteFunc = NULL;
|
||||
return pCon->data;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int SCOnlySockWrite(SConnection *self, char *buffer, int iOut)
|
||||
{
|
||||
|
Reference in New Issue
Block a user