xanlib.h File Reference

Structure of the XanLib. More...

#include <semaphore.h>
#include <pthread.h>
#include <stddef.h>
#include <stdbool.h>
Include dependency graph for xanlib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  XanListItem
 List element. More...
struct  XanList
 Doubly linked list. More...
struct  XanVar
 Variable. More...
struct  XanPipe
 Pipe. More...
struct  XanStack
 Stack. More...
struct  XanNode
 Node of a generic tree. More...
struct  XanHashTableItem
 Element of the hash table. More...
struct  XanHashTable
 Hash table. More...
struct  XanBitSet

Typedefs

typedef struct XanListItem XanListItem
 List element.
typedef struct XanList XanList
 Doubly linked list.
typedef struct XanVar XanVar
 Variable.
typedef struct XanPipe XanPipe
 Pipe.
typedef struct XanStack XanStack
 Stack.
typedef struct XanNode XanNode
 Node of a generic tree.
typedef struct XanHashTableItem XanHashTableItem
 Element of the hash table.
typedef struct XanHashTable XanHashTable
 Hash table.
typedef struct XanBitSet XanBitSet

Functions

bool xanStackSynchContains (XanStack *stack, void *element)
bool xanStackContains (XanStack *stack, void *element)
XanListXanHashTable_ToItemList (XanHashTable *table)
 From HashTable to List.
XanListxanListNew (void *(*allocFunction)(size_t size), void(*freeFunction)(void *addr), void *(*cloneFunction)(void *addr))
 Make a new list.
XanVarxanVarNew (void *(*allocFunction)(size_t size), void(*freeFunction)(void *addr))
 Make a new variable.
XanPipexanPipeNew (void *(*allocFunction)(size_t size), void(*freeFunction)(void *addr))
 Make a new pipe.
XanNodexanNodeNew (void *(*allocFunction)(size_t size), void(*freeFunction)(void *addr), void *(*cloneFunction)(void *data))
 Make a new node.
XanStackxanStackNew (void *(*allocFunction)(size_t size), void(*freeFunction)(void *addr), void *(*cloneFunction)(void *data))
XanHashTablexanHashTableNew (unsigned int length, int hasFixedLength, void *(*allocFunction)(size_t size), void *(*reallocFunction)(void *addr, size_t newSize), void(*freeFunction)(void *addr), unsigned int(*hashFunction)(void *element), int(*equalsFunction)(void *key1, void *key2))
 Make a new Hash Table.
void print_err (char *message, int err)
 Print an error message.
void print_ascii_err (signed char *message, int err)
 Print an error message.
int str_has_suffix (char *string, char *suffix)
void libxanCompilationFlags (char *buffer, int bufferLength)
void libxanCompilationTime (char *buffer, int bufferLength)
char * libxanVersion ()
XanBitSetXanBitSet_Alloc (size_t length)
 allocate a bitset structure in memory and return a pointer
void XanBitSet_ClearAll (XanBitSet *set)
 set to 0 all the bits in the bitset
void XanBitSet_SetAll (XanBitSet *set)
 set to 1 all the bits in the bitset
void XanBitSet_Subtract (XanBitSet *fromThis, XanBitSet *subtractThis)
void XanBitSet_Free (XanBitSet *set)
 release the memory used for the bitset
void XanBitSet_Intersect (XanBitSet *dest, XanBitSet *src)
 compute the intersection between dest and src and assign it to dest
int XanBitSet_GetCountOfBitsSet (XanBitSet *set)
 compute the number of bit that are set in the xan_bitset
bool XanBitSet_Equal (XanBitSet *bs1, XanBitSet *bs2)
 test if bs1 is equal to bs2
XanBitSetXanBitSet_Clone (XanBitSet *src)
 clone src and return it
void XanBitSet_Copy (XanBitSet *dest, XanBitSet *src)
void XanBitSet_ClearBit (XanBitSet *set, size_t pos)
 set the pos-st bit to 0
void XanBitSet_SetBit (XanBitSet *set, size_t pos)
 set the pos-st bit to 1
bool XanBitSet_IsBitSet (XanBitSet *set, size_t pos)
 return the value of the pos-th bit (1 if it is set, 0 otherwise)
bool XanBitSet_IsSubSetOf (XanBitSet *setA, XanBitSet *setB)
 Check wheter setA is a subset of setB. In particular, even if setA and setB contain exactly the same elements true is returned. setA and setB must be of the same length.
void XanBitSet_Print (XanBitSet *set, int cr)
 print the XanBitSet to the standard output. Set cr if you want a newline

Detailed Description

Structure of the XanLib.

Structure of the XanLib

Definition in file xanlib.h.


Typedef Documentation

typedef struct XanBitSet XanBitSet
typedef struct XanHashTable XanHashTable

Hash table.

This structure implements the closed hash table. The equals, hash functions can be customized by the user.

Element of the hash table.

typedef struct XanList XanList

Doubly linked list.

Doubly linked list containing pointers to user data with the ability to iterate over the list in both directions.

typedef struct XanListItem XanListItem

List element.

Element stored inside the XanList list

typedef struct XanNode XanNode

Node of a generic tree.

The XanNode structure implements a generic N-ary tree.

typedef struct XanPipe XanPipe

Pipe.

This is a pipe structure, which can store inside itself unbounded elements.

typedef struct XanStack XanStack

Stack.

This is a stack structure. This is a queue with the LIFO (Last In First Out) policy.

typedef struct XanVar XanVar

Variable.

Variable which store pointer


Function Documentation

void libxanCompilationFlags ( char *  buffer,
int  bufferLength 
)

Definition at line 3271 of file xanlib.c.

void libxanCompilationTime ( char *  buffer,
int  bufferLength 
)

Definition at line 3288 of file xanlib.c.

char* libxanVersion (  ) 

Definition at line 3296 of file xanlib.c.

void print_ascii_err ( signed char *  message,
int  err 
)

Print an error message.

Print to stderr the error message given as input. If the err parameter is different from zero, then it append to the message the error message given bound to the err number.

Parameters:
message The error message to print
err The errno number given by the Linux system

Definition at line 2995 of file xanlib.c.

References print_err().

Here is the call graph for this function:

void print_err ( char *  message,
int  err 
)

Print an error message.

Print to stderr the error message given as input. If the err parameter is different from zero, then it append to the message the error message given bound to the err number.

Parameters:
message The error message to print
err The errno number given by the Linux system

Definition at line 2999 of file xanlib.c.

Referenced by _xanHashTableDelete(), _xanHashTableInsert(), _xanListDelete(), and print_ascii_err().

int str_has_suffix ( char *  string,
char *  suffix 
)

Definition at line 3072 of file xanlib.c.

XanBitSet* XanBitSet_Alloc ( size_t  length  ) 

allocate a bitset structure in memory and return a pointer

Definition at line 3316 of file xanlib.c.

References WORDS_NECESSARY.

Referenced by XanBitSet_Clone().

void XanBitSet_ClearAll ( XanBitSet set  ) 

set to 0 all the bits in the bitset

Definition at line 3377 of file xanlib.c.

References WORDS_NECESSARY.

void XanBitSet_ClearBit ( XanBitSet set,
size_t  pos 
)

set the pos-st bit to 0

Definition at line 3408 of file xanlib.c.

References MASK, and WORD_NUMBER.

XanBitSet* XanBitSet_Clone ( XanBitSet src  ) 

clone src and return it

Definition at line 3357 of file xanlib.c.

References XanBitSet::data, XanBitSet::length, WORDS_NECESSARY, and XanBitSet_Alloc().

Here is the call graph for this function:

void XanBitSet_Copy ( XanBitSet dest,
XanBitSet src 
)

Definition at line 3364 of file xanlib.c.

References XanBitSet::data, XanBitSet::length, and WORDS_NECESSARY.

bool XanBitSet_Equal ( XanBitSet bs1,
XanBitSet bs2 
)

test if bs1 is equal to bs2

Definition at line 3352 of file xanlib.c.

References XanBitSet::data, XanBitSet::length, and WORDS_NECESSARY.

void XanBitSet_Free ( XanBitSet set  ) 

release the memory used for the bitset

Definition at line 3403 of file xanlib.c.

int XanBitSet_GetCountOfBitsSet ( XanBitSet set  ) 

compute the number of bit that are set in the xan_bitset

Definition at line 3335 of file xanlib.c.

References XanBitSet_IsBitSet().

Here is the call graph for this function:

void XanBitSet_Intersect ( XanBitSet dest,
XanBitSet src 
)

compute the intersection between dest and src and assign it to dest

Definition at line 3329 of file xanlib.c.

References XanBitSet::data, XanBitSet::length, and WORDS_NECESSARY.

bool XanBitSet_IsBitSet ( XanBitSet set,
size_t  pos 
)

return the value of the pos-th bit (1 if it is set, 0 otherwise)

Definition at line 3422 of file xanlib.c.

References is_bit_set().

Referenced by XanBitSet_GetCountOfBitsSet().

Here is the call graph for this function:

bool XanBitSet_IsSubSetOf ( XanBitSet setA,
XanBitSet setB 
)

Check wheter setA is a subset of setB. In particular, even if setA and setB contain exactly the same elements true is returned. setA and setB must be of the same length.

Definition at line 3427 of file xanlib.c.

References is_bit_set(), and XanBitSet::length.

Here is the call graph for this function:

void XanBitSet_Print ( XanBitSet set,
int  cr 
)

print the XanBitSet to the standard output. Set cr if you want a newline

Definition at line 3369 of file xanlib.c.

References MASK, and WORD_NUMBER.

void XanBitSet_SetAll ( XanBitSet set  ) 

set to 1 all the bits in the bitset

Definition at line 3382 of file xanlib.c.

References WORDS_NECESSARY.

void XanBitSet_SetBit ( XanBitSet set,
size_t  pos 
)

set the pos-st bit to 1

Definition at line 3413 of file xanlib.c.

References MASK, and WORD_NUMBER.

void XanBitSet_Subtract ( XanBitSet fromThis,
XanBitSet subtractThis 
)

Definition at line 3387 of file xanlib.c.

References XanBitSet::data, XanBitSet::length, and WORDS_NECESSARY.

XanList* XanHashTable_ToItemList ( XanHashTable table  ) 

From HashTable to List.

Returns the list of element and elementID pairs (in the form of XanHashTableItem) that are part of the hashtable. These are only copies of the XanHashTableItems of the hashtable, and modifing them does not affect the original hashtable. Each of the Items has to be deallocated while deallocating the XanList (e.g. calling the function destroyListAndData of the XanList data structure).

Definition at line 2660 of file xanlib.c.

References _xanListInsert(), XanHashTable::alloc, XanHashTable::free, XanHashTable::length, XanHashTableItem::next, XanHashTable::table, XanHashTableItem::used, and xanListNew().

Here is the call graph for this function:

XanHashTable* xanHashTableNew ( unsigned int  length,
int  hasFixedLength,
void *(*)(size_t size)  allocFunction,
void *(*)(void *addr, size_t newSize)  reallocFunction,
void(*)(void *addr)  freeFunction,
unsigned int(*)(void *element)  hashFunction,
int(*)(void *key1, void *key2)  equalsFunction 
)

Make a new Hash Table.

Allocate and initialize a new Hash table. After the allocation, the hash and equals functions cannot be changed.

Definition at line 2361 of file xanlib.c.

References _xanHashTableCloneHashTable(), _xanHashTableDelete(), _xanHashTableDestroy(), _xanHashTableElementsInside(), _xanHashTableGetCloneFunction(), _xanHashTableInsert(), _xanHashTableLock(), _xanHashTableLookup(), _xanHashTableSetCloneFunction(), _xanHashTableToList(), _xanHashTableToSlotList(), _xanHashTableUnlock(), XanHashTable::alloc, XanHashTable::clone, XanHashTable::cloneHashTable, XanHashTable::currentLoadFactor, XanHashTable::delete, XanHashTable::destroy, XanHashTable::elementsInside, XanHashTable::equals, XanHashTable::free, XanHashTable::getCloneFunction, XanHashTable::hasFixedLength, XanHashTable::hash, XanHashTable::insert, XanHashTable::length, XanHashTable::lock, XanHashTable::lookup, XanHashTable::mutex, XanHashTable::primeIndex, primes, PRIMES_TABLE_LENGTH, XanHashTable::realloc, XanHashTable::setCloneFunction, XanHashTable::size, XanHashTable::synchCloneHashTable, XanHashTable::synchDelete, XanHashTable::synchDestroy, XanHashTable::synchElementsInside, XanHashTable::synchGetCloneFunction, XanHashTable::synchInsert, XanHashTable::synchLookup, XanHashTable::synchSetCloneFunction, XanHashTable::synchToList, XanHashTable::synchToSlotList, XanHashTable::table, XanHashTable::toList, XanHashTable::toSlotList, XanHashTable::unlock, xanHashTableCloneHashTable(), xanHashTableDefaultEqualsFunction(), xanHashTableDefaultHashFunction(), xanHashTableDelete(), xanHashTableDestroy(), xanHashTableElementsInside(), xanHashTableGetCloneFunction(), xanHashTableInsert(), xanHashTableLookup(), xanHashTableSetCloneFunction(), xanHashTableToList(), and xanHashTableToSlotList().

Referenced by _xanHashTableCloneHashTable().

Here is the call graph for this function:

XanList* xanListNew ( void *(*)(size_t size)  allocFunction,
void(*)(void *addr)  freeFunction,
void *(*)(void *addr)  cloneFunction 
)

Make a new list.

Make a new list. e.g. XanList *myList = xanListNew(malloc, free, NULL);

Parameters:
allocFunction This function is called each time the list needs to allocate new memory; if it is NULL, then the list will use the malloc function.
freeFunction This function is called each time the list needs to free memory; if it is NULL, then the list will use the free function.
cloneFunction This function is called each time the list needs to clone the variable stored inside its elements; if it is NULL, then the list does not clone the variable stored inside each element of the list.
Returns:
Return the new list.

Definition at line 637 of file xanlib.c.

References _xanListAppend(), _xanListAppendList(), _xanListCloneList(), _xanListContainsTheSameElements(), _xanListData(), _xanListDelete(), _xanListDeleteAll(), _xanListDeleteClones(), _xanListDeleteItem(), _xanListDestroy(), _xanListDestroyListAndData(), _xanListEmptyOutList(), _xanListEqualsInstancesNumber(), _xanListFind(), _xanListFirst(), _xanListGetCloneFunction(), _xanListGetElementFromPositionNumber(), _xanListGetSlotData(), _xanListInsert(), _xanListInsertAfter(), _xanListInsertBefore(), _xanListLast(), _xanListLength(), _xanListLock(), _xanListMoveToBegin(), _xanListNext(), _xanListPrev(), _xanListSetCloneFunction(), _xanListShareSomeElements(), _xanListUnlock(), XanList::alloc, XanList::append, XanList::appendList, XanList::clone, XanList::cloneList, XanList::containsTheSameElements, XanList::data, XanList::delete, XanList::deleteAll, XanList::deleteClones, XanList::deleteItem, XanList::destroyList, XanList::destroyListAndData, XanList::emptyOutList, XanList::equalsInstancesNumber, XanList::find, XanList::first, XanList::firstItem, XanList::free, XanList::getCloneFunction, XanList::getElementFromPositionNumber, XanList::getSlotData, XanList::insert, XanList::insertAfter, XanList::insertBefore, XanList::itemsMutex, XanList::last, XanList::lastItem, XanList::len, XanList::length, XanList::lock, XanList::moveToBegin, XanList::next, XanList::prev, XanList::setCloneFunction, XanList::shareSomeElements, XanList::synchAppend, XanList::synchAppendList, XanList::synchCloneList, XanList::synchContainsTheSameElements, XanList::synchData, XanList::synchDelete, XanList::synchDeleteAll, XanList::synchDeleteClones, XanList::synchDeleteItem, XanList::synchDestroyList, XanList::synchDestroyListAndData, XanList::synchEmptyOutList, XanList::synchEqualsInstancesNumber, XanList::synchFind, XanList::synchFirst, XanList::synchGetCloneFunction, XanList::synchGetElementFromPositionNumber, XanList::synchGetSlotData, XanList::synchInsert, XanList::synchInsertAfter, XanList::synchInsertBefore, XanList::synchLast, XanList::synchLength, XanList::synchMoveToBegin, XanList::synchNext, XanList::synchPrev, XanList::synchSetCloneFunction, XanList::synchShareSomeElements, XanList::unlock, xanListAppend(), xanListAppendList(), xanListCloneList(), xanListContainsTheSameElements(), xanListData(), xanListDelete(), xanListDeleteAll(), xanListDeleteClones(), xanListDeleteItem(), xanListDestroy(), xanListDestroyListAndData(), xanListEmptyOutList(), xanListEqualsInstancesNumber(), xanListFind(), xanListFirst(), xanListGetCloneFunction(), xanListGetElementFromPositionNumber(), xanListGetSlotData(), xanListInsert(), xanListInsertAfter(), xanListInsertBefore(), xanListLast(), xanListLength(), xanListMoveToBegin(), xanListNext(), xanListPrev(), xanListSetCloneFunction(), and xanListShareSomeElements().

Referenced by _xanHashTableToList(), _xanHashTableToSlotList(), _xanListCloneList(), _xanNodeToInOrderList(), _xanNodeToPostOrderList(), _xanNodeToPreOrderList(), XanHashTable_ToItemList(), xanNodeNew(), xanPipeNew(), and xanStackNew().

XanNode* xanNodeNew ( void *(*)(size_t size)  allocFunction,
void(*)(void *addr)  freeFunction,
void *(*)(void *data)  cloneFunction 
)

Make a new node.

Make a new node of the N-ary tree.

Parameters:
allocFunction This function is called each time the tree needs to allocate new memory; if it is NULL, then the tree will use the malloc function.
freeFunction This function is called each time the tree needs to free memory; if it is NULL, then the tree will use the free function.
cloneFunction This function is called each time the tree needs to clone the variable stored inside its elements; if it is NULL, then the tree does not clone the variable stored inside each element of the tree rooted at the current node.
Returns:
Return the new node.

Definition at line 1785 of file xanlib.c.

References _xanNodeAddChildren(), _xanNodeAddNewChildren(), _xanNodeCloneTree(), _xanNodeDeleteChildren(), _xanNodeDestroyNode(), _xanNodeDestroyTree(), _xanNodeDestroyTreeAndData(), _xanNodeFind(), _xanNodeGetChildrens(), _xanNodeGetData(), _xanNodeGetNextChildren(), _xanNodeGetParent(), _xanNodeSetCloneFunction(), _xanNodeSetData(), _xanNodeSetParent(), _xanNodeToInOrderList(), _xanNodeToPostOrderList(), _xanNodeToPreOrderList(), XanNode::addChildren, XanNode::addNewChildren, XanNode::alloc, XanNode::childrens, XanNode::clone, XanNode::cloneTree, XanNode::data, XanNode::deleteChildren, XanNode::destroyNode, XanNode::destroyTree, XanNode::destroyTreeAndData, XanNode::find, XanNode::free, XanNode::getChildrens, XanNode::getData, XanNode::getNextChildren, XanNode::getParent, XanNode::mutex, XanNode::parent, XanNode::setCloneFunction, XanNode::setData, XanNode::setParent, XanNode::synchAddChildren, XanNode::synchAddNewChildren, XanNode::synchCloneTree, XanNode::synchDeleteChildren, XanNode::synchDestroyTree, XanNode::synchDestroyTreeAndData, XanNode::synchFind, XanNode::synchGetChildrens, XanNode::synchGetData, XanNode::synchGetNextChildren, XanNode::synchGetParent, XanNode::synchSetCloneFunction, XanNode::synchSetData, XanNode::synchSetParent, XanNode::synchToInOrderList, XanNode::synchToPostOrderList, XanNode::synchToPreOrderList, XanNode::toInOrderList, XanNode::toPostOrderList, XanNode::toPreOrderList, xanListNew(), xanNodeAddChildren(), xanNodeAddNewChildren(), xanNodeCloneTree(), xanNodeDeleteChildren(), xanNodeDestroyTree(), xanNodeDestroyTreeAndData(), xanNodeFind(), xanNodeGetChildrens(), xanNodeGetData(), xanNodeGetNextChildren(), xanNodeGetParent(), xanNodeSetCloneFunction(), xanNodeSetData(), xanNodeSetParent(), xanNodeToInOrderList(), xanNodeToPostOrderList(), and xanNodeToPreOrderList().

Referenced by _xanNodeAddNewChildren(), and _xanNodeCloneTree().

Here is the call graph for this function:

XanPipe* xanPipeNew ( void *(*)(size_t size)  allocFunction,
void(*)(void *addr)  freeFunction 
)

Make a new pipe.

Make a new pipe.

Parameters:
allocFunction This function is called each time the pipe needs to allocate new memory; if it is NULL, then the pipe will use the malloc function.
freeFunction This function is called each time the pipe needs to free memory; if it is NULL, then the pipe will use the free function.
Returns:
Return the new pipe.

Definition at line 1470 of file xanlib.c.

References _xanPipeDeleteItem(), _xanPipeDestroyPipe(), _xanPipeGet(), _xanPipeIsEmpty(), _xanPipeMoveToEnd(), _xanPipePut(), _xanPipePutAtEnd(), XanPipe::alloc, XanPipe::deleteItem, XanPipe::destroyPipe, XanPipe::free, XanPipe::get, XanPipe::isEmpty, XanPipe::items, XanPipe::itemsCond, XanPipe::itemsMutex, XanPipe::lock, XanPipe::moveToEnd, XanPipe::put, XanPipe::putAtEnd, XanPipe::synchDeleteItem, XanPipe::synchGet, XanPipe::synchIsEmpty, XanPipe::synchMoveToEnd, XanPipe::synchPut, XanPipe::synchPutAtEnd, XanPipe::unlock, xanListNew(), xanPipeDeleteItem(), xanPipeGet(), xanPipeIsEmpty(), xanPipeLock(), xanPipeMoveToEnd(), xanPipePut(), xanPipePutAtEnd(), and xanPipeUnlock().

Here is the call graph for this function:

bool xanStackContains ( XanStack stack,
void *  element 
)

Definition at line 3182 of file xanlib.c.

References _xanListFind(), and XanStack::internalList.

Referenced by xanStackSynchContains().

Here is the call graph for this function:

XanStack* xanStackNew ( void *(*)(size_t size)  allocFunction,
void(*)(void *addr)  freeFunction,
void *(*)(void *data)  cloneFunction 
)
bool xanStackSynchContains ( XanStack stack,
void *  element 
)

Definition at line 3198 of file xanlib.c.

References XanStack::mutex, and xanStackContains().

Here is the call graph for this function:

XanVar* xanVarNew ( void *(*)(size_t size)  allocFunction,
void(*)(void *addr)  freeFunction 
)

Make a new variable.

Make a new variable.

Parameters:
allocFunction This function is called each time the variable needs to allocate new memory; if it is NULL, then the variable will use the malloc function.
freeFunction This function is called each time the variable needs to free memory; if it is NULL, then the variable will use the free function.
Returns:
Return the new variable.

Definition at line 1386 of file xanlib.c.

References _varRead(), _varWrite(), XanVar::alloc, XanVar::data, XanVar::destroyVarAndData, XanVar::free, XanVar::lock, XanVar::mutex, XanVar::read, XanVar::synchRead, XanVar::synchWrite, XanVar::unlock, varDestroyVarAndData(), varLock(), varRead(), varUnlock(), varWrite(), and XanVar::write.

Here is the call graph for this function:

Generated on Mon Apr 26 15:54:47 2010 for xanlib by  doxygen 1.6.3