1 | /* |
---|
2 | * bltChain.h -- |
---|
3 | * |
---|
4 | * Copyright 1993-2000 Lucent Technologies, Inc. |
---|
5 | * |
---|
6 | * Permission to use, copy, modify, and distribute this software and |
---|
7 | * its documentation for any purpose and without fee is hereby |
---|
8 | * granted, provided that the above copyright notice appear in all |
---|
9 | * copies and that both that the copyright notice and warranty |
---|
10 | * disclaimer appear in supporting documentation, and that the names |
---|
11 | * of Lucent Technologies any of their entities not be used in |
---|
12 | * advertising or publicity pertaining to distribution of the software |
---|
13 | * without specific, written prior permission. |
---|
14 | * |
---|
15 | * Lucent Technologies disclaims all warranties with regard to this |
---|
16 | * software, including all implied warranties of merchantability and |
---|
17 | * fitness. In no event shall Lucent Technologies be liable for any |
---|
18 | * special, indirect or consequential damages or any damages |
---|
19 | * whatsoever resulting from loss of use, data or profits, whether in |
---|
20 | * an action of contract, negligence or other tortuous action, arising |
---|
21 | * out of or in connection with the use or performance of this |
---|
22 | * software. |
---|
23 | */ |
---|
24 | #ifndef _RP_CHAIN_H |
---|
25 | #define _RP_CHAIN_H |
---|
26 | |
---|
27 | #ifdef __cplusplus |
---|
28 | extern "C" { |
---|
29 | #endif |
---|
30 | |
---|
31 | typedef struct Rp_ChainLinkStruct Rp_ChainLink; |
---|
32 | |
---|
33 | /* |
---|
34 | * A Rp_ChainLink is the container structure for the Rp_Chain. |
---|
35 | */ |
---|
36 | |
---|
37 | struct Rp_ChainLinkStruct { |
---|
38 | Rp_ChainLink *prevPtr; /* Link to the previous link */ |
---|
39 | Rp_ChainLink *nextPtr; /* Link to the next link */ |
---|
40 | ClientData clientData; /* Pointer to the data object */ |
---|
41 | }; |
---|
42 | |
---|
43 | typedef int (Rp_ChainCompareProc) _ANSI_ARGS_((Rp_ChainLink **l1PtrPtr, |
---|
44 | Rp_ChainLink **l2PtrPtr)); |
---|
45 | |
---|
46 | /* |
---|
47 | * A Rp_Chain is a doubly chained list structure. |
---|
48 | */ |
---|
49 | typedef struct { |
---|
50 | Rp_ChainLink *headPtr; /* Pointer to first element in chain */ |
---|
51 | Rp_ChainLink *tailPtr; /* Pointer to last element in chain */ |
---|
52 | int nLinks; /* Number of elements in chain */ |
---|
53 | } Rp_Chain; |
---|
54 | |
---|
55 | extern void Rp_ChainInit _ANSI_ARGS_((Rp_Chain * chainPtr)); |
---|
56 | extern Rp_Chain *Rp_ChainCreate _ANSI_ARGS_(()); |
---|
57 | extern void Rp_ChainDestroy _ANSI_ARGS_((Rp_Chain * chainPtr)); |
---|
58 | extern Rp_ChainLink *Rp_ChainNewLink _ANSI_ARGS_((void)); |
---|
59 | extern Rp_ChainLink *Rp_ChainAllocLink _ANSI_ARGS_((unsigned int extraSize)); |
---|
60 | extern Rp_ChainLink *Rp_ChainAppend _ANSI_ARGS_((Rp_Chain * chainPtr, |
---|
61 | ClientData clientData)); |
---|
62 | extern Rp_ChainLink *Rp_ChainPrepend _ANSI_ARGS_((Rp_Chain * chainPtr, |
---|
63 | ClientData clientData)); |
---|
64 | extern void Rp_ChainReset _ANSI_ARGS_((Rp_Chain * chainPtr)); |
---|
65 | extern void Rp_ChainLinkAfter _ANSI_ARGS_((Rp_Chain * chainPtr, |
---|
66 | Rp_ChainLink * linkPtr, Rp_ChainLink * afterLinkPtr)); |
---|
67 | extern void Rp_ChainLinkBefore _ANSI_ARGS_((Rp_Chain * chainPtr, |
---|
68 | Rp_ChainLink * linkPtr, Rp_ChainLink * beforeLinkPtr)); |
---|
69 | extern void Rp_ChainUnlinkLink _ANSI_ARGS_((Rp_Chain * chainPtr, |
---|
70 | Rp_ChainLink * linkPtr)); |
---|
71 | extern void Rp_ChainDeleteLink _ANSI_ARGS_((Rp_Chain * chainPtr, |
---|
72 | Rp_ChainLink * linkPtr)); |
---|
73 | extern Rp_ChainLink *Rp_ChainGetNthLink _ANSI_ARGS_((Rp_Chain * chainPtr, int n)); |
---|
74 | extern void Rp_ChainSort _ANSI_ARGS_((Rp_Chain * chainPtr, |
---|
75 | Rp_ChainCompareProc * proc)); |
---|
76 | |
---|
77 | #define Rp_ChainGetLength(c) (((c) == NULL) ? 0 : (c)->nLinks) |
---|
78 | #define Rp_ChainFirstLink(c) (((c) == NULL) ? NULL : (c)->headPtr) |
---|
79 | #define Rp_ChainLastLink(c) (((c) == NULL) ? NULL : (c)->tailPtr) |
---|
80 | #define Rp_ChainPrevLink(l) ((l)->prevPtr) |
---|
81 | #define Rp_ChainNextLink(l) ((l)->nextPtr) |
---|
82 | #define Rp_ChainGetValue(l) ((l)->clientData) |
---|
83 | #define Rp_ChainSetValue(l, value) ((l)->clientData = (ClientData)(value)) |
---|
84 | #define Rp_ChainAppendLink(c, l) \ |
---|
85 | (Rp_ChainLinkBefore((c), (l), (Rp_ChainLink *)NULL)) |
---|
86 | #define Rp_ChainPrependLink(c, l) \ |
---|
87 | (Rp_ChainLinkAfter((c), (l), (Rp_ChainLink *)NULL)) |
---|
88 | |
---|
89 | #ifdef __cplusplus |
---|
90 | } |
---|
91 | #endif |
---|
92 | |
---|
93 | #endif /* _RP_CHAIN_H */ |
---|