rdataset.c revision 110d1702731f42dd620879c1d765ebe91f3920ce
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley/*
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Copyright (C) 1999 Internet Software Consortium.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley *
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Permission to use, copy, modify, and distribute this software for any
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * purpose with or without fee is hereby granted, provided that the above
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * copyright notice and this permission notice appear in all copies.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley *
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * SOFTWARE.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley */
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
110d1702731f42dd620879c1d765ebe91f3920ceMichael Graff#include <config.h>
110d1702731f42dd620879c1d765ebe91f3920ceMichael Graff
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley#include <stddef.h>
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley#include <string.h>
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley#include <isc/assertions.h>
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley#include <dns/rdata.h>
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley#include <dns/rdataclass.h>
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley#include <dns/rdatatype.h>
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley#include <dns/rdataset.h>
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleyvoid
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_rdataset_init(dns_rdataset_t *rdataset) {
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley /*
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Make 'rdataset' a valid, disassociated rdataset.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley */
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley REQUIRE(rdataset != NULL);
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
078d49b63324f01d98301ee21671abee0c41fcdeBob Halley rdataset->magic = DNS_RDATASET_MAGIC;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->methods = NULL;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley ISC_LINK_INIT(rdataset, link);
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->class = 0;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->type = 0;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->ttl = 0;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->private1 = NULL;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->private2 = NULL;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->private3 = NULL;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley}
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleyvoid
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_rdataset_invalidate(dns_rdataset_t *rdataset) {
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley /*
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Invalidate 'rdataset'.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley */
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
078d49b63324f01d98301ee21671abee0c41fcdeBob Halley REQUIRE(DNS_RDATASET_VALID(rdataset));
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley REQUIRE(rdataset->methods == NULL);
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->magic = 0;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley ISC_LINK_INIT(rdataset, link);
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->class = 0;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->type = 0;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->ttl = 0;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->private1 = NULL;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->private2 = NULL;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->private3 = NULL;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley}
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleyvoid
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_rdataset_disassociate(dns_rdataset_t *rdataset) {
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley /*
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Disassocate 'rdataset' from its rdata, allowing it to be reused.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley */
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
078d49b63324f01d98301ee21671abee0c41fcdeBob Halley REQUIRE(DNS_RDATASET_VALID(rdataset));
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley (rdataset->methods->disassociate)(rdataset);
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->methods = NULL;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley ISC_LINK_INIT(rdataset, link);
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->class = 0;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->type = 0;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->ttl = 0;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->private1 = NULL;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->private2 = NULL;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley rdataset->private3 = NULL;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley}
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_result_t
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_rdataset_first(dns_rdataset_t *rdataset) {
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley /*
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Move the rdata cursor to the first rdata in the rdataset (if any).
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley */
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
078d49b63324f01d98301ee21671abee0c41fcdeBob Halley REQUIRE(DNS_RDATASET_VALID(rdataset));
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley return ((rdataset->methods->first)(rdataset));
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley}
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_result_t
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_rdataset_next(dns_rdataset_t *rdataset) {
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley /*
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Move the rdata cursor to the next rdata in the rdataset (if any).
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley */
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
078d49b63324f01d98301ee21671abee0c41fcdeBob Halley REQUIRE(DNS_RDATASET_VALID(rdataset));
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley return ((rdataset->methods->next)(rdataset));
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley}
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleyvoid
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_rdataset_current(dns_rdataset_t *rdataset, dns_rdata_t *rdata) {
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley /*
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Make 'rdata' refer to the current rdata.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley */
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
078d49b63324f01d98301ee21671abee0c41fcdeBob Halley REQUIRE(DNS_RDATASET_VALID(rdataset));
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley (rdataset->methods->current)(rdataset, rdata);
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley}
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
95552051abdb3b6fc4f56b015da27c000742646bBob Halleystatic char *tabs = "\t\t\t\t\t\t\t\t\t\t";
95552051abdb3b6fc4f56b015da27c000742646bBob Halley
95552051abdb3b6fc4f56b015da27c000742646bBob Halleystatic inline int
95552051abdb3b6fc4f56b015da27c000742646bBob Halleytabs_needed(unsigned int current_offset, unsigned int desired_offset) {
95552051abdb3b6fc4f56b015da27c000742646bBob Halley unsigned int needed;
95552051abdb3b6fc4f56b015da27c000742646bBob Halley unsigned int spaces;
95552051abdb3b6fc4f56b015da27c000742646bBob Halley
95552051abdb3b6fc4f56b015da27c000742646bBob Halley /*
95552051abdb3b6fc4f56b015da27c000742646bBob Halley * Assumes tabs are 8 characters.
95552051abdb3b6fc4f56b015da27c000742646bBob Halley */
95552051abdb3b6fc4f56b015da27c000742646bBob Halley
95552051abdb3b6fc4f56b015da27c000742646bBob Halley if (current_offset >= desired_offset)
95552051abdb3b6fc4f56b015da27c000742646bBob Halley return (1);
95552051abdb3b6fc4f56b015da27c000742646bBob Halley spaces = desired_offset - current_offset;
95552051abdb3b6fc4f56b015da27c000742646bBob Halley needed = spaces / 8;
95552051abdb3b6fc4f56b015da27c000742646bBob Halley if (spaces % 8 != 0)
95552051abdb3b6fc4f56b015da27c000742646bBob Halley needed++;
95552051abdb3b6fc4f56b015da27c000742646bBob Halley if (needed > 10)
95552051abdb3b6fc4f56b015da27c000742646bBob Halley needed = 10;
95552051abdb3b6fc4f56b015da27c000742646bBob Halley return (needed);
95552051abdb3b6fc4f56b015da27c000742646bBob Halley}
95552051abdb3b6fc4f56b015da27c000742646bBob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_result_t
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_rdataset_totext(dns_rdataset_t *rdataset,
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley dns_name_t *owner_name,
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley isc_boolean_t omit_final_dot,
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley isc_buffer_t *target)
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley{
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley dns_result_t result;
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley unsigned int common_start, common_length, length, ntabs, ttabs;
95552051abdb3b6fc4f56b015da27c000742646bBob Halley char *common;
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley dns_rdata_t rdata;
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley isc_boolean_t first = ISC_TRUE;
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley isc_region_t r;
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley char ttl[64];
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley /*
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Convert 'rdataset' to text format, storing the result in 'target'.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley */
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
078d49b63324f01d98301ee21671abee0c41fcdeBob Halley REQUIRE(DNS_RDATASET_VALID(rdataset));
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley result = dns_rdataset_first(rdataset);
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley REQUIRE(result == DNS_R_SUCCESS);
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley /*
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley * XXX Explicit buffer structure references here. Improve buffer
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley * API.
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley */
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley common_start = target->used;
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley /*
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley * The caller might want to give us an empty owner
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley * name (e.g. if they are outputting into a master
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley * file and this rdataset has the same name as the
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley * previous one.)
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley */
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley if (dns_name_countlabels(owner_name) != 0) {
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley result = dns_name_totext(owner_name,
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley omit_final_dot,
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley target);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley if (result != DNS_R_SUCCESS)
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley return (result);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley }
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley common = (char *)target->base + common_start;
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley common_length = target->used - common_start;
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley ntabs = tabs_needed(common_length, 24);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley ttabs = ntabs;
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley isc_buffer_available(target, &r);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley if (r.length < ntabs)
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley return (DNS_R_NOSPACE);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley memcpy(r.base, tabs, ntabs);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley isc_buffer_add(target, ntabs);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley /*
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley * XXX The following sprintf() is safe, but it
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley * would still be good to use snprintf if we had it.
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley */
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley length = sprintf(ttl, "%u ", rdataset->ttl);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley INSIST(length <= sizeof ttl);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley isc_buffer_available(target, &r);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley if (r.length < length)
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley return (DNS_R_NOSPACE);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley memcpy(r.base, ttl, length);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley isc_buffer_add(target, length);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley result = dns_rdataclass_totext(rdataset->class, target);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley if (result != DNS_R_SUCCESS)
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley return (result);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley isc_buffer_available(target, &r);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley if (r.length == 0)
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley return (DNS_R_NOSPACE);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley *r.base = ' ';
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley isc_buffer_add(target, 1);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley result = dns_rdatatype_totext(rdataset->type, target);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley if (result != DNS_R_SUCCESS)
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley return (result);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley common_length = target->used - common_start;
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley ntabs = tabs_needed(common_length + ttabs * 7, 40);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley ttabs += ntabs;
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley isc_buffer_available(target, &r);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley if (r.length < ntabs)
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley return (DNS_R_NOSPACE);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley memcpy(r.base, tabs, ntabs);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley isc_buffer_add(target, ntabs);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley common_length = target->used - common_start;
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley do {
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley if (!first) {
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley isc_buffer_available(target, &r);
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley if (r.length < common_length)
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley return (DNS_R_NOSPACE);
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley memcpy(r.base, common, common_length);
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley isc_buffer_add(target, common_length);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley } else
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley first = ISC_FALSE;
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley dns_rdataset_current(rdataset, &rdata);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews result = dns_rdata_totext(&rdata, target);
95552051abdb3b6fc4f56b015da27c000742646bBob Halley if (result != DNS_R_SUCCESS)
95552051abdb3b6fc4f56b015da27c000742646bBob Halley return (result);
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley isc_buffer_available(target, &r);
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley if (r.length < 1)
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley return (DNS_R_NOSPACE);
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley memcpy(r.base, "\n", 1);
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley isc_buffer_add(target, 1);
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley result = dns_rdataset_next(rdataset);
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley } while (result == DNS_R_SUCCESS);
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley if (result != DNS_R_NOMORE)
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley return (result);
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley return (DNS_R_SUCCESS);
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley}
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_result_t
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_rdataset_towire(dns_rdataset_t *rdataset,
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley dns_name_t *owner_name,
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley dns_compress_t *cctx,
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley isc_buffer_t *target)
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley{
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley /*
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Convert 'rdataset' to wire format, compressing names as specified
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * in cctx, and storing the result in 'target'.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley */
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley REQUIRE(DNS_RDATASET_VALID(rdataset));
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley /* XXX stop warnings. */
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley owner_name = NULL;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley cctx = NULL;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley target = NULL;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley return (DNS_R_NOTIMPLEMENTED);
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley}