- Adapted indenation to new agreed upon system

- Added support for second generation scriptcontext based counter
This commit is contained in:
koennecke
2009-02-13 09:00:03 +00:00
parent a3dcad2bfa
commit 91d4af0541
405 changed files with 88101 additions and 88173 deletions

273
costa.c
View File

@ -45,154 +45,145 @@
#include "costa.h"
#include "costa.i"
/*-------------------------------------------------------------------------*/
pCosta CreateCommandStack(void)
{
pCosta pNew = NULL;
pNew = (pCosta)malloc(sizeof(Costa));
if(!pNew)
{
return NULL;
}
memset(pNew,0,sizeof(Costa));
pNew->iList = LLDcreate(sizeof(char *));
if(pNew->iList < 0)
{
free(pNew);
return NULL;
}
pNew->iCount = 0;
pNew->iMaxSize = INT_MAX;
return pNew;
}
/*-------------------------------------------------------------------------*/
void DeleteCommandStack(pCosta self)
{
int iRet;
char *pPtr;
assert(self);
iRet = LLDnodePtr2First(self->iList);
while(iRet != 0)
{
pPtr = NULL;
LLDnodeDataTo(self->iList,&pPtr);
if(pPtr)
{
free(pPtr);
}
iRet = LLDnodePtr2Next(self->iList);
}
LLDdelete(self->iList);
free(self);
pCosta CreateCommandStack(void)
{
pCosta pNew = NULL;
pNew = (pCosta) malloc(sizeof(Costa));
if (!pNew) {
return NULL;
}
/*--------------------------------------------------------------------------*/
int SetCommandStackMaxSize(pCosta self, int iNew)
{
assert(self);
if(iNew > 0)
{
self->iMaxSize = iNew;
return 1;
memset(pNew, 0, sizeof(Costa));
pNew->iList = LLDcreate(sizeof(char *));
if (pNew->iList < 0) {
free(pNew);
return NULL;
}
pNew->iCount = 0;
pNew->iMaxSize = INT_MAX;
return pNew;
}
/*-------------------------------------------------------------------------*/
void DeleteCommandStack(pCosta self)
{
int iRet;
char *pPtr;
assert(self);
iRet = LLDnodePtr2First(self->iList);
while (iRet != 0) {
pPtr = NULL;
LLDnodeDataTo(self->iList, &pPtr);
if (pPtr) {
free(pPtr);
}
else
{
return 0;
}
}
iRet = LLDnodePtr2Next(self->iList);
}
LLDdelete(self->iList);
free(self);
}
/*--------------------------------------------------------------------------*/
int CostaTop(pCosta self, char *pCommand)
{
char *pPtr = NULL;
int iRet, iRes = 1;
assert(self);
/* check for lock */
if(self->iLock)
{
return 0;
}
/* check Size */
if(self->iCount >= self->iMaxSize)
{
return 0;
}
/* do not want 0 commands */
if(strlen(pCommand) < 1)
{
return 1;
}
pPtr = strdup(pCommand);
iRet = LLDnodeAppendFrom(self->iList,&pPtr);
if(iRet < 0)
{
iRes = 0;
}
self->iCount++;
return iRes;
}
/*--------------------------------------------------------------------------*/
int CostaBottom(pCosta self, char *pCommand)
{
char *pPtr = NULL;
int iRet, iRes = 1;
assert(self);
int SetCommandStackMaxSize(pCosta self, int iNew)
{
assert(self);
/* check for lock */
if(self->iLock)
{
return 0;
}
/* do not want 0 commands */
if(strlen(pCommand) < 1)
{
return 1;
}
pPtr = strdup(pCommand);
iRet = LLDnodePrependFrom(self->iList,&pPtr);
if(iRet < 0)
{
iRes = 0;
}
self->iCount++;
return iRes;
}
/*--------------------------------------------------------------------------*/
int CostaPop(pCosta self, char **pBuf)
{
char *pPtr = NULL;
int iRet;
assert(self);
iRet = LLDnodePtr2First(self->iList);
if(iRet != 0)
{
LLDnodeDataTo(self->iList,&pPtr);
*pBuf = pPtr;
LLDnodeDelete(self->iList);
self->iCount--;
return 1;
}
*pBuf = NULL;
if (iNew > 0) {
self->iMaxSize = iNew;
return 1;
} else {
return 0;
}
/*--------------------------------------------------------------------------*/
void CostaLock(pCosta self)
{
self->iLock = 1;
}
}
/*--------------------------------------------------------------------------*/
void CostaUnlock(pCosta self)
{
self->iLock = 0;
int CostaTop(pCosta self, char *pCommand)
{
char *pPtr = NULL;
int iRet, iRes = 1;
assert(self);
/* check for lock */
if (self->iLock) {
return 0;
}
/* check Size */
if (self->iCount >= self->iMaxSize) {
return 0;
}
/* do not want 0 commands */
if (strlen(pCommand) < 1) {
return 1;
}
pPtr = strdup(pCommand);
iRet = LLDnodeAppendFrom(self->iList, &pPtr);
if (iRet < 0) {
iRes = 0;
}
self->iCount++;
return iRes;
}
/*--------------------------------------------------------------------------*/
int CostaBottom(pCosta self, char *pCommand)
{
char *pPtr = NULL;
int iRet, iRes = 1;
assert(self);
/* check for lock */
if (self->iLock) {
return 0;
}
/* do not want 0 commands */
if (strlen(pCommand) < 1) {
return 1;
}
pPtr = strdup(pCommand);
iRet = LLDnodePrependFrom(self->iList, &pPtr);
if (iRet < 0) {
iRes = 0;
}
self->iCount++;
return iRes;
}
/*--------------------------------------------------------------------------*/
int CostaPop(pCosta self, char **pBuf)
{
char *pPtr = NULL;
int iRet;
assert(self);
iRet = LLDnodePtr2First(self->iList);
if (iRet != 0) {
LLDnodeDataTo(self->iList, &pPtr);
*pBuf = pPtr;
LLDnodeDelete(self->iList);
self->iCount--;
return 1;
}
*pBuf = NULL;
return 0;
}
/*--------------------------------------------------------------------------*/
void CostaLock(pCosta self)
{
self->iLock = 1;
}
/*--------------------------------------------------------------------------*/
void CostaUnlock(pCosta self)
{
self->iLock = 0;
}