rriterator.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009, 2011  Internet Systems Consortium, Inc. ("ISC")
00003  *
00004  * Permission to use, copy, modify, and/or distribute this software for any
00005  * purpose with or without fee is hereby granted, provided that the above
00006  * copyright notice and this permission notice appear in all copies.
00007  *
00008  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00009  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00010  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00011  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00012  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00013  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00014  * PERFORMANCE OF THIS SOFTWARE.
00015  */
00016 
00017 /* $Id: rriterator.h,v 1.4 2011/11/01 23:47:00 tbox Exp $ */
00018 
00019 #ifndef DNS_RRITERATOR_H
00020 #define DNS_RRITERATOR_H 1
00021 
00022 /*****
00023  ***** Module Info
00024  *****/
00025 
00026 /*! \file dns/rriterator.h
00027  * \brief
00028  * Functions for "walking" a zone database, visiting each RR or RRset in turn.
00029  */
00030 
00031 /*****
00032  ***** Imports
00033  *****/
00034 
00035 #include <isc/lang.h>
00036 #include <isc/magic.h>
00037 #include <isc/ondestroy.h>
00038 #include <isc/stdtime.h>
00039 
00040 #include <dns/db.h>
00041 #include <dns/dbiterator.h>
00042 #include <dns/fixedname.h>
00043 #include <dns/name.h>
00044 #include <dns/rdata.h>
00045 #include <dns/rdataset.h>
00046 #include <dns/rdatasetiter.h>
00047 #include <dns/types.h>
00048 
00049 ISC_LANG_BEGINDECLS
00050 
00051 /*****
00052  ***** Types
00053  *****/
00054 
00055 /*%
00056  * A dns_rriterator_t is an iterator that iterates over an entire database,
00057  * returning one RR at a time, in some arbitrary order.
00058  */
00059 
00060 typedef struct dns_rriterator {
00061         unsigned int            magic;
00062         isc_result_t            result;
00063         dns_db_t                *db;
00064         dns_dbiterator_t        *dbit;
00065         dns_dbversion_t         *ver;
00066         isc_stdtime_t           now;
00067         dns_dbnode_t            *node;
00068         dns_fixedname_t         fixedname;
00069         dns_rdatasetiter_t      *rdatasetit;
00070         dns_rdataset_t          rdataset;
00071         dns_rdata_t             rdata;
00072 } dns_rriterator_t;
00073 
00074 #define RRITERATOR_MAGIC                ISC_MAGIC('R', 'R', 'I', 't')
00075 #define VALID_RRITERATOR(m)             ISC_MAGIC_VALID(m, RRITERATOR_MAGIC)
00076 
00077 isc_result_t
00078 dns_rriterator_init(dns_rriterator_t *it, dns_db_t *db,
00079                        dns_dbversion_t *ver, isc_stdtime_t now);
00080 /*%
00081  * Initialize an rriterator; sets the cursor to the origin node
00082  * of the database.
00083  *
00084  * Requires:
00085  *
00086  * \li  'db' is a valid database.
00087  *
00088  * Returns:
00089  *
00090  * \li  #ISC_R_SUCCESS
00091  * \li  #ISC_R_NOMEMORY
00092  */
00093 
00094 isc_result_t
00095 dns_rriterator_first(dns_rriterator_t *it);
00096 /*%<
00097  * Move the rriterator cursor to the first rdata in the database.
00098  *
00099  * Requires:
00100  *\li   'it' is a valid, initialized rriterator
00101  *
00102  * Returns:
00103  *\li   #ISC_R_SUCCESS
00104  *\li   #ISC_R_NOMORE                   There are no rdata in the set.
00105  */
00106 
00107 isc_result_t
00108 dns_rriterator_nextrrset(dns_rriterator_t *it);
00109 /*%<
00110  * Move the rriterator cursor to the next rrset in the database,
00111  * skipping over any remaining records that have the same rdatatype
00112  * as the current one.
00113  *
00114  * Requires:
00115  *\li   'it' is a valid, initialized rriterator
00116  *
00117  * Returns:
00118  *\li   #ISC_R_SUCCESS
00119  *\li   #ISC_R_NOMORE                   No more rrsets in the database
00120  */
00121 
00122 isc_result_t
00123 dns_rriterator_next(dns_rriterator_t *it);
00124 /*%<
00125  * Move the rriterator cursor to the next rrset in the database,
00126  * skipping over any remaining records that have the same rdatatype
00127  * as the current one.
00128  *
00129  * Requires:
00130  *\li   'it' is a valid, initialized rriterator
00131  *
00132  * Returns:
00133  *\li   #ISC_R_SUCCESS
00134  *\li   #ISC_R_NOMORE                   No more records in the database
00135  */
00136 
00137 void
00138 dns_rriterator_current(dns_rriterator_t *it, dns_name_t **name,
00139                           isc_uint32_t *ttl, dns_rdataset_t **rdataset,
00140                           dns_rdata_t **rdata);
00141 /*%<
00142  * Make '*name' refer to the current name.  If 'rdataset' is not NULL,
00143  * make '*rdataset' refer to the current * rdataset.  If '*rdata' is not
00144  * NULL, make '*rdata' refer to the current record.
00145  *
00146  * Requires:
00147  *\li   '*name' is a valid name object
00148  *\li   'rdataset' is NULL or '*rdataset' is NULL
00149  *\li   'rdata' is NULL or '*rdata' is NULL
00150  *
00151  * Ensures:
00152  *\li   'rdata' refers to the rdata at the rdata cursor location of
00153  *\li   'rdataset'.
00154  */
00155 
00156 void
00157 dns_rriterator_pause(dns_rriterator_t *it);
00158 /*%<
00159  * Pause rriterator.  Frees any locks held by the database iterator.
00160  * Callers should use this routine any time they are not going to
00161  * execute another rriterator method in the immediate future.
00162  *
00163  * Requires:
00164  *\li   'it' is a valid iterator.
00165  *
00166  * Ensures:
00167  *\li   Any database locks being held for efficiency of iterator access are
00168  *      released.
00169  */
00170 
00171 void
00172 dns_rriterator_destroy(dns_rriterator_t *it);
00173 /*%<
00174  * Shut down and free resources in rriterator 'it'.
00175  *
00176  * Requires:
00177  *
00178  *\li   'it' is a valid iterator.
00179  *
00180  * Ensures:
00181  *
00182  *\li   All resources used by the rriterator are freed.
00183  */
00184 
00185 ISC_LANG_ENDDECLS
00186 
00187 #endif /* DNS_RRITERATOR_H */

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