Commit 345a84c9 authored by Bob Halley's avatar Bob Halley
Browse files

add dns_name_print

parent fcddaadc
......@@ -79,6 +79,8 @@
#include <dns/types.h>
#include <dns/result.h>
#include <stdio.h>
ISC_LANG_BEGINDECLS
/*****
......@@ -983,7 +985,7 @@ dns_name_digest(dns_name_t *name, dns_digestfunc_t digest, void *arg);
isc_boolean_t
dns_name_dynamic(dns_name_t *name);
/*
* Returns whether there is dynamic memory associated with this name.
* Returns whether there is dynamic memory associated with this name.
*
* Requires:
*
......@@ -994,6 +996,24 @@ dns_name_dynamic(dns_name_t *name);
* 'ISC_TRUE' if the name is dynamic othewise 'ISC_FALSE'.
*/
isc_result_t
dns_name_print(dns_name_t *name, FILE *stream);
/*
* Print 'name' on 'stream'.
*
* Requires:
*
* 'name' is a valid name.
*
* 'stream' is a valid stream.
*
* Returns:
*
* ISC_R_SUCCESS
*
* Any error that dns_name_totext() can return.
*/
ISC_LANG_ENDDECLS
#endif /* DNS_NAME_H */
......@@ -2930,6 +2930,33 @@ isc_boolean_t
dns_name_dynamic(dns_name_t *name) {
REQUIRE(VALID_NAME(name));
/*
* Returns whether there is dynamic memory associated with this name.
*/
return ((name->attributes & DNS_NAMEATTR_DYNAMIC) != 0 ?
ISC_TRUE : ISC_FALSE);
}
isc_result_t
dns_name_print(dns_name_t *name, FILE *stream) {
isc_result_t result;
isc_buffer_t b;
isc_region_t r;
char t[1024];
/*
* Print 'name' on 'stream'.
*/
REQUIRE(VALID_NAME(name));
isc_buffer_init(&b, t, sizeof t, ISC_BUFFERTYPE_TEXT);
result = dns_name_totext(name, ISC_FALSE, &b);
if (result != ISC_R_SUCCESS)
return (result);
isc_buffer_used(&b, &r);
fprintf(stream, "%.*s", (int)r.length, (char *)r.base);
return (ISC_R_SUCCESS);
}
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