Commit 923e2ea4 authored by Mark Andrews's avatar Mark Andrews
Browse files

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.
parent 918ef3a7
......@@ -14,17 +14,17 @@
#include <dns/types.h>
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)
......
......@@ -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 */
......@@ -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 <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 *,
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(&current_list,
&current_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(&current_list, &current_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(&current_list, &current_name, callback, mctx);
result = commit(&current_list, &current_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);
......
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