rdataset.c revision 76883e8cee593f45c65b0936e5d6e8f778d6e3ef
/*
* 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 <config.h>
#include <stddef.h>
#include <string.h>
#include <isc/assertions.h>
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
#include <dns/rdataset.h>
void
/*
* Make 'rdataset' a valid, disassociated rdataset.
*/
}
void
/*
* Invalidate 'rdataset'.
*/
}
void
/*
* Disassocate 'rdataset' from its rdata, allowing it to be reused.
*/
}
/*
* Move the rdata cursor to the first rdata in the rdataset (if any).
*/
}
/*
* Move the rdata cursor to the next rdata in the rdataset (if any).
*/
}
void
/*
* Make 'rdata' refer to the current rdata.
*/
}
static char *tabs = "\t\t\t\t\t\t\t\t\t\t";
static inline int
unsigned int needed;
unsigned int spaces;
/*
* Assumes tabs are 8 characters.
*/
if (current_offset >= desired_offset)
return (1);
if (spaces % 8 != 0)
needed++;
if (needed > 10)
needed = 10;
return (needed);
}
{
char *common;
isc_region_t r;
char ttl[64];
/*
* Convert 'rdataset' to text format, storing the result in 'target'.
*/
/*
* XXX Explicit buffer structure references here. Improve buffer
* API.
*/
/*
* The caller might want to give us an empty owner
* name (e.g. if they are outputting into a master
* file and this rdataset has the same name as the
* previous one.)
*/
if (dns_name_countlabels(owner_name) != 0) {
target);
if (result != DNS_R_SUCCESS)
return (result);
}
isc_buffer_available(target, &r);
return (DNS_R_NOSPACE);
/*
* XXX The following sprintf() is safe, but it
* would still be good to use snprintf if we had it.
*/
isc_buffer_available(target, &r);
return (DNS_R_NOSPACE);
if (result != DNS_R_SUCCESS)
return (result);
isc_buffer_available(target, &r);
if (r.length == 0)
return (DNS_R_NOSPACE);
*r.base = ' ';
if (result != DNS_R_SUCCESS)
return (result);
isc_buffer_available(target, &r);
return (DNS_R_NOSPACE);
do {
if (!first) {
isc_buffer_available(target, &r);
if (r.length < common_length)
return (DNS_R_NOSPACE);
} else
if (result != DNS_R_SUCCESS)
return (result);
isc_buffer_available(target, &r);
if (r.length < 1)
return (DNS_R_NOSPACE);
} while (result == DNS_R_SUCCESS);
if (result != DNS_R_NOMORE)
return (result);
return (DNS_R_SUCCESS);
}
{
isc_region_t r;
/*
* Convert 'rdataset' to wire format, compressing names as specified
* in cctx, and storing the result in 'target'.
*/
do {
/*
* copy out the name, type, class, ttl.
*/
if (result != DNS_R_SUCCESS)
return (result);
isc_buffer_available(target, &r);
if (r.length < (sizeof(dns_rdataclass_t)
+ sizeof(dns_rdatatype_t)
+ sizeof(dns_ttl_t)
+ 2)) /* XXX 2? it's for the rdata length */
return (DNS_R_NOSPACE);
+ sizeof(dns_rdatatype_t)
+ sizeof(dns_ttl_t)
+ 2)); /* XXX see XXX above */
/*
* copy out the rdata length
*/
/*
* copy out the rdata
*/
if (result != DNS_R_SUCCESS)
return (result);
} while (result == DNS_R_SUCCESS);
if (result != DNS_R_NOMORE)
return (result);
return (DNS_R_SUCCESS);
}