Add dns_rdatacallbacks_init().

This commit is contained in:
Mark Andrews 1999-02-10 05:22:02 +00:00
parent df1ba071bc
commit 8eaa2ef566
2 changed files with 83 additions and 1 deletions

59
lib/dns/callbacks.c Normal file
View file

@ -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 <config.h>
#include <stdarg.h>
#include <isc/assertions.h>
#include <dns/callbacks.h>
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);
}

View file

@ -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 <stdio.h>
#include <dns/types.h>
#include <dns/result.h>
/***
*** 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 */