]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSShared/GenLinkedList.h
mDNSResponder-108.tar.gz
[apple/mdnsresponder.git] / mDNSShared / GenLinkedList.h
1 /*
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22
23 File: GenLinkedList.c
24
25 Contains: interface to generic linked lists.
26
27 Version: 1.0
28 Tabs: 4 spaces
29
30 Change History (most recent first):
31
32 $Log: GenLinkedList.h,v $
33 Revision 1.2 2004/02/05 07:41:08 cheshire
34 Add Log header
35
36 */
37
38 #ifndef __GenLinkedList__
39 #define __GenLinkedList__
40
41
42 #include <stddef.h>
43
44
45 struct GenLinkedList
46 {
47 void *Head,
48 *Tail;
49 size_t LinkOffset;
50 };
51 typedef struct GenLinkedList GenLinkedList;
52
53
54 void InitLinkedList( GenLinkedList *pList, size_t linkOffset);
55
56 void AddToHead( GenLinkedList *pList, void *elem);
57 void AddToTail( GenLinkedList *pList, void *elem);
58
59 int RemoveFromList( GenLinkedList *pList, void *elem);
60
61 int ReplaceElem( GenLinkedList *pList, void *elemInList, void *newElem);
62
63
64
65 struct GenDoubleLinkedList
66 {
67 void *Head,
68 *Tail;
69 size_t FwdLinkOffset,
70 BackLinkOffset;
71 };
72 typedef struct GenDoubleLinkedList GenDoubleLinkedList;
73
74
75 void InitDoubleLinkedList( GenDoubleLinkedList *pList, size_t fwdLinkOffset,
76 size_t backLinkOffset);
77
78 void DLLAddToHead( GenDoubleLinkedList *pList, void *elem);
79
80 void DLLRemoveFromList( GenDoubleLinkedList *pList, void *elem);
81
82
83
84 /* A GenLinkedOffsetList is like a GenLinkedList that stores the *Next field as a signed */
85 /* offset from the address of the beginning of the element, rather than as a pointer. */
86
87 struct GenLinkedOffsetList
88 {
89 size_t Head,
90 Tail;
91 size_t LinkOffset;
92 };
93 typedef struct GenLinkedOffsetList GenLinkedOffsetList;
94
95
96 void InitLinkedOffsetList( GenLinkedOffsetList *pList, size_t linkOffset);
97
98 void *GetHeadPtr( GenLinkedOffsetList *pList);
99 void *GetTailPtr( GenLinkedOffsetList *pList);
100 void *GetOffsetLink( GenLinkedOffsetList *pList, void *elem);
101
102 void OffsetAddToHead( GenLinkedOffsetList *pList, void *elem);
103 void OffsetAddToTail( GenLinkedOffsetList *pList, void *elem);
104
105 int OffsetRemoveFromList( GenLinkedOffsetList *pList, void *elem);
106
107 int OffsetReplaceElem( GenLinkedOffsetList *pList, void *elemInList, void *newElem);
108
109
110 #endif // __GenLinkedList__