Commit ab2981e3 authored by Bob Halley's avatar Bob Halley
Browse files

add rdatalist.c

parent a7053642
......@@ -12,7 +12,7 @@ CINCLUDES = -I${srcdir}/../isc/unix/include \
CDEFINES =
CWARNINGS =
OBJS = name.o rdataset.o result.o version.o
OBJS = name.o rdatalist.o rdataset.o result.o version.o
SUBDIRS = include
TARGETS = timestamp
......
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#include <stddef.h>
#include <isc/assertions.h>
#include <dns/rdata.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
static dns_result_t disassociate(dns_rdataset_t *rdatasetp);
static dns_result_t first(dns_rdataset_t *rdataset);
static dns_result_t next(dns_rdataset_t *rdataset);
void current(dns_rdataset_t *rdataset, dns_rdata_t *rdata);
static dns_rdatasetmethods_t methods = {
disassociate,
first,
next,
current
};
dns_result_t
dns_rdatalist_tordataset(dns_rdatalist_t *rdatalist,
dns_rdataset_t *rdataset) {
/*
* Make 'rdataset' refer to the rdata in 'rdatalist'.
*/
REQUIRE(rdatalist != NULL);
REQUIRE(DNS_RDATASET_VALID(rdataset));
REQUIRE(rdataset->methods == NULL);
rdataset->methods = &methods;
rdataset->class = rdatalist->class;
rdataset->type = rdatalist->type;
rdataset->ttl = rdatalist->ttl;
rdataset->private1 = rdatalist;
rdataset->private2 = NULL;
rdataset->private3 = NULL;
return (DNS_R_SUCCESS);
}
static dns_result_t
disassociate(dns_rdataset_t *rdataset) {
rdataset->methods = NULL;
rdataset->class = 0;
rdataset->type = 0;
rdataset->ttl = 0;
rdataset->private1 = NULL;
rdataset->private2 = NULL;
rdataset->private3 = NULL;
return (DNS_R_SUCCESS);
}
static dns_result_t
first(dns_rdataset_t *rdataset) {
dns_rdatalist_t *rdatalist;
rdatalist = rdataset->private1;
rdataset->private2 = ISC_LIST_HEAD(rdatalist->rdata);
if (rdataset->private2 == NULL)
return (DNS_R_NOMORE);
return (DNS_R_SUCCESS);
}
static dns_result_t
next(dns_rdataset_t *rdataset) {
dns_rdata_t *rdata;
rdata = rdataset->private2;
rdataset->private2 = ISC_LIST_NEXT(rdata, link);
if (rdataset->private2 == NULL)
return (DNS_R_NOMORE);
return (DNS_R_SUCCESS);
}
void
current(dns_rdataset_t *rdataset, dns_rdata_t *rdata) {
dns_rdata_t *list_rdata;
list_rdata = rdataset->private2;
INSIST(list_rdata != NULL);
*rdata = *list_rdata;
ISC_LINK_INIT(rdata, link);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment