From 4cb109d70f70195be2a1642ad52c16b982fcfd9e Mon Sep 17 00:00:00 2001 From: watcherhd Date: Sat, 24 Mar 2012 16:28:13 +0000 Subject: berlios is still alive so Skype and imo2sproxy hosted there and deleted from this repo git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@283 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- imo2sproxy/src/common/fifo.c | 144 ------------------------------------------- 1 file changed, 144 deletions(-) delete mode 100644 imo2sproxy/src/common/fifo.c (limited to 'imo2sproxy/src/common/fifo.c') diff --git a/imo2sproxy/src/common/fifo.c b/imo2sproxy/src/common/fifo.c deleted file mode 100644 index d703ac3..0000000 --- a/imo2sproxy/src/common/fifo.c +++ /dev/null @@ -1,144 +0,0 @@ -#include -#include -#include "fifo.h" - -struct _tagFIFO -{ - unsigned int uiCount; - unsigned int uiCapacity; - unsigned int uiActInd; - char *acStorage; -}; - - -TYP_FIFO *Fifo_Init(unsigned int uiCapacity) -{ - TYP_FIFO *pstHandle; - - pstHandle = (TYP_FIFO *)malloc(sizeof(TYP_FIFO)); - if (!pstHandle) return NULL; - pstHandle->uiCount = pstHandle->uiActInd = 0; - pstHandle->uiCapacity = uiCapacity; - if (uiCapacity == 0) - pstHandle->acStorage = NULL; - else - { - pstHandle->acStorage = (char *)malloc(uiCapacity); - if (!pstHandle->acStorage) - { - free (pstHandle); - return NULL; - } - } - return pstHandle; -} - -void Fifo_Exit(TYP_FIFO *pstHandle) -{ - if (pstHandle->acStorage) - free (pstHandle->acStorage); - free (pstHandle); -} - -char *Fifo_AllocBuffer(TYP_FIFO *pstHandle, unsigned int uiPCount) -{ - unsigned int uiCount = pstHandle->uiCount; - - if (!Fifo_Add (pstHandle, NULL, uiPCount)) return NULL; - return &pstHandle->acStorage[pstHandle->uiActInd+uiCount]; - -} - -BOOL Fifo_Add(TYP_FIFO *pstHandle, char *acPBytes, unsigned int uiPCount) -{ - unsigned int uiFree; - - if (uiPCount == 0) return TRUE; - if (pstHandle->uiCapacity == 0) - { - if (!(pstHandle->acStorage = (char *)calloc(1, uiPCount))) - return FALSE; - if (acPBytes) - memcpy(pstHandle->acStorage, acPBytes, uiPCount); - else - memset(pstHandle->acStorage, 0, uiPCount); - pstHandle->uiCapacity = pstHandle->uiCount = uiPCount; - pstHandle->uiActInd = 0; - } - else - { - uiFree = pstHandle->uiCapacity-(pstHandle->uiActInd+pstHandle->uiCount); - if (uiFree < uiPCount) - { - if (pstHandle->uiActInd>=uiPCount && pstHandle->uiActInd*4>pstHandle->uiCount) - { - memmove(pstHandle->acStorage, pstHandle->acStorage+pstHandle->uiActInd, pstHandle->uiCount); - pstHandle->uiActInd = 0; - } - else - { - char *acBuf; - unsigned int uiNewLen; - - if (pstHandle->uiCapacity*2 < - pstHandle->uiCount+pstHandle->uiActInd+uiPCount) - uiNewLen = pstHandle->uiCount+pstHandle->uiActInd+uiPCount; - else - uiNewLen = pstHandle->uiCapacity*2; - acBuf = realloc(pstHandle->acStorage, uiNewLen); - if (acBuf == NULL) return FALSE; - pstHandle->acStorage = acBuf; - memset (acBuf+pstHandle->uiCapacity, 0, uiNewLen-pstHandle->uiCapacity); - pstHandle->uiCapacity = uiNewLen; - } - } - if (acPBytes) - memcpy (&pstHandle->acStorage[pstHandle->uiActInd+pstHandle->uiCount], acPBytes, uiPCount); - else - memset (&pstHandle->acStorage[pstHandle->uiActInd+pstHandle->uiCount], 0, uiPCount); - - pstHandle->uiCount += uiPCount; - } - - return TRUE; -} - -BOOL Fifo_AddString(TYP_FIFO *pstHandle, char *pszString) -{ - BOOL bRet; - - while (pstHandle->uiCount && pstHandle->acStorage[pstHandle->uiCount+pstHandle->uiActInd-1]==0) - pstHandle->uiCount--; - bRet = Fifo_Add (pstHandle, pszString, strlen(pszString)+1); - return bRet; -} - -char *Fifo_Get (TYP_FIFO *pstHandle, unsigned int *uiPCount) -{ - unsigned int uiCount; - char *pRet; - - if (!uiPCount) uiCount = pstHandle->uiCount; - else - { - if (pstHandle->uiCount < *uiPCount) - *uiPCount = pstHandle->uiCount; - uiCount = *uiPCount; - } - if (!uiCount) return NULL; - - pRet = &pstHandle->acStorage[pstHandle->uiActInd]; - pstHandle->uiActInd += uiCount; - pstHandle->uiCount -= uiCount; - return pRet; -} - -void Fifo_Reset (TYP_FIFO *pstHandle) -{ - pstHandle->uiCount = pstHandle->uiActInd = 0; -} - -unsigned int Fifo_Count (TYP_FIFO *pstHandle) -{ - return pstHandle->uiCount; -} -- cgit v1.2.3