X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=lib%2Fabyss%2Fsrc%2Fdata.h;fp=lib%2Fabyss%2Fsrc%2Fdata.h;h=c990d99105223c40591e8fcae572d4ec905997c3;hb=ce67d0cdeaa37c3e856e23ae4010480887165630;hp=0000000000000000000000000000000000000000;hpb=e355d4e7962400470f467b88f5568de9c8324475;p=xmlrpc-c diff --git a/lib/abyss/src/data.h b/lib/abyss/src/data.h new file mode 100644 index 0000000..c990d99 --- /dev/null +++ b/lib/abyss/src/data.h @@ -0,0 +1,124 @@ +#ifndef DATA_H_INCLUDED +#define DATA_H_INCLUDED + +#include "thread.h" + +/********************************************************************* +** List +*********************************************************************/ + +typedef struct { + void **item; + uint16_t size; + uint16_t maxsize; + abyss_bool autofree; +} TList; + +void +ListInit(TList * const listP); + +void +ListInitAutoFree(TList * const listP); + +void +ListFree(TList * const listP); + +void +ListFreeItems(TList * const listP); + +abyss_bool +ListAdd(TList * const listP, + void * const str); + +void +ListRemove(TList * const listP); + +abyss_bool +ListAddFromString(TList * const listP, + const char * const c); + +abyss_bool +ListFindString(TList * const listP, + const char * const str, + uint16_t * const indexP); + + +typedef struct +{ + char *name,*value; + uint16_t hash; +} TTableItem; + +typedef struct +{ + TTableItem *item; + uint16_t size,maxsize; +} TTable; + +void +TableInit(TTable * const t); + +void +TableFree(TTable * const t); + +abyss_bool +TableAdd(TTable * const t, + const char * const name, + const char * const value); + +abyss_bool +TableAddReplace(TTable * const t, + const char * const name, + const char * const value); + +abyss_bool +TableFindIndex(TTable * const t, + const char * const name, + uint16_t * const index); + +char * +TableFind(TTable * const t, + const char * const name); + + +/********************************************************************* +** Pool +*********************************************************************/ + +typedef struct _TPoolZone { + char * pos; + char * maxpos; + struct _TPoolZone * next; + struct _TPoolZone * prev; +/* char data[0]; Some compilers don't accept this */ + char data[1]; +} TPoolZone; + +typedef struct { + TPoolZone * firstzone; + TPoolZone * currentzone; + uint32_t zonesize; + TMutex mutex; +} TPool; + +abyss_bool +PoolCreate(TPool * const poolP, + uint32_t const zonesize); + +void +PoolFree(TPool * const poolP); + +void * +PoolAlloc(TPool * const poolP, + uint32_t const size); + +void +PoolReturn(TPool * const poolP, + void * const blockP); + +const char * +PoolStrdup(TPool * const poolP, + const char * const origString); + + +#endif