mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +00:00
apply the modified style
This commit is contained in:
@@ -48,7 +48,7 @@
|
||||
#include <dns/time.h>
|
||||
#include <dns/ttl.h>
|
||||
|
||||
#define DNS_DCTX_MAGIC ISC_MAGIC('D', 'c', 't', 'x')
|
||||
#define DNS_DCTX_MAGIC ISC_MAGIC('D', 'c', 't', 'x')
|
||||
#define DNS_DCTX_VALID(d) ISC_MAGIC_VALID(d, DNS_DCTX_MAGIC)
|
||||
|
||||
#define RETERR(x) \
|
||||
@@ -66,13 +66,13 @@
|
||||
|
||||
struct dns_master_style {
|
||||
dns_masterstyle_flags_t flags; /* DNS_STYLEFLAG_* */
|
||||
unsigned int ttl_column;
|
||||
unsigned int class_column;
|
||||
unsigned int type_column;
|
||||
unsigned int rdata_column;
|
||||
unsigned int line_length;
|
||||
unsigned int tab_width;
|
||||
unsigned int split_width;
|
||||
unsigned int ttl_column;
|
||||
unsigned int class_column;
|
||||
unsigned int type_column;
|
||||
unsigned int rdata_column;
|
||||
unsigned int line_length;
|
||||
unsigned int tab_width;
|
||||
unsigned int split_width;
|
||||
};
|
||||
|
||||
/*%
|
||||
@@ -91,16 +91,16 @@ struct dns_master_style {
|
||||
*/
|
||||
typedef struct dns_totext_ctx {
|
||||
dns_master_style_t style;
|
||||
bool class_printed;
|
||||
char * linebreak;
|
||||
char linebreak_buf[DNS_TOTEXT_LINEBREAK_MAXLEN];
|
||||
dns_name_t * origin;
|
||||
dns_name_t * neworigin;
|
||||
dns_fixedname_t origin_fixname;
|
||||
uint32_t current_ttl;
|
||||
bool current_ttl_valid;
|
||||
dns_ttl_t serve_stale_ttl;
|
||||
dns_indent_t indent;
|
||||
bool class_printed;
|
||||
char *linebreak;
|
||||
char linebreak_buf[DNS_TOTEXT_LINEBREAK_MAXLEN];
|
||||
dns_name_t *origin;
|
||||
dns_name_t *neworigin;
|
||||
dns_fixedname_t origin_fixname;
|
||||
uint32_t current_ttl;
|
||||
bool current_ttl_valid;
|
||||
dns_ttl_t serve_stale_ttl;
|
||||
dns_indent_t indent;
|
||||
} dns_totext_ctx_t;
|
||||
|
||||
LIBDNS_EXTERNAL_DATA const dns_master_style_t dns_master_style_keyzone = {
|
||||
@@ -232,27 +232,27 @@ static char spaces[N_SPACES + 1] = " ";
|
||||
static char tabs[N_TABS + 1] = "\t\t\t\t\t\t\t\t\t\t";
|
||||
|
||||
struct dns_dumpctx {
|
||||
unsigned int magic;
|
||||
isc_mem_t * mctx;
|
||||
isc_mutex_t lock;
|
||||
isc_refcount_t references;
|
||||
atomic_bool canceled;
|
||||
bool first;
|
||||
bool do_date;
|
||||
isc_stdtime_t now;
|
||||
FILE * f;
|
||||
dns_db_t * db;
|
||||
dns_dbversion_t * version;
|
||||
dns_dbiterator_t * dbiter;
|
||||
dns_totext_ctx_t tctx;
|
||||
isc_task_t * task;
|
||||
unsigned int magic;
|
||||
isc_mem_t *mctx;
|
||||
isc_mutex_t lock;
|
||||
isc_refcount_t references;
|
||||
atomic_bool canceled;
|
||||
bool first;
|
||||
bool do_date;
|
||||
isc_stdtime_t now;
|
||||
FILE *f;
|
||||
dns_db_t *db;
|
||||
dns_dbversion_t *version;
|
||||
dns_dbiterator_t *dbiter;
|
||||
dns_totext_ctx_t tctx;
|
||||
isc_task_t *task;
|
||||
dns_dumpdonefunc_t done;
|
||||
void * done_arg;
|
||||
unsigned int nodes;
|
||||
void *done_arg;
|
||||
unsigned int nodes;
|
||||
/* dns_master_dumpinc() */
|
||||
char * file;
|
||||
char * tmpfile;
|
||||
dns_masterformat_t format;
|
||||
char *file;
|
||||
char *tmpfile;
|
||||
dns_masterformat_t format;
|
||||
dns_masterrawheader_t header;
|
||||
isc_result_t (*dumpsets)(isc_mem_t *mctx, const dns_name_t *name,
|
||||
dns_rdatasetiter_t *rdsiter,
|
||||
@@ -272,12 +272,11 @@ static const dns_indent_t default_yamlindent = { " ", 1 };
|
||||
*/
|
||||
static isc_result_t
|
||||
indent(unsigned int *current, unsigned int to, int tabwidth,
|
||||
isc_buffer_t *target)
|
||||
{
|
||||
isc_region_t r;
|
||||
isc_buffer_t *target) {
|
||||
isc_region_t r;
|
||||
unsigned char *p;
|
||||
unsigned int from;
|
||||
int ntabs, nspaces, t;
|
||||
unsigned int from;
|
||||
int ntabs, nspaces, t;
|
||||
|
||||
from = *current;
|
||||
|
||||
@@ -338,8 +337,7 @@ indent(unsigned int *current, unsigned int to, int tabwidth,
|
||||
|
||||
static isc_result_t
|
||||
totext_ctx_init(const dns_master_style_t *style, const dns_indent_t *indentctx,
|
||||
dns_totext_ctx_t *ctx)
|
||||
{
|
||||
dns_totext_ctx_t *ctx) {
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(style->tab_width != 0);
|
||||
@@ -376,7 +374,8 @@ totext_ctx_init(const dns_master_style_t *style, const dns_indent_t *indentctx,
|
||||
isc_buffer_add(&buf, 1);
|
||||
|
||||
if ((ctx->style.flags & DNS_STYLEFLAG_INDENT) != 0 ||
|
||||
(ctx->style.flags & DNS_STYLEFLAG_YAML) != 0) {
|
||||
(ctx->style.flags & DNS_STYLEFLAG_YAML) != 0)
|
||||
{
|
||||
unsigned int i, len = strlen(indentctx->string);
|
||||
for (i = 0; i < indentctx->count; i++) {
|
||||
if (isc_buffer_availablelength(&buf) < len) {
|
||||
@@ -445,8 +444,7 @@ totext_ctx_init(const dns_master_style_t *style, const dns_indent_t *indentctx,
|
||||
} while (0)
|
||||
|
||||
static isc_result_t
|
||||
str_totext(const char *source, isc_buffer_t *target)
|
||||
{
|
||||
str_totext(const char *source, isc_buffer_t *target) {
|
||||
unsigned int l;
|
||||
isc_region_t region;
|
||||
|
||||
@@ -464,11 +462,10 @@ str_totext(const char *source, isc_buffer_t *target)
|
||||
|
||||
static isc_result_t
|
||||
ncache_summary(dns_rdataset_t *rdataset, bool omit_final_dot,
|
||||
dns_totext_ctx_t *ctx, isc_buffer_t *target)
|
||||
{
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
dns_totext_ctx_t *ctx, isc_buffer_t *target) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
dns_rdataset_t rds;
|
||||
dns_name_t name;
|
||||
dns_name_t name;
|
||||
|
||||
dns_rdataset_init(&rds);
|
||||
dns_name_init(&name, NULL);
|
||||
@@ -476,9 +473,11 @@ ncache_summary(dns_rdataset_t *rdataset, bool omit_final_dot,
|
||||
do {
|
||||
dns_ncache_current(rdataset, &name, &rds);
|
||||
for (result = dns_rdataset_first(&rds); result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(&rds)) {
|
||||
result = dns_rdataset_next(&rds))
|
||||
{
|
||||
if ((ctx->style.flags & DNS_STYLEFLAG_INDENT) != 0 ||
|
||||
(ctx->style.flags & DNS_STYLEFLAG_YAML) != 0) {
|
||||
(ctx->style.flags & DNS_STYLEFLAG_YAML) != 0)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < ctx->indent.count; i++) {
|
||||
CHECK(str_totext(ctx->indent.string,
|
||||
@@ -534,18 +533,17 @@ cleanup:
|
||||
static isc_result_t
|
||||
rdataset_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
|
||||
dns_totext_ctx_t *ctx, bool omit_final_dot,
|
||||
isc_buffer_t *target)
|
||||
{
|
||||
isc_result_t result;
|
||||
unsigned int column;
|
||||
bool first = true;
|
||||
uint32_t current_ttl;
|
||||
bool current_ttl_valid;
|
||||
isc_buffer_t *target) {
|
||||
isc_result_t result;
|
||||
unsigned int column;
|
||||
bool first = true;
|
||||
uint32_t current_ttl;
|
||||
bool current_ttl_valid;
|
||||
dns_rdatatype_t type;
|
||||
unsigned int type_start;
|
||||
unsigned int type_start;
|
||||
dns_fixedname_t fixed;
|
||||
dns_name_t * name = NULL;
|
||||
unsigned int i;
|
||||
dns_name_t *name = NULL;
|
||||
unsigned int i;
|
||||
|
||||
REQUIRE(DNS_RDATASET_VALID(rdataset));
|
||||
|
||||
@@ -568,7 +566,8 @@ rdataset_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
|
||||
* Indent?
|
||||
*/
|
||||
if ((ctx->style.flags & DNS_STYLEFLAG_INDENT) != 0 ||
|
||||
(ctx->style.flags & DNS_STYLEFLAG_YAML) != 0) {
|
||||
(ctx->style.flags & DNS_STYLEFLAG_YAML) != 0)
|
||||
{
|
||||
for (i = 0; i < ctx->indent.count; i++) {
|
||||
RETERR(str_totext(ctx->indent.string, target));
|
||||
}
|
||||
@@ -579,8 +578,8 @@ rdataset_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
|
||||
*/
|
||||
if ((ctx->style.flags & DNS_STYLEFLAG_YAML) != 0) {
|
||||
RETERR(str_totext("- ", target));
|
||||
} else if ((ctx->style.flags & DNS_STYLEFLAG_COMMENTDATA) !=
|
||||
0) {
|
||||
} else if ((ctx->style.flags & DNS_STYLEFLAG_COMMENTDATA) != 0)
|
||||
{
|
||||
RETERR(str_totext(";", target));
|
||||
}
|
||||
|
||||
@@ -589,7 +588,8 @@ rdataset_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
|
||||
*/
|
||||
if (name != NULL &&
|
||||
!((ctx->style.flags & DNS_STYLEFLAG_OMIT_OWNER) != 0 &&
|
||||
!first)) {
|
||||
!first))
|
||||
{
|
||||
unsigned int name_start = target->used;
|
||||
RETERR(dns_name_totext(name, omit_final_dot, target));
|
||||
column += target->used - name_start;
|
||||
@@ -600,8 +600,9 @@ rdataset_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
|
||||
*/
|
||||
if ((ctx->style.flags & DNS_STYLEFLAG_NO_TTL) == 0 &&
|
||||
!((ctx->style.flags & DNS_STYLEFLAG_OMIT_TTL) != 0 &&
|
||||
current_ttl_valid && rdataset->ttl == current_ttl)) {
|
||||
char ttlbuf[64];
|
||||
current_ttl_valid && rdataset->ttl == current_ttl))
|
||||
{
|
||||
char ttlbuf[64];
|
||||
isc_region_t r;
|
||||
unsigned int length;
|
||||
|
||||
@@ -642,7 +643,8 @@ rdataset_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
|
||||
*/
|
||||
if ((ctx->style.flags & DNS_STYLEFLAG_NO_CLASS) == 0 &&
|
||||
((ctx->style.flags & DNS_STYLEFLAG_OMIT_CLASS) == 0 ||
|
||||
ctx->class_printed == false)) {
|
||||
ctx->class_printed == false))
|
||||
{
|
||||
unsigned int class_start;
|
||||
INDENT_TO(class_column);
|
||||
class_start = target->used;
|
||||
@@ -719,7 +721,7 @@ rdataset_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
|
||||
target));
|
||||
break;
|
||||
} else {
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
isc_region_t r;
|
||||
|
||||
dns_rdataset_current(rdataset, &rdata);
|
||||
@@ -769,8 +771,7 @@ rdataset_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
|
||||
static isc_result_t
|
||||
question_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
|
||||
dns_totext_ctx_t *ctx, bool omit_final_dot,
|
||||
isc_buffer_t *target)
|
||||
{
|
||||
isc_buffer_t *target) {
|
||||
unsigned int column;
|
||||
isc_result_t result;
|
||||
isc_region_t r;
|
||||
@@ -835,10 +836,9 @@ question_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
|
||||
|
||||
isc_result_t
|
||||
dns_rdataset_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
|
||||
bool omit_final_dot, bool question, isc_buffer_t *target)
|
||||
{
|
||||
bool omit_final_dot, bool question, isc_buffer_t *target) {
|
||||
dns_totext_ctx_t ctx;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
result = totext_ctx_init(&dns_master_style_debug, NULL, &ctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
@@ -866,13 +866,12 @@ dns_rdataset_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_master_rdatasettotext(const dns_name_t * owner_name,
|
||||
dns_rdataset_t * rdataset,
|
||||
dns_master_rdatasettotext(const dns_name_t *owner_name,
|
||||
dns_rdataset_t *rdataset,
|
||||
const dns_master_style_t *style, dns_indent_t *indent,
|
||||
isc_buffer_t *target)
|
||||
{
|
||||
isc_buffer_t *target) {
|
||||
dns_totext_ctx_t ctx;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
result = totext_ctx_init(style, indent, &ctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
@@ -884,12 +883,12 @@ dns_master_rdatasettotext(const dns_name_t * owner_name,
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_master_questiontotext(const dns_name_t * owner_name,
|
||||
dns_rdataset_t * rdataset,
|
||||
const dns_master_style_t *style, isc_buffer_t *target)
|
||||
{
|
||||
dns_master_questiontotext(const dns_name_t *owner_name,
|
||||
dns_rdataset_t *rdataset,
|
||||
const dns_master_style_t *style,
|
||||
isc_buffer_t *target) {
|
||||
dns_totext_ctx_t ctx;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
result = totext_ctx_init(style, NULL, &ctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
@@ -909,8 +908,7 @@ dns_master_questiontotext(const dns_name_t * owner_name,
|
||||
|
||||
static isc_result_t
|
||||
dump_rdataset(isc_mem_t *mctx, const dns_name_t *name, dns_rdataset_t *rdataset,
|
||||
dns_totext_ctx_t *ctx, isc_buffer_t *buffer, FILE *f)
|
||||
{
|
||||
dns_totext_ctx_t *ctx, isc_buffer_t *buffer, FILE *f) {
|
||||
isc_region_t r;
|
||||
isc_result_t result;
|
||||
|
||||
@@ -946,7 +944,7 @@ dump_rdataset(isc_mem_t *mctx, const dns_name_t *name, dns_rdataset_t *rdataset,
|
||||
* the buffer. If the buffer is too small, grow it.
|
||||
*/
|
||||
for (;;) {
|
||||
int newlength;
|
||||
int newlength;
|
||||
void *newmem;
|
||||
result = rdataset_totext(rdataset, name, ctx, false, buffer);
|
||||
if (result != ISC_R_NOSPACE) {
|
||||
@@ -988,8 +986,7 @@ dump_rdataset(isc_mem_t *mctx, const dns_name_t *name, dns_rdataset_t *rdataset,
|
||||
*/
|
||||
|
||||
static int
|
||||
dump_order(const dns_rdataset_t *rds)
|
||||
{
|
||||
dump_order(const dns_rdataset_t *rds) {
|
||||
int t;
|
||||
int sig;
|
||||
if (rds->type == dns_rdatatype_rrsig) {
|
||||
@@ -1014,8 +1011,7 @@ dump_order(const dns_rdataset_t *rds)
|
||||
}
|
||||
|
||||
static int
|
||||
dump_order_compare(const void *a, const void *b)
|
||||
{
|
||||
dump_order_compare(const void *a, const void *b) {
|
||||
return (dump_order(*((const dns_rdataset_t *const *)a)) -
|
||||
dump_order(*((const dns_rdataset_t *const *)b)));
|
||||
}
|
||||
@@ -1035,13 +1031,12 @@ dump_order_compare(const void *a, const void *b)
|
||||
static isc_result_t
|
||||
dump_rdatasets_text(isc_mem_t *mctx, const dns_name_t *name,
|
||||
dns_rdatasetiter_t *rdsiter, dns_totext_ctx_t *ctx,
|
||||
isc_buffer_t *buffer, FILE *f)
|
||||
{
|
||||
isc_result_t itresult, dumpresult;
|
||||
isc_region_t r;
|
||||
dns_rdataset_t rdatasets[MAXSORT];
|
||||
isc_buffer_t *buffer, FILE *f) {
|
||||
isc_result_t itresult, dumpresult;
|
||||
isc_region_t r;
|
||||
dns_rdataset_t rdatasets[MAXSORT];
|
||||
dns_rdataset_t *sorted[MAXSORT];
|
||||
int i, n;
|
||||
int i, n;
|
||||
|
||||
itresult = dns_rdatasetiter_first(rdsiter);
|
||||
dumpresult = ISC_R_SUCCESS;
|
||||
@@ -1057,7 +1052,8 @@ dump_rdatasets_text(isc_mem_t *mctx, const dns_name_t *name,
|
||||
|
||||
again:
|
||||
for (i = 0; itresult == ISC_R_SUCCESS && i < MAXSORT;
|
||||
itresult = dns_rdatasetiter_next(rdsiter), i++) {
|
||||
itresult = dns_rdatasetiter_next(rdsiter), i++)
|
||||
{
|
||||
dns_rdataset_init(&rdatasets[i]);
|
||||
dns_rdatasetiter_current(rdsiter, &rdatasets[i]);
|
||||
sorted[i] = &rdatasets[i];
|
||||
@@ -1071,7 +1067,8 @@ again:
|
||||
dns_rdataset_t *rds = sorted[i];
|
||||
if ((ctx->style.flags & DNS_STYLEFLAG_TRUST) != 0) {
|
||||
if ((ctx->style.flags & DNS_STYLEFLAG_INDENT) != 0 ||
|
||||
(ctx->style.flags & DNS_STYLEFLAG_YAML) != 0) {
|
||||
(ctx->style.flags & DNS_STYLEFLAG_YAML) != 0)
|
||||
{
|
||||
unsigned int j;
|
||||
for (j = 0; j < ctx->indent.count; j++) {
|
||||
fprintf(f, "%s", ctx->indent.string);
|
||||
@@ -1080,7 +1077,8 @@ again:
|
||||
fprintf(f, "; %s\n", dns_trust_totext(rds->trust));
|
||||
}
|
||||
if (((rds->attributes & DNS_RDATASETATTR_NEGATIVE) != 0) &&
|
||||
(ctx->style.flags & DNS_STYLEFLAG_NCACHE) == 0) {
|
||||
(ctx->style.flags & DNS_STYLEFLAG_NCACHE) == 0)
|
||||
{
|
||||
/* Omit negative cache entries */
|
||||
} else {
|
||||
isc_result_t result;
|
||||
@@ -1095,20 +1093,22 @@ again:
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
dumpresult = result;
|
||||
}
|
||||
if ((ctx->style.flags & DNS_STYLEFLAG_OMIT_OWNER) !=
|
||||
0) {
|
||||
if ((ctx->style.flags & DNS_STYLEFLAG_OMIT_OWNER) != 0)
|
||||
{
|
||||
name = NULL;
|
||||
}
|
||||
}
|
||||
if (((ctx->style.flags & DNS_STYLEFLAG_RESIGN) != 0) &&
|
||||
((rds->attributes & DNS_RDATASETATTR_RESIGN) != 0)) {
|
||||
((rds->attributes & DNS_RDATASETATTR_RESIGN) != 0))
|
||||
{
|
||||
isc_buffer_t b;
|
||||
char buf[sizeof("YYYYMMDDHHMMSS")];
|
||||
char buf[sizeof("YYYYMMDDHHMMSS")];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
isc_buffer_init(&b, buf, sizeof(buf) - 1);
|
||||
dns_time64_totext((uint64_t)rds->resign, &b);
|
||||
if ((ctx->style.flags & DNS_STYLEFLAG_INDENT) != 0 ||
|
||||
(ctx->style.flags & DNS_STYLEFLAG_YAML) != 0) {
|
||||
(ctx->style.flags & DNS_STYLEFLAG_YAML) != 0)
|
||||
{
|
||||
unsigned int j;
|
||||
for (j = 0; j < ctx->indent.count; j++) {
|
||||
fprintf(f, "%s", ctx->indent.string);
|
||||
@@ -1143,11 +1143,10 @@ again:
|
||||
*/
|
||||
static isc_result_t
|
||||
dump_rdataset_raw(isc_mem_t *mctx, const dns_name_t *name,
|
||||
dns_rdataset_t *rdataset, isc_buffer_t *buffer, FILE *f)
|
||||
{
|
||||
dns_rdataset_t *rdataset, isc_buffer_t *buffer, FILE *f) {
|
||||
isc_result_t result;
|
||||
uint32_t totallen;
|
||||
uint16_t dlen;
|
||||
uint32_t totallen;
|
||||
uint16_t dlen;
|
||||
isc_region_t r, r_hdr;
|
||||
|
||||
REQUIRE(buffer->length > 0);
|
||||
@@ -1200,7 +1199,7 @@ restart:
|
||||
*/
|
||||
if (isc_buffer_availablelength(buffer) <
|
||||
sizeof(dlen) + r.length) {
|
||||
int newlength;
|
||||
int newlength;
|
||||
void *newmem;
|
||||
|
||||
newlength = buffer->length * 2;
|
||||
@@ -1249,24 +1248,25 @@ restart:
|
||||
static isc_result_t
|
||||
dump_rdatasets_raw(isc_mem_t *mctx, const dns_name_t *owner_name,
|
||||
dns_rdatasetiter_t *rdsiter, dns_totext_ctx_t *ctx,
|
||||
isc_buffer_t *buffer, FILE *f)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_rdataset_t rdataset;
|
||||
isc_buffer_t *buffer, FILE *f) {
|
||||
isc_result_t result;
|
||||
dns_rdataset_t rdataset;
|
||||
dns_fixedname_t fixed;
|
||||
dns_name_t * name;
|
||||
dns_name_t *name;
|
||||
|
||||
name = dns_fixedname_initname(&fixed);
|
||||
dns_name_copynf(owner_name, name);
|
||||
for (result = dns_rdatasetiter_first(rdsiter); result == ISC_R_SUCCESS;
|
||||
result = dns_rdatasetiter_next(rdsiter)) {
|
||||
result = dns_rdatasetiter_next(rdsiter))
|
||||
{
|
||||
dns_rdataset_init(&rdataset);
|
||||
dns_rdatasetiter_current(rdsiter, &rdataset);
|
||||
|
||||
dns_rdataset_getownercase(&rdataset, name);
|
||||
|
||||
if (((rdataset.attributes & DNS_RDATASETATTR_NEGATIVE) != 0) &&
|
||||
(ctx->style.flags & DNS_STYLEFLAG_NCACHE) == 0) {
|
||||
(ctx->style.flags & DNS_STYLEFLAG_NCACHE) == 0)
|
||||
{
|
||||
/* Omit negative cache entries */
|
||||
} else {
|
||||
result = dump_rdataset_raw(mctx, name, &rdataset,
|
||||
@@ -1288,8 +1288,7 @@ dump_rdatasets_raw(isc_mem_t *mctx, const dns_name_t *owner_name,
|
||||
static isc_result_t
|
||||
dump_rdatasets_map(isc_mem_t *mctx, const dns_name_t *name,
|
||||
dns_rdatasetiter_t *rdsiter, dns_totext_ctx_t *ctx,
|
||||
isc_buffer_t *buffer, FILE *f)
|
||||
{
|
||||
isc_buffer_t *buffer, FILE *f) {
|
||||
UNUSED(mctx);
|
||||
UNUSED(name);
|
||||
UNUSED(rdsiter);
|
||||
@@ -1312,12 +1311,10 @@ dump_rdatasets_map(isc_mem_t *mctx, const dns_name_t *name,
|
||||
*/
|
||||
static const int initial_buffer_length = 1200;
|
||||
|
||||
static isc_result_t
|
||||
dumptostreaminc(dns_dumpctx_t *dctx);
|
||||
static isc_result_t dumptostreaminc(dns_dumpctx_t *dctx);
|
||||
|
||||
static void
|
||||
dumpctx_destroy(dns_dumpctx_t *dctx)
|
||||
{
|
||||
dumpctx_destroy(dns_dumpctx_t *dctx) {
|
||||
dctx->magic = 0;
|
||||
isc_mutex_destroy(&dctx->lock);
|
||||
dns_dbiterator_destroy(&dctx->dbiter);
|
||||
@@ -1338,8 +1335,7 @@ dumpctx_destroy(dns_dumpctx_t *dctx)
|
||||
}
|
||||
|
||||
void
|
||||
dns_dumpctx_attach(dns_dumpctx_t *source, dns_dumpctx_t **target)
|
||||
{
|
||||
dns_dumpctx_attach(dns_dumpctx_t *source, dns_dumpctx_t **target) {
|
||||
REQUIRE(DNS_DCTX_VALID(source));
|
||||
REQUIRE(target != NULL && *target == NULL);
|
||||
|
||||
@@ -1349,8 +1345,7 @@ dns_dumpctx_attach(dns_dumpctx_t *source, dns_dumpctx_t **target)
|
||||
}
|
||||
|
||||
void
|
||||
dns_dumpctx_detach(dns_dumpctx_t **dctxp)
|
||||
{
|
||||
dns_dumpctx_detach(dns_dumpctx_t **dctxp) {
|
||||
dns_dumpctx_t *dctx;
|
||||
|
||||
REQUIRE(dctxp != NULL);
|
||||
@@ -1364,30 +1359,26 @@ dns_dumpctx_detach(dns_dumpctx_t **dctxp)
|
||||
}
|
||||
|
||||
dns_dbversion_t *
|
||||
dns_dumpctx_version(dns_dumpctx_t *dctx)
|
||||
{
|
||||
dns_dumpctx_version(dns_dumpctx_t *dctx) {
|
||||
REQUIRE(DNS_DCTX_VALID(dctx));
|
||||
return (dctx->version);
|
||||
}
|
||||
|
||||
dns_db_t *
|
||||
dns_dumpctx_db(dns_dumpctx_t *dctx)
|
||||
{
|
||||
dns_dumpctx_db(dns_dumpctx_t *dctx) {
|
||||
REQUIRE(DNS_DCTX_VALID(dctx));
|
||||
return (dctx->db);
|
||||
}
|
||||
|
||||
void
|
||||
dns_dumpctx_cancel(dns_dumpctx_t *dctx)
|
||||
{
|
||||
dns_dumpctx_cancel(dns_dumpctx_t *dctx) {
|
||||
REQUIRE(DNS_DCTX_VALID(dctx));
|
||||
|
||||
atomic_store_release(&dctx->canceled, true);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
flushandsync(FILE *f, isc_result_t result, const char *temp)
|
||||
{
|
||||
flushandsync(FILE *f, isc_result_t result, const char *temp) {
|
||||
bool logit = (result == ISC_R_SUCCESS);
|
||||
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
@@ -1428,10 +1419,10 @@ flushandsync(FILE *f, isc_result_t result, const char *temp)
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
closeandrename(FILE *f, isc_result_t result, const char *temp, const char *file)
|
||||
{
|
||||
closeandrename(FILE *f, isc_result_t result, const char *temp,
|
||||
const char *file) {
|
||||
isc_result_t tresult;
|
||||
bool logit = (result == ISC_R_SUCCESS);
|
||||
bool logit = (result == ISC_R_SUCCESS);
|
||||
|
||||
result = flushandsync(f, result, temp);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
@@ -1464,10 +1455,9 @@ closeandrename(FILE *f, isc_result_t result, const char *temp, const char *file)
|
||||
}
|
||||
|
||||
static void
|
||||
dump_quantum(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_result_t tresult;
|
||||
dump_quantum(isc_task_t *task, isc_event_t *event) {
|
||||
isc_result_t result;
|
||||
isc_result_t tresult;
|
||||
dns_dumpctx_t *dctx;
|
||||
|
||||
REQUIRE(event != NULL);
|
||||
@@ -1499,8 +1489,7 @@ dump_quantum(isc_task_t *task, isc_event_t *event)
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
task_send(dns_dumpctx_t *dctx)
|
||||
{
|
||||
task_send(dns_dumpctx_t *dctx) {
|
||||
isc_event_t *event;
|
||||
|
||||
event = isc_event_allocate(dctx->mctx, NULL, DNS_EVENT_DUMPQUANTUM,
|
||||
@@ -1512,11 +1501,10 @@ task_send(dns_dumpctx_t *dctx)
|
||||
static isc_result_t
|
||||
dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
|
||||
const dns_master_style_t *style, FILE *f, dns_dumpctx_t **dctxp,
|
||||
dns_masterformat_t format, dns_masterrawheader_t *header)
|
||||
{
|
||||
dns_masterformat_t format, dns_masterrawheader_t *header) {
|
||||
dns_dumpctx_t *dctx;
|
||||
isc_result_t result;
|
||||
unsigned int options;
|
||||
isc_result_t result;
|
||||
unsigned int options;
|
||||
|
||||
dctx = isc_mem_get(mctx, sizeof(*dctx));
|
||||
|
||||
@@ -1578,7 +1566,8 @@ dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
|
||||
}
|
||||
|
||||
if (dctx->format == dns_masterformat_text &&
|
||||
(dctx->tctx.style.flags & DNS_STYLEFLAG_REL_OWNER) != 0) {
|
||||
(dctx->tctx.style.flags & DNS_STYLEFLAG_REL_OWNER) != 0)
|
||||
{
|
||||
options = DNS_DB_RELATIVENAMES;
|
||||
} else {
|
||||
options = 0;
|
||||
@@ -1614,14 +1603,13 @@ cleanup:
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
writeheader(dns_dumpctx_t *dctx)
|
||||
{
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
isc_buffer_t buffer;
|
||||
char * bufmem;
|
||||
isc_region_t r;
|
||||
writeheader(dns_dumpctx_t *dctx) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
isc_buffer_t buffer;
|
||||
char *bufmem;
|
||||
isc_region_t r;
|
||||
dns_masterrawheader_t rawheader;
|
||||
uint32_t rawversion, now32;
|
||||
uint32_t rawversion, now32;
|
||||
|
||||
bufmem = isc_mem_get(dctx->mctx, initial_buffer_length);
|
||||
|
||||
@@ -1688,15 +1676,14 @@ writeheader(dns_dumpctx_t *dctx)
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
dumptostreaminc(dns_dumpctx_t *dctx)
|
||||
{
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
isc_buffer_t buffer;
|
||||
char * bufmem;
|
||||
dns_name_t * name;
|
||||
dumptostreaminc(dns_dumpctx_t *dctx) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
isc_buffer_t buffer;
|
||||
char *bufmem;
|
||||
dns_name_t *name;
|
||||
dns_fixedname_t fixname;
|
||||
unsigned int nodes;
|
||||
isc_time_t start;
|
||||
unsigned int nodes;
|
||||
isc_time_t start;
|
||||
|
||||
bufmem = isc_mem_get(dctx->mctx, initial_buffer_length);
|
||||
|
||||
@@ -1733,7 +1720,7 @@ dumptostreaminc(dns_dumpctx_t *dctx)
|
||||
isc_time_now(&start);
|
||||
while (result == ISC_R_SUCCESS && (dctx->nodes == 0 || nodes--)) {
|
||||
dns_rdatasetiter_t *rdsiter = NULL;
|
||||
dns_dbnode_t * node = NULL;
|
||||
dns_dbnode_t *node = NULL;
|
||||
|
||||
result = dns_dbiterator_current(dctx->dbiter, &node, name);
|
||||
if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN) {
|
||||
@@ -1776,8 +1763,8 @@ dumptostreaminc(dns_dumpctx_t *dctx)
|
||||
if (dctx->nodes != 0 && result == ISC_R_SUCCESS) {
|
||||
unsigned int pps = dns_pps; /* packets per second */
|
||||
unsigned int interval;
|
||||
uint64_t usecs;
|
||||
isc_time_t end;
|
||||
uint64_t usecs;
|
||||
isc_time_t end;
|
||||
|
||||
isc_time_now(&end);
|
||||
if (pps < 100) {
|
||||
@@ -1823,13 +1810,12 @@ cleanup:
|
||||
|
||||
isc_result_t
|
||||
dns_master_dumptostreaminc(isc_mem_t *mctx, dns_db_t *db,
|
||||
dns_dbversion_t * version,
|
||||
dns_dbversion_t *version,
|
||||
const dns_master_style_t *style, FILE *f,
|
||||
isc_task_t *task, dns_dumpdonefunc_t done,
|
||||
void *done_arg, dns_dumpctx_t **dctxp)
|
||||
{
|
||||
void *done_arg, dns_dumpctx_t **dctxp) {
|
||||
dns_dumpctx_t *dctx = NULL;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(task != NULL);
|
||||
REQUIRE(f != NULL);
|
||||
@@ -1858,11 +1844,10 @@ dns_master_dumptostreaminc(isc_mem_t *mctx, dns_db_t *db,
|
||||
isc_result_t
|
||||
dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
|
||||
const dns_master_style_t *style,
|
||||
dns_masterformat_t format,
|
||||
dns_masterrawheader_t *header, FILE *f)
|
||||
{
|
||||
dns_masterformat_t format,
|
||||
dns_masterrawheader_t *header, FILE *f) {
|
||||
dns_dumpctx_t *dctx = NULL;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
|
||||
result = dumpctx_create(mctx, db, version, style, f, &dctx, format,
|
||||
header);
|
||||
@@ -1880,12 +1865,11 @@ dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
|
||||
|
||||
static isc_result_t
|
||||
opentmp(isc_mem_t *mctx, dns_masterformat_t format, const char *file,
|
||||
char **tempp, FILE **fp)
|
||||
{
|
||||
FILE * f = NULL;
|
||||
char **tempp, FILE **fp) {
|
||||
FILE *f = NULL;
|
||||
isc_result_t result;
|
||||
char * tempname = NULL;
|
||||
int tempnamelen;
|
||||
char *tempname = NULL;
|
||||
int tempnamelen;
|
||||
|
||||
tempnamelen = strlen(file) + 20;
|
||||
tempname = isc_mem_allocate(mctx, tempnamelen);
|
||||
@@ -1921,12 +1905,11 @@ dns_master_dumpinc(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
|
||||
const dns_master_style_t *style, const char *filename,
|
||||
isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg,
|
||||
dns_dumpctx_t **dctxp, dns_masterformat_t format,
|
||||
dns_masterrawheader_t *header)
|
||||
{
|
||||
FILE * f = NULL;
|
||||
isc_result_t result;
|
||||
char * tempname = NULL;
|
||||
char * file = NULL;
|
||||
dns_masterrawheader_t *header) {
|
||||
FILE *f = NULL;
|
||||
isc_result_t result;
|
||||
char *tempname = NULL;
|
||||
char *file = NULL;
|
||||
dns_dumpctx_t *dctx = NULL;
|
||||
|
||||
file = isc_mem_strdup(mctx, filename);
|
||||
@@ -1975,11 +1958,10 @@ cleanup:
|
||||
isc_result_t
|
||||
dns_master_dump(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
|
||||
const dns_master_style_t *style, const char *filename,
|
||||
dns_masterformat_t format, dns_masterrawheader_t *header)
|
||||
{
|
||||
FILE * f = NULL;
|
||||
isc_result_t result;
|
||||
char * tempname;
|
||||
dns_masterformat_t format, dns_masterrawheader_t *header) {
|
||||
FILE *f = NULL;
|
||||
isc_result_t result;
|
||||
char *tempname;
|
||||
dns_dumpctx_t *dctx = NULL;
|
||||
|
||||
result = opentmp(mctx, format, filename, &tempname, &f);
|
||||
@@ -2011,14 +1993,13 @@ cleanup:
|
||||
isc_result_t
|
||||
dns_master_dumpnodetostream(isc_mem_t *mctx, dns_db_t *db,
|
||||
dns_dbversion_t *version, dns_dbnode_t *node,
|
||||
const dns_name_t * name,
|
||||
const dns_master_style_t *style, FILE *f)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_buffer_t buffer;
|
||||
char * bufmem;
|
||||
isc_stdtime_t now;
|
||||
dns_totext_ctx_t ctx;
|
||||
const dns_name_t *name,
|
||||
const dns_master_style_t *style, FILE *f) {
|
||||
isc_result_t result;
|
||||
isc_buffer_t buffer;
|
||||
char *bufmem;
|
||||
isc_stdtime_t now;
|
||||
dns_totext_ctx_t ctx;
|
||||
dns_rdatasetiter_t *rdsiter = NULL;
|
||||
|
||||
result = totext_ctx_init(style, NULL, &ctx);
|
||||
@@ -2054,9 +2035,8 @@ failure:
|
||||
isc_result_t
|
||||
dns_master_dumpnode(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
|
||||
dns_dbnode_t *node, const dns_name_t *name,
|
||||
const dns_master_style_t *style, const char *filename)
|
||||
{
|
||||
FILE * f = NULL;
|
||||
const dns_master_style_t *style, const char *filename) {
|
||||
FILE *f = NULL;
|
||||
isc_result_t result;
|
||||
|
||||
result = isc_stdio_open(filename, "w", &f);
|
||||
@@ -2092,20 +2072,18 @@ dns_master_dumpnode(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
|
||||
}
|
||||
|
||||
dns_masterstyle_flags_t
|
||||
dns_master_styleflags(const dns_master_style_t *style)
|
||||
{
|
||||
dns_master_styleflags(const dns_master_style_t *style) {
|
||||
REQUIRE(style != NULL);
|
||||
return (style->flags);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_master_stylecreate(dns_master_style_t ** stylep,
|
||||
dns_master_stylecreate(dns_master_style_t **stylep,
|
||||
dns_masterstyle_flags_t flags, unsigned int ttl_column,
|
||||
unsigned int class_column, unsigned int type_column,
|
||||
unsigned int rdata_column, unsigned int line_length,
|
||||
unsigned int tab_width, unsigned int split_width,
|
||||
isc_mem_t *mctx)
|
||||
{
|
||||
isc_mem_t *mctx) {
|
||||
dns_master_style_t *style;
|
||||
|
||||
REQUIRE(stylep != NULL && *stylep == NULL);
|
||||
@@ -2124,8 +2102,7 @@ dns_master_stylecreate(dns_master_style_t ** stylep,
|
||||
}
|
||||
|
||||
void
|
||||
dns_master_styledestroy(dns_master_style_t **stylep, isc_mem_t *mctx)
|
||||
{
|
||||
dns_master_styledestroy(dns_master_style_t **stylep, isc_mem_t *mctx) {
|
||||
dns_master_style_t *style;
|
||||
|
||||
REQUIRE(stylep != NULL && *stylep != NULL);
|
||||
|
Reference in New Issue
Block a user