From 923e2ea4002d8b59437d2bc144f79455371431d6 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 28 Jan 1999 22:32:45 +0000 Subject: [PATCH] dns_load_master()'s callback last arguement is now void * rather than isc_mem_t * to provide a general mechanism to pass context to the call back. dns_load_master() has an additional arguement to support this. to get the old behaviour set the arguement, private, to the same value as mctx. --- bin/tests/master_test.c | 8 ++++---- lib/dns/include/dns/master.h | 3 ++- lib/dns/master.c | 29 ++++++++++++++++------------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/bin/tests/master_test.c b/bin/tests/master_test.c index 1862a6ba13..59df3b79be 100644 --- a/bin/tests/master_test.c +++ b/bin/tests/master_test.c @@ -14,17 +14,17 @@ #include dns_result_t print_dataset(dns_name_t *owner, dns_rdataset_t *dataset, - isc_mem_t *mctx); + void *private); isc_mem_t *mctx; dns_result_t -print_dataset(dns_name_t *owner, dns_rdataset_t *dataset, isc_mem_t *mctx) { +print_dataset(dns_name_t *owner, dns_rdataset_t *dataset, void *private) { char buf[64*1024]; isc_buffer_t target; dns_result_t result; - mctx = mctx; + private = private; isc_buffer_init(&target, buf, 64*1024, ISC_BUFFERTYPE_TEXT); result = dns_rdataset_totext(dataset, owner, ISC_FALSE, &target); @@ -70,7 +70,7 @@ main(int argc, char *argv[]) { result = dns_load_master(argv[1], &origin, &origin, 1, &soacount, &nscount, - print_dataset, mctx); + print_dataset, NULL, mctx); fprintf(stdout, "dns_load_master: %s\n", dns_result_totext(result)); if (result == DNS_R_SUCCESS) diff --git a/lib/dns/include/dns/master.h b/lib/dns/include/dns/master.h index d0d6cbf7b4..e4e2a1b043 100644 --- a/lib/dns/include/dns/master.h +++ b/lib/dns/include/dns/master.h @@ -33,6 +33,7 @@ dns_result_t dns_load_master(char *master_file, int *nscount, dns_result_t (*callback)(dns_name_t *owner, dns_rdataset_t *dataset, - isc_mem_t *mctx), + void *private), + void *private, isc_mem_t *mctx); #endif /* DNS_MASTER_H */ diff --git a/lib/dns/master.c b/lib/dns/master.c index a4140192ee..151606f815 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: master.c,v 1.5 1999/01/28 05:03:24 marka Exp $ */ + /* $Id: master.c,v 1.6 1999/01/28 22:32:44 marka Exp $ */ #include @@ -41,8 +41,8 @@ typedef ISC_LIST(dns_rdatalist_t) rdatalist_head_t; static dns_result_t commit(rdatalist_head_t *, dns_name_t *, dns_result_t (*)(dns_name_t *, dns_rdataset_t *, - isc_mem_t *), - isc_mem_t *); + void *), + void *); static isc_boolean_t is_glue(rdatalist_head_t *, dns_name_t *); static dns_rdatalist_t *grow_rdatalist(int, dns_rdatalist_t *, int, rdatalist_head_t *, @@ -77,8 +77,8 @@ dns_result_t dns_load_master(char *master_file, dns_name_t *top, dns_name_t *origin, dns_rdataclass_t zclass, int *soacount, int *nscount, dns_result_t (*callback)(dns_name_t *, dns_rdataset_t *, - isc_mem_t *mctx), - isc_mem_t *mctx) + void *private), + void *private, isc_mem_t *mctx) { dns_rdataclass_t class; dns_rdatatype_t type; @@ -218,6 +218,7 @@ dns_load_master(char *master_file, dns_name_t *top, dns_name_t *origin, soacount, nscount, callback, + private, mctx); if (result != DNS_R_SUCCESS) goto cleanup; @@ -263,6 +264,7 @@ dns_load_master(char *master_file, dns_name_t *top, dns_name_t *origin, soacount, nscount, callback, + private, mctx); if (result != DNS_R_SUCCESS) goto cleanup; @@ -275,7 +277,7 @@ dns_load_master(char *master_file, dns_name_t *top, dns_name_t *origin, if (in_glue && dns_name_compare(&glue_name, &new_name) != 0) { result = commit(&glue_list, - &glue_name, callback, mctx); + &glue_name, callback, private); if (result != DNS_R_SUCCESS) goto cleanup; if (glue_in_use != -1) @@ -302,7 +304,7 @@ dns_load_master(char *master_file, dns_name_t *top, dns_name_t *origin, } else { result = commit(¤t_list, ¤t_name, - callback, mctx); + callback, private); if (result != DNS_R_SUCCESS) goto cleanup; rdcount = 0; @@ -438,11 +440,11 @@ dns_load_master(char *master_file, dns_name_t *top, dns_name_t *origin, /* We must have at least 64k as rdlen is 16 bits. */ if (target.used > (64*1024)) { result = commit(¤t_list, ¤t_name, - callback, mctx); + callback, private); if (result != DNS_R_SUCCESS) goto cleanup; result = commit(&glue_list, &glue_name, - callback, mctx); + callback, private); if (result != DNS_R_SUCCESS) goto cleanup; rdcount = 0; @@ -456,10 +458,10 @@ dns_load_master(char *master_file, dns_name_t *top, dns_name_t *origin, ISC_BUFFERTYPE_BINARY); } } while (!done); - result = commit(¤t_list, ¤t_name, callback, mctx); + result = commit(¤t_list, ¤t_name, callback, private); if (result != DNS_R_SUCCESS) goto cleanup; - result = commit(&glue_list, &glue_name, callback, mctx); + result = commit(&glue_list, &glue_name, callback, private); if (result != DNS_R_SUCCESS) goto cleanup; result = DNS_R_SUCCESS; @@ -586,7 +588,8 @@ grow_rdata(int new_len, dns_rdata_t *old, int old_len, static dns_result_t commit(rdatalist_head_t *head, dns_name_t *owner, - dns_result_t (*callback)(), isc_mem_t *mctx) + dns_result_t (*callback)(dns_name_t *, dns_rdataset_t *, void *), + void *private) { dns_rdatalist_t *this; dns_rdataset_t dataset; @@ -596,7 +599,7 @@ commit(rdatalist_head_t *head, dns_name_t *owner, dns_rdataset_init(&dataset); dns_rdatalist_tordataset(this, &dataset); - result = ((*callback)(owner, &dataset, mctx)); + result = ((*callback)(owner, &dataset, private)); if (result != DNS_R_SUCCESS) return (result); ISC_LIST_UNLINK(*head, this, link);