common.h revision 269257
1/**
2 * \file common.h
3 *
4 * Common definitions for LDNS
5 */
6
7/**
8 * a Net::DNS like library for C
9 *
10 * (c) NLnet Labs, 2004-2006
11 *
12 * See the file LICENSE for the license
13 */
14
15#ifndef LDNS_COMMON_H
16#define LDNS_COMMON_H
17
18/*
19 * The build configuration that is used in the distributed headers,
20 * as detected and determined by the auto configure script.
21 */
22#define LDNS_BUILD_CONFIG_HAVE_SSL         1
23#define LDNS_BUILD_CONFIG_HAVE_INTTYPES_H  1
24#define LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT 1
25#define LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED 1
26#define LDNS_BUILD_CONFIG_HAVE_SOCKLEN_T   1
27#define LDNS_BUILD_CONFIG_USE_DANE         1
28#define LDNS_BUILD_CONFIG_HAVE_B32_PTON    0
29#define LDNS_BUILD_CONFIG_HAVE_B32_NTOP    0
30
31/*
32 * HAVE_STDBOOL_H is not available when distributed as a library, but no build
33 * configuration variables may be used (like those above) because the header
34 * is sometimes only available when using special compiler flags to enable the
35 * c99 environment. Because we cannot force the usage of this flag, we have to
36 * provide a default type. Below what is suggested by the autoconf manual.
37 */
38/*@ignore@*/
39/* splint barfs on this construct */
40#ifdef HAVE_STDBOOL_H
41# include <stdbool.h>
42#else
43# ifndef HAVE__BOOL
44#  ifdef __cplusplus
45typedef bool _Bool;
46#  else
47#   define _Bool signed char
48#  endif
49# endif
50# define bool _Bool
51# define false 0
52# define true 1
53# define __bool_true_false_are_defined 1
54#endif
55/*@end@*/
56
57#if LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT
58#define ATTR_FORMAT(archetype, string_index, first_to_check) \
59    __attribute__ ((format (archetype, string_index, first_to_check)))
60#else /* !LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT */
61#define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */
62#endif /* !LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT */
63
64#if defined(__cplusplus)
65#define ATTR_UNUSED(x)
66#elif LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED
67#define ATTR_UNUSED(x)  x __attribute__((unused))
68#else /* !LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED */
69#define ATTR_UNUSED(x)  x
70#endif /* !LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED */
71
72#if !LDNS_BUILD_CONFIG_HAVE_SOCKLEN_T
73typedef int socklen_t;
74#endif
75
76#endif /* LDNS_COMMON_H */
77