dbiterator.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004, 2005, 2007  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 1999-2001  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and/or distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00010  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00011  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00012  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00013  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00014  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00015  * PERFORMANCE OF THIS SOFTWARE.
00016  */
00017 
00018 /* $Id: dbiterator.c,v 1.18 2007/06/19 23:47:16 tbox Exp $ */
00019 
00020 /*! \file */
00021 
00022 #include <config.h>
00023 
00024 #include <isc/util.h>
00025 
00026 #include <dns/dbiterator.h>
00027 #include <dns/name.h>
00028 
00029 void
00030 dns_dbiterator_destroy(dns_dbiterator_t **iteratorp) {
00031         /*
00032          * Destroy '*iteratorp'.
00033          */
00034 
00035         REQUIRE(iteratorp != NULL);
00036         REQUIRE(DNS_DBITERATOR_VALID(*iteratorp));
00037 
00038         (*iteratorp)->methods->destroy(iteratorp);
00039 
00040         ENSURE(*iteratorp == NULL);
00041 }
00042 
00043 isc_result_t
00044 dns_dbiterator_first(dns_dbiterator_t *iterator) {
00045         /*
00046          * Move the node cursor to the first node in the database (if any).
00047          */
00048 
00049         REQUIRE(DNS_DBITERATOR_VALID(iterator));
00050 
00051         return (iterator->methods->first(iterator));
00052 }
00053 
00054 isc_result_t
00055 dns_dbiterator_last(dns_dbiterator_t *iterator) {
00056         /*
00057          * Move the node cursor to the first node in the database (if any).
00058          */
00059 
00060         REQUIRE(DNS_DBITERATOR_VALID(iterator));
00061 
00062         return (iterator->methods->last(iterator));
00063 }
00064 
00065 isc_result_t
00066 dns_dbiterator_seek(dns_dbiterator_t *iterator, dns_name_t *name) {
00067         /*
00068          * Move the node cursor to the node with name 'name'.
00069          */
00070 
00071         REQUIRE(DNS_DBITERATOR_VALID(iterator));
00072 
00073         return (iterator->methods->seek(iterator, name));
00074 }
00075 
00076 isc_result_t
00077 dns_dbiterator_prev(dns_dbiterator_t *iterator) {
00078         /*
00079          * Move the node cursor to the previous node in the database (if any).
00080          */
00081 
00082         REQUIRE(DNS_DBITERATOR_VALID(iterator));
00083 
00084         return (iterator->methods->prev(iterator));
00085 }
00086 
00087 isc_result_t
00088 dns_dbiterator_next(dns_dbiterator_t *iterator) {
00089         /*
00090          * Move the node cursor to the next node in the database (if any).
00091          */
00092 
00093         REQUIRE(DNS_DBITERATOR_VALID(iterator));
00094 
00095         return (iterator->methods->next(iterator));
00096 }
00097 
00098 isc_result_t
00099 dns_dbiterator_current(dns_dbiterator_t *iterator, dns_dbnode_t **nodep,
00100                        dns_name_t *name)
00101 {
00102         /*
00103          * Return the current node.
00104          */
00105 
00106         REQUIRE(DNS_DBITERATOR_VALID(iterator));
00107         REQUIRE(nodep != NULL && *nodep == NULL);
00108         REQUIRE(name == NULL || dns_name_hasbuffer(name));
00109 
00110         return (iterator->methods->current(iterator, nodep, name));
00111 }
00112 
00113 isc_result_t
00114 dns_dbiterator_pause(dns_dbiterator_t *iterator) {
00115         /*
00116          * Pause iteration.
00117          */
00118 
00119         REQUIRE(DNS_DBITERATOR_VALID(iterator));
00120 
00121         return (iterator->methods->pause(iterator));
00122 }
00123 
00124 isc_result_t
00125 dns_dbiterator_origin(dns_dbiterator_t *iterator, dns_name_t *name) {
00126 
00127         /*
00128          * Return the origin to which returned node names are relative.
00129          */
00130 
00131         REQUIRE(DNS_DBITERATOR_VALID(iterator));
00132         REQUIRE(iterator->relative_names);
00133         REQUIRE(dns_name_hasbuffer(name));
00134 
00135         return (iterator->methods->origin(iterator, name));
00136 }
00137 
00138 void
00139 dns_dbiterator_setcleanmode(dns_dbiterator_t *iterator, isc_boolean_t mode) {
00140         REQUIRE(DNS_DBITERATOR_VALID(iterator));
00141 
00142         iterator->cleaning = mode;
00143 }

Generated on Tue Apr 28 17:40:56 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha