/contrib/bind9/lib/dns/include/dns/rriterator.h

https://bitbucket.org/freebsd/freebsd-head/ · C Header · 187 lines · 49 code · 21 blank · 117 comment · 0 complexity · 05926989f12d8f9d108c854f1ad2a8aa MD5 · raw file

  1. /*
  2. * Copyright (C) 2009, 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  9. * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  10. * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  11. * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  12. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  13. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  14. * PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. /* $Id$ */
  17. #ifndef DNS_RRITERATOR_H
  18. #define DNS_RRITERATOR_H 1
  19. /*****
  20. ***** Module Info
  21. *****/
  22. /*! \file dns/rriterator.h
  23. * \brief
  24. * Functions for "walking" a zone database, visiting each RR or RRset in turn.
  25. */
  26. /*****
  27. ***** Imports
  28. *****/
  29. #include <isc/lang.h>
  30. #include <isc/magic.h>
  31. #include <isc/ondestroy.h>
  32. #include <isc/stdtime.h>
  33. #include <dns/db.h>
  34. #include <dns/dbiterator.h>
  35. #include <dns/fixedname.h>
  36. #include <dns/name.h>
  37. #include <dns/rdata.h>
  38. #include <dns/rdataset.h>
  39. #include <dns/rdatasetiter.h>
  40. #include <dns/types.h>
  41. ISC_LANG_BEGINDECLS
  42. /*****
  43. ***** Types
  44. *****/
  45. /*%
  46. * A dns_rriterator_t is an iterator that iterates over an entire database,
  47. * returning one RR at a time, in some arbitrary order.
  48. */
  49. typedef struct dns_rriterator {
  50. unsigned int magic;
  51. isc_result_t result;
  52. dns_db_t *db;
  53. dns_dbiterator_t *dbit;
  54. dns_dbversion_t *ver;
  55. isc_stdtime_t now;
  56. dns_dbnode_t *node;
  57. dns_fixedname_t fixedname;
  58. dns_rdatasetiter_t *rdatasetit;
  59. dns_rdataset_t rdataset;
  60. dns_rdata_t rdata;
  61. } dns_rriterator_t;
  62. #define RRITERATOR_MAGIC ISC_MAGIC('R', 'R', 'I', 't')
  63. #define VALID_RRITERATOR(m) ISC_MAGIC_VALID(m, RRITERATOR_MAGIC)
  64. isc_result_t
  65. dns_rriterator_init(dns_rriterator_t *it, dns_db_t *db,
  66. dns_dbversion_t *ver, isc_stdtime_t now);
  67. /*%
  68. * Initialize an rriterator; sets the cursor to the origin node
  69. * of the database.
  70. *
  71. * Requires:
  72. *
  73. * \li 'db' is a valid database.
  74. *
  75. * Returns:
  76. *
  77. * \li #ISC_R_SUCCESS
  78. * \li #ISC_R_NOMEMORY
  79. */
  80. isc_result_t
  81. dns_rriterator_first(dns_rriterator_t *it);
  82. /*%<
  83. * Move the rriterator cursor to the first rdata in the database.
  84. *
  85. * Requires:
  86. *\li 'it' is a valid, initialized rriterator
  87. *
  88. * Returns:
  89. *\li #ISC_R_SUCCESS
  90. *\li #ISC_R_NOMORE There are no rdata in the set.
  91. */
  92. isc_result_t
  93. dns_rriterator_nextrrset(dns_rriterator_t *it);
  94. /*%<
  95. * Move the rriterator cursor to the next rrset in the database,
  96. * skipping over any remaining records that have the same rdatatype
  97. * as the current one.
  98. *
  99. * Requires:
  100. *\li 'it' is a valid, initialized rriterator
  101. *
  102. * Returns:
  103. *\li #ISC_R_SUCCESS
  104. *\li #ISC_R_NOMORE No more rrsets in the database
  105. */
  106. isc_result_t
  107. dns_rriterator_next(dns_rriterator_t *it);
  108. /*%<
  109. * Move the rriterator cursor to the next rrset in the database,
  110. * skipping over any remaining records that have the same rdatatype
  111. * as the current one.
  112. *
  113. * Requires:
  114. *\li 'it' is a valid, initialized rriterator
  115. *
  116. * Returns:
  117. *\li #ISC_R_SUCCESS
  118. *\li #ISC_R_NOMORE No more records in the database
  119. */
  120. void
  121. dns_rriterator_current(dns_rriterator_t *it, dns_name_t **name,
  122. isc_uint32_t *ttl, dns_rdataset_t **rdataset,
  123. dns_rdata_t **rdata);
  124. /*%<
  125. * Make '*name' refer to the current name. If 'rdataset' is not NULL,
  126. * make '*rdataset' refer to the current * rdataset. If '*rdata' is not
  127. * NULL, make '*rdata' refer to the current record.
  128. *
  129. * Requires:
  130. *\li '*name' is a valid name object
  131. *\li 'rdataset' is NULL or '*rdataset' is NULL
  132. *\li 'rdata' is NULL or '*rdata' is NULL
  133. *
  134. * Ensures:
  135. *\li 'rdata' refers to the rdata at the rdata cursor location of
  136. *\li 'rdataset'.
  137. */
  138. void
  139. dns_rriterator_pause(dns_rriterator_t *it);
  140. /*%<
  141. * Pause rriterator. Frees any locks held by the database iterator.
  142. * Callers should use this routine any time they are not going to
  143. * execute another rriterator method in the immediate future.
  144. *
  145. * Requires:
  146. *\li 'it' is a valid iterator.
  147. *
  148. * Ensures:
  149. *\li Any database locks being held for efficiency of iterator access are
  150. * released.
  151. */
  152. void
  153. dns_rriterator_destroy(dns_rriterator_t *it);
  154. /*%<
  155. * Shut down and free resources in rriterator 'it'.
  156. *
  157. * Requires:
  158. *
  159. *\li 'it' is a valid iterator.
  160. *
  161. * Ensures:
  162. *
  163. *\li All resources used by the rriterator are freed.
  164. */
  165. ISC_LANG_ENDDECLS
  166. #endif /* DNS_RRITERATOR_H */