Merge from vendor branch GROFF:
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / dns / include / dns / rdatasetiter.h
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1999-2001  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* $Id: rdatasetiter.h,v 1.14.2.1 2004/03/09 06:11:20 marka Exp $ */
19
20 #ifndef DNS_RDATASETITER_H
21 #define DNS_RDATASETITER_H 1
22
23 /*****
24  ***** Module Info
25  *****/
26
27 /*
28  * DNS Rdataset Iterator
29  *
30  * The DNS Rdataset Iterator interface allows iteration of all of the
31  * rdatasets at a node.
32  *
33  * The dns_rdatasetiter_t type is like a "virtual class".  To actually use
34  * it, an implementation of the class is required.  This implementation is
35  * supplied by the database.
36  *
37  * It is the client's responsibility to call dns_rdataset_disassociate()
38  * on all rdatasets returned.
39  *
40  * XXX <more> XXX
41  *
42  * MP:
43  *      The iterator itself is not locked.  The caller must ensure
44  *      synchronization.
45  *
46  *      The iterator methods ensure appropriate database locking.
47  *
48  * Reliability:
49  *      No anticipated impact.
50  *
51  * Resources:
52  *      <TBS>
53  *
54  * Security:
55  *      No anticipated impact.
56  *
57  * Standards:
58  *      None.
59  */
60
61 /*****
62  ***** Imports
63  *****/
64
65 #include <isc/lang.h>
66 #include <isc/magic.h>
67 #include <isc/stdtime.h>
68
69 #include <dns/types.h>
70
71 ISC_LANG_BEGINDECLS
72
73 /*****
74  ***** Types
75  *****/
76
77 typedef struct dns_rdatasetitermethods {
78         void            (*destroy)(dns_rdatasetiter_t **iteratorp);
79         isc_result_t    (*first)(dns_rdatasetiter_t *iterator);
80         isc_result_t    (*next)(dns_rdatasetiter_t *iterator);
81         void            (*current)(dns_rdatasetiter_t *iterator,
82                                    dns_rdataset_t *rdataset);
83 } dns_rdatasetitermethods_t;
84
85 #define DNS_RDATASETITER_MAGIC       ISC_MAGIC('D','N','S','i')
86 #define DNS_RDATASETITER_VALID(i)    ISC_MAGIC_VALID(i, DNS_RDATASETITER_MAGIC)
87
88 /*
89  * This structure is actually just the common prefix of a DNS db
90  * implementation's version of a dns_rdatasetiter_t.
91  *
92  * Direct use of this structure by clients is forbidden.  DB implementations
93  * may change the structure.  'magic' must be DNS_RDATASETITER_MAGIC for
94  * any of the dns_rdatasetiter routines to work.  DB implementations must
95  * maintain all DB rdataset iterator invariants.
96  */
97 struct dns_rdatasetiter {
98         /* Unlocked. */
99         unsigned int                    magic;
100         dns_rdatasetitermethods_t *     methods;
101         dns_db_t *                      db;
102         dns_dbnode_t *                  node;
103         dns_dbversion_t *               version;
104         isc_stdtime_t                   now;
105 };
106
107 void
108 dns_rdatasetiter_destroy(dns_rdatasetiter_t **iteratorp);
109 /*
110  * Destroy '*iteratorp'.
111  *
112  * Requires:
113  *
114  *      '*iteratorp' is a valid iterator.
115  *
116  * Ensures:
117  *
118  *      All resources used by the iterator are freed.
119  *
120  *      *iteratorp == NULL.
121  */
122
123 isc_result_t
124 dns_rdatasetiter_first(dns_rdatasetiter_t *iterator);
125 /*
126  * Move the rdataset cursor to the first rdataset at the node (if any).
127  *
128  * Requires:
129  *      'iterator' is a valid iterator.
130  *
131  * Returns:
132  *      ISC_R_SUCCESS
133  *      ISC_R_NOMORE                    There are no rdatasets at the node.
134  *
135  *      Other results are possible, depending on the DB implementation.
136  */
137
138 isc_result_t
139 dns_rdatasetiter_next(dns_rdatasetiter_t *iterator);
140 /*
141  * Move the rdataset cursor to the next rdataset at the node (if any).
142  *
143  * Requires:
144  *      'iterator' is a valid iterator.
145  *
146  * Returns:
147  *      ISC_R_SUCCESS
148  *      ISC_R_NOMORE                    There are no more rdatasets at the
149  *                                      node.
150  *
151  *      Other results are possible, depending on the DB implementation.
152  */
153
154 void
155 dns_rdatasetiter_current(dns_rdatasetiter_t *iterator,
156                          dns_rdataset_t *rdataset);
157 /*
158  * Return the current rdataset.
159  *
160  * Requires:
161  *      'iterator' is a valid iterator.
162  *
163  *      'rdataset' is a valid, disassociated rdataset.
164  *
165  *      The rdataset cursor of 'iterator' is at a valid location (i.e. the
166  *      result of last call to a cursor movement command was ISC_R_SUCCESS).
167  */
168
169 ISC_LANG_ENDDECLS
170
171 #endif /* DNS_RDATASETITER_H */