Cyber Garage Portable Runtime (CGPR) for C
list.h File Reference
#include <stdlib.h>
#include <cgpr/util/typedef.h>

Data Structures

struct  _CGList
 The generic list interface in mUPnP. More...
 

Macros

#define CG_LIST_STRUCT_MEMBERS
 

Typedefs

typedef void(* CG_LIST_DESTRUCTORFUNC) (void *)
 
typedef struct _CGList CGList
 The generic list interface in mUPnP.
 

Functions

bool cg_list_header_init (CGList *list)
 
bool cg_list_node_init (CGList *list)
 
bool cg_list_insert (CGList *prevList, CGList *list)
 
bool cg_list_add (CGList *headList, CGList *list)
 
bool cg_list_remove (CGList *list)
 
size_t cg_list_size (CGList *headList)
 
CGListcg_list_get (CGList *headList, int index)
 
CGListcg_list_prev_circular (CGList *list)
 
CGListcg_list_prev (CGList *list)
 
CGListcg_list_next_circular (CGList *list)
 
CGListcg_list_next (CGList *list)
 
bool cg_list_clear (CGList *headList, CG_LIST_DESTRUCTORFUNC destructorFunc)
 
CGListcg_list_gets (CGList *headList)
 

Macro Definition Documentation

◆ CG_LIST_STRUCT_MEMBERS

#define CG_LIST_STRUCT_MEMBERS
Value:
\
bool headFlag; \
\
struct _CGList* prev; \
\
struct _CGList* next;
The generic list interface in mUPnP.
Definition list.h:69

Macro for list node members

Typedef Documentation

◆ CG_LIST_DESTRUCTORFUNC

typedef void(* CG_LIST_DESTRUCTORFUNC) (void *)

Prototype for individual list node destructor functions

◆ CGList

typedef struct _CGList CGList

The generic list interface in mUPnP.

Each struct in mUPnP, that is designed to be a part of a list, must have these elements in their definition before the actual struct definition. The struct pointers are then cast to CGList* and operated with cg_list_* functions.

Function Documentation

◆ cg_list_add()

bool cg_list_add ( CGList * headList,
CGList * list )
Todo

This works essentially like insert, although it is more error-prone?!

There might be a bug in this function.

◆ cg_list_clear()

bool cg_list_clear ( CGList * headList,
CG_LIST_DESTRUCTORFUNC destructorFunc )

Clear the list and delete all of its contents with CG_LIST_DESTRUCTORFUNC

Parameters
headListList header
destructorFuncFunction pointer that clears the contents of individual nodes

◆ cg_list_get()

CGList * cg_list_get ( CGList * headList,
int index )

Get an item from the list by the item's index

Parameters
headListList header
indexThe index of the item to get

◆ cg_list_gets()

CGList * cg_list_gets ( CGList * headList)

Get the first actual item from a list for iteration

Parameters
headListList header

◆ cg_list_header_init()

bool cg_list_header_init ( CGList * list)

Initialize a list node to act as the first node

Parameters
listList node

◆ cg_list_insert()

bool cg_list_insert ( CGList * prevList,
CGList * list )

Insert a list node or a complete list structure after the given node

Parameters
prevListInsert after this node
listList node or list structure to insert

◆ cg_list_next()

CGList * cg_list_next ( CGList * list)

Get the next node. Returns NULL if end has been reached.

Parameters
listCurrent node

◆ cg_list_next_circular()

CGList * cg_list_next_circular ( CGList * list)

Get the next node. Wrap around if the end has been reached.

Parameters
listCurrent node

◆ cg_list_node_init()

bool cg_list_node_init ( CGList * list)

Initialize a list node to act as a regular node, part of a list.

Parameters
listList node

◆ cg_list_prev()

CGList * cg_list_prev ( CGList * list)

Get the previous node. Returns NULL if beginning has been reached

Parameters
listCurrent node

◆ cg_list_prev_circular()

CGList * cg_list_prev_circular ( CGList * list)

Get the previous node. Wrap around if the beginning has been reached.

Parameters
listCurrent node

◆ cg_list_remove()

bool cg_list_remove ( CGList * list)

Remove a node from a list. Does not free any memory, but only removes the next and previous link associations regarding the given node.

Parameters
listList node to remove

◆ cg_list_size()

size_t cg_list_size ( CGList * headList)

Get the number of nodes in the current list structure. Counts forwards from the given node, so if you want to get the complete size, give a header node as the parameter.

Parameters
headListList header