]> git.draconx.ca Git - rarpd-dx.git/blob - src/iputils_common.h
Get rid of IPUTILS_VERSION macro.
[rarpd-dx.git] / src / iputils_common.h
1 #ifndef IPUTILS_COMMON_H
2 #define IPUTILS_COMMON_H
3
4 #include <stdio.h>
5 #include <sys/time.h>
6
7 #define ARRAY_SIZE(arr) \
8   (sizeof(arr) / sizeof((arr)[0]) + \
9    sizeof(__typeof__(int[1 - 2 * \
10           !!__builtin_types_compatible_p(__typeof__(arr), \
11                                          __typeof__(&arr[0]))])) * 0)
12
13 #ifdef __GNUC__
14 # define iputils_attribute_format(t, n, m) __attribute__((__format__ (t, n, m)))
15 #else
16 # define iputils_attribute_format(t, n, m)
17 #endif
18
19 #if defined(USE_IDN) || defined(ENABLE_NLS)
20 # include <locale.h>
21 #endif
22
23 #ifdef ENABLE_NLS
24 # include <libintl.h>
25 # define _(Text) gettext (Text)
26 #else
27 # undef bindtextdomain
28 # define bindtextdomain(Domain, Directory) /* empty */
29 # undef textdomain
30 # define textdomain(Domain) /* empty */
31 # define _(Text) Text
32 #endif
33
34 #ifdef USE_IDN
35 # include <idn2.h>
36
37 # include <netdb.h>
38 # ifndef AI_IDN
39 #  define AI_IDN                0x0040
40 # endif
41 # ifndef AI_CANONIDN
42 #  define AI_CANONIDN           0x0080
43 # endif
44 # ifndef NI_IDN
45 #  define NI_IDN 32
46 # endif
47 #endif /* #ifdef USE_IDN */
48
49 #ifndef SOL_IPV6
50 # define SOL_IPV6 IPPROTO_IPV6
51 #endif
52 #ifndef IP_PMTUDISC_DO
53 # define IP_PMTUDISC_DO         2
54 #endif
55 #ifndef IPV6_PMTUDISC_DO
56 # define IPV6_PMTUDISC_DO       2
57 #endif
58
59 #ifdef HAVE_ERROR_H
60 # include <error.h>
61 #else
62 extern void error(int status, int errnum, const char *format, ...);
63 #endif
64
65 extern int close_stream(FILE *stream);
66 extern void close_stdout(void);
67 extern long strtol_or_err(char const *const str, char const *const errmesg,
68                           const long min, const long max);
69 extern void iputils_srand(void);
70 extern void timespecsub(struct timespec *a, struct timespec *b,
71                         struct timespec *res);
72
73 #endif /* IPUTILS_COMMON_H */