2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 14:07:59 +00:00

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.
This commit is contained in:
Mark Andrews
1999-01-28 22:32:45 +00:00
parent 918ef3a73e
commit 923e2ea400
3 changed files with 22 additions and 18 deletions

View File

@@ -14,17 +14,17 @@
#include <dns/types.h> #include <dns/types.h>
dns_result_t print_dataset(dns_name_t *owner, dns_rdataset_t *dataset, dns_result_t print_dataset(dns_name_t *owner, dns_rdataset_t *dataset,
isc_mem_t *mctx); void *private);
isc_mem_t *mctx; isc_mem_t *mctx;
dns_result_t 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]; char buf[64*1024];
isc_buffer_t target; isc_buffer_t target;
dns_result_t result; dns_result_t result;
mctx = mctx; private = private;
isc_buffer_init(&target, buf, 64*1024, ISC_BUFFERTYPE_TEXT); isc_buffer_init(&target, buf, 64*1024, ISC_BUFFERTYPE_TEXT);
result = dns_rdataset_totext(dataset, owner, ISC_FALSE, &target); 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, result = dns_load_master(argv[1], &origin, &origin, 1,
&soacount, &nscount, &soacount, &nscount,
print_dataset, mctx); print_dataset, NULL, mctx);
fprintf(stdout, "dns_load_master: %s\n", fprintf(stdout, "dns_load_master: %s\n",
dns_result_totext(result)); dns_result_totext(result));
if (result == DNS_R_SUCCESS) if (result == DNS_R_SUCCESS)

View File

@@ -33,6 +33,7 @@ dns_result_t dns_load_master(char *master_file,
int *nscount, int *nscount,
dns_result_t (*callback)(dns_name_t *owner, dns_result_t (*callback)(dns_name_t *owner,
dns_rdataset_t *dataset, dns_rdataset_t *dataset,
isc_mem_t *mctx), void *private),
void *private,
isc_mem_t *mctx); isc_mem_t *mctx);
#endif /* DNS_MASTER_H */ #endif /* DNS_MASTER_H */

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * 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 <config.h> #include <config.h>
@@ -41,8 +41,8 @@ typedef ISC_LIST(dns_rdatalist_t) rdatalist_head_t;
static dns_result_t commit(rdatalist_head_t *, dns_name_t *, static dns_result_t commit(rdatalist_head_t *, dns_name_t *,
dns_result_t (*)(dns_name_t *, dns_result_t (*)(dns_name_t *,
dns_rdataset_t *, dns_rdataset_t *,
isc_mem_t *), void *),
isc_mem_t *); void *);
static isc_boolean_t is_glue(rdatalist_head_t *, dns_name_t *); static isc_boolean_t is_glue(rdatalist_head_t *, dns_name_t *);
static dns_rdatalist_t *grow_rdatalist(int, dns_rdatalist_t *, int, static dns_rdatalist_t *grow_rdatalist(int, dns_rdatalist_t *, int,
rdatalist_head_t *, 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_load_master(char *master_file, dns_name_t *top, dns_name_t *origin,
dns_rdataclass_t zclass, int *soacount, int *nscount, dns_rdataclass_t zclass, int *soacount, int *nscount,
dns_result_t (*callback)(dns_name_t *, dns_rdataset_t *, dns_result_t (*callback)(dns_name_t *, dns_rdataset_t *,
isc_mem_t *mctx), void *private),
isc_mem_t *mctx) void *private, isc_mem_t *mctx)
{ {
dns_rdataclass_t class; dns_rdataclass_t class;
dns_rdatatype_t type; dns_rdatatype_t type;
@@ -218,6 +218,7 @@ dns_load_master(char *master_file, dns_name_t *top, dns_name_t *origin,
soacount, soacount,
nscount, nscount,
callback, callback,
private,
mctx); mctx);
if (result != DNS_R_SUCCESS) if (result != DNS_R_SUCCESS)
goto cleanup; goto cleanup;
@@ -263,6 +264,7 @@ dns_load_master(char *master_file, dns_name_t *top, dns_name_t *origin,
soacount, soacount,
nscount, nscount,
callback, callback,
private,
mctx); mctx);
if (result != DNS_R_SUCCESS) if (result != DNS_R_SUCCESS)
goto cleanup; 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, if (in_glue && dns_name_compare(&glue_name,
&new_name) != 0) { &new_name) != 0) {
result = commit(&glue_list, result = commit(&glue_list,
&glue_name, callback, mctx); &glue_name, callback, private);
if (result != DNS_R_SUCCESS) if (result != DNS_R_SUCCESS)
goto cleanup; goto cleanup;
if (glue_in_use != -1) if (glue_in_use != -1)
@@ -302,7 +304,7 @@ dns_load_master(char *master_file, dns_name_t *top, dns_name_t *origin,
} else { } else {
result = commit(&current_list, result = commit(&current_list,
&current_name, &current_name,
callback, mctx); callback, private);
if (result != DNS_R_SUCCESS) if (result != DNS_R_SUCCESS)
goto cleanup; goto cleanup;
rdcount = 0; 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. */ /* We must have at least 64k as rdlen is 16 bits. */
if (target.used > (64*1024)) { if (target.used > (64*1024)) {
result = commit(&current_list, &current_name, result = commit(&current_list, &current_name,
callback, mctx); callback, private);
if (result != DNS_R_SUCCESS) if (result != DNS_R_SUCCESS)
goto cleanup; goto cleanup;
result = commit(&glue_list, &glue_name, result = commit(&glue_list, &glue_name,
callback, mctx); callback, private);
if (result != DNS_R_SUCCESS) if (result != DNS_R_SUCCESS)
goto cleanup; goto cleanup;
rdcount = 0; rdcount = 0;
@@ -456,10 +458,10 @@ dns_load_master(char *master_file, dns_name_t *top, dns_name_t *origin,
ISC_BUFFERTYPE_BINARY); ISC_BUFFERTYPE_BINARY);
} }
} while (!done); } while (!done);
result = commit(&current_list, &current_name, callback, mctx); result = commit(&current_list, &current_name, callback, private);
if (result != DNS_R_SUCCESS) if (result != DNS_R_SUCCESS)
goto cleanup; goto cleanup;
result = commit(&glue_list, &glue_name, callback, mctx); result = commit(&glue_list, &glue_name, callback, private);
if (result != DNS_R_SUCCESS) if (result != DNS_R_SUCCESS)
goto cleanup; goto cleanup;
result = DNS_R_SUCCESS; result = DNS_R_SUCCESS;
@@ -586,7 +588,8 @@ grow_rdata(int new_len, dns_rdata_t *old, int old_len,
static dns_result_t static dns_result_t
commit(rdatalist_head_t *head, dns_name_t *owner, 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_rdatalist_t *this;
dns_rdataset_t dataset; dns_rdataset_t dataset;
@@ -596,7 +599,7 @@ commit(rdatalist_head_t *head, dns_name_t *owner,
dns_rdataset_init(&dataset); dns_rdataset_init(&dataset);
dns_rdatalist_tordataset(this, &dataset); dns_rdatalist_tordataset(this, &dataset);
result = ((*callback)(owner, &dataset, mctx)); result = ((*callback)(owner, &dataset, private));
if (result != DNS_R_SUCCESS) if (result != DNS_R_SUCCESS)
return (result); return (result);
ISC_LIST_UNLINK(*head, this, link); ISC_LIST_UNLINK(*head, this, link);