summaryrefslogtreecommitdiffstats
path: root/src/compat.h
blob: 8d7cff188638ba8eddc7ce2c45048f6e19934bc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * Authors: Martin Nagy <mnagy@redhat.com>
 *
 * Copyright (C) 2009  Red Hat
 * see file 'COPYING' for use and warranty information
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; version 2 or later
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#else
#error "Can't compile without config.h"
#endif

/*
 * dns_rdatalist_fromrdataset() did not exist in older versions of libdns.
 * Add a substitude function here.
 */
#if LIBDNS_VERSION_MAJOR < 40
static inline isc_result_t
dns_rdatalist_fromrdataset(dns_rdataset_t *rdataset,
			   dns_rdatalist_t **rdatalist)
{
	REQUIRE(rdatalist != NULL && rdataset != NULL);

	*rdatalist = rdataset->private1;

	return ISC_R_SUCCESS;
}
#endif /* LIBDNS_VERSION_MAJOR < 40 */

/*
 * In older libdns versions, isc_refcount_init() was defined as a macro.
 * However, in newer versions, it is a function returning isc_result_t type.
 * This piece of code should take care of that problem.
 */
#if LIBDNS_VERSION_MAJOR < 30
#include <isc/refcount.h>

static inline isc_result_t
isc_refcount_init_func(isc_refcount_t *ref, unsigned int n)
{
	isc_refcount_init(ref, n);
	return ISC_R_SUCCESS;
}
#undef isc_refcount_init
#define isc_refcount_init isc_refcount_init_func
#endif /* LIBDNS_VERSION_MAJOR < 30 */