summaryrefslogtreecommitdiff
path: root/utils.h
blob: 32055b3e57f85083d2328ab48824552a46762eba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef WHOIS_UTILS_H
#define WHOIS_UTILS_H

/* Convenience macros */
#define streq(a, b) (strcmp(a, b) == 0)
#define strcaseeq(a, b) (strcasecmp(a, b) == 0)
#define strneq(a, b, n) (strncmp(a, b, n) == 0)
#define strncaseeq(a, b, n) (strncasecmp(a, b, n) == 0)

#define NOFAIL(ptr) do_nofail((ptr), __FILE__, __LINE__)

#ifndef AFL_MODE
# define AFL_MODE 0
#endif

/* Portability macros */
#ifdef __GNUC__
# define NORETURN __attribute__((noreturn))
#else
# define NORETURN
#endif

#ifndef AI_IDN
# define AI_IDN 0
#endif

#ifndef AI_ADDRCONFIG
# define AI_ADDRCONFIG 0
#endif

#ifdef HAVE_GETOPT_LONG
# define GETOPT_LONGISH(c, v, o, l, i) getopt_long(c, v, o, l, i)
#else
# define GETOPT_LONGISH(c, v, o, l, i) getopt(c, v, o)
#endif

#ifdef ENABLE_NLS
# include <libintl.h>
# include <locale.h>
# define _(a) (gettext(a))
# ifdef gettext_noop
#  define N_(a) gettext_noop(a)
# else
#  define N_(a) (a)
# endif
#else
# define _(a) (a)
# define N_(a) (a)
# define ngettext(a, b, c) ((c==1) ? (a) : (b))
#endif

#if defined IDN2_VERSION_NUMBER && IDN2_VERSION_NUMBER < 0x00140000
# define IDN2_NONTRANSITIONAL IDN2_NFC_INPUT
#endif

/* Prototypes */
void *do_nofail(void *ptr, const char *file, const int line);
char **merge_args(char *args, char *argv[], int *argc);

void NORETURN err_quit(const char *fmt, ...);
void NORETURN err_sys(const char *fmt, ...);

#endif