1238104Sdes/**
2238104Sdes * \file common.h
3238104Sdes *
4238104Sdes * Common definitions for LDNS
5238104Sdes */
6238104Sdes
7238104Sdes/**
8238104Sdes * a Net::DNS like library for C
9238104Sdes *
10238104Sdes * (c) NLnet Labs, 2004-2006
11238104Sdes *
12238104Sdes * See the file LICENSE for the license
13238104Sdes */
14238104Sdes
15238104Sdes#ifndef LDNS_COMMON_H
16238104Sdes#define LDNS_COMMON_H
17238104Sdes
18238104Sdes/*
19238104Sdes * The build configuration that is used in the distributed headers,
20238104Sdes * as detected and determined by the auto configure script.
21238104Sdes */
22238104Sdes#define LDNS_BUILD_CONFIG_HAVE_SSL         @ldns_build_config_have_ssl@
23238104Sdes#define LDNS_BUILD_CONFIG_HAVE_INTTYPES_H  @ldns_build_config_have_inttypes_h@
24238104Sdes#define LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT @ldns_build_config_have_attr_format@
25238104Sdes#define LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED @ldns_build_config_have_attr_unused@
26246854Sdes#define LDNS_BUILD_CONFIG_HAVE_SOCKLEN_T   @ldns_build_config_have_socklen_t@
27238104Sdes
28238104Sdes/*
29238104Sdes * HAVE_STDBOOL_H is not available when distributed as a library, but no build 
30238104Sdes * configuration variables may be used (like those above) because the header
31238104Sdes * is sometimes only available when using special compiler flags to enable the
32238104Sdes * c99 environment. Because we cannot force the usage of this flag, we have to
33238104Sdes * provide a default type. Below what is suggested by the autoconf manual.
34238104Sdes */
35238104Sdes/*@ignore@*/
36238104Sdes/* splint barfs on this construct */
37238104Sdes#ifdef HAVE_STDBOOL_H
38238104Sdes# include <stdbool.h>
39238104Sdes#else
40238104Sdes# ifndef HAVE__BOOL
41238104Sdes#  ifdef __cplusplus
42238104Sdestypedef bool _Bool;
43238104Sdes#  else
44238104Sdes#   define _Bool signed char
45238104Sdes#  endif
46238104Sdes# endif
47238104Sdes# define bool _Bool
48238104Sdes# define false 0
49238104Sdes# define true 1
50238104Sdes# define __bool_true_false_are_defined 1
51238104Sdes#endif
52238104Sdes/*@end@*/
53238104Sdes
54238104Sdes#if LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT
55238104Sdes#define ATTR_FORMAT(archetype, string_index, first_to_check) \
56238104Sdes    __attribute__ ((format (archetype, string_index, first_to_check)))
57238104Sdes#else /* !LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT */
58238104Sdes#define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */
59238104Sdes#endif /* !LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT */
60238104Sdes
61238104Sdes#if defined(__cplusplus)
62238104Sdes#define ATTR_UNUSED(x)
63238104Sdes#elif LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED
64238104Sdes#define ATTR_UNUSED(x)  x __attribute__((unused))
65238104Sdes#else /* !LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED */
66238104Sdes#define ATTR_UNUSED(x)  x
67238104Sdes#endif /* !LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED */
68238104Sdes
69246854Sdes#if !LDNS_BUILD_CONFIG_HAVE_SOCKLEN_T
70246854Sdestypedef int socklen_t;
71246854Sdes#endif
72246854Sdes
73238104Sdes#endif /* LDNS_COMMON_H */
74