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
27246853Sdes
28246853Sdes/*
29246853Sdes * HAVE_STDBOOL_H is not available when distributed as a library, but no build
30246853Sdes * configuration variables may be used (like those above) because the header
31246853Sdes * is sometimes only available when using special compiler flags to enable the
32246853Sdes * c99 environment. Because we cannot force the usage of this flag, we have to
33246853Sdes * provide a default type. Below what is suggested by the autoconf manual.
34246853Sdes */
35246853Sdes/*@ignore@*/
36246853Sdes/* splint barfs on this construct */
37246853Sdes#ifdef HAVE_STDBOOL_H
38246853Sdes# include <stdbool.h>
39246853Sdes#else
40246853Sdes# ifndef HAVE__BOOL
41246853Sdes#  ifdef __cplusplus
42246853Sdestypedef bool _Bool;
43246853Sdes#  else
44246853Sdes#   define _Bool signed char
45246853Sdes#  endif
46246853Sdes# endif
47246853Sdes# define bool _Bool
48246853Sdes# define false 0
49246853Sdes# define true 1
50246853Sdes# define __bool_true_false_are_defined 1
51246853Sdes#endif
52246853Sdes/*@end@*/
53246853Sdes
54246853Sdes#if LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT
55246853Sdes#define ATTR_FORMAT(archetype, string_index, first_to_check) \
56246853Sdes    __attribute__ ((format (archetype, string_index, first_to_check)))
57246853Sdes#else /* !LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT */
58246853Sdes#define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */
59246853Sdes#endif /* !LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT */
60246853Sdes
61246853Sdes#if defined(__cplusplus)
62246853Sdes#define ATTR_UNUSED(x)
63246853Sdes#elif LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED
64246853Sdes#define ATTR_UNUSED(x)  x __attribute__((unused))
65246853Sdes#else /* !LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED */
66246853Sdes#define ATTR_UNUSED(x)  x
67246853Sdes#endif /* !LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED */
68246853Sdes
69246854Sdes#if !LDNS_BUILD_CONFIG_HAVE_SOCKLEN_T
70246854Sdestypedef int socklen_t;
71246854Sdes#endif
72246854Sdes
73246853Sdes#endif /* LDNS_COMMON_H */
74