rdatasetiter.c revision 7d32c065c7bb56f281651ae3dd2888f32ce4f1d9
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Copyright (C) 1999, 2000 Internet Software Consortium.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Permission to use, copy, modify, and distribute this software for any
f808c858fa61e7769218966759510a8b1190dfcfraf * purpose with or without fee is hereby granted, provided that the above
f808c858fa61e7769218966759510a8b1190dfcfraf * copyright notice and this permission notice appear in all copies.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
fa9e4066f08beec538e775443c5be79dd423fcabahrens * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
fa9e4066f08beec538e775443c5be79dd423fcabahrens * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
fa9e4066f08beec538e775443c5be79dd423fcabahrens * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
fa9e4066f08beec538e775443c5be79dd423fcabahrens * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
fa9e4066f08beec538e775443c5be79dd423fcabahrens * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
fa9e4066f08beec538e775443c5be79dd423fcabahrens * SOFTWARE.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <config.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <stddef.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens
3c112a2b34403220c06c3e2fcac403358cfba168Eric Taylor#include <isc/assertions.h>
f83b46baf98d276f5f84fa84c8b461f412ac1f5ePaul Dagnelie
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <dns/rdataset.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <dns/rdatasetiter.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrensvoid
fa9e4066f08beec538e775443c5be79dd423fcabahrensdns_rdatasetiter_destroy(dns_rdatasetiter_t **iteratorp) {
088e9d477eee66081e407fbc5a33c4da25f66f6aeschrock /*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Destroy '*iteratorp'.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
be6fd75a69ae679453d9cda5bff3326111e6d1caMatthew Ahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens REQUIRE(iteratorp != NULL);
3c112a2b34403220c06c3e2fcac403358cfba168Eric Taylor REQUIRE(DNS_RDATASETITER_VALID(*iteratorp));
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens (*iteratorp)->methods->destroy(iteratorp);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens ENSURE(*iteratorp == NULL);
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
088e9d477eee66081e407fbc5a33c4da25f66f6aeschrock
fa9e4066f08beec538e775443c5be79dd423fcabahrensisc_result_t
fa9e4066f08beec538e775443c5be79dd423fcabahrensdns_rdatasetiter_first(dns_rdatasetiter_t *iterator) {
3c112a2b34403220c06c3e2fcac403358cfba168Eric Taylor /*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Move the rdataset cursor to the first rdataset at the node (if any).
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
f808c858fa61e7769218966759510a8b1190dfcfraf
f808c858fa61e7769218966759510a8b1190dfcfraf REQUIRE(DNS_RDATASETITER_VALID(iterator));
f808c858fa61e7769218966759510a8b1190dfcfraf
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (iterator->methods->first(iterator));
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrensisc_result_t
fa9e4066f08beec538e775443c5be79dd423fcabahrensdns_rdatasetiter_next(dns_rdatasetiter_t *iterator) {
ecd6cf800b63704be73fb264c3f5b6e0dafc068dmarks /*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Move the rdataset cursor to the next rdataset at the node (if any).
be6fd75a69ae679453d9cda5bff3326111e6d1caMatthew Ahrens */
b6805bf78d2bbbeeaea8909a05623587b42d58b3Gordon Ross
be6fd75a69ae679453d9cda5bff3326111e6d1caMatthew Ahrens REQUIRE(DNS_RDATASETITER_VALID(iterator));
fa9e4066f08beec538e775443c5be79dd423fcabahrens
be6fd75a69ae679453d9cda5bff3326111e6d1caMatthew Ahrens return (iterator->methods->next(iterator));
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrensvoid
fa9e4066f08beec538e775443c5be79dd423fcabahrensdns_rdatasetiter_current(dns_rdatasetiter_t *iterator,
fa9e4066f08beec538e775443c5be79dd423fcabahrens dns_rdataset_t *rdataset)
fb09f5aad449c97fe309678f3f604982b563a96fMadhav Suresh{
3c112a2b34403220c06c3e2fcac403358cfba168Eric Taylor /*
fb09f5aad449c97fe309678f3f604982b563a96fMadhav Suresh * Return the current rdataset.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe REQUIRE(DNS_RDATASETITER_VALID(iterator));
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe REQUIRE(DNS_RDATASET_VALID(rdataset));
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe REQUIRE(rdataset->methods == NULL);
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe iterator->methods->current(iterator, rdataset);
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe}
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe