]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSShared/GenLinkedList.h
mDNSResponder-214.3.2.tar.gz
[apple/mdnsresponder.git] / mDNSShared / GenLinkedList.h
1 /* -*- Mode: C; tab-width: 4 -*-
2 *
3 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16
17 File: GenLinkedList.c
18
19 Contains: interface to generic linked lists.
20
21 Version: 1.0
22 Tabs: 4 spaces
23
24 Change History (most recent first):
25
26 $Log: GenLinkedList.h,v $
27 Revision 1.3 2006/08/14 23:24:56 cheshire
28 Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
29
30 Revision 1.2 2004/02/05 07:41:08 cheshire
31 Add Log header
32
33 */
34
35 #ifndef __GenLinkedList__
36 #define __GenLinkedList__
37
38
39 #include <stddef.h>
40
41
42 struct GenLinkedList
43 {
44 void *Head,
45 *Tail;
46 size_t LinkOffset;
47 };
48 typedef struct GenLinkedList GenLinkedList;
49
50
51 void InitLinkedList( GenLinkedList *pList, size_t linkOffset);
52
53 void AddToHead( GenLinkedList *pList, void *elem);
54 void AddToTail( GenLinkedList *pList, void *elem);
55
56 int RemoveFromList( GenLinkedList *pList, void *elem);
57
58 int ReplaceElem( GenLinkedList *pList, void *elemInList, void *newElem);
59
60
61
62 struct GenDoubleLinkedList
63 {
64 void *Head,
65 *Tail;
66 size_t FwdLinkOffset,
67 BackLinkOffset;
68 };
69 typedef struct GenDoubleLinkedList GenDoubleLinkedList;
70
71
72 void InitDoubleLinkedList( GenDoubleLinkedList *pList, size_t fwdLinkOffset,
73 size_t backLinkOffset);
74
75 void DLLAddToHead( GenDoubleLinkedList *pList, void *elem);
76
77 void DLLRemoveFromList( GenDoubleLinkedList *pList, void *elem);
78
79
80
81 /* A GenLinkedOffsetList is like a GenLinkedList that stores the *Next field as a signed */
82 /* offset from the address of the beginning of the element, rather than as a pointer. */
83
84 struct GenLinkedOffsetList
85 {
86 size_t Head,
87 Tail;
88 size_t LinkOffset;
89 };
90 typedef struct GenLinkedOffsetList GenLinkedOffsetList;
91
92
93 void InitLinkedOffsetList( GenLinkedOffsetList *pList, size_t linkOffset);
94
95 void *GetHeadPtr( GenLinkedOffsetList *pList);
96 void *GetTailPtr( GenLinkedOffsetList *pList);
97 void *GetOffsetLink( GenLinkedOffsetList *pList, void *elem);
98
99 void OffsetAddToHead( GenLinkedOffsetList *pList, void *elem);
100 void OffsetAddToTail( GenLinkedOffsetList *pList, void *elem);
101
102 int OffsetRemoveFromList( GenLinkedOffsetList *pList, void *elem);
103
104 int OffsetReplaceElem( GenLinkedOffsetList *pList, void *elemInList, void *newElem);
105
106
107 #endif // __GenLinkedList__