libUPnP  1.6.17
LinkedList.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *
00003  * Copyright (c) 2000-2003 Intel Corporation 
00004  * All rights reserved. 
00005  *
00006  * Redistribution and use in source and binary forms, with or without 
00007  * modification, are permitted provided that the following conditions are met: 
00008  *
00009  * * Redistributions of source code must retain the above copyright notice, 
00010  * this list of conditions and the following disclaimer. 
00011  * * Redistributions in binary form must reproduce the above copyright notice, 
00012  * this list of conditions and the following disclaimer in the documentation 
00013  * and/or other materials provided with the distribution. 
00014  * * Neither name of Intel Corporation nor the names of its contributors 
00015  * may be used to endorse or promote products derived from this software 
00016  * without specific prior written permission.
00017  * 
00018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00019  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
00020  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
00021  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR 
00022  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00023  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00024  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
00025  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
00026  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00027  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
00028  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029  *
00030  ******************************************************************************/
00031 
00032 #ifndef LINKED_LIST_H
00033 #define LINKED_LIST_H
00034 
00039 #include "FreeList.h"
00040 
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044 
00045 #define EOUTOFMEM (-7 & 1<<29)
00046 
00047 #define FREELISTSIZE 100
00048 #define LIST_SUCCESS 1
00049 #define LIST_FAIL 0
00050 
00052 typedef void (*free_function)(void *arg);
00053 
00055 typedef int (*cmp_routine)(void *itemA,void *itemB);
00056 
00060 typedef struct LISTNODE
00061 {
00062         struct LISTNODE *prev;
00063         struct LISTNODE *next;
00064         void *item;
00065 } ListNode;
00066 
00083 typedef struct LINKEDLIST
00084 {
00086         ListNode head;
00088         ListNode tail;
00090         long size;
00092         FreeList freeNodeList;
00094         free_function free_func;
00096         cmp_routine cmp_func;
00097 } LinkedList;
00098 
00106 int ListInit(
00108         LinkedList *list,
00110         cmp_routine cmp_func,
00112         free_function free_func);
00113 
00123 ListNode *ListAddHead(
00125         LinkedList *list,
00127         void *item);
00128 
00137 ListNode *ListAddTail(
00139         LinkedList *list,
00141         void *item);
00142 
00151 ListNode *ListAddAfter(
00153         LinkedList *list,
00155         void *item,
00157         ListNode *bnode);
00158 
00167 ListNode *ListAddBefore(
00169         LinkedList *list,
00171         void *item,
00173         ListNode *anode);
00174 
00183 void *ListDelNode(
00185         LinkedList *list,
00187         ListNode *dnode,
00190         int freeItem);
00191 
00200 int ListDestroy(
00202         LinkedList *list,
00205         int freeItem);
00206 
00214 ListNode *ListHead(
00216         LinkedList *list);
00217 
00225 ListNode *ListTail(
00227         LinkedList *list);
00228 
00236 ListNode *ListNext(
00238         LinkedList *list,
00240         ListNode *node);
00241 
00249 ListNode *ListPrev(
00251         LinkedList *list,
00253         ListNode *node);
00254 
00265 ListNode* ListFind(
00267         LinkedList *list,
00269         ListNode *start,
00271         void *item);
00272 
00280 long ListSize(
00282         LinkedList* list);
00283 
00284 #ifdef __cplusplus
00285 }
00286 #endif
00287 
00288 #endif /* LINKED_LIST_H */
00289