rdataset.c revision 110d1702731f42dd620879c1d765ebe91f3920ce
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Copyright (C) 1999 Internet Software Consortium.
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 * 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 * Make 'rdataset' a valid, disassociated rdataset.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_rdataset_invalidate(dns_rdataset_t *rdataset) {
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Invalidate 'rdataset'.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_rdataset_disassociate(dns_rdataset_t *rdataset) {
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Disassocate 'rdataset' from its rdata, allowing it to be reused.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Move the rdata cursor to the first rdata in the rdataset (if any).
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Move the rdata cursor to the next rdata in the rdataset (if any).
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydns_rdataset_current(dns_rdataset_t *rdataset, dns_rdata_t *rdata) {
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Make 'rdata' refer to the current rdata.
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 * Assumes tabs are 8 characters.
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley unsigned int common_start, common_length, length, ntabs, ttabs;
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Convert 'rdataset' to text format, storing the result in 'target'.
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley * XXX Explicit buffer structure references here. Improve buffer
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 * XXX The following sprintf() is safe, but it
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley * would still be good to use snprintf if we had it.
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley result = dns_rdataclass_totext(rdataset->class, target);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley result = dns_rdatatype_totext(rdataset->type, target);
0d0d9a9d9895605aba3a44fd03c051e15f88ecf5Bob Halley ntabs = tabs_needed(common_length + ttabs * 7, 40);
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * Convert 'rdataset' to wire format, compressing names as specified
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley * in cctx, and storing the result in 'target'.
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley /* XXX stop warnings. */