diff --git a/lib/dns/callbacks.c b/lib/dns/callbacks.c new file mode 100644 index 0000000000..1278fd7312 --- /dev/null +++ b/lib/dns/callbacks.c @@ -0,0 +1,59 @@ +/* + * Copyright (C) 1999 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + + /* $Id: callbacks.c,v 1.1 1999/02/10 05:22:01 marka Exp $ */ + +#include + +#include + +#include +#include + +static void default_error_warn_callback(dns_rdatacallbacks_t *, char *, ...); + +/* + * Public. + */ + +void +dns_rdatacallbacks_init(dns_rdatacallbacks_t *callbacks) { + + REQUIRE(callbacks != NULL); + + callbacks->commit = NULL; + callbacks->error = default_error_warn_callback; + callbacks->warn = default_error_warn_callback; + callbacks->commit_private = NULL; + callbacks->error_private = NULL; + callbacks->warn_private = NULL; +} + +/* + * Private + */ + +static void +default_error_warn_callback(dns_rdatacallbacks_t *callbacks, char *fmt, ...) { + va_list ap; + + callbacks = callbacks; /*unused*/ + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); +} diff --git a/lib/dns/include/dns/callbacks.h b/lib/dns/include/dns/callbacks.h index 52d43a5844..ed97946f21 100644 --- a/lib/dns/include/dns/callbacks.h +++ b/lib/dns/include/dns/callbacks.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1999 Internet Software Consortium. + * Copyright (C) 1999 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -17,9 +17,19 @@ #ifndef DNS_CALLBACKS_H #define DNS_CALLBACKS_H 1 + +/*** + *** Imports + ***/ + +#include #include #include +/*** + *** Types + ***/ + typedef struct dns_rdatacallbacks { /* dns_load_master calls this when it has rdatasets to commit */ dns_result_t (*commit)(struct dns_rdatacallbacks *, @@ -34,4 +44,17 @@ typedef struct dns_rdatacallbacks { void *warn_private; } dns_rdatacallbacks_t; +/*** + *** Initialization + ***/ + +void dns_rdatacallbacks_init(dns_rdatacallbacks_t *callbacks); + +/* + * Make 'callbacks' empty. + * + * Requires: + * 'callbacks' is a valid dns_rdatacallbacks_t, + */ + #endif /* DNS_CALLBACKS_H */