PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/bind9/lib/dns/rdatasetiter.c

https://bitbucket.org/freebsd/freebsd-head/
C | 80 lines | 31 code | 19 blank | 30 comment | 2 complexity | 82ca33857df2a1a346a7c2e8f7325a92 MD5 | raw file
 1/*
 2 * Copyright (C) 2004, 2005, 2007  Internet Systems Consortium, Inc. ("ISC")
 3 * Copyright (C) 1999-2001  Internet Software Consortium.
 4 *
 5 * Permission to use, copy, modify, and/or distribute this software for any
 6 * purpose with or without fee is hereby granted, provided that the above
 7 * copyright notice and this permission notice appear in all copies.
 8 *
 9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
16 */
17
18/* $Id: rdatasetiter.c,v 1.16 2007/06/19 23:47:16 tbox Exp $ */
19
20/*! \file */
21
22#include <config.h>
23
24#include <stddef.h>
25
26#include <isc/util.h>
27
28#include <dns/rdataset.h>
29#include <dns/rdatasetiter.h>
30
31void
32dns_rdatasetiter_destroy(dns_rdatasetiter_t **iteratorp) {
33	/*
34	 * Destroy '*iteratorp'.
35	 */
36
37	REQUIRE(iteratorp != NULL);
38	REQUIRE(DNS_RDATASETITER_VALID(*iteratorp));
39
40	(*iteratorp)->methods->destroy(iteratorp);
41
42	ENSURE(*iteratorp == NULL);
43}
44
45isc_result_t
46dns_rdatasetiter_first(dns_rdatasetiter_t *iterator) {
47	/*
48	 * Move the rdataset cursor to the first rdataset at the node (if any).
49	 */
50
51	REQUIRE(DNS_RDATASETITER_VALID(iterator));
52
53	return (iterator->methods->first(iterator));
54}
55
56isc_result_t
57dns_rdatasetiter_next(dns_rdatasetiter_t *iterator) {
58	/*
59	 * Move the rdataset cursor to the next rdataset at the node (if any).
60	 */
61
62	REQUIRE(DNS_RDATASETITER_VALID(iterator));
63
64	return (iterator->methods->next(iterator));
65}
66
67void
68dns_rdatasetiter_current(dns_rdatasetiter_t *iterator,
69			 dns_rdataset_t *rdataset)
70{
71	/*
72	 * Return the current rdataset.
73	 */
74
75	REQUIRE(DNS_RDATASETITER_VALID(iterator));
76	REQUIRE(DNS_RDATASET_VALID(rdataset));
77	REQUIRE(! dns_rdataset_isassociated(rdataset));
78
79	iterator->methods->current(iterator, rdataset);
80}