Add BIND 9.2.4rc7.
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / dns / include / dns / rdatasetiter.h
blobc50246c0a03cda8f04ecb3bcdb485f3cc866d748
1 /*
2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2001 Internet Software Consortium.
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.
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.
18 /* $Id: rdatasetiter.h,v 1.14.2.1 2004/03/09 06:11:20 marka Exp $ */
20 #ifndef DNS_RDATASETITER_H
21 #define DNS_RDATASETITER_H 1
23 /*****
24 ***** Module Info
25 *****/
28 * DNS Rdataset Iterator
30 * The DNS Rdataset Iterator interface allows iteration of all of the
31 * rdatasets at a node.
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.
37 * It is the client's responsibility to call dns_rdataset_disassociate()
38 * on all rdatasets returned.
40 * XXX <more> XXX
42 * MP:
43 * The iterator itself is not locked. The caller must ensure
44 * synchronization.
46 * The iterator methods ensure appropriate database locking.
48 * Reliability:
49 * No anticipated impact.
51 * Resources:
52 * <TBS>
54 * Security:
55 * No anticipated impact.
57 * Standards:
58 * None.
61 /*****
62 ***** Imports
63 *****/
65 #include <isc/lang.h>
66 #include <isc/magic.h>
67 #include <isc/stdtime.h>
69 #include <dns/types.h>
71 ISC_LANG_BEGINDECLS
73 /*****
74 ***** Types
75 *****/
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;
85 #define DNS_RDATASETITER_MAGIC ISC_MAGIC('D','N','S','i')
86 #define DNS_RDATASETITER_VALID(i) ISC_MAGIC_VALID(i, DNS_RDATASETITER_MAGIC)
89 * This structure is actually just the common prefix of a DNS db
90 * implementation's version of a dns_rdatasetiter_t.
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.
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;
107 void
108 dns_rdatasetiter_destroy(dns_rdatasetiter_t **iteratorp);
110 * Destroy '*iteratorp'.
112 * Requires:
114 * '*iteratorp' is a valid iterator.
116 * Ensures:
118 * All resources used by the iterator are freed.
120 * *iteratorp == NULL.
123 isc_result_t
124 dns_rdatasetiter_first(dns_rdatasetiter_t *iterator);
126 * Move the rdataset cursor to the first rdataset at the node (if any).
128 * Requires:
129 * 'iterator' is a valid iterator.
131 * Returns:
132 * ISC_R_SUCCESS
133 * ISC_R_NOMORE There are no rdatasets at the node.
135 * Other results are possible, depending on the DB implementation.
138 isc_result_t
139 dns_rdatasetiter_next(dns_rdatasetiter_t *iterator);
141 * Move the rdataset cursor to the next rdataset at the node (if any).
143 * Requires:
144 * 'iterator' is a valid iterator.
146 * Returns:
147 * ISC_R_SUCCESS
148 * ISC_R_NOMORE There are no more rdatasets at the
149 * node.
151 * Other results are possible, depending on the DB implementation.
154 void
155 dns_rdatasetiter_current(dns_rdatasetiter_t *iterator,
156 dns_rdataset_t *rdataset);
158 * Return the current rdataset.
160 * Requires:
161 * 'iterator' is a valid iterator.
163 * 'rdataset' is a valid, disassociated rdataset.
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).
169 ISC_LANG_ENDDECLS
171 #endif /* DNS_RDATASETITER_H */