Most platforms have these as enums, which are converted to int (for use
as arguments) by the compiler automatically. However, some platforms do
not have these as enums, and use macros to define their values instead.
The former platforms also have those macros to define them in terms of
the corresponding enum, so use the macros instead of the enums for
broader compatibility, defining them in terms of their enums when they
don't exist.
glibc2 and musl have enums and compatibility macros, uclibc and
uclibc-ng have enums only, and OpenBSD libc has macros only.
Fixes: 740371b4e2f48fbe8e24 ("Initial commit.")
#include <netinet/in.h>
#include <resolv.h>
+#ifndef C_ANY
+# define C_ANY ns_c_any
+#endif
+
+#ifndef T_MX
+# define T_MX ns_t_mx
+#endif
+
static int
count_mx(const char *host)
{
if (! host || ! *host)
return 0;
- const int len = res_query(host, ns_c_any, ns_t_mx, nsbuf, sizeof nsbuf);
+ const int len = res_query(host, C_ANY, T_MX, nsbuf, sizeof nsbuf);
if (len < 0)
return 0;
#include <netinet/in.h>
#include <resolv.h>
+#ifndef C_ANY
+# define C_ANY ns_c_any
+#endif
+
+#ifndef T_MX
+# define T_MX ns_t_mx
+#endif
+
#define MAX_CHILDPROCS 10
struct procdata
if (! host || ! *host)
return 0;
- const int len = res_query(host, ns_c_any, ns_t_mx, nsbuf, sizeof nsbuf);
+ const int len = res_query(host, C_ANY, T_MX, nsbuf, sizeof nsbuf);
if (len < 0)
return 0;