rdatasetiter.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004-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: rdatasetiter.h,v 1.21 2007/06/19 23:47:17 tbox Exp $ */
00019 
00020 #ifndef DNS_RDATASETITER_H
00021 #define DNS_RDATASETITER_H 1
00022 
00023 /*****
00024  ***** Module Info
00025  *****/
00026 
00027 /*! \file dns/rdatasetiter.h
00028  * \brief
00029  * The DNS Rdataset Iterator interface allows iteration of all of the
00030  * rdatasets at a node.
00031  *
00032  * The dns_rdatasetiter_t type is like a "virtual class".  To actually use
00033  * it, an implementation of the class is required.  This implementation is
00034  * supplied by the database.
00035  *
00036  * It is the client's responsibility to call dns_rdataset_disassociate()
00037  * on all rdatasets returned.
00038  *
00039  * XXX more XXX
00040  *
00041  * MP:
00042  *\li   The iterator itself is not locked.  The caller must ensure
00043  *      synchronization.
00044  *
00045  *\li   The iterator methods ensure appropriate database locking.
00046  *
00047  * Reliability:
00048  *\li   No anticipated impact.
00049  *
00050  * Resources:
00051  *\li   TBS
00052  *
00053  * Security:
00054  *\li   No anticipated impact.
00055  *
00056  * Standards:
00057  *\li   None.
00058  */
00059 
00060 /*****
00061  ***** Imports
00062  *****/
00063 
00064 #include <isc/lang.h>
00065 #include <isc/magic.h>
00066 #include <isc/stdtime.h>
00067 
00068 #include <dns/types.h>
00069 
00070 ISC_LANG_BEGINDECLS
00071 
00072 /*****
00073  ***** Types
00074  *****/
00075 
00076 typedef struct dns_rdatasetitermethods {
00077         void            (*destroy)(dns_rdatasetiter_t **iteratorp);
00078         isc_result_t    (*first)(dns_rdatasetiter_t *iterator);
00079         isc_result_t    (*next)(dns_rdatasetiter_t *iterator);
00080         void            (*current)(dns_rdatasetiter_t *iterator,
00081                                    dns_rdataset_t *rdataset);
00082 } dns_rdatasetitermethods_t;
00083 
00084 #define DNS_RDATASETITER_MAGIC       ISC_MAGIC('D','N','S','i')
00085 #define DNS_RDATASETITER_VALID(i)    ISC_MAGIC_VALID(i, DNS_RDATASETITER_MAGIC)
00086 
00087 /*%
00088  * This structure is actually just the common prefix of a DNS db
00089  * implementation's version of a dns_rdatasetiter_t.
00090  * \brief
00091  * Direct use of this structure by clients is forbidden.  DB implementations
00092  * may change the structure.  'magic' must be #DNS_RDATASETITER_MAGIC for
00093  * any of the dns_rdatasetiter routines to work.  DB implementations must
00094  * maintain all DB rdataset iterator invariants.
00095  */
00096 struct dns_rdatasetiter {
00097         /* Unlocked. */
00098         unsigned int                    magic;
00099         dns_rdatasetitermethods_t *     methods;
00100         dns_db_t *                      db;
00101         dns_dbnode_t *                  node;
00102         dns_dbversion_t *               version;
00103         isc_stdtime_t                   now;
00104 };
00105 
00106 void
00107 dns_rdatasetiter_destroy(dns_rdatasetiter_t **iteratorp);
00108 /*%<
00109  * Destroy '*iteratorp'.
00110  *
00111  * Requires:
00112  *
00113  *\li   '*iteratorp' is a valid iterator.
00114  *
00115  * Ensures:
00116  *
00117  *\li   All resources used by the iterator are freed.
00118  *
00119  *\li   *iteratorp == NULL.
00120  */
00121 
00122 isc_result_t
00123 dns_rdatasetiter_first(dns_rdatasetiter_t *iterator);
00124 /*%<
00125  * Move the rdataset cursor to the first rdataset at the node (if any).
00126  *
00127  * Requires:
00128  *\li   'iterator' is a valid iterator.
00129  *
00130  * Returns:
00131  *\li   ISC_R_SUCCESS
00132  *\li   ISC_R_NOMORE                    There are no rdatasets at the node.
00133  *
00134  *\li   Other results are possible, depending on the DB implementation.
00135  */
00136 
00137 isc_result_t
00138 dns_rdatasetiter_next(dns_rdatasetiter_t *iterator);
00139 /*%<
00140  * Move the rdataset cursor to the next rdataset at the node (if any).
00141  *
00142  * Requires:
00143  *\li   'iterator' is a valid iterator.
00144  *
00145  * Returns:
00146  *\li   ISC_R_SUCCESS
00147  *\li   ISC_R_NOMORE                    There are no more rdatasets at the
00148  *                                      node.
00149  *
00150  *\li   Other results are possible, depending on the DB implementation.
00151  */
00152 
00153 void
00154 dns_rdatasetiter_current(dns_rdatasetiter_t *iterator,
00155                          dns_rdataset_t *rdataset);
00156 /*%<
00157  * Return the current rdataset.
00158  *
00159  * Requires:
00160  *\li   'iterator' is a valid iterator.
00161  *
00162  *\li   'rdataset' is a valid, disassociated rdataset.
00163  *
00164  *\li   The rdataset cursor of 'iterator' is at a valid location (i.e. the
00165  *      result of last call to a cursor movement command was #ISC_R_SUCCESS).
00166  */
00167 
00168 ISC_LANG_ENDDECLS
00169 
00170 #endif /* DNS_RDATASETITER_H */

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