4 * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 1999-2001 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 /* Id: dbiterator.c,v 1.18 2007/06/19 23:47:16 tbox Exp */
28 #include <dns/dbiterator.h>
32 dns_dbiterator_destroy(dns_dbiterator_t
**iteratorp
) {
34 * Destroy '*iteratorp'.
37 REQUIRE(iteratorp
!= NULL
);
38 REQUIRE(DNS_DBITERATOR_VALID(*iteratorp
));
40 (*iteratorp
)->methods
->destroy(iteratorp
);
42 ENSURE(*iteratorp
== NULL
);
46 dns_dbiterator_first(dns_dbiterator_t
*iterator
) {
48 * Move the node cursor to the first node in the database (if any).
51 REQUIRE(DNS_DBITERATOR_VALID(iterator
));
53 return (iterator
->methods
->first(iterator
));
57 dns_dbiterator_last(dns_dbiterator_t
*iterator
) {
59 * Move the node cursor to the first node in the database (if any).
62 REQUIRE(DNS_DBITERATOR_VALID(iterator
));
64 return (iterator
->methods
->last(iterator
));
68 dns_dbiterator_seek(dns_dbiterator_t
*iterator
, dns_name_t
*name
) {
70 * Move the node cursor to the node with name 'name'.
73 REQUIRE(DNS_DBITERATOR_VALID(iterator
));
75 return (iterator
->methods
->seek(iterator
, name
));
79 dns_dbiterator_prev(dns_dbiterator_t
*iterator
) {
81 * Move the node cursor to the previous node in the database (if any).
84 REQUIRE(DNS_DBITERATOR_VALID(iterator
));
86 return (iterator
->methods
->prev(iterator
));
90 dns_dbiterator_next(dns_dbiterator_t
*iterator
) {
92 * Move the node cursor to the next node in the database (if any).
95 REQUIRE(DNS_DBITERATOR_VALID(iterator
));
97 return (iterator
->methods
->next(iterator
));
101 dns_dbiterator_current(dns_dbiterator_t
*iterator
, dns_dbnode_t
**nodep
,
105 * Return the current node.
108 REQUIRE(DNS_DBITERATOR_VALID(iterator
));
109 REQUIRE(nodep
!= NULL
&& *nodep
== NULL
);
110 REQUIRE(name
== NULL
|| dns_name_hasbuffer(name
));
112 return (iterator
->methods
->current(iterator
, nodep
, name
));
116 dns_dbiterator_pause(dns_dbiterator_t
*iterator
) {
121 REQUIRE(DNS_DBITERATOR_VALID(iterator
));
123 return (iterator
->methods
->pause(iterator
));
127 dns_dbiterator_origin(dns_dbiterator_t
*iterator
, dns_name_t
*name
) {
130 * Return the origin to which returned node names are relative.
133 REQUIRE(DNS_DBITERATOR_VALID(iterator
));
134 REQUIRE(iterator
->relative_names
);
135 REQUIRE(dns_name_hasbuffer(name
));
137 return (iterator
->methods
->origin(iterator
, name
));
141 dns_dbiterator_setcleanmode(dns_dbiterator_t
*iterator
, isc_boolean_t mode
) {
142 REQUIRE(DNS_DBITERATOR_VALID(iterator
));
144 iterator
->cleaning
= mode
;