1246853Sdes/**
2246853Sdes * \file common.h
3246853Sdes *
4246853Sdes * Common definitions for LDNS
5246853Sdes */
6246853Sdes
7246853Sdes/**
8246853Sdes * a Net::DNS like library for C
9246853Sdes *
10246853Sdes * (c) NLnet Labs, 2004-2006
11246853Sdes *
12246853Sdes * See the file LICENSE for the license
13246853Sdes */
14246853Sdes
15246853Sdes#ifndef LDNS_COMMON_H
16246853Sdes#define LDNS_COMMON_H
17246853Sdes
18246853Sdes/*
19246853Sdes * The build configuration that is used in the distributed headers,
20246853Sdes * as detected and determined by the auto configure script.
21246853Sdes */
22246853Sdes#define LDNS_BUILD_CONFIG_HAVE_SSL         1
23246853Sdes#define LDNS_BUILD_CONFIG_HAVE_INTTYPES_H  1
24246853Sdes#define LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT 1
25246853Sdes#define LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED 1
26246854Sdes#define LDNS_BUILD_CONFIG_HAVE_SOCKLEN_T   1
27269257Sdes#define LDNS_BUILD_CONFIG_USE_DANE         1
28269257Sdes#define LDNS_BUILD_CONFIG_HAVE_B32_PTON    0
29269257Sdes#define LDNS_BUILD_CONFIG_HAVE_B32_NTOP    0
30246853Sdes
31246853Sdes/*
32246853Sdes * HAVE_STDBOOL_H is not available when distributed as a library, but no build
33246853Sdes * configuration variables may be used (like those above) because the header
34246853Sdes * is sometimes only available when using special compiler flags to enable the
35246853Sdes * c99 environment. Because we cannot force the usage of this flag, we have to
36246853Sdes * provide a default type. Below what is suggested by the autoconf manual.
37246853Sdes */
38246853Sdes/*@ignore@*/
39246853Sdes/* splint barfs on this construct */
40246853Sdes#ifdef HAVE_STDBOOL_H
41246853Sdes# include <stdbool.h>
42246853Sdes#else
43246853Sdes# ifndef HAVE__BOOL
44246853Sdes#  ifdef __cplusplus
45246853Sdestypedef bool _Bool;
46246853Sdes#  else
47246853Sdes#   define _Bool signed char
48246853Sdes#  endif
49246853Sdes# endif
50246853Sdes# define bool _Bool
51246853Sdes# define false 0
52246853Sdes# define true 1
53246853Sdes# define __bool_true_false_are_defined 1
54246853Sdes#endif
55246853Sdes/*@end@*/
56246853Sdes
57246853Sdes#if LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT
58246853Sdes#define ATTR_FORMAT(archetype, string_index, first_to_check) \
59246853Sdes    __attribute__ ((format (archetype, string_index, first_to_check)))
60246853Sdes#else /* !LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT */
61246853Sdes#define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */
62246853Sdes#endif /* !LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT */
63246853Sdes
64246853Sdes#if defined(__cplusplus)
65246853Sdes#define ATTR_UNUSED(x)
66246853Sdes#elif LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED
67246853Sdes#define ATTR_UNUSED(x)  x __attribute__((unused))
68246853Sdes#else /* !LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED */
69246853Sdes#define ATTR_UNUSED(x)  x
70246853Sdes#endif /* !LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED */
71246853Sdes
72246854Sdes#if !LDNS_BUILD_CONFIG_HAVE_SOCKLEN_T
73246854Sdestypedef int socklen_t;
74246854Sdes#endif
75246854Sdes
76246853Sdes#endif /* LDNS_COMMON_H */
77