Sync usage with man page.
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / util / ring.h
blob785101bea6292fbfa163af69ad2617b6fb8ae16f
1 /* $NetBSD$ */
3 #ifndef _RING_H_INCLUDED_
4 #define _RING_H_INCLUDED_
6 /*++
7 /* NAME
8 /* ring 3h
9 /* SUMMARY
10 /* circular list management
11 /* SYNOPSIS
12 /* #include <ring.h>
13 /* DESCRIPTION
14 /* .nf
17 * External interface.
19 typedef struct RING RING;
21 struct 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
43 * it.
45 #define RING_TO_APPL(ring_ptr,app_type,ring_member) \
46 ((app_type *) (((char *) (ring_ptr)) - offsetof(app_type,ring_member)))
48 /* LICENSE
49 /* .ad
50 /* .fi
51 /* The Secure Mailer license must be distributed with this software.
52 /* AUTHOR(S)
53 /* Wietse Venema
54 /* IBM T.J. Watson Research
55 /* P.O. Box 704
56 /* Yorktown Heights, NY 10598, USA
57 /* LAST MODIFICATION
58 /* Tue Jan 28 16:50:20 EST 1997
59 /*--*/
61 #endif