3 #ifndef _RING_H_INCLUDED_
4 #define _RING_H_INCLUDED_
10 /* circular list management
19 typedef struct RING RING
;
22 RING
*succ
; /* successor */
23 RING
*pred
; /* predecessor */
26 extern void ring_init(RING
*);
27 extern void ring_prepend(RING
*, RING
*);
28 extern void ring_append(RING
*, RING
*);
29 extern void ring_detach(RING
*);
31 #define ring_succ(c) ((c)->succ)
32 #define ring_pred(c) ((c)->pred)
34 #define RING_FOREACH(entry, head) \
35 for (entry = ring_succ(head); entry != (head); entry = ring_succ(entry))
38 * Typically, an application will embed a RING structure into a larger
39 * structure that also contains application-specific members. This approach
40 * gives us the best of both worlds. The application can still use the
41 * generic RING primitives for manipulating RING structures. The macro below
42 * transforms a pointer from RING structure to the structure that contains
45 #define RING_TO_APPL(ring_ptr,app_type,ring_member) \
46 ((app_type *) (((char *) (ring_ptr)) - offsetof(app_type,ring_member)))
51 /* The Secure Mailer license must be distributed with this software.
54 /* IBM T.J. Watson Research
56 /* Yorktown Heights, NY 10598, USA
58 /* Tue Jan 28 16:50:20 EST 1997