2 * Copyright (C) 2009, 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 * PERFORMANCE OF THIS SOFTWARE.
19 #ifndef DNS_RRITERATOR_H
20 #define DNS_RRITERATOR_H 1
26 /*! \file dns/rriterator.h
28 * Functions for "walking" a zone database, visiting each RR or RRset in turn.
36 #include <isc/magic.h>
37 #include <isc/ondestroy.h>
38 #include <isc/stdtime.h>
41 #include <dns/dbiterator.h>
42 #include <dns/fixedname.h>
44 #include <dns/rdata.h>
45 #include <dns/rdataset.h>
46 #include <dns/rdatasetiter.h>
47 #include <dns/types.h>
56 * A dns_rriterator_t is an iterator that iterates over an entire database,
57 * returning one RR at a time, in some arbitrary order.
60 typedef struct dns_rriterator {
64 dns_dbiterator_t *dbit;
68 dns_fixedname_t fixedname;
69 dns_rdatasetiter_t *rdatasetit;
70 dns_rdataset_t rdataset;
74 #define RRITERATOR_MAGIC ISC_MAGIC('R', 'R', 'I', 't')
75 #define VALID_RRITERATOR(m) ISC_MAGIC_VALID(m, RRITERATOR_MAGIC)
78 dns_rriterator_init(dns_rriterator_t *it, dns_db_t *db,
79 dns_dbversion_t *ver, isc_stdtime_t now);
81 * Initialize an rriterator; sets the cursor to the origin node
86 * \li 'db' is a valid database.
95 dns_rriterator_first(dns_rriterator_t *it);
97 * Move the rriterator cursor to the first rdata in the database.
100 *\li 'it' is a valid, initialized rriterator
104 *\li #ISC_R_NOMORE There are no rdata in the set.
108 dns_rriterator_nextrrset(dns_rriterator_t *it);
110 * Move the rriterator cursor to the next rrset in the database,
111 * skipping over any remaining records that have the same rdatatype
112 * as the current one.
115 *\li 'it' is a valid, initialized rriterator
119 *\li #ISC_R_NOMORE No more rrsets in the database
123 dns_rriterator_next(dns_rriterator_t *it);
125 * Move the rriterator cursor to the next rrset in the database,
126 * skipping over any remaining records that have the same rdatatype
127 * as the current one.
130 *\li 'it' is a valid, initialized rriterator
134 *\li #ISC_R_NOMORE No more records in the database
138 dns_rriterator_current(dns_rriterator_t *it, dns_name_t **name,
139 isc_uint32_t *ttl, dns_rdataset_t **rdataset,
140 dns_rdata_t **rdata);
142 * Make '*name' refer to the current name. If 'rdataset' is not NULL,
143 * make '*rdataset' refer to the current * rdataset. If '*rdata' is not
144 * NULL, make '*rdata' refer to the current record.
147 *\li '*name' is a valid name object
148 *\li 'rdataset' is NULL or '*rdataset' is NULL
149 *\li 'rdata' is NULL or '*rdata' is NULL
152 *\li 'rdata' refers to the rdata at the rdata cursor location of
157 dns_rriterator_pause(dns_rriterator_t *it);
159 * Pause rriterator. Frees any locks held by the database iterator.
160 * Callers should use this routine any time they are not going to
161 * execute another rriterator method in the immediate future.
164 *\li 'it' is a valid iterator.
167 *\li Any database locks being held for efficiency of iterator access are
172 dns_rriterator_destroy(dns_rriterator_t *it);
174 * Shut down and free resources in rriterator 'it'.
178 *\li 'it' is a valid iterator.
182 *\li All resources used by the rriterator are freed.
187 #endif /* DNS_RRITERATOR_H */